-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMoveKey.v
More file actions
29 lines (29 loc) · 816 Bytes
/
Copy pathMoveKey.v
File metadata and controls
29 lines (29 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module MoveKey(key_push, out, clk, RST);
input key_push;
output reg out;
input clk, RST;
reg [31:0] counter;
always @(posedge clk or negedge RST) begin
if (RST == 1'b0) begin
out <= 1'b0;
counter <= 32'b0;
end
else begin
if (key_push == 1'b1) begin
// If it's less than 0.2 seconds from the last key press
if (counter < 32'd10000000) begin
out <= 1'b0;
counter <= counter + 1'b1;
end
else begin
out <= 1'b1;
counter <= 1'b0;
end
end
else begin
out <= 1'b0;
counter <= 1'b0;
end
end
end
endmodule