2012年10月18日 星期四

PushButton_Debouncer

源自

module PushButton_Debouncer (Do, Di, clk, rst);
output  Do;
input   Di;  
input   clk,rst;   

reg   [24:0] buff;   

reg     Do;   
    
always @ (posedge clk or posedge rst)    
begin  
if(rst)
begin
buff=0;
end
else
begin
if(Di)
begin

if (buff>25'd10_000_000)
  buff=buff;
else
buff=buff+25'd1;
end
else
 begin
    buff=0;
end
end
end



always @ (posedge clk)
begin
if (buff>25'd5_000_000)
Do=1;
else
Do=0;
end

endmodule

沒有留言:

張貼留言

WOKWI DHT22 & LED , Node-Red + SQLite database

 WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...