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 signal state_int, state_next : DISPLAY_STATE;
36 signal d_zeile_int, d_zeile_next : hzeile;
37 signal d_spalte_int, d_spalte_next : hspalte;
38 signal d_get_int, d_get_next : std_logic;
39 signal command_int, command_next : std_logic_vector(7 downto 0);
40 signal command_data_int, command_data_next : std_logic_vector(31 downto 0);
41 signal istate_next, istate_int : signed(4 downto 0);
43 d_zeile <= d_zeile_int;
44 d_spalte <= d_spalte_int;
46 command <= command_int;
47 command_data <= command_data_int;
49 process(sys_clk, sys_res_n)
51 if sys_res_n = '0' then
54 istate_int <= (others => '0');
56 d_zeile_int <= (others => '0');
57 d_spalte_int <= (others => '0');
59 command_int <= COMMAND_NOP;
60 command_data_int <= (others => '0');
61 elsif rising_edge(sys_clk) then
63 state_int <= state_next;
64 istate_int <= istate_next;
66 d_zeile_int <= d_zeile_next;
67 d_spalte_int <= d_spalte_next;
68 d_get_int <= d_get_next;
69 command_int <= command_next;
70 command_data_int <= command_data_next;
75 process(state_int, d_new_result, d_new_eingabe, d_new_bs, d_done, free,
76 d_spalte_int, d_char, istate_int)
78 state_next <= state_int;
79 istate_next <= istate_int;
83 state_next <= S_PS1_0;
86 istate_next <= b"01001";
89 istate_next <= b"01010";
92 istate_next <= b"01011";
95 istate_next <= b"01100";
98 istate_next <= b"01101";
101 istate_next <= b"00111";
102 state_next <= S_WAIT;
105 istate_next <= b"00111"; -- default: immer wieder ins SIDLE;
106 if d_new_bs = '1' then
107 state_next <= S_NEW_BS;
108 elsif d_new_eingabe = '1' then
109 state_next <= S_NEW_INPUT;
111 if d_new_result = '1' then
112 state_next <= S_NEW_RESULT;
116 state_next <= S_ZEILEUP;
118 state_next <= S_COUNTUP;
121 state_next <= S_BACK;
124 state_next <= S_WAIT;
126 when b"00111" => istate_next <= b"00001"; -- => danach S_BLANK und wieder hierher
127 when others => istate_next <= b"00111"; -- => danach SIDLE
132 state_next <= S_WAIT;
133 istate_next <= b"00010"; -- => danach S_BACK
139 state_next <= S_WAIT;
140 istate_next <= b"01000"; -- => danach S_PS1
141 when others => state_next <= S_CR1;
146 state_next <= S_WAIT;
148 when b"00110" => istate_next <= b"00101"; -- => danach S_NL1, S_ZEILEUP, S_PS1, SIDLE
149 when others => istate_next <= b"00000"; -- => danach S_NL1 und S_COUNTUP
154 state_next <= S_WAIT;
156 when b"00101" => istate_next <= b"00011"; -- => danach S_ZEILEUP, PS1
157 when others => istate_next <= b"10000"; -- => danach S_READ_RESULT_0
161 when S_READ_RESULT_0 =>
162 istate_next <= b"10001";
163 state_next <= S_WAIT;
164 when S_READ_RESULT_1 =>
165 istate_next <= b"10010";
166 state_next <= S_WAIT;
167 when S_READ_RESULT_2 =>
168 if unsigned(d_spalte_int) /= 70 then
169 state_next <= S_COUNTUP;
170 istate_next <= b"10010"; -- => wieder nach S_READ_RESULT_2
172 state_next <= S_WAIT;
173 istate_next <= b"00110"; -- => danach S_CR1 und d_spalte_next clearen und d_zeile_next inkrementieren
177 state_next <= S_GETCH;
179 if free = '1' and d_done = '1' and d_new_result = '0' and d_new_eingabe = '0' then
180 state_next <= S_PUTCH1;
183 state_next <= S_PUTCH2;
185 if free = '0' or (free = '1' and d_char = x"00") then
186 state_next <= S_WAIT;
189 if free = '1' and d_done = '0' then
190 state_next <= S_NOP1;
195 when b"00000" => state_next <= S_NL1;
196 when b"00001" => state_next <= S_BLANK;
197 when b"00010" => state_next <= S_BACK;
198 when b"00011" => state_next <= S_ZEILEUP;
199 when b"00110" => state_next <= S_CR1;
200 when b"00101" => state_next <= S_NL1;
202 when b"10000" => state_next <= S_READ_RESULT_0;
203 when b"10001" => state_next <= S_READ_RESULT_1;
204 when b"10010" => state_next <= S_READ_RESULT_2;
206 when b"01000" => state_next <= S_PS1_0;
207 when b"01001" => state_next <= S_PS1_1;
208 when b"01010" => state_next <= S_PS1_2;
209 when b"01011" => state_next <= S_PS1_3;
210 when b"01100" => state_next <= S_PS1_4;
211 when b"01101" => state_next <= S_PS1_5;
212 when others => state_next <= SIDLE;
219 process(state_int, d_zeile_int, d_spalte_int, d_get_int, command_int,
220 command_data_int, d_char)
222 d_zeile_next <= d_zeile_int;
223 d_spalte_next <= d_spalte_int;
225 command_next <= command_int;
226 command_data_next <= command_data_int;
231 -- TODO: coole farben
233 command_next <= COMMAND_SET_CHAR;
234 command_data_next <= x"ffffff" & x"28"; -- '('
236 command_next <= COMMAND_SET_CHAR;
237 -- d_zeile/2, zehnerstelle
238 command_data_next <= x"ffffff" & x"78"; -- 'x'
240 command_next <= COMMAND_SET_CHAR;
241 -- d_zeile/2, einerstelle
242 command_data_next <= x"ffffff" & x"79"; -- 'y'
244 command_next <= COMMAND_SET_CHAR;
245 command_data_next <= x"ffffff" & x"29"; -- ')'
247 command_next <= COMMAND_SET_CHAR;
248 command_data_next <= x"ffffff" & x"24"; -- '$'
250 command_next <= COMMAND_SET_CHAR;
251 command_data_next <= x"ffffff" & x"20"; -- ' '
254 when S_NEW_RESULT => null;
255 when S_NEW_INPUT => null;
258 -- underflow check schon im history modul
259 d_spalte_next <= std_logic_vector(unsigned(d_spalte_int) - 1);
261 -- einen schritt zurueck, +6 wegen $PS1
262 command_next <= COMMAND_SET_CURSOR_COLUMN;
263 command_data_next <= x"ffffff" & '0' & std_logic_vector(unsigned(d_spalte_int) + 6);
265 command_next <= COMMAND_SET_CHAR;
266 command_data_next <= x"ffffff" & x"20"; -- white space
269 d_spalte_next <= (others => '0');
272 when "1100010" => d_zeile_next <= (others => '0');
273 when others => d_zeile_next <= std_logic_vector(unsigned(d_zeile_int) + 1);
277 command_next <= COMMAND_SET_CHAR;
278 command_data_next <= x"ffffff" & x"0d"; -- carrige return
280 command_next <= COMMAND_SET_CHAR;
281 command_data_next <= x"ffffff" & x"0a"; -- newline
283 -- TODO: coole farben
284 when S_READ_RESULT_0 =>
285 command_next <= COMMAND_SET_CHAR;
286 command_data_next <= x"ffffff" & x"3e"; -- '>'
287 when S_READ_RESULT_1 =>
288 command_next <= COMMAND_SET_CHAR;
289 command_data_next <= x"ffffff" & x"20"; -- ' '
290 when S_READ_RESULT_2 => null;
294 d_spalte_next <= std_logic_vector(unsigned(d_spalte_int) + 1);
298 if d_char /= x"00" then
299 command_next <= COMMAND_SET_CHAR;
300 command_data_next <= x"ffffff" & std_logic_vector(d_char);
302 when S_PUTCH2 => null;
303 when S_WAIT | S_NOP1 =>
304 command_next <= COMMAND_NOP;
305 command_data_next <= x"00000000";
308 end architecture beh;