From 3c59b32a70de2f9d3523345124e3e75b96d27a30 Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Tue, 23 Nov 2021 11:53:21 +0100
Subject: [PATCH] Use c_sdp_N_clk_per_sync = c_sdp_f_adc_MHz*10**6.

---
 .../designs/lofar2_unb2b_ring/src/vhdl/lofar2_unb2b_ring.vhd   | 2 +-
 .../src/vhdl/lofar2_unb2b_sdp_station.vhd                      | 3 +--
 .../src/vhdl/lofar2_unb2c_sdp_station.vhd                      | 3 +--
 applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd         | 3 ++-
 applications/lofar2/libraries/sdp/src/vhdl/sdp_station.vhd     | 2 +-
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/applications/lofar2/designs/lofar2_unb2b_ring/src/vhdl/lofar2_unb2b_ring.vhd b/applications/lofar2/designs/lofar2_unb2b_ring/src/vhdl/lofar2_unb2b_ring.vhd
index 612609097a..f9c128cc79 100644
--- a/applications/lofar2/designs/lofar2_unb2b_ring/src/vhdl/lofar2_unb2b_ring.vhd
+++ b/applications/lofar2/designs/lofar2_unb2b_ring/src/vhdl/lofar2_unb2b_ring.vhd
@@ -113,7 +113,7 @@ ARCHITECTURE str OF lofar2_unb2b_ring IS
   -- Firmware version x.y
   CONSTANT c_fw_version             : t_unb2b_board_fw_version := (2, 0);
   CONSTANT c_mm_clk_freq            : NATURAL := c_unb2b_board_mm_clk_freq_100M;
-  CONSTANT c_lofar2_sample_clk_freq : NATURAL := c_sdp_f_adc_MHz * 10**6;  -- fixed 200 MHz for LOFAR2.0 stage 1
+  CONSTANT c_lofar2_sample_clk_freq : NATURAL := c_sdp_N_clk_per_sync;  -- fixed 200 MHz for LOFAR2.0 stage 1
 
    -- QSFP
   CONSTANT c_nof_qsfp_bus           : NATURAL := 1;
diff --git a/applications/lofar2/designs/lofar2_unb2b_sdp_station/src/vhdl/lofar2_unb2b_sdp_station.vhd b/applications/lofar2/designs/lofar2_unb2b_sdp_station/src/vhdl/lofar2_unb2b_sdp_station.vhd
index 7790d20c01..0d5e39337f 100644
--- a/applications/lofar2/designs/lofar2_unb2b_sdp_station/src/vhdl/lofar2_unb2b_sdp_station.vhd
+++ b/applications/lofar2/designs/lofar2_unb2b_sdp_station/src/vhdl/lofar2_unb2b_sdp_station.vhd
@@ -58,7 +58,7 @@ ENTITY lofar2_unb2b_sdp_station IS
     g_factory_image          : BOOLEAN := FALSE;
     g_protect_addr_range     : BOOLEAN := FALSE;
     g_wpfb                   : t_wpfb  := c_sdp_wpfb_subbands;
-    g_bsn_nof_clk_per_sync   : NATURAL := c_sdp_f_adc_MHz*10**6;  -- Default 200M, overide for short simulation 
+    g_bsn_nof_clk_per_sync   : NATURAL := c_sdp_N_clk_per_sync;  -- Default 200M, overide for short simulation
     g_scope_selected_subband : NATURAL := 0
   );
   PORT (
@@ -115,7 +115,6 @@ ARCHITECTURE str OF lofar2_unb2b_sdp_station IS
   -- Firmware version x.y
   CONSTANT c_fw_version             : t_unb2b_board_fw_version := (2, 0);
   CONSTANT c_mm_clk_freq            : NATURAL := c_unb2b_board_mm_clk_freq_100M;
-  CONSTANT c_lofar2_sample_clk_freq : NATURAL := c_sdp_f_adc_MHz * 10**6;  -- fixed 200 MHz for LOFAR2.0 stage 1
 
   -- 10 GbE Interface
   CONSTANT c_nof_streams_qsfp       : NATURAL := c_unb2b_board_tr_qsfp.nof_bus * c_quad;
diff --git a/applications/lofar2/designs/lofar2_unb2c_sdp_station/src/vhdl/lofar2_unb2c_sdp_station.vhd b/applications/lofar2/designs/lofar2_unb2c_sdp_station/src/vhdl/lofar2_unb2c_sdp_station.vhd
index 3d23da21e2..9fa5e7c992 100644
--- a/applications/lofar2/designs/lofar2_unb2c_sdp_station/src/vhdl/lofar2_unb2c_sdp_station.vhd
+++ b/applications/lofar2/designs/lofar2_unb2c_sdp_station/src/vhdl/lofar2_unb2c_sdp_station.vhd
@@ -58,7 +58,7 @@ ENTITY lofar2_unb2c_sdp_station IS
     g_factory_image          : BOOLEAN := FALSE;
     g_protect_addr_range     : BOOLEAN := FALSE;
     g_wpfb                   : t_wpfb  := c_sdp_wpfb_subbands;
-    g_bsn_nof_clk_per_sync   : NATURAL := c_sdp_f_adc_MHz*10**6;  -- Default 200M, overide for short simulation 
+    g_bsn_nof_clk_per_sync   : NATURAL := c_sdp_N_clk_per_sync;  -- Default 200M, overide for short simulation
     g_scope_selected_subband : NATURAL := 0
   );
   PORT (
@@ -107,7 +107,6 @@ ARCHITECTURE str OF lofar2_unb2c_sdp_station IS
   -- Firmware version x.y
   CONSTANT c_fw_version             : t_unb2c_board_fw_version := (2, 0);
   CONSTANT c_mm_clk_freq            : NATURAL := c_unb2c_board_mm_clk_freq_100M;
-  CONSTANT c_lofar2_sample_clk_freq : NATURAL := c_sdp_f_adc_MHz * 10**6;  -- fixed 200 MHz for LOFAR2.0 stage 1
 
   -- 10 GbE Interface
   CONSTANT c_nof_streams_qsfp       : NATURAL := c_unb2c_board_tr_qsfp.nof_bus * c_quad;
diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd
index 213dea60f7..4dbd3fd7db 100644
--- a/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd
+++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd
@@ -110,6 +110,7 @@ PACKAGE sdp_pkg is
 
   -- Derived constants
   CONSTANT c_sdp_FS_adc          : NATURAL := 2**(c_sdp_W_adc - 1); -- full scale FS corresponds to amplitude 1.0
+  CONSTANT c_sdp_N_clk_per_sync  : NATURAL := c_sdp_f_adc_MHz*10**6;  -- Default 200M clock cycles per second
   CONSTANT c_sdp_N_sync_jesd     : NATURAL := c_sdp_S_pn * c_sdp_N_sync_rcu / c_sdp_S_rcu; -- = 4, nof JESD IP sync outputs per PN
   CONSTANT c_sdp_P_pfb           : NATURAL := c_sdp_S_pn / c_sdp_Q_fft;
   CONSTANT c_sdp_T_adc           : TIME    := (10**6 / c_sdp_f_adc_MHz) * 1 ps;
@@ -341,7 +342,7 @@ PACKAGE sdp_pkg is
                                                      init_sl  => '0'); -- Default = 1
   CONSTANT c_sdp_nof_crosslets_reg_w : NATURAL := c_sdp_mm_reg_nof_crosslets.nof_dat*c_sdp_mm_reg_nof_crosslets.dat_w;
 
-  CONSTANT c_sdp_xst_nof_clk_per_sync_min : NATURAL := (c_sdp_f_adc_MHz *10**6) / 10; -- 0.1 second
+  CONSTANT c_sdp_xst_nof_clk_per_sync_min : NATURAL := c_sdp_N_clk_per_sync / 10; -- 0.1 second
 
   -- XSUB MM address widths
   CONSTANT c_sdp_reg_crosslets_info_addr_w          : NATURAL := c_sdp_mm_reg_crosslets_info.adr_w;
diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_station.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_station.vhd
index abe7debfc7..a0d6261300 100644
--- a/applications/lofar2/libraries/sdp/src/vhdl/sdp_station.vhd
+++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_station.vhd
@@ -46,7 +46,7 @@ ENTITY sdp_station IS
     g_technology             : NATURAL := c_tech_arria10_e1sg;
     g_sim                    : BOOLEAN := FALSE; --Overridden by TB
     g_wpfb                   : t_wpfb  := c_sdp_wpfb_subbands;
-    g_bsn_nof_clk_per_sync   : NATURAL := c_sdp_f_adc_MHz*10**6;  -- Default 200M, overide for short simulation 
+    g_bsn_nof_clk_per_sync   : NATURAL := c_sdp_N_clk_per_sync;  -- Default 200M, overide for short simulation
     g_scope_selected_subband : NATURAL := 0;
     g_use_fsub               : BOOLEAN := TRUE;
     g_use_xsub               : BOOLEAN := TRUE;
-- 
GitLab