-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumeric_display.vhd
More file actions
278 lines (258 loc) · 5.03 KB
/
numeric_display.vhd
File metadata and controls
278 lines (258 loc) · 5.03 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity numeric_display is
port (
num: in UNSIGNED(3 downto 0); -- number to display
pos_x, pos_y: in INTEGER; -- top-left corner of text display
hcount, vcount: in INTEGER; -- current position
lit: out STD_LOGIC -- whether the current pixel should be lit by the displayed number
);
end numeric_display;
architecture behavioural of numeric_display is
type CHAR_BITMAP is array(0 to 11) of STD_LOGIC_VECTOR(0 to 7); -- 8x12 character bitmap type
constant char_0: CHAR_BITMAP := (
"00000000",
"01111100",
"11000110",
"11001110",
"11011110",
"11110110",
"11100110",
"11000110",
"11000110",
"01111100",
"00000000",
"00000000"
);
constant char_1: CHAR_BITMAP := (
"00000000",
"00011000",
"01111000",
"00011000",
"00011000",
"00011000",
"00011000",
"00011000",
"00011000",
"01111110",
"00000000",
"00000000"
);
constant char_2: CHAR_BITMAP := (
"00000000",
"01111100",
"11000110",
"11000110",
"00001100",
"00011000",
"00110000",
"01100000",
"11000110",
"11111110",
"00000000",
"00000000"
);
constant char_3: CHAR_BITMAP := (
"00000000",
"01111100",
"11000110",
"00000110",
"00000110",
"00111100",
"00000110",
"00000110",
"11000110",
"01111100",
"00000000",
"00000000"
);
constant char_4: CHAR_BITMAP := (
"00000000",
"00001100",
"00011100",
"00111100",
"01101100",
"11001100",
"11111110",
"00001100",
"00001100",
"00001100",
"00000000",
"00000000"
);
constant char_5: CHAR_BITMAP := (
"00000000",
"11111110",
"11000000",
"11000000",
"11000000",
"11111100",
"00000110",
"00000110",
"11000110",
"01111100",
"00000000",
"00000000"
);
constant char_6: CHAR_BITMAP := (
"00000000",
"01111100",
"11000110",
"11000000",
"11000000",
"11111100",
"11000110",
"11000110",
"11000110",
"01111100",
"00000000",
"00000000"
);
constant char_7: CHAR_BITMAP := (
"00000000",
"11111110",
"11000110",
"00001100",
"00011000",
"00110000",
"00110000",
"00110000",
"00110000",
"00110000",
"00000000",
"00000000"
);
constant char_8: CHAR_BITMAP := (
"00000000",
"01111100",
"11000110",
"11000110",
"11000110",
"01111100",
"11000110",
"11000110",
"11000110",
"01111100",
"00000000",
"00000000"
);
constant char_9: CHAR_BITMAP := (
"00000000",
"01111100",
"11000110",
"11000110",
"11000110",
"01111110",
"00000110",
"00000110",
"11000110",
"01111100",
"00000000",
"00000000"
);
constant char_a: CHAR_BITMAP := (
"00000000",
"00111000",
"01101100",
"11000110",
"11000110",
"11000110",
"11111110",
"11000110",
"11000110",
"11000110",
"00000000",
"00000000"
);
constant char_b: CHAR_BITMAP := (
"00000000",
"11111100",
"01100110",
"01100110",
"01100110",
"01111100",
"01100110",
"01100110",
"01100110",
"11111100",
"00000000",
"00000000"
);
constant char_c: CHAR_BITMAP := (
"00000000",
"00111100",
"01100110",
"11000000",
"11000000",
"11000000",
"11000000",
"11000000",
"01100110",
"00111100",
"00000000",
"00000000"
);
constant char_d: CHAR_BITMAP := (
"00000000",
"11111000",
"01101100",
"01100110",
"01100110",
"01100110",
"01100110",
"01100110",
"01101100",
"11111000",
"00000000",
"00000000"
);
constant char_e: CHAR_BITMAP := (
"00000000",
"11111110",
"01100110",
"01100000",
"01100000",
"01111100",
"01100000",
"01100000",
"01100110",
"11111110",
"00000000",
"00000000"
);
constant char_f: CHAR_BITMAP := (
"00000000",
"11111110",
"01100110",
"01100000",
"01100000",
"01111100",
"01100000",
"01100000",
"01100000",
"11110000",
"00000000",
"00000000"
);
begin
-- lighting pixel if we're inside bounding box, and the pixel is active in the respective bitmap position
lit <= '0' when (hcount < pos_x) or (hcount >= pos_x+8) or (vcount < pos_y) or (vcount >= pos_y+12) else
char_0(vcount - pos_y)(hcount - pos_x) when num = "0000" else
char_1(vcount - pos_y)(hcount - pos_x) when num = "0001" else
char_2(vcount - pos_y)(hcount - pos_x) when num = "0010" else
char_3(vcount - pos_y)(hcount - pos_x) when num = "0011" else
char_4(vcount - pos_y)(hcount - pos_x) when num = "0100" else
char_5(vcount - pos_y)(hcount - pos_x) when num = "0101" else
char_6(vcount - pos_y)(hcount - pos_x) when num = "0110" else
char_7(vcount - pos_y)(hcount - pos_x) when num = "0111" else
char_8(vcount - pos_y)(hcount - pos_x) when num = "1000" else
char_9(vcount - pos_y)(hcount - pos_x) when num = "1001" else
char_a(vcount - pos_y)(hcount - pos_x) when num = "1010" else
char_b(vcount - pos_y)(hcount - pos_x) when num = "1011" else
char_c(vcount - pos_y)(hcount - pos_x) when num = "1100" else
char_d(vcount - pos_y)(hcount - pos_x) when num = "1101" else
char_e(vcount - pos_y)(hcount - pos_x) when num = "1110" else
char_f(vcount - pos_y)(hcount - pos_x) when num = "1111" else
'0';
end behavioural;