2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
6 entity post_parser_tb is
7 end entity post_parser_tb;
9 architecture sim of post_parser_tb is
12 sys_clk : in std_logic;
13 sys_res_n : in std_logic;
15 p_rget : out std_logic;
16 p_rdone : in std_logic;
18 p_wtake : out std_logic;
19 p_wdone : in std_logic;
21 p_finished : out std_logic;
24 finished : out std_logic
28 signal sys_clk, sys_res_n : std_logic;
30 signal p_rget, p_rdone, p_wtake, p_wdone, p_finished : std_logic;
31 signal p_read, p_write : hbyte;
33 signal do_it : std_logic;
34 signal finished : std_logic;
36 signal stop : boolean := false;
42 sys_res_n => sys_res_n,
50 p_finished => p_finished,
70 file f : text open read_mode is "../../src/parser.test";
73 variable input : hstring;
74 variable expectedresult : hstring;
75 variable realresult : hstring;
76 variable hstrtmp : hstring;
78 variable checkall : boolean := true;
79 variable run_tc : boolean := true;
80 variable i, j, k, y : natural;
86 p_read <= (others => '0');
93 f_loop : while not endfile(f) loop
94 realresult := (HSPALTE_MAX+1 => nul, others => ' ');
96 f1_loop : while not endfile(f) loop
98 input := (others => nul);
99 if (l'length <= HSPALTE_MAX+1) then
100 input(1 to l'length) := l.all;
101 if (input(1) = '#') then
107 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
112 f2_loop : while not endfile(f) loop
114 expectedresult := (others => nul);
115 if (l'length <= HSPALTE_MAX+1) then
116 expectedresult(1 to l'length) := l.all;
117 if (expectedresult(1) = '#') then
124 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
129 -- ergebnis string richtig formatieren
130 hstrtmp := expectedresult;
131 expectedresult := (HSPALTE_MAX+1 => nul, others => ' ');
132 for x in 1 to HSPALTE_MAX loop
133 if hstrtmp(x) /= nul then
134 expectedresult((HSPALTE_MAX-y) + x) := hstrtmp(x);
139 report "testcase(" & natural'image(i) & ").input: " & input;
140 report "testcase(" & natural'image(i) & ").expectedresult: " & expectedresult;
146 j := 1; k := HSPALTE_MAX;
149 wait on p_rget, p_wtake, p_finished, finished;
153 p_read <= hbyte( to_unsigned(character'pos(input(j)),8) );
161 if p_wtake = '1' then
162 realresult(k) := character'val(to_integer(unsigned(p_write)));
166 if p_wtake = '0' then
170 if p_finished = '1' or finished = '1' then
176 report "realresult : " & realresult;
177 if realresult /= expectedresult then
180 report "==================";
184 report "alle testfaelle des Parser waren erfolgreich!";
186 report "nicht alle testfaelle des Parsers waren erfolgreich!";
191 end architecture sim;