From 714ff2be5675470c73fd7f1d8c551df1b327c666 Mon Sep 17 00:00:00 2001 From: Reinier van der Walle <walle@astron.nl> Date: Tue, 12 Apr 2022 16:12:46 +0200 Subject: [PATCH] added hex generating script and set bf_weights init to UNUSED for g_sim = False. --- .../libraries/sdp/src/python/sdp_hex.py | 52 +++++++++++++++++++ .../sdp/src/vhdl/node_sdp_beamformer.vhd | 3 +- .../sdp/src/vhdl/node_sdp_filterbank.vhd | 2 +- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 applications/lofar2/libraries/sdp/src/python/sdp_hex.py diff --git a/applications/lofar2/libraries/sdp/src/python/sdp_hex.py b/applications/lofar2/libraries/sdp/src/python/sdp_hex.py new file mode 100644 index 0000000000..1efa228e1a --- /dev/null +++ b/applications/lofar2/libraries/sdp/src/python/sdp_hex.py @@ -0,0 +1,52 @@ +#! /usr/bin/env python3 +############################################################################### +# +# Copyright 2022 +# 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: Reinier vd Walle +# Purpose: Generate the hex files for RAM initialization in SDP designs +############################################################################### + +from intelhex import IntelHex +import struct + +for i in range(0,6): + f = IntelHex() + for j in range(0,2*488): + #f.puts(j*4, struct.pack(">I",j)) + f.puts(j*2, struct.pack(">H",j)) + + f.write_hex_file("bf_unit_ss_wide_"+str(i)+".hex", byte_count = 2) + +for i in range(0,12): + f = IntelHex() + for j in range(0,2*488): + f[4*j] = 0x00 + f[4*j + 1] = 0x00 + f[4*j + 2] = 0x40 + f[4*j + 3] = 0x00 + f.write_hex_file("bf_unit_weights_"+str(i)+".hex", byte_count = 4) + +for i in range(0,6): + f = IntelHex() + for j in range(0,1024): + f[4*j] = 0x00 + f[4*j + 1] = 0x00 + f[4*j + 2] = 0x20 + f[4*j + 3] = 0x00 + f.write_hex_file("gains_1024_complex_16b13f_unit_"+str(i)+".hex", byte_count = 4) diff --git a/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_beamformer.vhd b/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_beamformer.vhd index 669db80faa..3053b5f21d 100644 --- a/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_beamformer.vhd +++ b/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_beamformer.vhd @@ -107,8 +107,9 @@ END node_sdp_beamformer; ARCHITECTURE str OF node_sdp_beamformer IS + -- Note that the sdp library contains src/python/sdp_hex.py to generate hex files. CONSTANT c_bf_select_file_prefix : STRING := "data/bf_unit_ss_wide"; - CONSTANT c_bf_weights_file_name : STRING := "data/bf_unit_weights"; + CONSTANT c_bf_weights_file_name : STRING := sel_a_b(g_sim, "data/bf_unit_weights", "UNUSED"); CONSTANT c_nof_masters : POSITIVE := 2; diff --git a/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd b/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd index 149139e4ff..e5634c5516 100644 --- a/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd +++ b/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd @@ -97,7 +97,7 @@ END node_sdp_filterbank; ARCHITECTURE str OF node_sdp_filterbank IS CONSTANT c_coefs_file_prefix : STRING := "data/Coeffs16384Kaiser-quant_1wb"; - CONSTANT c_gains_file_name : STRING := "data/gains_1024_complex_16b13f_unit"; + CONSTANT c_gains_file_name : STRING := "data/gains_1024_complex_16b13f_unit"; -- Can be generated by src/python/sdp_hex.py CONSTANT c_subband_equalizer_latency : NATURAL := 4; -- GitLab