-
Notifications
You must be signed in to change notification settings - Fork 1
/
DigitLoader.v
182 lines (177 loc) · 4.26 KB
/
DigitLoader.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: University of Thessaly
// Engineer: Viktoria Biliouri
//
// Create Date: 23:49:16 10/21/2018
// Design Name:
// Module Name: DigitLoader
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module DigitLoader(clk, reset, char1, char2, char3, char4, an3, an2, an1, an0, char);
input clk, reset;
input [3:0] char1;
input [3:0] char2;
input [3:0] char3;
input [3:0] char4;
output an3, an2, an1, an0;
output char;
reg an3, an2, an1, an0;
reg [3:0] char;
reg [3:0] counter;
always @(posedge clk or posedge reset)
begin
if(reset)
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
counter = 4'b1111;
char = char1;
end
else if (counter == 4'b1111) //checks if counter is 1111 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
char = char1; //char is 0000 to show number 0 when an3 is on, in 1 circle
counter = counter - 4'b0001;
end
else if (counter == 4'b1110) // checks if counter is 1110 -> an3 is on
begin
an3 = 1'b0;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
counter = counter - 4'b0001;
end
else if (counter == 4'b1101) //checks if counter is 1101 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
counter = counter - 4'b0001;
end
else if (counter == 4'b1100) //checks if counter is 1100 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
char = char2; //char is 0001 ready to show number 1 in 2 circles, when an2 is on
counter = counter - 4'b0001;
end
else if (counter == 4'b1011) //checks if counter is 1011 -> no led is on
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
counter = counter - 1;
end
else if (counter == 4'b1010) //checks if counter is 1010 -> an2 is on
begin
an3 = 1'b1;
an2 = 1'b0;
an1 = 1'b1;
an0 = 1'b1;
counter = counter - 4'b0001;
end
else if (counter == 4'b1001) //checks if counter is 1001 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
counter = counter - 4'b0001;
end
else if (counter == 4'b1000) //checks if counter is 1000 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
char = char3; //char is ready to show number 2 in 2 circles, when an1 is on
counter = counter - 4'b0001;
end
else if (counter == 4'b0111) //checks if counter is 0111 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
counter = counter - 4'b0001;
end
else if (counter == 4'b0110) //checks if counter is 0110 -> an1 is on
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b0;
an0 = 1'b1;
counter = counter - 4'b0001;
end
else if (counter == 4'b0101) //checks if counter is 0101 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
counter = counter - 4'b0001;
end
else if (counter == 4'b0100) //checks if counter is 0100 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
char = char4; //char is ready to show number 3 in 2 circles, when an0 is on
counter = counter - 4'b0001;
end
else if (counter == 4'b0011) //checks if counter is 0011 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
counter = counter - 4'b0001;
end
else if (counter == 4'b0010) //checks if counter is 0010 -> an0 is on
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b0;
counter = counter - 4'b0001;
end
else if (counter == 4'b0001) //checks if counter is 0001 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
counter = counter - 4'b0001;
end
else //if counter is 0000 -> no led can light
begin
an3 = 1'b1;
an2 = 1'b1;
an1 = 1'b1;
an0 = 1'b1;
char = char1;
counter = 4'b1111; //counter should return to initial number 1111
end
end
endmodule