⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hex.v

📁 在FPGA上实现序列机 用的是Altera公司的DE1板子
💻 V
字号:
//显示所接受正确序列的个数
module hex(clk,rst,Y_or_NO,hex0,hex1,ledg);
input clk;
input rst;
input Y_or_NO;
output [6:0] hex0,hex1;
output reg ledg;//灯的控制信号
reg [3:0] h0,h1;

always @(posedge clk or negedge rst) 
begin	   
	if (!rst)
	begin 
		h0<=4'b0;
		h1<=4'b0;
		ledg<=1'b0;
	end
/*	else if(load)//这是置位的一段程序
	begin 
		h3=(SW[9:6])>9 ? 9:SW[9:6];
		h2=(SW[9:6])>9 ? 9:SW[9:6];
    end
*/
	else if(Y_or_NO)//检测到一个正确的序列,计数器加1
	begin
	    ledg<=1'b1;
		if(h0==4'h9)
		begin 
			h0<=4'b0;
			if(h1==4'h9) h1<=4'b0;				
			else h1<=h1+4'b1;
		end
	    else h0<=h0+4'b1;
	end
	else 
	begin 
        ledg<=1'b0;
		h0<=h0;
		h1<=h1;
    end
end
decode4_7 decode0(hex0,h0);
decode4_7 decode1(hex1,h1);
endmodule 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -