Skip to content
Snippets Groups Projects
Commit 1351a6d0 authored by Daniel van der Schuur's avatar Daniel van der Schuur
Browse files

Added tb_beamlet_lookup_pkg.vhd which is generated by gen_beamlet_lookup.py.

Now all test benches are passing again.
parent 1e8629ff
No related branches found
No related tags found
No related merge requests found
Showing
with 1074 additions and 6 deletions
......@@ -19,6 +19,7 @@ synth_files =
src/vhdl/apertif_unb1_correlator_nodes.vhd
test_bench_files =
tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb/vhdl/tb_node_apertif_unb1_correlator_processing.vhd
tb/vhdl/tb_tb_node_apertif_unb1_correlator_processing.vhd
tb/vhdl/tb_node_apertif_unb1_correlator_processing_output.vhd
......
......@@ -21,6 +21,7 @@ synth_files =
apertif_unb1_correlator_bg_output.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_bg_output.vhd
[modelsim_project_file]
......
......@@ -22,6 +22,7 @@ synth_files =
apertif_unb1_correlator_bm6_bg_ch320.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_bm6_bg_ch320.vhd
regression_test_vhdl =
......
......@@ -20,6 +20,7 @@ synth_files =
apertif_unb1_correlator_filter.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_filter.vhd
......
......@@ -22,6 +22,7 @@ synth_files =
apertif_unb1_correlator_full.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_full.vhd
regression_test_vhdl =
......
......@@ -21,6 +21,7 @@ synth_files =
apertif_unb1_correlator_full_bg.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_full_bg.vhd
......
......@@ -21,6 +21,7 @@ synth_files =
apertif_unb1_correlator_full_bg_int.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_full_bg_int.vhd
......
......@@ -22,6 +22,7 @@ synth_files =
apertif_unb1_correlator_full_bm6.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_full_bm6.vhd
regression_test_vhdl =
......
......@@ -21,6 +21,7 @@ synth_files =
apertif_unb1_correlator_full_no_fft.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_full_no_fft.vhd
../../tb/vhdl/tb_node_apertif_unb1_correlator_input.vhd
......
......@@ -20,7 +20,8 @@ synth_files =
../../src/vhdl/apertif_unb1_correlator_nodes.vhd
apertif_unb1_correlator_lite.vhd
test_bench_files =
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_lite.vhd
......
......@@ -21,6 +21,7 @@ synth_files =
apertif_unb1_correlator_lite_bg.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_lite_bg.vhd
../../tb/vhdl/tb_apertif_unb1_correlator_output_framer.vhd
......
......@@ -21,6 +21,7 @@ synth_files =
apertif_unb1_correlator_lite_bg_8.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_lite_bg_8.vhd
../../tb/vhdl/tb_apertif_unb1_correlator_output_framer.vhd
......
......@@ -21,6 +21,7 @@ synth_files =
apertif_unb1_correlator_mesh_distr_ref.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_mesh_distr_ref.vhd
......
......@@ -21,6 +21,7 @@ synth_files =
apertif_unb1_correlator_mesh_ref.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_mesh_ref.vhd
......
......@@ -21,6 +21,7 @@ synth_files =
apertif_unb1_correlator_rx_only.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
[modelsim_project_file]
......
......@@ -20,6 +20,7 @@ synth_files =
apertif_unb1_correlator_simple.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_apertif_unb1_correlator_simple.vhd
......
......@@ -17,6 +17,7 @@ synth_files =
../../src/vhdl/node_apertif_unb1_correlator_output.vhd
test_bench_files =
../../tb/vhdl/tb_beamlet_lookup_pkg.vhd
tb_node_apertif_unb1_correlator_input.vhd
......
......@@ -2,8 +2,20 @@
# . Daniel van der Schuur
# Purpose:
# . Print beamlet mappings of Imaging vs. Time domain (ARTS SC4, SC3).
# . Generate the corresponding lookup table as VHDL code.
# . Generate 2 VHDL files:
# 1) ARTS -> Imaging lookup table (ROM entity) used in correlator output
# . beamlet_loopup.vhd with entity 'beamlet_lookup'
# 2) Inverse Imaging -> ARTS lookup function used for verification
# . tb_beamlet_lookup_pkg.vhd with function 'beamlet_lookip_inverse'
# Remarks:
# . Any changes in the beamlet mapping and/or reordering should be done in the
# first Numpy stage below only. No need to change the VHDL generation
# stages.
###############################################################################
# Generate and print the Imaging vs. Time domain beamlet mappings and lookup
# table between the two
###############################################################################
import numpy as np
np.set_printoptions(linewidth=250)
......@@ -24,13 +36,16 @@ for cb in range(5): t[:,30+cb] = range(513+cb*48,513+cb*48+48,2) # CB 30..34: be
for cb in range(5): t[:,35+cb] = range(769+cb*48,769+cb*48+48,2) # CB 35..39: beamlets 769,771,..,1007
print t
print 'Generating VHDL file with lookup table [time domain beamlet] -> [imaging beamlet]: ../vhdl/beamlet_lookup.vhd'
lookup_list = []
for bt,bi in zip(np.nditer(t), np.nditer(i)):
lookup_list.append((int(bt),int(bi)))
lookup_list.sort(key=lambda tup: tup[0]) # Sort the list so we get incrementing addresses (beamlet_in)
###############################################################################
# Generate the Time domain -> Imaging lookup table as a VHDL entity
###############################################################################
print 'Generating VHDL file with lookup table [time domain beamlet] -> [imaging beamlet]: ../vhdl/beamlet_lookup.vhd'
head = """LIBRARY ieee;
USE ieee.std_logic_1164.all;
......@@ -69,3 +84,50 @@ with open('../vhdl/beamlet_lookup.vhd', 'w') as f:
f.write(tail)
f.close()
###############################################################################
# Generate the inverse Imaging -> Time domain lookup table as a VHDL function
###############################################################################
print 'Generating inverse VHDL function with lookup table [imaging beamlet] -> [time domain beamlet]: ../../tb/vhdl/tb_beamlet_lookup_pkg.vhd'
head = """LIBRARY IEEE, common_lib;
USE IEEE.STD_LOGIC_1164.ALL;
USE common_lib.common_pkg.ALL;
USE common_lib.common_str_pkg.ALL;
-- This file was generated by ../python/gen_beamlet_lookup.py
PACKAGE tb_beamlet_lookup_pkg IS
FUNCTION beamlet_lookup_inverse(beamlet_in : NATURAL) RETURN NATURAL;
END tb_beamlet_lookup_pkg;
PACKAGE BODY tb_beamlet_lookup_pkg IS
FUNCTION beamlet_lookup_inverse(beamlet_in : NATURAL) RETURN NATURAL IS
VARIABLE v_beamlet_in_slv : STD_LOGIC_VECTOR(15 DOWNTO 0) := TO_UVEC(beamlet_in, 16);
VARIABLE v_beamlet_in_lsb : NATURAL := TO_UINT(v_beamlet_in_slv( 9 DOWNTO 0));
VARIABLE v_beamlet_in_msb : NATURAL := TO_UINT(v_beamlet_in_slv(15 DOWNTO 10) & "0000000000");
VARIABLE v_beamlet_out_msb : NATURAL := v_beamlet_in_msb;
VARIABLE v_beamlet_out_lsb : NATURAL;
BEGIN
CASE v_beamlet_in_lsb IS
"""
tail = """ WHEN OTHERS => REPORT "Unknown beamlet_in: " & int_to_str(beamlet_in) SEVERITY FAILURE;
END CASE;
RETURN v_beamlet_out_msb + v_beamlet_out_lsb;
END;
END tb_beamlet_lookup_pkg;
"""
with open('../../tb/vhdl/tb_beamlet_lookup_pkg.vhd', 'w') as f:
f.write(head)
for beamlet_mapping in lookup_list:
beamlet_in = str(beamlet_mapping[1])
beamlet_out = str(beamlet_mapping[0])
line = ' WHEN '+beamlet_in+' => v_beamlet_out_lsb := '+beamlet_out+';\n'
f.write(line)
f.write(tail)
f.close()
......@@ -54,6 +54,7 @@ USE common_lib.tb_common_pkg.ALL;
USE work.apertif_unb1_correlator_pkg.ALL;
USE fft_lib.fft_pkg.ALL;
USE wpfb_lib.wpfb_pkg.ALL;
USE work.tb_beamlet_lookup_pkg.ALL;
ENTITY tb_apertif_unb1_correlator_nodes IS
GENERIC (
......@@ -456,9 +457,9 @@ BEGIN
-- . channel
mmf_mm_bus_rd(c_mm_file_ram_diag_data_buffer_output, v_addr + 12, rd_data_db, tb_clk);
v_rd_channel := TO_UINT(rd_data_db(31 DOWNTO 16));
ASSERT v_rd_beamlet = v_exp_beamlet AND v_rd_channel = v_exp_channel REPORT "Wrong beamlet, channel index in packet header: " &
ASSERT beamlet_lookup_inverse(v_rd_beamlet) = v_exp_beamlet AND v_rd_channel = v_exp_channel REPORT "Wrong beamlet, channel index in packet header: " &
"(" & int_to_str(v_exp_beamlet) & ", " & int_to_str(v_exp_channel) & ") /= " &
"(" & int_to_str(v_rd_beamlet) & ", " & int_to_str(v_rd_channel) & ")" SEVERITY ERROR;
"(" & int_to_str(beamlet_lookup_inverse(v_rd_beamlet)) & ", " & int_to_str(v_rd_channel) & ")" SEVERITY ERROR;
-- . timestamp (= bsn)
mmf_mm_bus_rd(c_mm_file_ram_diag_data_buffer_output, v_addr + 13, rd_data_db, tb_clk);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment