-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHexKeypad.txt
97 lines (82 loc) · 1.64 KB
/
HexKeypad.txt
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
module key(clk, read, scan, dispn, disp); //SCAN= ROW &&&&&&&& READ=COLUMN
input clk;
input [3:0]read;
output reg [3:0]scan=4'b0000;
output [3:0]dispn;
output reg [6:0]disp;
reg [1:0]count=2'b00;
always@(posedge clk)
begin
count<=count+1'b1;
end
always@(count)
begin
case(count)
2'b00:scan=4'b1000;
2'b01:scan=4'b0100;
2'b10:scan=4'b0010;
2'b11:scan=4'b0001;
default:scan=4'b0000;
endcase
end
assign dispn=4'b0111;
always@(scan,read)
begin
case(scan)
4'b0001:
case(read)
4'b0001:disp=7'b1111110;
4'b0010:disp=7'b0110011;
4'b0100:disp=7'b1111111;
4'b1000:disp=7'b1001110;
default:disp=7'b0000000;
endcase
4'b0010:
case(read)
4'b0001:disp=7'b0110000;
4'b0010:disp=7'b1011011;
4'b0100:disp=7'b1111011;
4'b1000:disp=7'b0111101;
default:disp=7'b0000000;
endcase
4'b0100:
case(read)
4'b0001:disp=7'b1101101;
4'b0010:disp=7'b1011111;
4'b0100:disp=7'b1110111;
4'b1000:disp=7'b1001111;
default:disp=7'b0000000;
endcase
4'b1000:
case(read)
4'b0001:disp=7'b1111001;
4'b0010:disp=7'b1110000;
4'b0100:disp=7'b0011111;
4'b1000:disp=7'b1000111;
default:disp=7'b0000000;
endcase
default:disp=7'b0000000;
endcase
end
endmodule
UCF
net "clk" loc="p55";
net "disp<0>" loc="p22";
net "disp<1>" loc="p21";
net "disp<2>" loc="p17";
net "disp<3>" loc="p15";
net "disp<4>" loc="p14";
net "disp<5>" loc="p12";
net "disp<6>" loc="p1";
net "read<0>" loc="p121";
net "read<1>" loc="p124";
net "read<2>" loc="p127";
net "read<3>" loc="p126";
net "scan<0>" loc="p132";
net "scan<1>" loc="p140";
net "scan<2>" loc="p139";
net "scan<3>" loc="p143";
net "dispn<0>"loc="p30";
net "dispn<1>"loc="p29";
net "dispn<2>"loc="p27";
net "dispn<3>"loc="p26";