2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
6 entity beh_scanner_tb is
7 end entity beh_scanner_tb;
9 architecture sim of beh_scanner_tb is
11 signal sys_clk, sys_res_n : std_logic;
13 signal new_data : std_logic;
14 signal data : std_logic_vector(7 downto 0);
16 signal s_char : hbyte;
17 signal s_take, s_done, s_backspace : std_logic;
19 signal do_it : std_logic;
20 signal finished : std_logic;
22 signal stop : boolean := false;
24 inst : entity work.scanner(beh)
27 sys_res_n => sys_res_n,
35 s_backspace => s_backspace,
55 file f : text open read_mode is "../../src/scanner.test";
58 variable input : hstring;
59 variable expectedresult : hstring;
60 variable realresult : hstring;
62 variable checkall : boolean := true;
63 variable run_tc, run_inner : boolean := true;
64 variable i, j, k, y : natural;
69 data <= (others => '0');
77 f_loop : while not endfile(f) loop
78 data <= (others => '0');
79 realresult := (others => nul);
81 f1_loop : while not endfile(f) loop
83 input := (others => nul);
84 if (l'length <= 72) then
85 input(1 to l'length) := l.all;
86 if (input(1) = '#') then
92 report "fehler in scanner.test: eingabe zu lange in testfall " & natural'image(i);
97 f2_loop : while not endfile(f) loop
99 expectedresult := (others => nul);
100 if (l'length <= 72) then
101 expectedresult(1 to l'length) := l.all;
102 if (expectedresult(1) = '#') then
109 report "fehler in scanner.test: eingabe zu lange in testfall " & natural'image(i);
116 report "testcase(" & natural'image(i) & ").input: " & input;
117 report "testcase(" & natural'image(i) & ").expectedresult: " & expectedresult;
124 mainl : while run_tc loop
130 assert(false) report "wtf @ schleife";
137 when nul => data <= ascii2sc(x"1c"); -- $ (enter)
138 when '!' => data <= ascii2sc(x"0e"); -- ! (backspace)
146 when others => data <= ascii2sc(std_logic_vector(to_unsigned(character'pos(input(j)),8)));
151 -- ack'en skippen, falls es ein "spezielles" zeichen ist
152 if(not valid_char(data)) then
156 -- wuenschswert waere das hier:
157 -- > wait on s_backspace, s_take, do_it;
158 -- geht aber leider nicht, weil sich die signale vllt schon
161 main_inner : while run_inner loop
165 if s_backspace = '1' then
167 realresult(k) := nul;
169 realresult(k) := nul;
173 wait on s_take; -- = '0'
176 elsif do_it = '1' then
177 -- dauert normalweiser noch laenger (parser braucht
181 wait on do_it; -- = '0'
186 elsif s_take = '1' then
187 realresult(k) := character'val(to_integer(unsigned(s_char)));
192 wait on s_take; -- = '0'
196 -- assert(false) report "scanner_tb: kann passieren. wenn tb haengt, dann hier auskommentieren";
202 report "realresult : " & realresult;
203 if realresult /= expectedresult then
206 report "==================";
210 report "alle testfaelle des Scanners waren erfolgreich!";
212 report "nicht alle testfaelle des Scanners waren erfolgreich!";
217 end architecture sim;