surenyi
4 years ago
5 changed files with 38 additions and 36 deletions
@ -1,19 +1,19 @@ |
|||
module key_delay #(parameter debound = 30) ( |
|||
input keypin ,// switch pin |
|||
input clk_1K ,// 1ms period |
|||
output reg keyout // if key on out 1 |
|||
); |
|||
reg [9:0] keystate = 0; |
|||
|
|||
always @(posedge clk_1K) |
|||
if (!keypin) |
|||
keystate = keystate + 1'b1; |
|||
else |
|||
keystate = 0; |
|||
|
|||
always @(posedge clk_1K) |
|||
if (keystate >= debound) |
|||
keyout = 1; // default 30ms key on, if have 30 times 1, can ensure key on, and output 1 |
|||
else |
|||
keyout = 0; |
|||
endmodule |
|||
module key_delay #(parameter debound = 10'd30) ( |
|||
input keypin ,// switch pin |
|||
input clk_1K ,// 1ms period |
|||
output reg keyout // if key on out 1 |
|||
); |
|||
reg [9:0] keystate = 0; |
|||
|
|||
always @(posedge clk_1K) |
|||
if (!keypin) |
|||
keystate = keystate + 1'b1; |
|||
else |
|||
keystate = 0; |
|||
|
|||
always @(posedge clk_1K) |
|||
if (keystate >= debound) |
|||
keyout = 1; // default 30ms key on, if have 30 times 1, can ensure key on, and output 1 |
|||
else |
|||
keyout = 0; |
|||
endmodule |
|||
|
Loading…
Reference in new issue