2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
6 entity beh_parser_tb is
7 end entity beh_parser_tb;
9 architecture sim of beh_parser_tb is
11 signal sys_clk, sys_res_n : std_logic;
13 signal p_rw, p_rget, p_rdone, p_wtake, p_wdone, p_finished : std_logic;
14 signal p_read, p_write : hbyte;
15 signal p_spalte : hspalte;
17 signal do_it : std_logic;
18 signal finished : std_logic;
20 signal stop : boolean := false;
22 inst : entity work.parser(beh)
26 sys_res_n => sys_res_n,
35 p_finished => p_finished,
55 file f : text open read_mode is "../../src/parser.test";
58 variable input : hstring;
59 variable expectedresult : hstring;
60 variable realresult : hstring;
61 variable hstrtmp : hstring;
63 variable checkall : boolean := true;
64 variable run_tc : boolean := true;
65 variable i, j, k, y : natural;
71 p_read <= (others => '0');
78 f_loop : while not endfile(f) loop
79 realresult := (72 => nul, others => ' ');
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 parser.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 parser.test: eingabe zu lange in testfall " & natural'image(i);
114 -- ergebnis string richtig formatieren
115 hstrtmp := expectedresult;
116 expectedresult := (72 => nul, others => ' ');
117 for x in 1 to 71 loop
118 if hstrtmp(x) /= nul then
119 expectedresult((71-y) + x) := hstrtmp(x);
124 report "testcase(" & natural'image(i) & ").input: " & input;
125 report "testcase(" & natural'image(i) & ").expectedresult: " & expectedresult;
134 wait on p_rget, p_wtake, p_finished, finished;
138 p_read <= hbyte( to_unsigned(character'pos(input(j)),8) );
146 if p_wtake = '1' then
147 realresult(k) := character'val(to_integer(unsigned(p_write)));
151 if p_wtake = '0' then
155 if p_finished = '1' or finished = '1' then
161 report "realresult : " & realresult;
162 if realresult /= expectedresult then
165 report "==================";
169 report "alle testfaelle des Parser waren erfolgreich!";
171 report "nicht alle testfaelle des Parsers waren erfolgreich!";
176 end architecture sim;