From 8cedd923333fb4c35acd6fe25c72a1d089db64d7 Mon Sep 17 00:00:00 2001 From: Eric Kooistra <kooistra@astron.nl> Date: Tue, 19 Jan 2021 16:50:38 +0100 Subject: [PATCH] Define pfs coeff constants in pfs_pkg.vhd. --- applications/lofar1/pfb2/src/vhdl/pfb2.vhd | 9 ++-- .../lofar1/pfb2/src/vhdl/pfb2_unit.vhd | 11 +++-- applications/lofar1/pfs/hdllib.cfg | 1 + applications/lofar1/pfs/src/vhdl/pfs.vhd | 5 ++- .../lofar1/pfs/src/vhdl/pfs_coefsbuf.vhd | 11 ++--- applications/lofar1/pfs/src/vhdl/pfs_pkg.vhd | 41 +++++++++++++++++++ applications/lofar1/pfs/tb/vhdl/tb_pfs.vhd | 23 +++++++++++ applications/lofar1/readme_lofar1.txt | 14 +++++-- 8 files changed, 98 insertions(+), 17 deletions(-) create mode 100644 applications/lofar1/pfs/src/vhdl/pfs_pkg.vhd diff --git a/applications/lofar1/pfb2/src/vhdl/pfb2.vhd b/applications/lofar1/pfb2/src/vhdl/pfb2.vhd index 54ce610ba7..cd8327a0b3 100644 --- a/applications/lofar1/pfb2/src/vhdl/pfb2.vhd +++ b/applications/lofar1/pfb2/src/vhdl/pfb2.vhd @@ -1,6 +1,6 @@ ------------------------------------------------------------------------------- -- --- Copyright 2020 +-- Copyright 2021 -- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> -- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -- @@ -33,6 +33,7 @@ LIBRARY IEEE, common_lib, dp_lib, pfs_lib, pft2_lib; USE IEEE.std_logic_1164.ALL; USE common_lib.common_pkg.ALL; USE dp_lib.dp_stream_pkg.ALL; +USE pfs_lib.pfs_pkg.ALL; USE pft2_lib.pft_pkg.ALL; ENTITY pfb2 IS @@ -44,7 +45,8 @@ ENTITY pfb2 IS g_pfs_nof_taps : NATURAL := 16; g_pfs_in_dat_w : NATURAL := 12; g_pfs_out_dat_w : NATURAL := 18; - g_pfs_coef_dat_w : NATURAL := 16; + g_pfs_coef_dat_w : NATURAL := c_pfs_coef_w; -- = 16, should match coefs in g_pfs_coefs_file + g_pfs_coefs_file : STRING := c_pfs_coefs_file; -- = "data/pfs_coefsbuf_1024.hex" -- pft2 g_pft_mode : PFT_MODE_TYPE := PFT_MODE_REAL2; @@ -94,7 +96,8 @@ BEGIN g_nof_taps => c_nof_coeffs, g_in_dat_w => g_pfs_in_dat_w, g_out_dat_w => g_pfs_out_dat_w, - g_coef_dat_w => g_pfs_coef_dat_w + g_coef_dat_w => g_pfs_coef_dat_w, + g_coefs_file => g_pfs_coefs_file ) PORT MAP ( in_dat_x => pfs_in_dat_x, diff --git a/applications/lofar1/pfb2/src/vhdl/pfb2_unit.vhd b/applications/lofar1/pfb2/src/vhdl/pfb2_unit.vhd index be145f288f..3d4e01d114 100644 --- a/applications/lofar1/pfb2/src/vhdl/pfb2_unit.vhd +++ b/applications/lofar1/pfb2/src/vhdl/pfb2_unit.vhd @@ -1,6 +1,6 @@ ------------------------------------------------------------------------------- -- --- Copyright 2020 +-- Copyright 2021 -- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> -- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -- @@ -22,8 +22,8 @@ -- Purpose: Combine LOFAR1 pfb2 with subband statistics (SST), similar as wpfb_unit_dev -- Description: -- . support multiple complex input streams via g_nof_streams --- . 1 complex pfb2 per stream --- . 1 complex pfb2 can process two real inputs with PFT_MODE_REAL2 +-- . one complex pfb2 per stream +-- . one complex pfb2 can process two real inputs with PFT_MODE_REAL2 -- . pass on in_sosi.bsn -- -- Remark: @@ -33,6 +33,7 @@ USE IEEE.std_logic_1164.ALL; USE common_lib.common_pkg.ALL; USE common_lib.common_mem_pkg.ALL; USE dp_lib.dp_stream_pkg.ALL; +USE pfs_lib.pfs_pkg.ALL; USE pft2_lib.pft_pkg.ALL; ENTITY pfb2_unit IS @@ -45,7 +46,8 @@ ENTITY pfb2_unit IS g_pfs_nof_taps : NATURAL := 16; g_pfs_in_dat_w : NATURAL := 12; g_pfs_out_dat_w : NATURAL := 18; - g_pfs_coef_dat_w : NATURAL := 16; + g_pfs_coef_dat_w : NATURAL := c_pfs_coef_w; -- = 16, should match coefs in g_pfs_coefs_file + g_pfs_coefs_file : STRING := c_pfs_coefs_file; -- = "data/pfs_coefsbuf_1024.hex" -- pft2 g_pft_mode : PFT_MODE_TYPE := PFT_MODE_REAL2; @@ -95,6 +97,7 @@ BEGIN g_pfs_in_dat_w => g_pfs_in_dat_w, g_pfs_out_dat_w => g_pfs_out_dat_w, g_pfs_coef_dat_w => g_pfs_coef_dat_w, + g_pfs_coefs_file => g_pfs_coefs_file, -- pft2 g_pft_mode => g_pft_mode, diff --git a/applications/lofar1/pfs/hdllib.cfg b/applications/lofar1/pfs/hdllib.cfg index 3023ef367f..051dcac156 100644 --- a/applications/lofar1/pfs/hdllib.cfg +++ b/applications/lofar1/pfs/hdllib.cfg @@ -5,6 +5,7 @@ hdl_lib_uses_sim = hdl_lib_technology = synth_files = + src/vhdl/pfs_pkg.vhd src/vhdl/pfs_ctrl.vhd src/vhdl/pfs_tapsbuf.vhd src/vhdl/pfs_coefsbuf.vhd diff --git a/applications/lofar1/pfs/src/vhdl/pfs.vhd b/applications/lofar1/pfs/src/vhdl/pfs.vhd index f639776cad..fc750abced 100644 --- a/applications/lofar1/pfs/src/vhdl/pfs.vhd +++ b/applications/lofar1/pfs/src/vhdl/pfs.vhd @@ -26,6 +26,7 @@ LIBRARY IEEE, common_lib; USE IEEE.std_logic_1164.ALL; USE common_lib.common_pkg.ALL; +USE work.pfs_pkg.ALL; ENTITY pfs IS GENERIC ( @@ -33,7 +34,8 @@ ENTITY pfs IS g_nof_taps : NATURAL := 16*1024; g_in_dat_w : NATURAL := 12; g_out_dat_w : NATURAL := 18; - g_coef_dat_w : NATURAL := 16 + g_coef_dat_w : NATURAL := c_pfs_coef_w; -- = 16, should match coefs in g_coefs_file + g_coefs_file : STRING := c_pfs_coefs_file -- = "data/pfs_coefsbuf_1024.hex" ); PORT ( in_dat_x : IN STD_LOGIC_VECTOR(g_in_dat_w-1 DOWNTO 0); @@ -162,6 +164,7 @@ BEGIN coefsbuf : ENTITY work.pfs_coefsbuf GENERIC MAP ( g_data_w => g_coef_dat_w * c_nof_fir_taps, + g_coefs_file => g_coefs_file, g_nof_coefs => g_nof_bands, g_addr_w => c_nof_bands_w ) diff --git a/applications/lofar1/pfs/src/vhdl/pfs_coefsbuf.vhd b/applications/lofar1/pfs/src/vhdl/pfs_coefsbuf.vhd index 3d0965b570..e7ae9a6fd4 100644 --- a/applications/lofar1/pfs/src/vhdl/pfs_coefsbuf.vhd +++ b/applications/lofar1/pfs/src/vhdl/pfs_coefsbuf.vhd @@ -31,9 +31,11 @@ USE common_lib.common_mem_pkg.ALL; ENTITY pfs_coefsbuf IS GENERIC ( - g_data_w : NATURAL; - g_nof_coefs : NATURAL; - g_addr_w : NATURAL + g_data_w : NATURAL; + g_coefs_file : STRING := "data/pfs_coefsbuf_1024.hex"; -- Quartus .hex extension, replaced by .bin in common_rom works for XST + --g_coefs_file : STRING := "data/pfs_coefsbuf_1024.bin"; -- Synplify fails on file extension change to .bin in common_rom and requires extra ../ + g_nof_coefs : NATURAL; + g_addr_w : NATURAL ); PORT ( addr : IN STD_LOGIC_VECTOR(g_addr_w-1 DOWNTO 0); @@ -57,8 +59,7 @@ BEGIN rom : ENTITY common_lib.common_rom GENERIC MAP ( g_ram => c_coefs_rom, - g_init_file => "data/pfs_coefsbuf_1024.hex" -- Quartus .hex extension, replaced by .bin in common_rom works for XST - --g_init_file => "data/pfs_coefsbuf_1024.bin" -- Synplify fails on file extension change to .bin in common_rom and requires extra ../ + g_init_file => g_coefs_file ) PORT MAP ( rst => rst, diff --git a/applications/lofar1/pfs/src/vhdl/pfs_pkg.vhd b/applications/lofar1/pfs/src/vhdl/pfs_pkg.vhd new file mode 100644 index 0000000000..e708a66d17 --- /dev/null +++ b/applications/lofar1/pfs/src/vhdl/pfs_pkg.vhd @@ -0,0 +1,41 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2021 +-- 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: E. Kooistra, for pfs original 2004 by W. Lubberhuizen / W. Poeisz +-- Purpose: Polyphase FIR filter +-- Description: Ported from LOFAR1, see readme_lofar1.txt +-- Remark: Use package to keep default pfs constants + +LIBRARY IEEE; +USE IEEE.STD_LOGIC_1164.ALL; +USE IEEE.NUMERIC_STD.ALL; + +PACKAGE pfs_pkg IS + + CONSTANT c_pfs_coef_w : NATURAL := 16; + CONSTANT c_pfs_coefs_file : STRING := "data/pfs_coefsbuf_1024.hex"; + +END pfs_pkg; + + +PACKAGE BODY pfs_pkg IS +END pfs_pkg; + + diff --git a/applications/lofar1/pfs/tb/vhdl/tb_pfs.vhd b/applications/lofar1/pfs/tb/vhdl/tb_pfs.vhd index 3d1420b170..db7c793e6c 100644 --- a/applications/lofar1/pfs/tb/vhdl/tb_pfs.vhd +++ b/applications/lofar1/pfs/tb/vhdl/tb_pfs.vhd @@ -1,3 +1,26 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2021 +-- 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: ported by E. Kooistra, original 2004 by W. Lubberhuizen / W. Poeisz +-- Purpose: Testbench for Polyphase FIR filter +-- -- Usage: -- > as 5 -- > run -a diff --git a/applications/lofar1/readme_lofar1.txt b/applications/lofar1/readme_lofar1.txt index c252f9e0b7..a2919ef272 100644 --- a/applications/lofar1/readme_lofar1.txt +++ b/applications/lofar1/readme_lofar1.txt @@ -113,12 +113,18 @@ c) Simulating tb/vhdl/tb_pft2.vhd -5) Add generics - * pft2: - - g_stage_dat_w +5) Add generics and package constant defaults + * pfs_pkg.vhd: + - g_pfs_coef_dat_w, default is c_pfs_coef_w = 16, should match coefs in g_pfs_coefs_file + - g_pfs_coefs_file, default is c_pfs_coefs_file = "data/pfs_coefsbuf_1024.hex" + + * pft2_pkg.vhd: + - c_coeff_w in pft_tmult.vhd default is c_pft_twiddle_w = 16 + - g_stage_dat_w in pft.vhd, default is c_pft_stage_dat_w = 20 - verified range of g_stage_dat_w in tb_pft2 - verified switch_en input in tb_pft2 - * pfb2: + + * pfb2.vhd: - g_switch_en - g_stage_dat_w - g_pfs_bypass -- GitLab