-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebouncer.v
More file actions
55 lines (50 loc) · 1.06 KB
/
debouncer.v
File metadata and controls
55 lines (50 loc) · 1.06 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// courtesy of Digilent https://github.com/Digilent/Nexys-A7-50T-Keyboard
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 03/03/2015 09:08:56 PM
// Design Name:
// Module Name: debouncer
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module debouncer(
input clk,
input I0,
input I1,
output reg O0,
output reg O1
);
reg [4:0]cnt0, cnt1;
reg Iv0=0,Iv1=0;
reg out0, out1;
always@(posedge(clk))begin
if (I0==Iv0)begin
if (cnt0==19)O0<=I0;
else cnt0<=cnt0+1;
end
else begin
cnt0<="00000";
Iv0<=I0;
end
if (I1==Iv1)begin
if (cnt1==19)O1<=I1;
else cnt1<=cnt1+1;
end
else begin
cnt1<="00000";
Iv1<=I1;
end
end
endmodule