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;
9 entity beh_history_tb is
10 end entity beh_history_tb;
12 architecture sim of beh_history_tb is
14 signal sys_clk, sys_res_n : std_logic;
16 signal d_new_eingabe, d_new_result, d_new_bs : std_logic;
17 signal d_zeile : hzeile;
18 signal d_spalte : hspalte;
19 signal d_get, d_done : std_logic;
20 signal d_char : hbyte;
22 signal s_char : hbyte;
23 signal s_take, s_done, s_backspace : std_logic;
25 signal new_data : std_logic;
26 signal data : std_logic_vector(7 downto 0);
28 signal free : std_logic;
29 signal command : std_logic_vector(COMMAND_SIZE - 1 downto 0);
30 signal command_data : std_logic_vector(3 * COLOR_SIZE + CHAR_SIZE -1 downto 0);
32 -- tmp: history<>scanner
33 signal do_it, finished : std_logic;
35 signal stop : boolean := false;
38 inst : entity work.history(beh)
41 sys_res_n => sys_res_n,
46 s_backspace => s_backspace,
48 d_new_eingabe => d_new_eingabe,
49 d_new_result => d_new_result,
62 inst_disp : entity work.display(beh)
65 sys_res_n => sys_res_n,
67 d_new_eingabe => d_new_eingabe,
68 d_new_result => d_new_result,
77 command_data => command_data,
82 inst_scan : entity work.scanner(beh)
85 sys_res_n => sys_res_n,
93 s_backspace => s_backspace,
123 function ascii2sc (x : hbyte) return hbyte is
127 when x"30" => y := SC_KP_0;
128 when x"31" => y := SC_KP_1;
129 when x"32" => y := SC_KP_2;
130 when x"33" => y := SC_KP_3;
131 when x"34" => y := SC_KP_4;
132 when x"35" => y := SC_KP_5;
133 when x"36" => y := SC_KP_6;
134 when x"37" => y := SC_KP_7;
135 when x"38" => y := SC_KP_8;
136 when x"39" => y := SC_KP_9;
137 when x"2b" => y := SC_KP_PLUS;
138 when x"2d" => y := SC_KP_MINUS;
139 when x"2a" => y := SC_KP_MUL;
140 when x"2f" => y := SC_KP_DIV;
141 when x"20" => y := SC_SPACE;
142 when x"1c" => y := SC_ENTER;
143 when x"0e" => y := SC_BKSP;
144 when others => y := x"41";
149 function valid_char (x : std_logic_vector(7 downto 0)) return boolean is
150 variable y : boolean;
153 when SC_KP_0 | SC_KP_1 | SC_KP_2 | SC_KP_3 |
154 SC_KP_4 | SC_KP_5 | SC_KP_6 | SC_KP_7 |
155 SC_KP_8 | SC_KP_9 | SC_KP_PLUS |
156 SC_KP_MINUS | SC_KP_MUL |
157 SC_KP_DIV | SC_SPACE |
158 SC_BKSP | SC_ENTER =>
160 when others => y := false;
167 file f : text open read_mode is "../../src/history.test";
170 variable input : hstring;
172 variable run_tc, run_inner : boolean := true;
173 variable i, j, y : natural;
178 data <= (others => '0');
186 f_loop : while not endfile(f) loop
187 data <= (others => '0');
189 f1_loop : while not endfile(f) loop
191 input := (others => nul);
192 if (l'length <= 72) then
193 input(1 to l'length) := l.all;
194 if (input(1) = '#') then
200 report "fehler in history.test: eingabe zu lange in testfall " & natural'image(i);
205 report "testcase(" & natural'image(i) & ").input: " & input;
212 mainl : while run_tc loop
218 assert(false) report "wtf @ schleife";
231 when nul => data <= ascii2sc(x"1c"); -- $ (enter)
232 when '!' => data <= ascii2sc(x"0e"); -- ! (backspace)
233 when others => data <= ascii2sc(std_logic_vector(to_unsigned(character'pos(input(j)),8)));
238 -- ack'en skippen, falls es ein "spezielles" zeichen ist (steht
239 -- in abhaengigkeit zum vorherigen zeichen)
240 if(not valid_char(data)) then
244 -- wuenschswert waere das hier:
245 -- > wait on s_backspace, s_take, do_it;
246 -- geht aber leider nicht, weil sich die signale vllt schon
249 main_inner : while run_inner loop
253 if s_backspace = '1' or s_take = '1' then
256 wait on s_take; -- = '0'
259 elsif do_it = '1' then
260 -- dauert normalweiser noch laenger (parser braucht
264 wait on do_it; -- = '0'
270 -- assert(false) report "history_tb: kann passieren. wenn tb haengt, dann hier auskommentieren";
275 report "==================";
282 end architecture sim;