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_rget, p_rdone, p_wtake, p_wdone, p_finished : std_logic;
14 signal p_read, p_write : hbyte;
16 signal do_it : std_logic;
17 signal finished : std_logic;
19 signal stop : boolean := false;
21 inst : entity work.parser(beh)
25 sys_res_n => sys_res_n,
33 p_finished => p_finished,
53 file f : text open read_mode is "../../src/parser.test";
56 variable input : hstring;
57 variable expectedresult : hstring;
58 variable realresult : hstring;
59 variable hstrtmp : hstring;
61 variable checkall : boolean := true;
62 variable run_tc : boolean := true;
63 variable i, j, k, y : natural;
69 p_read <= (others => '0');
76 f_loop : while not endfile(f) loop
77 realresult := (HSPALTE_MAX+1 => nul, others => ' ');
79 f1_loop : while not endfile(f) loop
81 input := (others => nul);
82 if (l'length <= HSPALTE_MAX+1) then
83 input(1 to l'length) := l.all;
84 if (input(1) = '#') then
90 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
95 f2_loop : while not endfile(f) loop
97 expectedresult := (others => nul);
98 if (l'length <= HSPALTE_MAX+1) then
99 expectedresult(1 to l'length) := l.all;
100 if (expectedresult(1) = '#') then
107 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
112 -- ergebnis string richtig formatieren
113 hstrtmp := expectedresult;
114 expectedresult := (HSPALTE_MAX+1 => nul, others => ' ');
115 for x in 1 to HSPALTE_MAX loop
116 if hstrtmp(x) /= nul then
117 expectedresult((HSPALTE_MAX-y) + x) := hstrtmp(x);
122 report "testcase(" & natural'image(i) & ").input: " & input;
123 report "testcase(" & natural'image(i) & ").expectedresult: " & expectedresult;
129 j := 1; k := HSPALTE_MAX;
132 wait on p_rget, p_wtake, p_finished, finished;
136 p_read <= hbyte( to_unsigned(character'pos(input(j)),8) );
144 if p_wtake = '1' then
145 realresult(k) := character'val(to_integer(unsigned(p_write)));
149 if p_wtake = '0' then
153 if p_finished = '1' or finished = '1' then
159 report "realresult : " & realresult;
160 if realresult /= expectedresult then
163 report "==================";
167 report "alle testfaelle des Parser waren erfolgreich!";
169 report "nicht alle testfaelle des Parsers waren erfolgreich!";
174 end architecture sim;