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;
18 signal opcode : alu_ops;
19 signal op1, op2, op3, opM : csigned;
20 signal do_calc, calc_done, calc_error : std_logic;
23 signal do_it : std_logic;
24 signal finished : std_logic;
26 signal stop : boolean := false;
28 inst : entity work.parser(beh)
32 sys_res_n => sys_res_n,
41 p_finished => p_finished,
49 calc_done => calc_done,
50 calc_error => calc_error,
51 -- TODO: calc_error : in std_logic;
57 instalu : entity work.alu(beh)
61 sys_res_n => sys_res_n,
63 calc_done => calc_done,
64 calc_error => calc_error,
86 file f : text open read_mode is "../../src/parser.test";
89 variable input : hstring;
90 variable expectedresult : hstring;
91 variable realresult : hstring;
92 variable hstrtmp : hstring;
94 variable checkall : boolean := true;
95 variable run_tc : boolean := true;
96 variable i, j, k, y : natural;
102 p_read <= (others => '0');
109 f_loop : while not endfile(f) loop
110 realresult := (71 => nul, others => ' ');
112 f1_loop : while not endfile(f) loop
114 input := (others => nul);
115 if (l'length <= 72) then
116 input(1 to l'length) := l.all;
117 if (input(1) = '#') then
123 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
128 f2_loop : while not endfile(f) loop
130 expectedresult := (others => nul);
131 if (l'length <= 72) then
132 expectedresult(1 to l'length) := l.all;
133 if (expectedresult(1) = '#') then
140 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
145 -- ergebnis string richtig formatieren
146 hstrtmp := expectedresult;
147 expectedresult := (71 => nul, others => ' ');
148 for x in 1 to 70 loop
149 if hstrtmp(x) /= nul then
150 expectedresult((70-y) + x) := hstrtmp(x);
155 report "testcase(" & natural'image(i) & ").input: " & input;
156 report "testcase(" & natural'image(i) & ").expectedresult: " & expectedresult;
165 wait on p_rget, p_wtake, p_finished, finished;
169 p_read <= hbyte( to_unsigned(character'pos(input(j)),8) );
177 if p_wtake = '1' then
178 realresult(k) := character'val(to_integer(unsigned(p_write)));
182 if p_wtake = '0' then
186 if p_finished = '1' or finished = '1' then
192 report "realresult : " & realresult;
193 if realresult /= expectedresult then
196 report "==================";
200 report "alle testfaelle des Parser waren erfolgreich!";
202 report "nicht alle testfaelle des Parsers waren erfolgreich!";
207 end architecture sim;