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;
24 sys_res_n => sys_res_n,
32 p_finished => p_finished,
52 file f : text open read_mode is "../../src/parser.test";
55 variable input : hstring;
56 variable expectedresult : hstring;
57 variable realresult : hstring;
58 variable hstrtmp : hstring;
60 variable checkall : boolean := true;
61 variable run_tc : boolean := true;
62 variable i, j, k, y : natural;
68 p_read <= (others => '0');
75 f_loop : while not endfile(f) loop
76 realresult := (HSPALTE_MAX+1 => nul, others => ' ');
78 f1_loop : while not endfile(f) loop
80 input := (others => nul);
81 if (l'length <= HSPALTE_MAX+1) then
82 input(1 to l'length) := l.all;
83 if (input(1) = '#') then
89 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
94 f2_loop : while not endfile(f) loop
96 expectedresult := (others => nul);
97 if (l'length <= HSPALTE_MAX+1) then
98 expectedresult(1 to l'length) := l.all;
99 if (expectedresult(1) = '#') then
106 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
111 -- ergebnis string richtig formatieren
112 hstrtmp := expectedresult;
113 expectedresult := (HSPALTE_MAX+1 => nul, others => ' ');
114 for x in 1 to HSPALTE_MAX loop
115 if hstrtmp(x) /= nul then
116 expectedresult((HSPALTE_MAX-y) + x) := hstrtmp(x);
121 report "testcase(" & natural'image(i) & ").input: " & input;
122 report "testcase(" & natural'image(i) & ").expectedresult: " & expectedresult;
128 j := 1; k := HSPALTE_MAX;
131 wait on p_rget, p_wtake, p_finished, finished;
135 p_read <= hbyte( to_unsigned(character'pos(input(j)),8) );
143 if p_wtake = '1' then
144 realresult(k) := character'val(to_integer(unsigned(p_write)));
148 if p_wtake = '0' then
152 if p_finished = '1' or finished = '1' then
158 report "realresult : " & realresult;
159 if realresult /= expectedresult then
162 report "==================";
166 report "alle testfaelle des Parser waren erfolgreich!";
168 report "nicht alle testfaelle des Parsers waren erfolgreich!";
173 end architecture sim;