From b9c26b2c933e07787a1b36e0934b7123e7f6bd02 Mon Sep 17 00:00:00 2001 From: Erik Kooistra <kooistra@astron.nl> Date: Mon, 9 May 2016 10:54:35 +0000 Subject: [PATCH] Made tb self stopping and self checking by means of golden reference files. --- .../base/common/tb/vhdl/tb_requantize.vhd | 107 +++++++++++++++++- 1 file changed, 103 insertions(+), 4 deletions(-) diff --git a/libraries/base/common/tb/vhdl/tb_requantize.vhd b/libraries/base/common/tb/vhdl/tb_requantize.vhd index 92505aa7bb..9f4ca004fa 100644 --- a/libraries/base/common/tb/vhdl/tb_requantize.vhd +++ b/libraries/base/common/tb/vhdl/tb_requantize.vhd @@ -45,7 +45,7 @@ END tb_requantize; ARCHITECTURE tb OF tb_requantize IS CONSTANT clk_period : TIME := 10 ns; - CONSTANT c_output_file_dir : STRING := "../../../data/"; + CONSTANT c_output_file_dir : STRING := "data/"; CONSTANT c_nof_dut : NATURAL := 4; CONSTANT g_pipeline_remove_lsb : NATURAL := 0; @@ -86,21 +86,41 @@ ARCHITECTURE tb OF tb_requantize IS -- Verification by means of writing output files that can be compared with stored golden reference files SIGNAL out_s_dat_vec : STD_LOGIC_VECTOR(c_out_dat_w*c_nof_dut-1 DOWNTO 0); + SIGNAL ref_s_dat_vec : STD_LOGIC_VECTOR(c_out_dat_w*c_nof_dut-1 DOWNTO 0); SIGNAL out_s_ovr_vec : STD_LOGIC_VECTOR( c_nof_dut-1 DOWNTO 0); + SIGNAL ref_s_ovr_vec : STD_LOGIC_VECTOR( c_nof_dut-1 DOWNTO 0); SIGNAL out_u_dat_vec : STD_LOGIC_VECTOR(c_out_dat_w*c_nof_dut-1 DOWNTO 0); + SIGNAL ref_u_dat_vec : STD_LOGIC_VECTOR(c_out_dat_w*c_nof_dut-1 DOWNTO 0); SIGNAL out_u_ovr_vec : STD_LOGIC_VECTOR( c_nof_dut-1 DOWNTO 0); + SIGNAL ref_u_ovr_vec : STD_LOGIC_VECTOR( c_nof_dut-1 DOWNTO 0); + SIGNAL ref_val : STD_LOGIC; + SIGNAL ref_eof : STD_LOGIC; - SIGNAL rst : STD_LOGIC; + SIGNAL tb_end : STD_LOGIC := '0'; SIGNAL clk : STD_LOGIC := '1'; + SIGNAL rst : STD_LOGIC; CONSTANT c_init : STD_LOGIC_VECTOR(in_dat'RANGE) := (OTHERS=>'0'); BEGIN -- Stimuli - clk <= NOT(clk) AFTER clk_period/2; + clk <= NOT clk OR tb_end AFTER clk_period/2; rst <= '1', '0' AFTER 3*clk_period; + -- Testbench end + p_tb_end : PROCESS + BEGIN + tb_end <= '0'; + WAIT UNTIL ref_val='1'; + WAIT UNTIL rising_edge(clk); + WAIT UNTIL ref_val='0'; + WAIT UNTIL rising_edge(clk); + WAIT UNTIL rising_edge(clk); + tb_end <= '1'; + WAIT; + END PROCESS; + p_clk : PROCESS (rst, clk) BEGIN IF rst='1' THEN @@ -293,7 +313,18 @@ BEGIN out_ovr => out_u_t_w_ovr ); - -- Verification + -- Verification usign golden results from file + p_verify : PROCESS + BEGIN + WAIT UNTIL rising_edge(clk); + IF ref_val = '1' THEN + IF out_s_dat_vec /= ref_s_dat_vec THEN REPORT "Mismatch in signed requantize data" SEVERITY ERROR; END IF; + IF out_s_ovr_vec /= ref_s_ovr_vec THEN REPORT "Mismatch in signed requantize overflow" SEVERITY ERROR; END IF; + IF out_u_dat_vec /= ref_u_dat_vec THEN REPORT "Mismatch in unsigned requantize data" SEVERITY ERROR; END IF; + IF out_u_ovr_vec /= ref_u_ovr_vec THEN REPORT "Mismatch in unsigned requantize overflow" SEVERITY ERROR; END IF; + END IF; + END PROCESS; + out_s_dat_vec <= out_s_r_c_dat & out_s_r_w_dat & out_s_t_c_dat & out_s_t_w_dat; out_s_ovr_vec <= out_s_r_c_ovr & out_s_r_w_ovr & out_s_t_c_ovr & out_s_t_w_ovr; out_u_dat_vec <= out_u_r_c_dat & out_u_r_w_dat & out_u_t_c_dat & out_u_t_w_dat; @@ -313,6 +344,23 @@ BEGIN in_val => reg_val ); + u_ref_file_s_dat : ENTITY tst_lib.tst_input + GENERIC MAP ( + g_file_name => c_output_file_dir & "tb_requantize_s_dat.gold", + g_file_repeat => 1, + g_nof_data => c_nof_dut, + g_data_width => c_out_dat_w, + g_data_type => "SIGNED" + ) + PORT MAP ( + clk => clk, + rst => rst, + en => in_val, + out_dat => ref_s_dat_vec, + out_val => ref_val, + out_eof => ref_eof + ); + u_output_file_s_ovr : ENTITY tst_lib.tst_output GENERIC MAP ( g_file_name => c_output_file_dir & "tb_requantize_s_ovr.out", @@ -327,6 +375,23 @@ BEGIN in_val => reg_val ); + u_ref_file_s_ovr : ENTITY tst_lib.tst_input + GENERIC MAP ( + g_file_name => c_output_file_dir & "tb_requantize_s_ovr.gold", + g_file_repeat => 1, + g_nof_data => c_nof_dut, + g_data_width => 1, + g_data_type => "SIGNED" + ) + PORT MAP ( + clk => clk, + rst => rst, + en => in_val, + out_dat => ref_s_ovr_vec, + out_val => OPEN, + out_eof => OPEN + ); + u_output_file_u_dat : ENTITY tst_lib.tst_output GENERIC MAP ( g_file_name => c_output_file_dir & "tb_requantize_u_dat.out", @@ -341,6 +406,23 @@ BEGIN in_val => reg_val ); + u_ref_file_u_dat : ENTITY tst_lib.tst_input + GENERIC MAP ( + g_file_name => c_output_file_dir & "tb_requantize_u_dat.gold", + g_file_repeat => 1, + g_nof_data => c_nof_dut, + g_data_width => c_out_dat_w, + g_data_type => "SIGNED" + ) + PORT MAP ( + clk => clk, + rst => rst, + en => in_val, + out_dat => ref_u_dat_vec, + out_val => OPEN, + out_eof => OPEN + ); + u_output_file_u_ovr : ENTITY tst_lib.tst_output GENERIC MAP ( g_file_name => c_output_file_dir & "tb_requantize_u_ovr.out", @@ -355,4 +437,21 @@ BEGIN in_val => reg_val ); + u_ref_file_u_ovr : ENTITY tst_lib.tst_input + GENERIC MAP ( + g_file_name => c_output_file_dir & "tb_requantize_u_ovr.gold", + g_file_repeat => 1, + g_nof_data => c_nof_dut, + g_data_width => 1, + g_data_type => "SIGNED" + ) + PORT MAP ( + clk => clk, + rst => rst, + en => in_val, + out_dat => ref_u_ovr_vec, + out_val => OPEN, + out_eof => OPEN + ); + END tb; -- GitLab