From 005b6c45856de8a0c6d9c33b7fc0eafcb4ce079d Mon Sep 17 00:00:00 2001
From: Daniel van der Schuur <schuur@astron.nl>
Date: Thu, 18 Dec 2014 14:04:43 +0000
Subject: [PATCH] -Added libraries to hdllib.cfg; -Added wpfb_unit to
 apertif_unb1_correlator.vhd; -Removed FIFOs and dp_src_out_timers from
 apertif_unb1_correlator.vhd.

---
 .../apertif_unb1_correlator/hdllib.cfg        |  2 +-
 .../src/vhdl/apertif_unb1_correlator.vhd      | 59 ++++++++++++++++++-
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/applications/apertif_unb1_correlator/hdllib.cfg b/applications/apertif_unb1_correlator/hdllib.cfg
index 706c547dde..33ffb46773 100644
--- a/applications/apertif_unb1_correlator/hdllib.cfg
+++ b/applications/apertif_unb1_correlator/hdllib.cfg
@@ -1,6 +1,6 @@
 hdl_lib_name = apertif_unb1_correlator
 hdl_library_clause_name = apertif_unb1_correlator_lib
-hdl_lib_uses = common mm i2c unb1_board correlator 
+hdl_lib_uses = common mm dp i2c unb1_board correlator diag rTwoSDF wpfb st filter fft
 hdl_lib_technology = ip_stratixiv
 
 build_dir_sim = $HDL_BUILD_DIR
diff --git a/applications/apertif_unb1_correlator/src/vhdl/apertif_unb1_correlator.vhd b/applications/apertif_unb1_correlator/src/vhdl/apertif_unb1_correlator.vhd
index 32b5fb6dbf..9e1577e623 100644
--- a/applications/apertif_unb1_correlator/src/vhdl/apertif_unb1_correlator.vhd
+++ b/applications/apertif_unb1_correlator/src/vhdl/apertif_unb1_correlator.vhd
@@ -20,7 +20,7 @@
 --
 -------------------------------------------------------------------------------
 
-LIBRARY IEEE, common_lib, unb1_board_lib, correlator_lib, diag_lib, dp_lib;
+LIBRARY IEEE, common_lib, unb1_board_lib, correlator_lib, diag_lib, dp_lib, rTwoSDF_lib, wpfb_lib, st_lib, filter_lib, fft_lib;
 USE IEEE.STD_LOGIC_1164.ALL;
 USE IEEE.NUMERIC_STD.ALL;
 USE common_lib.common_pkg.ALL;
@@ -28,6 +28,13 @@ USE common_lib.common_mem_pkg.ALL;
 USE unb1_board_lib.unb1_board_pkg.ALL;
 USE diag_lib.diag_pkg.ALL;
 USE dp_lib.dp_stream_pkg.ALL;
+USE rTwoSDF_lib.rTwoSDFPkg.ALL; 
+USE st_lib.ALL; 
+USE filter_lib.ALL;
+USE filter_lib.fil_pkg.ALL;
+USE fft_lib.ALL;
+USE fft_lib.fft_pkg.ALL; 
+USE wpfb_lib.wpfb_pkg.ALL;
 
 ENTITY apertif_unb1_correlator IS
   GENERIC (
@@ -114,6 +121,25 @@ ARCHITECTURE str OF apertif_unb1_correlator IS
   SIGNAL eth1g_reg_interrupt        : STD_LOGIC;   -- Interrupt
   SIGNAL eth1g_ram_mosi             : t_mem_mosi;  -- ETH rx frame and tx frame memory
   SIGNAL eth1g_ram_miso             : t_mem_miso;
+  
+  -- WPFB
+  CONSTANT c_wpfb_wb_factor         : NATURAL := 1;      -- = default 1, wideband factor
+  CONSTANT c_wpfb_nof_wb_streams    : NATURAL := 12;     -- = 1, the number of parallel wideband streams. The fi
+  CONSTANT c_wpfb_nof_chan          : NATURAL := 1;      -- = default 0, defines the number of channels (=time-m
+  CONSTANT c_wpfb_nof_points        : NATURAL := 64;     -- = 1024, N point FFT
+  CONSTANT c_wpfb_nof_taps          : NATURAL := 8;      -- = 8 nof taps n the filter
+  CONSTANT c_wpfb_in_dat_w          : NATURAL := 6;      -- = 8, number of input bits                           
+  CONSTANT c_wpfb_out_dat_w         : NATURAL := 12;     -- = 14, number of output bits: in_dat_w + natural((cei
+  CONSTANT c_wpfb_use_separate      : BOOLEAN := FALSE;  -- = false for complex input, true for two real inputs
+
+
+
+  CONSTANT c_wpfb : t_wpfb  := (c_wpfb_wb_factor, c_wpfb_nof_points, c_wpfb_nof_chan, c_wpfb_nof_wb_streams,
+                                c_wpfb_nof_taps, c_wpfb_in_dat_w, 16, 16,
+                                true, c_wpfb_use_separate, 16, c_wpfb_out_dat_w, 18, 2, true, 56, 2,                      
+                                c_fft_pipeline, c_fft_pipeline, c_fil_ppf_pipeline);
+
+  CONSTANT c_wpfb_coefs_file_prefix : STRING  := "../../../../../UniBoard/trunk/Firmware/dsp/filter/build/data/coefs_wide";
 
   -- Correlator
   CONSTANT c_nof_inputs             : NATURAL := 24;
@@ -147,6 +173,7 @@ ARCHITECTURE str OF apertif_unb1_correlator IS
                                                           TO_UVEC(   c_bg_block_size-1, c_diag_bg_mem_high_adrs_w),
                                                           TO_UVEC(                   0, c_diag_bg_bsn_init_w));
 
+  SIGNAL wpfb_snk_in_arr            : t_dp_sosi_arr(c_nof_input_streams-1 DOWNTO 0);
   SIGNAL correlator_snk_in_arr      : t_dp_sosi_arr(c_nof_input_streams-1 DOWNTO 0);
   SIGNAL correlator_src_out_arr     : t_dp_sosi_arr(1-1 DOWNTO 0);
 
@@ -179,9 +206,37 @@ BEGIN
     dp_rst           => dp_rst,
     dp_clk           => dp_clk,
 
-    out_sosi_arr     => correlator_snk_in_arr
+    out_sosi_arr     => wpfb_snk_in_arr
   );
 
+  -----------------------------------------------------------------------------
+  -- WPFB
+  -----------------------------------------------------------------------------
+  u_wpfb_unit : ENTITY wpfb_lib.wpfb_unit
+  GENERIC MAP(
+    g_wpfb              => c_wpfb,     
+    g_stats_ena         => FALSE,
+    g_use_bg            => FALSE,    
+    g_file_index_arr    => array_init(0, 128, 1),    
+    g_coefs_file_prefix => c_wpfb_coefs_file_prefix 
+  )
+  PORT MAP(
+    dp_rst             => dp_rst,
+    dp_clk             => dp_clk,
+    mm_rst             => mm_rst,
+    mm_clk             => mm_clk,  
+    ram_fil_coefs_mosi => c_mem_mosi_rst,
+    ram_fil_coefs_miso => OPEN,
+    ram_st_sst_mosi    => c_mem_mosi_rst,
+    ram_st_sst_miso    => OPEN, 
+    reg_bg_ctrl_mosi   => c_mem_mosi_rst,
+    reg_bg_ctrl_miso   => OPEN,
+    ram_bg_data_mosi   => c_mem_mosi_rst,
+    ram_bg_data_miso   => OPEN,
+    in_sosi_arr        => wpfb_snk_in_arr,     
+    out_sosi_arr       => correlator_snk_in_arr
+  ); 
+
   -----------------------------------------------------------------------------
   -- Correlator
   -----------------------------------------------------------------------------
-- 
GitLab