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