Verilog中延迟建模有哪三种方式?

如题所述

第1个回答  2011-01-09
/********************按键消抖程序****************************/
//按键的消抖,按键的输入时高电平时发光二极管亮
//data 2010-6-1 9:51:44
module key_xdou_1(clk,in,out,led);
input clk,in;
output out,led;
/************************************************************/
reg out,led;
reg[17:0] cnt;
always @(posedge clk)
begin
case (in)
0:
begin
cnt<=cnt+1;
if (cnt==250000)
if (in==0)
out<=0;
end
1:
begin
cnt<=cnt+1;
if (cnt==250000)
if (in==1)
out<=1;
end
default : out<=in;
endcase
end
always @(posedge out)
begin
led<=~led;
end
endmodule
//硬件消抖

参考资料:自己亲身经历

相似回答