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 : 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,
48 calc_done => calc_done,
49 calc_error => calc_error,
50 -- TODO: calc_error : in std_logic;
56 instalu : entity work.alu(beh)
60 sys_res_n => sys_res_n,
62 calc_done => calc_done,
63 calc_error => calc_error,
84 file f : text open read_mode is "../../src/parser.test";
87 variable input : hstring;
88 variable expectedresult : hstring;
89 variable realresult : hstring;
90 variable hstrtmp : hstring;
92 variable checkall : boolean := true;
93 variable run_tc : boolean := true;
94 variable i, j, k, y : natural;
100 p_read <= (others => '0');
107 f_loop : while not endfile(f) loop
108 realresult := (71 => character'val(0), others => character'val(32));
110 f1_loop : while not endfile(f) loop
112 input := (others => character'val(0));
113 if (l'length <= 72) then
114 input(1 to l'length) := l.all;
115 if (input(1) = '#') then
121 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
126 f2_loop : while not endfile(f) loop
128 expectedresult := (others => character'val(0));
129 if (l'length <= 72) then
130 expectedresult(1 to l'length) := l.all;
131 if (expectedresult(1) = '#') then
138 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
143 -- ergebnis string richtig formatieren
144 hstrtmp := expectedresult;
145 expectedresult := (71 => character'val(0), others => character'val(32));
146 for x in 1 to 70 loop
147 if hstrtmp(x) /= character'val(0) then
148 expectedresult((70-y) + x) := hstrtmp(x);
153 report "testcase(" & natural'image(i) & ").input: " & input;
154 report "testcase(" & natural'image(i) & ").expectedresult: " & expectedresult;
163 wait on p_rget, p_wtake, p_finished, finished;
167 p_read <= hbyte( to_unsigned(character'pos(input(j)),8) );
175 if p_wtake = '1' then
176 realresult(k) := character'val(to_integer(unsigned(p_write)));
180 if p_wtake = '0' then
184 if p_finished = '1' or finished = '1' then
190 report "realresult : " & realresult;
191 if realresult /= expectedresult then
194 report "==================";
198 report "alle testfaelle des Parser waren erfolgreich!";
200 report "nicht alle testfaelle des Parsers waren erfolgreich!";
205 end architecture sim;