Skip to content
Snippets Groups Projects
Commit 1e126f8c authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Use python script to verify VHDL function func_sdp_bdo_transpose_packet().

parent 7f8ff41a
No related branches found
No related tags found
1 merge request!348Use use_bdo_transpose = true in c_bf revision. Test use_bdo_transpose = false...
###############################################################################
#
# Copyright 2023
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
# Author: Eric Kooistra
# Date: Aug 2023
# Purpose:
# Use Python to verify equivalent VHDL function func_sdp_bdo_transpose_packet()
# in tb_sdp_pkg.vhd
# Usage:
# > python test_func_sdp_bdo_transpose_packet.py > x
# > more x
# > tail -n 50 x
c_sdp_N_pol_bf = 2
def func_sdp_bdo_transpose_packet(nof_blocks_per_packet, nof_beamlets_per_block, packet_list):
v_list = [0] * len(packet_list)
for blk in range(nof_blocks_per_packet):
for blet in range(nof_beamlets_per_block):
for pol_bf in range(c_sdp_N_pol_bf):
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]
return v_list
nof_blocks_per_packet = 4
nof_beamlets_per_block = 488
packet_list = list(range(0, nof_beamlets_per_block * nof_blocks_per_packet * c_sdp_N_pol_bf))
out_list = func_sdp_bdo_transpose_packet(nof_blocks_per_packet, nof_beamlets_per_block, packet_list)
for d in out_list:
print('%d' % d)
...@@ -114,9 +114,11 @@ package tb_sdp_pkg is ...@@ -114,9 +114,11 @@ package tb_sdp_pkg is
subtype t_sdp_beamlet_part_arr is t_slv_8_arr(0 to c_sdp_cep_nof_beamlets_per_longword * c_sdp_N_pol_bf - 1); subtype t_sdp_beamlet_part_arr is t_slv_8_arr(0 to c_sdp_cep_nof_beamlets_per_longword * c_sdp_N_pol_bf - 1);
-- beamlet part index in packet with 4 blocks [0 : 4 * 488 * 2 - 1] = [0 : 3903] -- beamlet part index in packet with 4 blocks [0 : 4 * 488 * 2 - 1] = [0 : 3903]
-- . use separate list for re and for im
subtype t_sdp_beamlet_packet_list is t_slv_8_arr(0 to c_sdp_cep_nof_beamlets_per_packet * c_sdp_N_pol_bf - 1); subtype t_sdp_beamlet_packet_list is t_slv_8_arr(0 to c_sdp_cep_nof_beamlets_per_packet * c_sdp_N_pol_bf - 1);
-- beamlet part index in one block [0 : 488 * 2 - 1] = [0 : 975] -- beamlet part index in one block [0 : 488 * 2 - 1] = [0 : 975]
-- . use separate list for re and for im
subtype t_sdp_beamlet_block_list is t_slv_8_arr(0 to c_sdp_cep_nof_beamlets_per_block * c_sdp_N_pol_bf - 1); subtype t_sdp_beamlet_block_list is t_slv_8_arr(0 to c_sdp_cep_nof_beamlets_per_block * c_sdp_N_pol_bf - 1);
function func_sdp_bdo_transpose_packet(nof_blocks_per_packet : natural; function func_sdp_bdo_transpose_packet(nof_blocks_per_packet : natural;
...@@ -493,16 +495,26 @@ package body tb_sdp_pkg is ...@@ -493,16 +495,26 @@ package body tb_sdp_pkg is
return v_tuple; return v_tuple;
end; end;
-- BDO transpose:
-- . See sdp/python/test_func_sdp_bdo_transpose_packet.py to verify that
-- v_out = func_sdp_bdo_transpose_packet(4, 488, v_in) yields the expected v_out.
-- . See data repacking section in:
-- https://support.astron.nl/confluence/pages/viewpage.action?spaceKey=L2M&title=L4+SDPFW+Decision%3A+Multiple+beamlet+output+destinations
-- . Use separate packet_list for re and im
-- input packet_list: -- input packet_list:
-- . blk 0, 1, 2, 3, for nof_blocks_per_packet = 4 -- . blk 0, 1, 2, 3, for nof_blocks_per_packet = 4
-- . blet 0:487, 0:487, 0:487, 0:487, for nof_beamlets_per_block = 488 -- . blet 0, ... 487, 0, ... 487, 0, ... 487, 0, ... 487, for nof_beamlets_per_block = 488
-- . v_in 0,1,2, ... 1951 -- . pol_bf X,Y, ... X,Y, X,Y, ... X,Y, X,Y, ... X,Y, X,Y, ... X,Y, for N_pol_bf = 2, X,Y = 0,1
-- . v_in 0, ... 975, 976, ...1951,1952, ...2927,2928, ...3903, input list index
-- return v_list = transposed packet_list: -- return v_list = transposed packet_list:
-- 0, 1, ..., 487 -- . pol_bf X,Y,X,Y,X,Y,X,Y, ..., X,Y,X,Y,X,Y,X,Y, for N_pol_bf = 2, X,Y = 0,1
-- 0:3, 0:3, ..., 0:3 -- . blk 0, 1, 2, 3, ..., 0, 1, 2, 3, for nof_blocks_per_packet = 4
-- 0,488,976,1464, 1,489,977,1465, ..., 487,975,1463,1951 -- . blet 0, ..., 487, for nof_beamlets_per_block = 488
-- -- . v_out 0,1, 976, 977, 1952,1953, 2928,2929,
-- . v_out 0,4,8,...,1948, 1,5,9,...,1949, 2,6,10,...,1950, 3,7,11,...,1951 -- 2,3, 978, 979, 1954,1955, 2930,2931,
-- ..., ..., ..., ...,
-- 972,973, 1948,1949, 2924,2925, 3900,3901,
-- 974,775, 1950,1951, 2926,2927, 3902,3903, output list index
function func_sdp_bdo_transpose_packet(nof_blocks_per_packet : natural; function func_sdp_bdo_transpose_packet(nof_blocks_per_packet : natural;
nof_beamlets_per_block : natural; nof_beamlets_per_block : natural;
packet_list : t_sdp_beamlet_packet_list) return t_sdp_beamlet_packet_list is packet_list : t_sdp_beamlet_packet_list) return t_sdp_beamlet_packet_list is
...@@ -512,12 +524,14 @@ package body tb_sdp_pkg is ...@@ -512,12 +524,14 @@ package body tb_sdp_pkg is
begin begin
for blk in 0 to nof_blocks_per_packet - 1 loop for blk in 0 to nof_blocks_per_packet - 1 loop
for blet in 0 to nof_beamlets_per_block - 1 loop for blet in 0 to nof_beamlets_per_block - 1 loop
v_in := blk * nof_beamlets_per_block + blet; for pol_bf in 0 to c_sdp_N_pol_bf - 1 loop
v_out := blet * nof_blocks_per_packet + blk; v_in := (blk * nof_beamlets_per_block + blet) * c_sdp_N_pol_bf + pol_bf;
v_list(v_out) := packet_list(v_in); 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;
end loop; end loop;
return v_list; return v_list;
end func_sdp_bdo_transpose_packet; end func_sdp_bdo_transpose_packet;
end tb_sdp_pkg; end tb_sdp_pkg;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment