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);
33 signal state_int, state_next : DISPLAY_STATE;
34 signal d_zeile_int, d_zeile_next : hzeile;
35 signal d_spalte_int, d_spalte_next : hspalte;
36 signal d_get_int, d_get_next : std_logic;
37 signal command_int, command_next : std_logic_vector(7 downto 0);
38 signal command_data_int, command_data_next : std_logic_vector(31 downto 0);
39 signal istate_next, istate_int : signed(2 downto 0);
41 d_zeile <= d_zeile_int;
42 d_spalte <= d_spalte_int;
44 command <= command_int;
45 command_data <= command_data_int;
47 process(sys_clk, sys_res_n)
49 if sys_res_n = '0' then
52 istate_int <= (others => '0');
54 d_zeile_int <= (others => '0');
55 d_spalte_int <= (others => '0');
57 command_int <= COMMAND_NOP;
58 command_data_int <= (others => '0');
59 elsif rising_edge(sys_clk) then
61 state_int <= state_next;
62 istate_int <= istate_next;
64 d_zeile_int <= d_zeile_next;
65 d_spalte_int <= d_spalte_next;
66 d_get_int <= d_get_next;
67 command_int <= command_next;
68 command_data_int <= command_data_next;
73 process(state_int, d_new_result, d_new_eingabe, d_new_bs, d_done, free,
74 d_spalte_int, d_char, istate_int)
76 state_next <= state_int;
77 istate_next <= istate_int;
81 istate_next <= b"111"; -- default: immer wieder ins SIDLE;
82 if d_new_bs = '1' then
83 state_next <= S_NEW_BS;
84 elsif d_new_eingabe = '1' then
85 state_next <= S_NEW_INPUT;
87 if d_new_result = '1' then
88 state_next <= S_NEW_RESULT;
92 state_next <= S_ZEILEUP;
94 state_next <= S_COUNTUP;
100 state_next <= S_WAIT;
102 when b"111" => istate_next <= b"001"; -- => danach S_BLANK und wieder hierher
103 when others => istate_next <= b"111"; -- => danach SIDLE
108 state_next <= S_WAIT;
109 istate_next <= b"010"; -- => danach S_BACK
115 state_next <= S_WAIT;
116 istate_next <= b"111";
117 when others => state_next <= S_CR1;
122 state_next <= S_WAIT;
124 when b"110" => istate_next <= b"101"; -- => danach S_NL1 und SIDLe
125 when others => istate_next <= b"000"; -- => danach S_NL1 und S_COUNTUP
130 state_next <= S_WAIT;
132 when b"101" => istate_next <= b"011"; -- => danach S_ZEILEUP
133 when others => istate_next <= b"100"; -- => danach S_READ_RESULT
136 when S_READ_RESULT =>
137 if unsigned(d_spalte_int) /= 70 then
138 state_next <= S_COUNTUP;
139 istate_next <= b"100"; -- => wieder nach S_READ_RESULT
141 state_next <= S_WAIT;
142 istate_next <= b"110"; -- => danach S_CR1 und d_spalte_next clearen und d_zeile_next inkrementieren
146 state_next <= S_GETCH;
148 if free = '1' and d_done = '1' and d_new_result = '0' and d_new_eingabe = '0' then
149 state_next <= S_PUTCH1;
152 state_next <= S_PUTCH2;
154 if free = '0' or (free = '1' and d_char = x"00") then
155 state_next <= S_WAIT;
158 if free = '1' and d_done = '0' then
159 state_next <= S_NOP1;
164 when b"000" => state_next <= S_NL1;
165 when b"001" => state_next <= S_BLANK;
166 when b"010" => state_next <= S_BACK;
167 when b"011" => state_next <= S_ZEILEUP;
168 when b"100" => state_next <= S_READ_RESULT;
169 when b"110" => state_next <= S_CR1;
170 when b"101" => state_next <= S_NL1;
171 when others => state_next <= SIDLE;
178 process(state_int, d_zeile_int, d_spalte_int, d_get_int, command_int,
179 command_data_int, d_char, istate_int)
181 d_zeile_next <= d_zeile_int;
182 d_spalte_next <= d_spalte_int;
184 command_next <= command_int;
185 command_data_next <= command_data_int;
195 -- underflow check schon im history modul
196 d_spalte_next <= std_logic_vector(unsigned(d_spalte_int) - 1);
198 -- einen schritt zurueck
199 command_next <= COMMAND_SET_CURSOR_COLUMN;
200 command_data_next <= x"ffffff" & '0' & std_logic_vector(unsigned(d_spalte_int));
202 command_next <= COMMAND_SET_CHAR;
203 command_data_next <= x"ffffff" & x"20"; -- white space
206 d_spalte_next <= (others => '0');
208 when "1111111" => d_zeile_next <= (others => '0');
209 when others => d_zeile_next <= std_logic_vector(unsigned(d_zeile_int) + 1);
213 command_next <= COMMAND_SET_CHAR;
214 command_data_next <= x"ffffff" & x"0d"; -- carrige return
216 command_next <= COMMAND_SET_CHAR;
217 command_data_next <= x"ffffff" & x"0a"; -- newline
218 when S_READ_RESULT => null;
222 d_spalte_next <= std_logic_vector(unsigned(d_spalte_int) + 1);
226 if d_char /= x"00" then
227 command_next <= COMMAND_SET_CHAR;
228 command_data_next <= x"ffffff" & std_logic_vector(d_char);
230 when S_PUTCH2 => null;
231 when S_WAIT | S_NOP1 =>
232 command_next <= COMMAND_NOP;
233 command_data_next <= x"00000000";
236 end architecture beh;