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 : 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 -- TODO: calc_error : in std_logic;
55 instalu : entity work.alu(beh)
59 sys_res_n => sys_res_n,
61 calc_done => calc_done,
82 file f : text open read_mode is "../../src/parser.test";
85 variable input : hstring;
86 variable expectedresult : hstring;
87 variable realresult : hstring;
89 variable checkall : boolean := true;
90 variable run_tc : boolean := true;
91 variable i, j, k : natural;
97 p_read <= (others => '0');
104 f_loop : while not endfile(f) loop
105 realresult := (others => character'val(0));
107 f1_loop : while not endfile(f) loop
109 input := (others => character'val(0));
110 if (l'length <= 72) then
111 input(1 to l'length) := l.all;
112 if (input(1) = '#') then
118 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
123 f2_loop : while not endfile(f) loop
125 expectedresult := (others => character'val(0));
126 if (l'length <= 72) then
127 expectedresult(1 to l'length) := l.all;
128 if (expectedresult(1) = '#') then
134 report "fehler in parser.test: eingabe zu lange in testfall " & natural'image(i);
139 report "testcase(" & natural'image(i) & ").input: " & input;
140 report "testcase(" & natural'image(i) & ").expectedresult: " & expectedresult;
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;