diff --git a/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_pkg.vhd b/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_pkg.vhd index 8889a1e731a4fb0ae52651a363bd4070263bfcd3..e49931e96a21654d8858ac39830149adf432b777 100644 --- a/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_pkg.vhd +++ b/applications/lofar2/libraries/sdp/tb/vhdl/tb_sdp_pkg.vhd @@ -25,10 +25,11 @@ -- . This package contains specific constants, functions for sdp test benches. -- Description: ------------------------------------------------------------------------------- -library IEEE, common_lib; +library IEEE, common_lib, reorder_lib; use IEEE.std_logic_1164.all; use common_lib.common_pkg.all; use common_lib.common_network_layers_pkg.all; +use reorder_lib.reorder_pkg.all; use work.sdp_pkg.all; package tb_sdp_pkg is @@ -515,18 +516,11 @@ package body tb_sdp_pkg is nof_beamlets_per_block : natural; packet_list : t_sdp_beamlet_packet_list) return t_sdp_beamlet_packet_list is variable v_list : t_sdp_beamlet_packet_list; - variable v_in : natural; - variable v_out : natural; begin - for blk in 0 to nof_blocks_per_packet - 1 loop - for blet in 0 to nof_beamlets_per_block - 1 loop - for pol_bf in 0 to c_sdp_N_pol_bf - 1 loop - v_in := (blk * nof_beamlets_per_block + blet) * c_sdp_N_pol_bf + pol_bf; - v_out := (blet * nof_blocks_per_packet + blk) * c_sdp_N_pol_bf + pol_bf; - v_list(v_out) := packet_list(v_in); - end loop; - end loop; - end loop; + v_list := func_reorder_transpose_packet(nof_blocks_per_packet, + nof_beamlets_per_block, + c_sdp_N_pol_bf, + packet_list); return v_list; end func_sdp_bdo_transpose_packet; diff --git a/libraries/base/reorder/src/vhdl/reorder_pkg.vhd b/libraries/base/reorder/src/vhdl/reorder_pkg.vhd index 3d9898ae44622002fb3004ec0b6bf797188ce7ce..4db2a54945e51eefcdfdb7232dcb6eaf9382ba37 100644 --- a/libraries/base/reorder/src/vhdl/reorder_pkg.vhd +++ b/libraries/base/reorder/src/vhdl/reorder_pkg.vhd @@ -108,6 +108,11 @@ package reorder_pkg is function func_reorder_transpose_indices_impl(nof_blocks_per_packet : natural; nof_data_per_block : natural; nof_words_per_data : natural) return t_natural_arr; + -- Transpose function that operates on a packet + function func_reorder_transpose_packet(nof_blocks_per_packet : natural; + nof_data_per_block : natural; + nof_words_per_data : natural; + packet_list : t_slv_8_arr) return t_slv_8_arr; -- Transpose functions that operate sequentially to determine the read -- transpose.select_copi.address @@ -158,7 +163,6 @@ end reorder_pkg; package body reorder_pkg is -- Determine transpose index for input packet_index - -- . Similar function as func_sdp_bdo_transpose_packet() in tb_sdp_pkg.vhd. -- . The transpose is between nof_blocks_per_packet and nof_data_per_block. -- Doing transpose again with swapped nof_blocks_per_packet and -- nof_data_per_block, yields original order. @@ -240,6 +244,25 @@ package body reorder_pkg is return v_arr; end; + -- Apply func_reorder_transpose_indices() on a packet + function func_reorder_transpose_packet(nof_blocks_per_packet : natural; + nof_data_per_block : natural; + nof_words_per_data : natural; + packet_list : t_slv_8_arr) return t_slv_8_arr is + constant c_nof_ch : natural := nof_blocks_per_packet * nof_data_per_block * nof_words_per_data; + constant c_look_up_list : t_natural_arr(0 to c_nof_ch - 1) := + func_reorder_transpose_indices(nof_blocks_per_packet, + nof_data_per_block, + nof_words_per_data); + variable v_list : t_slv_8_arr(packet_list'range); + begin + assert c_nof_ch = packet_list'length report "Wrong packet_list length" severity error; + for ch in 0 to c_nof_ch - 1 loop + v_list(ch) := packet_list(c_look_up_list(ch)); + end loop; + return v_list; + end func_reorder_transpose_packet; + -- A transpose process and an undo transpose process can both use -- func_reorder_transpose(), by swapping the transpose dimensions. -- For example, to get transposed output with: