-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest_Test.v
106 lines (92 loc) · 1.81 KB
/
Test_Test.v
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
98
99
100
101
102
103
104
105
106
`timescale 1 ns / 1 ps
module quad_seven_seg (
input wire clk,
input wire [3:0] val3,
input wire [3:0] val2,
input wire [3:0] val1,
input wire [3:0] val0,
output wire an3,
output wire an2,
output wire an1,
output wire an0,
output wire ca,
output wire cb,
output wire cc,
output wire cd,
output wire ce,
output wire cf,
output wire cg,
output wire dp,
output reg [4:0] clk_counter
);
reg clk_counter = 0;
reg [1:0] count = 0;
always@(posedge clk)
begin
clk_counter <= clk_counter + 1;
end
always@(posedge clk)
begin
if(clk_counter == 0)
begin
count <= count + 1;
end
end
reg [3:0] state;
always@(*)
begin
case(count)
0: state = 4'b1110;
1: state = 4'b1101;
2: state = 4'b1011;
3: state = 4'b0111;
default: state = 4'bxxxx;
endcase
end
assign an3 = state[3];
assign an2 = state[2];
assign an1 = state[1];
assign an0 = state[0];
reg [3:0]val;
always@(*)
begin
case(count)
0: val = val0;
1: val = val1;
2: val = val2;
3: val = val3;
default: val = 4'bxxxx;
endcase
end
reg [15:0] ssd;
always@(*)
begin
case(val)
0: ssd = 8'b1000_0001;
1: ssd = 8'b1100_1111;
2: ssd = 8'b1001_0010;
3: ssd = 8'b1000_0110;
4: ssd = 8'b1100_1100;
5: ssd = 8'b1010_0100;
6: ssd = 8'b1010_0000;
7: ssd = 8'b1000_1111;
8: ssd = 8'b1000_0000;
9: ssd = 8'b1000_0100;
10: ssd = 8'b1000_1000;
11: ssd = 8'b1110_0000;
12: ssd = 8'b1011_0001;
13: ssd = 8'b1100_0010;
14: ssd = 8'b1011_0000;
15: ssd = 8'b1011_1000;
default: ssd = 8'b1111_1110;
endcase
end
assign dp = ssd[7];
assign ca = ssd[6];
assign cb = ssd[5];
assign cc = ssd[4];
assign cd = ssd[3];
assign ce = ssd[2];
assign cf = ssd[1];
assign cg = ssd[0];
endmodule