From 222a55a020f3a4036681e5f24cf4db08664704e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Mon, 20 Feb 2023 20:06:56 +0100 Subject: [PATCH] tests: update octets_to_samples tests --- .../transport/octets_to_samples_fc_tb.vhd | 59 +++++++-------- .../octets_to_samples_multi_cf_tb.vhd | 56 ++++++--------- .../transport/octets_to_samples_simp_tb.vhd | 72 ++++++++----------- 3 files changed, 77 insertions(+), 110 deletions(-) diff --git a/testbench/transport/octets_to_samples_fc_tb.vhd b/testbench/transport/octets_to_samples_fc_tb.vhd index 0ae365d..6dc815d 100644 --- a/testbench/transport/octets_to_samples_fc_tb.vhd +++ b/testbench/transport/octets_to_samples_fc_tb.vhd @@ -16,83 +16,74 @@ architecture a1 of octets_to_samples_fc_tb is constant CF : integer := 1; -- Count of control word bits constant N : integer := 4; -- Sample size constant Nn : integer := 4; - constant CLK_PERIOD : time := 1 ns; + constant CLK_PERIOD : time := 5 ns; - constant DUMMY_FC : frame_character := ('1', '1', '1', "11111111", 0, 0, '1'); constant DUMMY_S : sample := ("0000", "0"); type test_vector is record - di_lanes_data : frame_character_array (0 to L - 1); + di_lanes_data : lane_character_array (0 to L - 1) (F*8-1 downto 0); + ci_frame_states : frame_state_array (0 to L - 1); expected_result : integer; end record test_vector; type result_vector is record - co_correct_data : std_logic; do_samples_data : samples_array (0 to M - 1, 0 to S - 1)(data(M - 1 downto 0), ctrl_bits(CONTROL_SIZE - 1 downto 0)); + co_frame_state : frame_state; end record result_vector; + constant dummy_frame_state : frame_state := ('0', '0', '0', '0', '0', '0', '0', '0'); + type test_vector_array is array (natural range<>) of test_vector; constant test_vectors : test_vector_array := ( - ((('1', '0', '0', "00000000", 0, 0, '0'), others => DUMMY_FC), -1), - ((('1', '0', '0', "00000000", 0, 0, '0'), others => DUMMY_FC), -1), - ((('1', '0', '0', "00000000", 0, 0, '0'), others => DUMMY_FC), -1), - ((('1', '0', '0', "00000000", 0, 0, '0'), others => DUMMY_FC), -1), - ((('0', '0', '0', "10111110", 0, 0, '1'), others => DUMMY_FC), -1), - ((('0', '0', '0', "00010100", 1, 0, '1'), others => DUMMY_FC), -1), - ((('0', '0', '0', "10100000", 2, 0, '1'), others => DUMMY_FC), -1), - ((('0', '0', '0', "00010001", 0, 1, '1'), others => DUMMY_FC), 0), - ((('0', '0', '0', "00010001", 1, 1, '1'), others => DUMMY_FC), 0), - ((('0', '0', '0', "11110000", 2, 1, '1'), others => DUMMY_FC), 0), - ((('0', '0', '0', "11101110", 0, 2, '1'), others => DUMMY_FC), 1), - ((('0', '0', '0', "11101110", 1, 2, '1'), others => DUMMY_FC), 1), - ((('0', '0', '0', "00000000", 2, 2, '1'), others => DUMMY_FC), 1), - ((('0', '0', '0', "00000000", 0, 3, '1'), others => DUMMY_FC), 2), - ((('0', '0', '0', "11100000", 1, 3, '1'), others => DUMMY_FC), 2), - ((('0', '0', '0', "11100000", 2, 3, '1'), others => DUMMY_FC), 2) + (("000000000000000000000000", others => (others => '0')), (('0', '0', '0', '0', '0', '0', '0', '0'), others => dummy_frame_state), -1), + (("101111100001010010100000", others => (others => '0')), (('1', '0', '0', '0', '0', '0', '0', '0'), others => dummy_frame_state), -1), + (("000100010001000111110000", others => (others => '0')), (('1', '0', '0', '0', '0', '0', '0', '0'), others => dummy_frame_state), 0), + (("111011101110111000000000", others => (others => '0')), (('1', '0', '0', '0', '0', '0', '0', '0'), others => dummy_frame_state), 1), + (("000000001110000011100000", others => (others => '0')), (('1', '0', '0', '0', '0', '0', '0', '0'), others => dummy_frame_state), 2) ); type result_vector_array is array (natural range<>) of result_vector; constant result_vectors : result_vector_array := ( ( - '1', ( (("1011", "1"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S), (("0001", "1"), others => DUMMY_S), (("0100", "0"), others => DUMMY_S) - ) + ), + ('1', '0', '0', '0', '0', '0', '0', '0') ), ( - '1', ( (("0001", "1"), others => DUMMY_S), (("0001", "1"), others => DUMMY_S), (("0001", "1"), others => DUMMY_S), (("0001", "1"), others => DUMMY_S) - ) + ), + ('1', '0', '0', '0', '0', '0', '0', '0') ), ( - '1', ( (("1110", "0"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S) - ) + ), + ('1', '0', '0', '0', '0', '0', '0', '0') ) ); - signal ci_char_clk : std_logic := '0'; signal ci_frame_clk : std_logic := '0'; signal ci_reset : std_logic := '0'; - signal di_lanes_data : frame_character_array(0 to L - 1); + signal di_lanes_data : lane_character_array (0 to L - 1)(F*8-1 downto 0); + signal ci_frame_states : frame_state_array (0 to L - 1); signal do_samples_data : samples_array (0 to M - 1, 0 to S - 1) (data(N - 1 downto 0), ctrl_bits(CONTROL_SIZE - 1 downto 0)); - signal co_correct_data : std_logic; + signal co_frame_state : frame_state; signal test_data_index : integer := 0; begin -- architecture a1 @@ -107,14 +98,14 @@ begin -- architecture a1 N => N, Nn => Nn) port map ( - ci_char_clk => ci_char_clk, ci_reset => ci_reset, ci_frame_clk => ci_frame_clk, di_lanes_data => di_lanes_data, - co_correct_data => co_correct_data, + ci_frame_states => ci_frame_states, + co_frame_state => co_frame_state, do_samples_data => do_samples_data); - ci_char_clk <= not ci_char_clk after CLK_PERIOD/2; + ci_frame_clk <= not ci_frame_clk after CLK_PERIOD/2; ci_reset <= '1' after CLK_PERIOD*2; test: process is @@ -128,13 +119,13 @@ begin -- architecture a1 test_data_index <= i; test_vec := test_vectors(i); di_lanes_data <= test_vec.di_lanes_data; + ci_frame_states <= test_vec.ci_frame_states; if i > 0 then prev_test_vec := test_vectors(i - 1); if prev_test_vec.expected_result /= -1 then - assert co_correct_data = result_vectors(prev_test_vec.expected_result).co_correct_data report "The correct data does not match, Index: " & integer'image(i-1) severity error; - + assert co_frame_state = result_vectors(prev_test_vec.expected_result).co_frame_state report "The frame state does not match, index: " & integer'image(prev_test_vec.expected_result) severity error; for ci in 0 to M - 1 loop for si in 0 to S - 1 loop assert do_samples_data(ci, si).data = result_vectors(prev_test_vec.expected_result).do_samples_data(ci, si).data report "The samples data do not match, expected: " & vec2str(result_vectors(prev_test_vec.expected_result).do_samples_data(ci, si).data) & ", got: " & vec2str(dummy) & ", index: " & integer'image(i-1) & ", ci: " & integer'image(ci) & ", si: " & integer'image(si) severity error; diff --git a/testbench/transport/octets_to_samples_multi_cf_tb.vhd b/testbench/transport/octets_to_samples_multi_cf_tb.vhd index c67ba5b..c939136 100644 --- a/testbench/transport/octets_to_samples_multi_cf_tb.vhd +++ b/testbench/transport/octets_to_samples_multi_cf_tb.vhd @@ -18,83 +18,73 @@ architecture a1 of octets_to_samples_multi_fc_tb is constant Nn : integer := 4; constant CLK_PERIOD : time := 1 ns; - constant DUMMY_FC : frame_character := ('1', '1', '1', "11111111", 0, 0, '1'); - constant DUMMY_S : sample := ("0000", "0"); type test_vector is record - di_lanes_data : frame_character_array (0 to L - 1); + di_lanes_data : lane_character_array (0 to L - 1) (F*8-1 downto 0); + ci_frame_states : frame_state_array (0 to L - 1); expected_result : integer; end record test_vector; type result_vector is record - co_correct_data : std_logic; do_samples_data : samples_array (0 to M - 1, 0 to S - 1)(data(M - 1 downto 0), ctrl_bits(CONTROL_SIZE - 1 downto 0)); + co_frame_state : frame_state; end record result_vector; type test_vector_array is array (natural range<>) of test_vector; constant test_vectors : test_vector_array := ( - ((('1', '0', '0', "00000000", 0, 0, '0'), ('1', '0', '0', "00000000", 0, 0, '0')), -1), - ((('1', '0', '0', "00000000", 0, 0, '0'), ('1', '0', '0', "00000000", 0, 0, '0')), -1), - ((('1', '0', '0', "00000000", 0, 0, '0'), ('1', '0', '0', "00000000", 0, 0, '0')), -1), - ((('0', '0', '0', "00010101", 0, 0, '1'), ('0', '0', '0', "00110111", 0, 0, '1')), -1), - ((('0', '0', '0', "00100110", 1, 0, '1'), ('0', '0', '0', "01001000", 1, 0, '1')), -1), - ((('0', '0', '0', "01011010", 2, 0, '1'), ('0', '0', '0', "11110000", 2, 0, '1')), -1), - ((('0', '0', '0', "00111111", 0, 1, '1'), ('0', '0', '0', "00001010", 0, 1, '1')), 0), - ((('0', '0', '0', "11000101", 1, 1, '1'), ('0', '0', '0', "11110000", 1, 1, '1')), 0), - ((('0', '0', '0', "00101101", 2, 1, '1'), ('0', '0', '0', "00101101", 2, 1, '1')), 0), - ((('0', '0', '0', "00010101", 0, 1, '1'), ('0', '0', '0', "00110111", 0, 1, '1')), 1), - ((('0', '0', '0', "00100110", 1, 1, '1'), ('0', '0', '0', "01001000", 1, 1, '1')), 1), - ((('0', '0', '0', "01011010", 2, 1, '1'), ('0', '0', '0', "11110000", 2, 1, '1')), 1), - ((('0', '0', '0', "00010101", 0, 1, '1'), ('0', '0', '0', "00110111", 0, 1, '1')), 2), - ((('0', '0', '0', "00100110", 1, 1, '1'), ('0', '0', '0', "01001000", 1, 1, '1')), 2), - ((('0', '0', '0', "01011010", 2, 1, '1'), ('0', '0', '0', "11110000", 2, 1, '1')), 2) + (("000000000000000000000000", "000000000000000000000000"), (('0', '0', '0', '0', '0', '0', '0', '0'), ('0', '0', '0', '0', '0', '0', '0', '0')), -1), + (("000101010010011001011010", "001101110100100011110000"), (('1', '0', '0', '0', '0', '0', '0', '0'), ('1', '0', '0', '0', '0', '0', '0', '0')), -1), + (("001111111100010100101101", "000010101111000000101101"), (('1', '0', '0', '0', '0', '0', '0', '0'), ('1', '0', '0', '0', '0', '0', '0', '0')), 0), + (("000101010010011001011010", "001101110100100011110000"), (('1', '0', '0', '0', '0', '0', '0', '0'), ('1', '0', '0', '0', '0', '0', '0', '0')), 1), + (("000101010010011001011010", "001101110100100011110000"), (('1', '0', '0', '0', '0', '0', '0', '0'), ('1', '0', '0', '0', '0', '0', '0', '0')), 2) ); type result_vector_array is array (natural range<>) of result_vector; constant result_vectors : result_vector_array := ( ( - '1', ( (("0001", "01"), ("0101", "01")), (("0010", "10"), ("0110", "10")), (("0011", "11"), ("0111", "11")), (("0100", "00"), ("1000", "00")) - ) + ), + ('1', '0', '0', '0', '0', '0', '0', '0') ), ( - '1', ( (("0011", "00"), ("1111", "10")), (("1100", "11"), ("0101", "01")), (("0000", "00"), ("1010", "10")), (("1111", "11"), ("0000", "01")) - ) + ), + ('1', '0', '0', '0', '0', '0', '0', '0') ), ( - '1', ( (("0001", "01"), ("0101", "01")), (("0010", "10"), ("0110", "10")), (("0011", "11"), ("0111", "11")), (("0100", "00"), ("1000", "00")) - ) + ), + ('1', '0', '0', '0', '0', '0', '0', '0') ) ); - signal ci_char_clk : std_logic := '0'; signal ci_frame_clk : std_logic := '0'; signal ci_reset : std_logic := '0'; - signal di_lanes_data : frame_character_array(0 to L - 1); + signal di_lanes_data : lane_character_array (0 to L - 1)(F*8-1 downto 0); + signal ci_frame_states : frame_state_array (0 to L - 1); signal do_samples_data : samples_array (0 to M - 1, 0 to S - 1) (data(N - 1 downto 0), ctrl_bits(CONTROL_SIZE - 1 downto 0)); - signal co_correct_data : std_logic; + signal co_frame_state : frame_state; signal test_data_index : integer := 0; begin -- architecture a1 + uut : entity work.octets_to_samples generic map ( CS => CONTROL_SIZE, @@ -106,14 +96,14 @@ begin -- architecture a1 N => N, Nn => Nn) port map ( - ci_char_clk => ci_char_clk, ci_reset => ci_reset, ci_frame_clk => ci_frame_clk, di_lanes_data => di_lanes_data, - co_correct_data => co_correct_data, + ci_frame_states => ci_frame_states, + co_frame_state => co_frame_state, do_samples_data => do_samples_data); - ci_char_clk <= not ci_char_clk after CLK_PERIOD/2; + ci_frame_clk <= not ci_frame_clk after CLK_PERIOD/2; ci_reset <= '1' after CLK_PERIOD*2; test: process is @@ -127,13 +117,13 @@ begin -- architecture a1 test_data_index <= i; test_vec := test_vectors(i); di_lanes_data <= test_vec.di_lanes_data; + ci_frame_states <= test_vec.ci_frame_states; if i > 0 then prev_test_vec := test_vectors(i - 1); if prev_test_vec.expected_result /= -1 then - assert co_correct_data = result_vectors(prev_test_vec.expected_result).co_correct_data report "The correct data does not match, Index: " & integer'image(i-1) severity error; - + assert co_frame_state = result_vectors(prev_test_vec.expected_result).co_frame_state report "The frame state does not match, index: " & integer'image(prev_test_vec.expected_result) severity error; for ci in 0 to M - 1 loop for si in 0 to S - 1 loop assert do_samples_data(ci, si).data = result_vectors(prev_test_vec.expected_result).do_samples_data(ci, si).data report "The samples data do not match, expected: " & vec2str(result_vectors(prev_test_vec.expected_result).do_samples_data(ci, si).data) & ", got: " & vec2str(dummy) & ", index: " & integer'image(i-1) & ", ci: " & integer'image(ci) & ", si: " & integer'image(si) severity error; diff --git a/testbench/transport/octets_to_samples_simp_tb.vhd b/testbench/transport/octets_to_samples_simp_tb.vhd index a0a6bfe..59eb1f6 100644 --- a/testbench/transport/octets_to_samples_simp_tb.vhd +++ b/testbench/transport/octets_to_samples_simp_tb.vhd @@ -18,98 +18,83 @@ architecture a1 of octets_to_samples_simp_tb is constant Nn : integer := 8; constant CLK_PERIOD : time := 1 ns; - constant DUMMY_FC : frame_character := ('1', '1', '1', "11111111", 0, 0, '1'); constant DUMMY_S : sample := ("0000", "0"); type test_vector is record - di_lanes_data : frame_character_array (0 to L - 1); + di_lanes_data : lane_character_array (0 to L - 1) (F*8-1 downto 0); + ci_frame_states : frame_state_array (0 to L - 1); expected_result : integer; end record test_vector; type result_vector is record - co_correct_data : std_logic; do_samples_data : samples_array (0 to M - 1, 0 to S - 1)(data(M - 1 downto 0), ctrl_bits(CONTROL_SIZE - 1 downto 0)); + co_frame_state : frame_state; end record result_vector; + constant dummy_frame_state : frame_state := ('0', '0', '0', '0', '0', '0', '0', '0'); + type test_vector_array is array (natural range<>) of test_vector; constant test_vectors : test_vector_array := ( - ((('1', '0', '0', "00000000", 0, 0, '0'), others => DUMMY_FC), -1), - ((('1', '0', '0', "00000000", 0, 0, '0'), others => DUMMY_FC), -1), - ((('1', '0', '0', "00000000", 0, 0, '0'), others => DUMMY_FC), -1), - ((('1', '0', '0', "00000000", 0, 0, '0'), others => DUMMY_FC), -1), - ((('0', '0', '0', "10111000", 0, 0, '1'), others => DUMMY_FC), -1), - ((('0', '0', '0', "11100000", 1, 0, '1'), others => DUMMY_FC), -1), - ((('0', '0', '0', "00011000", 2, 0, '1'), others => DUMMY_FC), -1), - ((('0', '0', '0', "01000000", 3, 0, '1'), others => DUMMY_FC), -1), - ((('0', '0', '0', "00011000", 0, 1, '1'), others => DUMMY_FC), 0), - ((('0', '0', '0', "00011000", 1, 1, '1'), others => DUMMY_FC), 0), - ((('0', '0', '0', "00011000", 2, 1, '1'), others => DUMMY_FC), 0), - ((('0', '0', '0', "00011000", 3, 1, '1'), others => DUMMY_FC), 0), - ((('0', '0', '0', "11100000", 0, 2, '1'), others => DUMMY_FC), 1), - ((('0', '0', '0', "11100000", 1, 2, '1'), others => DUMMY_FC), 1), - ((('0', '0', '0', "11100000", 2, 2, '1'), others => DUMMY_FC), 1), - ((('0', '0', '0', "11100000", 3, 2, '1'), others => DUMMY_FC), 1), - ((('0', '0', '0', "11100000", 0, 3, '0'), others => DUMMY_FC), 2), - ((('0', '0', '0', "11100000", 1, 3, '1'), others => DUMMY_FC), 2), - ((('0', '0', '0', "11100000", 2, 3, '1'), others => DUMMY_FC), 2), - ((('0', '0', '0', "11100000", 3, 3, '1'), others => DUMMY_FC), 2), - ((('0', '0', '0', "11100000", 0, 3, '0'), others => DUMMY_FC), 3), - ((('0', '0', '0', "11100000", 1, 3, '1'), others => DUMMY_FC), 3), - ((('0', '0', '0', "11100000", 2, 3, '1'), others => DUMMY_FC), 3), - ((('0', '0', '0', "11100000", 3, 3, '1'), others => DUMMY_FC), 3) + (("00000000000000000000000000000000", others => (others => '0')), (('0', '0', '0', '0', '0', '0', '0', '0'), others => dummy_frame_state), -1), + (("10111000111000000001100001000000", others => (others => '0')), (('1', '0', '0', '0', '0', '0', '0', '0'), others => dummy_frame_state), -1), + (("00011000000110000001100000011000", others => (others => '0')), (('1', '0', '0', '0', '0', '0', '0', '0'), others => dummy_frame_state), 0), + (("11100000111000001110000011100000", others => (others => '0')), (('1', '0', '0', '0', '0', '0', '0', '0'), others => dummy_frame_state), 1), + (("00000000000000000000000000000000", others => (others => '0')), (('1', '1', '0', '0', '0', '1', '0', '0'), others => dummy_frame_state), 2), + (("11100000111000001110000011100000", others => (others => '0')), (('1', '1', '0', '0', '0', '1', '0', '0'), others => dummy_frame_state), 3), + (("00000000000000000000000000000000", others => (others => '0')), (('1', '1', '0', '0', '0', '1', '0', '0'), others => dummy_frame_state), -1) ); type result_vector_array is array (natural range<>) of result_vector; constant result_vectors : result_vector_array := ( ( - '1', ( (("1011", "1"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S), (("0001", "1"), others => DUMMY_S), (("0100", "0"), others => DUMMY_S) - ) + ), + ('1', '0', '0', '0', '0', '0', '0', '0') ), ( - '1', ( (("0001", "1"), others => DUMMY_S), (("0001", "1"), others => DUMMY_S), (("0001", "1"), others => DUMMY_S), (("0001", "1"), others => DUMMY_S) - ) + ), + ('1', '0', '0', '0', '0', '0', '0', '0') ), ( - '1', ( (("1110", "0"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S) - ) + ), + ('1', '0', '0', '0', '0', '0', '0', '0') ), ( - '0', ( (("1110", "0"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S), (("1110", "0"), others => DUMMY_S) - ) + ), + ('1', '1', '0', '0', '0', '1', '0', '1') ) ); - signal ci_char_clk : std_logic := '0'; signal ci_frame_clk : std_logic := '0'; signal ci_reset : std_logic := '0'; - signal di_lanes_data : frame_character_array(0 to L - 1); + signal di_lanes_data : lane_character_array (0 to L - 1)(F*8-1 downto 0); + signal ci_frame_states : frame_state_array (0 to L - 1); signal do_samples_data : samples_array (0 to M - 1, 0 to S - 1) (data(N - 1 downto 0), ctrl_bits(CONTROL_SIZE - 1 downto 0)); - signal co_correct_data : std_logic; + signal co_frame_state : frame_state; signal test_data_index : integer := 0; begin -- architecture a1 @@ -124,16 +109,17 @@ begin -- architecture a1 N => N, Nn => Nn) port map ( - ci_char_clk => ci_char_clk, ci_reset => ci_reset, ci_frame_clk => ci_frame_clk, di_lanes_data => di_lanes_data, - co_correct_data => co_correct_data, + ci_frame_states => ci_frame_states, + co_frame_state => co_frame_state, do_samples_data => do_samples_data); - ci_char_clk <= not ci_char_clk after CLK_PERIOD/2; + ci_frame_clk <= not ci_frame_clk after CLK_PERIOD/2; ci_reset <= '1' after CLK_PERIOD*2; + test: process is variable test_vec : test_vector; variable prev_test_vec : test_vector; @@ -145,13 +131,13 @@ begin -- architecture a1 test_data_index <= i; test_vec := test_vectors(i); di_lanes_data <= test_vec.di_lanes_data; + ci_frame_states <= test_vec.ci_frame_states; if i > 0 then prev_test_vec := test_vectors(i - 1); if prev_test_vec.expected_result /= -1 then - assert co_correct_data = result_vectors(prev_test_vec.expected_result).co_correct_data report "The correct data does not match, Index: " & integer'image(i-1) severity error; - + assert co_frame_state = result_vectors(prev_test_vec.expected_result).co_frame_state report "The frame state does not match, index: " & integer'image(prev_test_vec.expected_result) severity error; for ci in 0 to M - 1 loop for si in 0 to S - 1 loop assert do_samples_data(ci, si).data = result_vectors(prev_test_vec.expected_result).do_samples_data(ci, si).data report "The samples data do not match, expected: " & vec2str(result_vectors(prev_test_vec.expected_result).do_samples_data(ci, si).data) & ", got: " & vec2str(dummy) & ", index: " & integer'image(i-1) & ", ci: " & integer'image(ci) & ", si: " & integer'image(si) severity error; -- 2.48.1