2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
5 use work.textmode_vga_component_pkg.all;
6 use work.textmode_vga_pkg.all;
7 use work.textmode_vga_platform_dependent_pkg.all;
11 sys_clk : in std_logic;
12 sys_res_n : in std_logic;
14 d_new_eingabe : in std_logic;
15 d_new_result : in std_logic;
16 d_new_bs : in std_logic;
18 d_spalte : out hspalte;
19 d_get : out std_logic;
20 d_done : in std_logic;
23 command : out std_logic_vector(7 downto 0);
24 command_data : out std_logic_vector(31 downto 0);
29 architecture beh of display is
30 type DISPLAY_STATE is (SIDLE, S_NEW_BS, S_BACK, S_BLANK, S_NEW_RESULT,
31 S_ZEILEUP, S_NEW_INPUT, S_COUNTUP, S_GETCH, S_CR1, S_NL1, S_PUTCH1,
32 S_PUTCH2, S_WAIT, S_NOP1, S_READ_RESULT_0, S_READ_RESULT_1,
33 S_READ_RESULT_2, S_INIT, S_PS1_0, S_PS1_1, S_PS1_2, S_PS1_3, S_PS1_4,
35 type DISPLAY_ISTATE is (IS_BACK_2_BLANK, IS_BLANK_2_BACK,
36 IS_NL1_2_ZEILEUP, IS_RESULT2_2_CR1, IS_CR1_2_NL1, IS_NL1_2_RESULT0,
37 IS_RESULT0_2_RESULT1, IS_RESULT1_2_RESULT2, IS_ZEILEUP_2_PS10,
38 IS_PS10_2_PS11, IS_PS11_2_PS12, IS_PS12_2_PS13, IS_PS13_2_PS14,
39 IS_PS14_2_PS15, IS_RANDOM_2_IDLE, IS_OTHER_2_NL1);
41 signal state_int, state_next : DISPLAY_STATE;
42 signal istate_next, istate_int : DISPLAY_ISTATE;
43 signal d_zeile_int, d_zeile_next : hzeile;
44 signal d_spalte_int, d_spalte_next : hspalte;
45 signal d_get_int, d_get_next : std_logic;
46 signal command_int, command_next : std_logic_vector(7 downto 0);
47 signal command_data_int, command_data_next : std_logic_vector(31 downto 0);
49 d_zeile <= d_zeile_int;
50 d_spalte <= d_spalte_int;
52 command <= command_int;
53 command_data <= command_data_int;
55 process(sys_clk, sys_res_n)
57 if sys_res_n = '0' then
60 istate_int <= IS_RANDOM_2_IDLE;
62 d_zeile_int <= (others => '0');
63 d_spalte_int <= (others => '0');
65 command_int <= COMMAND_NOP;
66 command_data_int <= (others => '0');
67 elsif rising_edge(sys_clk) then
69 state_int <= state_next;
70 istate_int <= istate_next;
72 d_zeile_int <= d_zeile_next;
73 d_spalte_int <= d_spalte_next;
74 d_get_int <= d_get_next;
75 command_int <= command_next;
76 command_data_int <= command_data_next;
81 process(state_int, d_new_result, d_new_eingabe, d_new_bs, d_done, free,
82 d_spalte_int, d_char, istate_int)
84 state_next <= state_int;
85 istate_next <= istate_int;
89 state_next <= S_PS1_0;
92 istate_next <= IS_PS10_2_PS11;
95 istate_next <= IS_PS11_2_PS12;
98 istate_next <= IS_PS12_2_PS13;
101 istate_next <= IS_PS13_2_PS14;
102 state_next <= S_WAIT;
104 istate_next <= IS_PS14_2_PS15;
105 state_next <= S_WAIT;
107 istate_next <= IS_RANDOM_2_IDLE;
108 state_next <= S_WAIT;
111 istate_next <= IS_RANDOM_2_IDLE;
112 if d_new_bs = '1' then
113 state_next <= S_NEW_BS;
114 elsif d_new_eingabe = '1' then
115 state_next <= S_NEW_INPUT;
117 if d_new_result = '1' then
118 state_next <= S_NEW_RESULT;
122 state_next <= S_ZEILEUP;
124 state_next <= S_COUNTUP;
127 state_next <= S_BACK;
130 state_next <= S_WAIT;
132 when IS_RANDOM_2_IDLE => istate_next <= IS_BACK_2_BLANK;
133 when others => istate_next <= IS_RANDOM_2_IDLE;
138 state_next <= S_WAIT;
139 istate_next <= IS_BLANK_2_BACK;
144 when IS_NL1_2_ZEILEUP =>
145 state_next <= S_WAIT;
146 istate_next <= IS_ZEILEUP_2_PS10;
147 when others => state_next <= S_CR1;
152 state_next <= S_WAIT;
154 when IS_RESULT2_2_CR1 => istate_next <= IS_OTHER_2_NL1;
155 when others => istate_next <= IS_CR1_2_NL1;
160 state_next <= S_WAIT;
162 when IS_OTHER_2_NL1 => istate_next <= IS_NL1_2_ZEILEUP;
163 when others => istate_next <= IS_NL1_2_RESULT0;
167 when S_READ_RESULT_0 =>
168 istate_next <= IS_RESULT0_2_RESULT1;
169 state_next <= S_WAIT;
170 when S_READ_RESULT_1 =>
171 istate_next <= IS_RESULT1_2_RESULT2;
172 state_next <= S_WAIT;
173 when S_READ_RESULT_2 =>
174 if unsigned(d_spalte_int) /= HSPALTE_MAX-1 then
175 state_next <= S_COUNTUP;
176 istate_next <= IS_RESULT1_2_RESULT2;
178 state_next <= S_WAIT;
179 istate_next <= IS_RESULT2_2_CR1;
183 state_next <= S_GETCH;
185 if free = '1' and d_done = '1' and d_new_result = '0' and d_new_eingabe = '0' then
186 state_next <= S_PUTCH1;
189 state_next <= S_PUTCH2;
192 state_next <= S_WAIT;
195 if free = '1' and d_done = '0' then
196 state_next <= S_NOP1;
201 when IS_CR1_2_NL1 => state_next <= S_NL1;
202 when IS_BACK_2_BLANK => state_next <= S_BLANK;
203 when IS_BLANK_2_BACK => state_next <= S_BACK;
204 when IS_NL1_2_ZEILEUP => state_next <= S_ZEILEUP;
205 when IS_RESULT2_2_CR1 => state_next <= S_CR1;
206 when IS_OTHER_2_NL1 => state_next <= S_NL1;
208 when IS_NL1_2_RESULT0 => state_next <= S_READ_RESULT_0;
209 when IS_RESULT0_2_RESULT1 => state_next <= S_READ_RESULT_1;
210 when IS_RESULT1_2_RESULT2 => state_next <= S_READ_RESULT_2;
212 when IS_ZEILEUP_2_PS10 => state_next <= S_PS1_0;
213 when IS_PS10_2_PS11 => state_next <= S_PS1_1;
214 when IS_PS11_2_PS12 => state_next <= S_PS1_2;
215 when IS_PS12_2_PS13 => state_next <= S_PS1_3;
216 when IS_PS13_2_PS14 => state_next <= S_PS1_4;
217 when IS_PS14_2_PS15 => state_next <= S_PS1_5;
218 when IS_RANDOM_2_IDLE => state_next <= SIDLE;
225 process(state_int, d_zeile_int, d_spalte_int, d_get_int, command_int,
226 command_data_int, d_char)
227 function zeile2char(i : std_logic_vector; stelle : natural) return hbyte is
228 subtype zeilnum is string(1 to 2);
229 type zeilnum_arr is array (natural range 0 to 49) of zeilnum;
230 constant zn : zeilnum_arr := (
231 0 => "00", 1 => "01", 2 => "02", 3 => "03", 4 => "04",
232 5 => "05", 6 => "06", 7 => "07", 8 => "08", 9 => "09",
233 10 => "10", 11 => "11", 12 => "12", 13 => "13", 14 => "14",
234 15 => "15", 16 => "16", 17 => "17", 18 => "18", 19 => "19",
235 20 => "20", 21 => "21", 22 => "22", 23 => "23", 24 => "24",
236 25 => "25", 26 => "26", 27 => "27", 28 => "28", 29 => "29",
237 30 => "30", 31 => "31", 32 => "32", 33 => "33", 34 => "34",
238 35 => "35", 36 => "36", 37 => "37", 38 => "38", 39 => "39",
239 40 => "40", 41 => "41", 42 => "42", 43 => "43", 44 => "44",
240 45 => "45", 46 => "46", 47 => "47", 48 => "48", 49 => "49",
242 variable t : signed(hzeile'length downto 0);
244 t := signed('0' & i);
246 return hbyte(to_unsigned(character'pos(zn(to_integer(t))(stelle)),8));
249 d_zeile_next <= d_zeile_int;
250 d_spalte_next <= d_spalte_int;
252 command_next <= command_int;
253 command_data_next <= command_data_int;
259 command_next <= COMMAND_SET_CHAR;
260 command_data_next <= x"0000ff" & x"28"; -- '('
262 command_next <= COMMAND_SET_CHAR;
263 command_data_next <= x"00ff00" & zeile2char(d_zeile_int,1); -- 'x'
265 command_next <= COMMAND_SET_CHAR;
266 command_data_next <= x"00ff00" & zeile2char(d_zeile_int,2); -- 'y'
268 command_next <= COMMAND_SET_CHAR;
269 command_data_next <= x"0000ff" & x"29"; -- ')'
271 command_next <= COMMAND_SET_CHAR;
272 command_data_next <= x"00ffff" & x"24"; -- '$'
274 command_next <= COMMAND_SET_CHAR;
275 command_data_next <= x"ffffff" & x"20"; -- ' '
278 when S_NEW_RESULT => null;
279 when S_NEW_INPUT => null;
282 -- underflow check schon im history modul
283 d_spalte_next <= std_logic_vector(unsigned(d_spalte_int) - 1);
285 -- einen schritt zurueck, +6 wegen $PS1
286 command_next <= COMMAND_SET_CURSOR_COLUMN;
287 command_data_next <= x"ffffff" & '0' & std_logic_vector(unsigned(d_spalte_int) + 6);
289 command_next <= COMMAND_SET_CHAR;
290 command_data_next <= x"ffffff" & x"20"; -- white space
293 d_spalte_next <= (others => '0');
296 std_logic_vector(to_unsigned(HZEILE_MAX-1,d_zeile_int'length)) => d_zeile_next <= (others => '0');
297 when others => d_zeile_next <= std_logic_vector(unsigned(d_zeile_int) + 1);
301 command_next <= COMMAND_SET_CHAR;
302 command_data_next <= x"ffffff" & x"0d"; -- carrige return
304 command_next <= COMMAND_SET_CHAR;
305 command_data_next <= x"ffffff" & x"0a"; -- newline
307 when S_READ_RESULT_0 =>
308 command_next <= COMMAND_SET_CHAR;
309 command_data_next <= x"ff0000" & x"3e"; -- '>'
310 when S_READ_RESULT_1 =>
311 command_next <= COMMAND_SET_CHAR;
312 command_data_next <= x"ffffff" & x"20"; -- ' '
313 when S_READ_RESULT_2 => null;
317 d_spalte_next <= std_logic_vector(unsigned(d_spalte_int) + 1);
321 command_next <= COMMAND_SET_CHAR;
322 if d_char = x"00" then
323 command_data_next <= x"ffffff" & x"20";
325 command_data_next <= x"ffffff" & std_logic_vector(d_char);
327 when S_PUTCH2 => null;
328 when S_WAIT | S_NOP1 =>
329 command_next <= COMMAND_NOP;
330 command_data_next <= x"00000000";
333 end architecture beh;