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, S_INIT, S_PS1_0,
33 S_PS1_1, S_PS1_2, S_PS1_3, S_PS1_4, S_PS1_5);
34 signal state_int, state_next : DISPLAY_STATE;
35 signal d_zeile_int, d_zeile_next : hzeile;
36 signal d_spalte_int, d_spalte_next : hspalte;
37 signal d_get_int, d_get_next : std_logic;
38 signal command_int, command_next : std_logic_vector(7 downto 0);
39 signal command_data_int, command_data_next : std_logic_vector(31 downto 0);
40 signal istate_next, istate_int : signed(3 downto 0);
42 d_zeile <= d_zeile_int;
43 d_spalte <= d_spalte_int;
45 command <= command_int;
46 command_data <= command_data_int;
48 process(sys_clk, sys_res_n)
50 if sys_res_n = '0' then
53 istate_int <= (others => '0');
55 d_zeile_int <= (others => '0');
56 d_spalte_int <= (others => '0');
58 command_int <= COMMAND_NOP;
59 command_data_int <= (others => '0');
60 elsif rising_edge(sys_clk) then
62 state_int <= state_next;
63 istate_int <= istate_next;
65 d_zeile_int <= d_zeile_next;
66 d_spalte_int <= d_spalte_next;
67 d_get_int <= d_get_next;
68 command_int <= command_next;
69 command_data_int <= command_data_next;
74 process(state_int, d_new_result, d_new_eingabe, d_new_bs, d_done, free,
75 d_spalte_int, d_char, istate_int)
77 state_next <= state_int;
78 istate_next <= istate_int;
82 state_next <= S_PS1_0;
85 istate_next <= b"1001";
88 istate_next <= b"1010";
91 istate_next <= b"1011";
94 istate_next <= b"1100";
97 istate_next <= b"1101";
100 istate_next <= b"0111";
101 state_next <= S_WAIT;
104 istate_next <= b"0111"; -- default: immer wieder ins SIDLE;
105 if d_new_bs = '1' then
106 state_next <= S_NEW_BS;
107 elsif d_new_eingabe = '1' then
108 state_next <= S_NEW_INPUT;
110 if d_new_result = '1' then
111 state_next <= S_NEW_RESULT;
115 state_next <= S_ZEILEUP;
117 state_next <= S_COUNTUP;
120 state_next <= S_BACK;
123 state_next <= S_WAIT;
125 when b"0111" => istate_next <= b"0001"; -- => danach S_BLANK und wieder hierher
126 when others => istate_next <= b"0111"; -- => danach SIDLE
131 state_next <= S_WAIT;
132 istate_next <= b"0010"; -- => danach S_BACK
138 state_next <= S_WAIT;
139 istate_next <= b"1000"; -- => danach S_PS1
140 when others => state_next <= S_CR1;
145 state_next <= S_WAIT;
147 when b"0110" => istate_next <= b"0101"; -- => danach S_NL1, S_ZEILEUP, S_PS1, SIDLE
148 when others => istate_next <= b"0000"; -- => danach S_NL1 und S_COUNTUP
153 state_next <= S_WAIT;
155 when b"0101" => istate_next <= b"0011"; -- => danach S_ZEILEUP, PS1
156 when others => istate_next <= b"0100"; -- => danach S_READ_RESULT
159 when S_READ_RESULT =>
160 if unsigned(d_spalte_int) /= 70 then
161 state_next <= S_COUNTUP;
162 istate_next <= b"0100"; -- => wieder nach S_READ_RESULT
164 state_next <= S_WAIT;
165 istate_next <= b"0110"; -- => danach S_CR1 und d_spalte_next clearen und d_zeile_next inkrementieren
169 state_next <= S_GETCH;
171 if free = '1' and d_done = '1' and d_new_result = '0' and d_new_eingabe = '0' then
172 state_next <= S_PUTCH1;
175 state_next <= S_PUTCH2;
177 if free = '0' or (free = '1' and d_char = x"00") then
178 state_next <= S_WAIT;
181 if free = '1' and d_done = '0' then
182 state_next <= S_NOP1;
187 when b"0000" => state_next <= S_NL1;
188 when b"0001" => state_next <= S_BLANK;
189 when b"0010" => state_next <= S_BACK;
190 when b"0011" => state_next <= S_ZEILEUP;
191 when b"0100" => state_next <= S_READ_RESULT;
192 when b"0110" => state_next <= S_CR1;
193 when b"0101" => state_next <= S_NL1;
195 when b"1000" => state_next <= S_PS1_0;
196 when b"1001" => state_next <= S_PS1_1;
197 when b"1010" => state_next <= S_PS1_2;
198 when b"1011" => state_next <= S_PS1_3;
199 when b"1100" => state_next <= S_PS1_4;
200 when b"1101" => state_next <= S_PS1_5;
201 when others => state_next <= SIDLE;
208 process(state_int, d_zeile_int, d_spalte_int, d_get_int, command_int,
209 command_data_int, d_char)
211 d_zeile_next <= d_zeile_int;
212 d_spalte_next <= d_spalte_int;
214 command_next <= command_int;
215 command_data_next <= command_data_int;
220 -- TODO: coole farben
222 command_next <= COMMAND_SET_CHAR;
223 command_data_next <= x"ffffff" & x"28"; -- '('
225 command_next <= COMMAND_SET_CHAR;
226 -- d_zeile/2, zehnerstelle
227 command_data_next <= x"ffffff" & x"78"; -- 'x'
229 command_next <= COMMAND_SET_CHAR;
230 -- d_zeile/2, einerstelle
231 command_data_next <= x"ffffff" & x"79"; -- 'y'
233 command_next <= COMMAND_SET_CHAR;
234 command_data_next <= x"ffffff" & x"29"; -- ')'
236 command_next <= COMMAND_SET_CHAR;
237 command_data_next <= x"ffffff" & x"24"; -- '$'
239 command_next <= COMMAND_SET_CHAR;
240 command_data_next <= x"ffffff" & x"20"; -- ' '
243 when S_NEW_RESULT => null;
244 when S_NEW_INPUT => null;
247 -- underflow check schon im history modul
248 d_spalte_next <= std_logic_vector(unsigned(d_spalte_int) - 1);
250 -- einen schritt zurueck, +6 wegen $PS1
251 command_next <= COMMAND_SET_CURSOR_COLUMN;
252 command_data_next <= x"ffffff" & '0' & std_logic_vector(unsigned(d_spalte_int) + 6);
254 command_next <= COMMAND_SET_CHAR;
255 command_data_next <= x"ffffff" & x"20"; -- white space
258 d_spalte_next <= (others => '0');
261 when "1100010" => d_zeile_next <= (others => '0');
262 when others => d_zeile_next <= std_logic_vector(unsigned(d_zeile_int) + 1);
266 command_next <= COMMAND_SET_CHAR;
267 command_data_next <= x"ffffff" & x"0d"; -- carrige return
269 command_next <= COMMAND_SET_CHAR;
270 command_data_next <= x"ffffff" & x"0a"; -- newline
271 when S_READ_RESULT => null;
275 d_spalte_next <= std_logic_vector(unsigned(d_spalte_int) + 1);
279 if d_char /= x"00" then
280 command_next <= COMMAND_SET_CHAR;
281 command_data_next <= x"ffffff" & std_logic_vector(d_char);
283 when S_PUTCH2 => null;
284 when S_WAIT | S_NOP1 =>
285 command_next <= COMMAND_NOP;
286 command_data_next <= x"00000000";
289 end architecture beh;