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

📄 counter.v.bak

📁 FPGA EP2C5Q288C8 串口原码,测试OK 打开即用.
💻 BAK
字号:
module counter(clk,rst_n,beep,sled,dataout);
input clk;
input rst_n;

output wire beep;
output wire[3:0]sled;
output wire[15:0]dataout;
reg[5:0]scount;
reg[5:0]mcount;
reg[3:0]hcount;

assign sled[3:0]={clk,clk,clk,clk};
assign dataout[3:0]=mcount%'d10,
	   dataout[7:4]=mcount/'d10,
	   dataout[11:8]=hcount%'d10,
	   dataout[15:12]=hcount/'d10;
assign beep=scount==0?0:1;

always @(negedge rst_n or posedge clk)
begin
	if(!rst_n)
		begin
			scount<=0;
			mcount<=0;
			hcount<=0;
		end
	else if(scount<'d60)
		scount<=scount+'d1;
	else if(mcount<'d60)
			begin
				scount<=0;
				mcount<=mcount+'d1;
			end
	else if(hcount<'d24)
	        begin
			    scount<=0;
				mcount<=0;
				hcount<=hcount+'d1;
			end
	else
		begin
			scount<=0;
			mcount<=0;
			hcount<=0;
		end
end

endmodule

	    
	

⌨️ 快捷键说明

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