-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings_pixgen.vhd
240 lines (213 loc) · 10 KB
/
settings_pixgen.vhd
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
----------------------------------------------------------------------------------
-- Author: Osowski Marcin
-- Create Date: 20:16:43 05/22/2011
----------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
use work.types.all;
entity settings_pixgen is
port (
nrst : in std_logic;
clk108 : in std_logic;
segment : in integer range 0 to 15;
segment_change : in std_logic;
subsegment : in integer range 0 to 3;
subsegment_change : in std_logic;
line : in integer range 0 to 15;
line_change : in std_logic;
column : in integer range 0 to 1279;
column_mod_8 : in integer range 0 to 7;
column_div_8 : in integer range 0 to 159;
column_change : in std_logic;
page_change : in std_logic;
active_pixgen_source : in PIXGEN_SOURCE_T;
is_reading_active : in std_logic;
trigger_event : in TRIGGER_EVENT_T;
red_enable : in std_logic;
green_enable : in std_logic;
blue_enable : in std_logic;
continue_after_reading : in std_logic;
time_resolution : in integer range 0 to 15;
char : out short_character;
char_pixel : in std_logic;
vout : out std_logic_vector (7 downto 0)
);
end settings_pixgen;
architecture behavioral of settings_pixgen is
constant s_red_sig : short_string := to_short_string (" Red signal (C6): ???abled (SW6)");
constant s_green_sig : short_string := to_short_string ("Green signal (B6): ???abled (SW5)");
constant s_blue_sig : short_string := to_short_string (" Blue signal (C5): ???abled (SW4)");
constant s_enabled : short_string := to_short_string (" en");
constant s_disabled : short_string := to_short_string ("dis");
constant s_resolution : short_string := to_short_string (" Resolution: ???????? (SW3 ~ SW0)");
constant s_trigger : short_string := to_short_string (" Trigger on: ???????? (BTN2 to change)");
constant s_after : short_string := to_short_string ("After reading: ???????? (BTN1 to change)");
type res_array_t is array (0 to 15) of short_string (7 downto 0);
constant res_array : res_array_t := (
to_short_string (" 54 Mhz"),
to_short_string ("21.6 Mhz"),
to_short_string ("10.8 Mhz"),
to_short_string (" 5.4 Mhz"),
to_short_string (" 1 Mhz"),
to_short_string (" 500 khz"),
to_short_string (" 250 khz"),
to_short_string (" 100 khz"),
to_short_string (" 50 khz"),
to_short_string (" 25 khz"),
to_short_string (" 10 khz"),
to_short_string (" 5 khz"),
to_short_string (" 2.5 khz"),
to_short_string (" 1 khz"),
to_short_string (" 500 hz"),
to_short_string (" 250 hz")
);
constant s_btn0 : short_string := to_short_string (" BTN0");
constant s_red : short_string := to_short_string (" red");
constant s_green : short_string := to_short_string (" green");
constant s_blue : short_string := to_short_string (" blue");
constant s_continue : short_string := to_short_string ("continue");
constant s_stop : short_string := to_short_string (" stop");
constant s_reading_active : short_string := to_short_string (" Running... (press BTN0 to stop)");
constant s_reading_stopped : short_string := to_short_string ("Stopped. Waiting for trigger event.");
begin
process (nrst, clk108) is
begin
if nrst = '0' then
char <= character_conv_table (0);
elsif rising_edge (clk108) then
if segment = 14 then
-- Upper settings segment (segment = 14)
if subsegment = 0 then
-- Red subsegment
if column_div_8 < 19 then
char <= s_red_sig (column_div_8);
elsif column_div_8 < 22 then
if red_enable = '1' then
char <= s_enabled (column_div_8 - 19);
else
char <= s_disabled (column_div_8 - 19);
end if;
elsif column_div_8 < s_red_sig'length then
char <= s_red_sig (column_div_8);
else
char <= to_short_character (' ');
end if;
elsif subsegment = 1 then
-- Green subsegment
if column_div_8 < 19 then
char <= s_green_sig (column_div_8);
elsif column_div_8 < 22 then
if green_enable = '1' then
char <= s_enabled (column_div_8 - 19);
else
char <= s_disabled (column_div_8 - 19);
end if;
elsif column_div_8 < s_green_sig'length then
char <= s_green_sig (column_div_8);
else
char <= to_short_character (' ');
end if;
elsif subsegment = 2 then
-- Blue subsegment
if column_div_8 < 19 then
char <= s_blue_sig (column_div_8);
elsif column_div_8 < 22 then
if blue_enable = '1' then
char <= s_enabled (column_div_8 - 19);
else
char <= s_disabled (column_div_8 - 19);
end if;
elsif column_div_8 < s_blue_sig'length then
char <= s_blue_sig (column_div_8);
else
char <= to_short_character (' ');
end if;
else
-- Empty subsegment
char <= to_short_character (' ');
end if;
else
-- Lower settings segment (segment = 15)
if subsegment = 0 then
-- Resolution subsegment
if column_div_8 < 15 then
char <= s_resolution (column_div_8);
elsif column_div_8 < 23 then
char <= res_array (time_resolution) (column_div_8 - 15);
elsif column_div_8 < s_resolution'length then
char <= s_resolution (column_div_8);
else
char <= to_short_character (' ');
end if;
elsif subsegment = 1 then
-- Trigger subsegment
if column_div_8 < 15 then
char <= s_trigger (column_div_8);
elsif column_div_8 < 23 then
if trigger_event = RED_TRIGGER_T then
char <= s_red (column_div_8 - 15);
elsif trigger_event = GREEN_TRIGGER_T then
char <= s_green (column_div_8 - 15);
elsif trigger_event = BLUE_TRIGGER_T then
char <= s_blue (column_div_8 - 15);
else
char <= s_btn0 (column_div_8 - 15);
end if;
elsif column_div_8 < s_trigger'length then
char <= s_trigger (column_div_8);
else
char <= to_short_character (' ');
end if;
elsif subsegment = 2 then
-- Behaviour after reading subsegment
if column_div_8 < 15 then
char <= s_after (column_div_8);
elsif column_div_8 < 23 then
if continue_after_reading = '1' then
char <= s_continue (column_div_8 - 15);
else
char <= s_stop (column_div_8 - 15);
end if;
elsif column_div_8 < s_after'length then
char <= s_after (column_div_8);
else
char <= to_short_character (' ');
end if;
else
-- Status subsegment.
if column_div_8 < 125 then
char <= to_short_character (' ');
else
if is_reading_active = '1' then
char <= s_reading_active (column_div_8 - 125);
else
char <= s_reading_stopped (column_div_8 - 125);
end if;
end if;
end if;
end if;
end if;
end process;
process (char_pixel, segment, subsegment) is
begin
if char_pixel = '1' then
if segment = 14 then
if subsegment = 0 then
vout <= "11100000";
elsif subsegment = 1 then
vout <= "00011100";
elsif subsegment = 2 then
vout <= "00000011";
else
vout <= "11111111";
end if;
else
vout <= "11111111";
end if;
else
vout <= "00000000";
end if;
end process;
end behavioral;