From fe333a2745ef59cdaa296f65082adc040925129a Mon Sep 17 00:00:00 2001
From: Reinier van der Walle <walle@astron.nl>
Date: Fri, 3 Sep 2021 15:08:15 +0200
Subject: [PATCH] Updated rTwoWMul to use arria10 multipliers if available and
 updated sdc files for lofar2_unb2b/c_sdp_station

---
 .../quartus/lofar2_unb2b_sdp_station.sdc                  | 4 ++--
 .../quartus/lofar2_unb2c_sdp_station.sdc                  | 4 ++--
 libraries/base/common/src/vhdl/common_pkg.vhd             | 3 ++-
 libraries/dsp/rTwoSDF/src/vhdl/rTwoWMul.vhd               | 8 +++++---
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/applications/lofar2/designs/lofar2_unb2b_sdp_station/quartus/lofar2_unb2b_sdp_station.sdc b/applications/lofar2/designs/lofar2_unb2b_sdp_station/quartus/lofar2_unb2b_sdp_station.sdc
index 82c0df011c..ce015b6d62 100644
--- a/applications/lofar2/designs/lofar2_unb2b_sdp_station/quartus/lofar2_unb2b_sdp_station.sdc
+++ b/applications/lofar2/designs/lofar2_unb2b_sdp_station/quartus/lofar2_unb2b_sdp_station.sdc
@@ -86,8 +86,8 @@ set_clock_groups -asynchronous -group [get_clocks pll_clk400]
 #set_clock_groups -asynchronous -group [get_clocks {*mac_clock*xcvr_fpll_a10_0|outclk0}]
 #set_clock_groups -asynchronous -group [get_clocks {*dp_clk*xcvr_fpll_a10_0|outclk0}]
 #set_clock_groups -asynchronous -group [get_clocks {*xcvr_fpll_a10_0|outclk1}]
-set_clock_groups -asynchronous -group [get_clocks {*xcvr_fpll_a10_0|outclk3}]
-
+set_clock_groups -asynchronous -group [get_clocks {*_board_clk125_pll|*xcvr_fpll_a10_0|outclk2}]
+set_clock_groups -asynchronous -group [get_clocks {*_board_clk125_pll|*xcvr_fpll_a10_0|outclk3}]
 
 set_clock_groups -asynchronous -group [get_clocks {*xcvr_native_a10_0|g_xcvr_native_insts[*]|rx_pma_clk}]
 
diff --git a/applications/lofar2/designs/lofar2_unb2c_sdp_station/quartus/lofar2_unb2c_sdp_station.sdc b/applications/lofar2/designs/lofar2_unb2c_sdp_station/quartus/lofar2_unb2c_sdp_station.sdc
index b6e28ef53d..6f0327b422 100644
--- a/applications/lofar2/designs/lofar2_unb2c_sdp_station/quartus/lofar2_unb2c_sdp_station.sdc
+++ b/applications/lofar2/designs/lofar2_unb2c_sdp_station/quartus/lofar2_unb2c_sdp_station.sdc
@@ -86,8 +86,8 @@ set_clock_groups -asynchronous -group [get_clocks pll_clk400]
 #set_clock_groups -asynchronous -group [get_clocks {*mac_clock*xcvr_fpll_a10_0|outclk0}]
 #set_clock_groups -asynchronous -group [get_clocks {*dp_clk*xcvr_fpll_a10_0|outclk0}]
 #set_clock_groups -asynchronous -group [get_clocks {*xcvr_fpll_a10_0|outclk1}]
-set_clock_groups -asynchronous -group [get_clocks {*xcvr_fpll_a10_0|outclk3}]
-
+set_clock_groups -asynchronous -group [get_clocks {*_board_clk125_pll|*xcvr_fpll_a10_0|outclk2}]
+set_clock_groups -asynchronous -group [get_clocks {*_board_clk125_pll|*xcvr_fpll_a10_0|outclk3}]
 
 set_clock_groups -asynchronous -group [get_clocks {*xcvr_native_a10_0|g_xcvr_native_insts[*]|rx_pma_clk}]
 
diff --git a/libraries/base/common/src/vhdl/common_pkg.vhd b/libraries/base/common/src/vhdl/common_pkg.vhd
index 3931d10770..30edfe8dc9 100644
--- a/libraries/base/common/src/vhdl/common_pkg.vhd
+++ b/libraries/base/common/src/vhdl/common_pkg.vhd
@@ -98,7 +98,8 @@ PACKAGE common_pkg IS
   CONSTANT c_fifo_afull_margin    : NATURAL := 4;       -- default or minimal FIFO almost full margin
   
   -- DSP
-  CONSTANT c_dsp_mult_w           : NATURAL := 18;   -- Width of the embedded multipliers in Stratix IV
+  CONSTANT c_dsp_mult_w           : NATURAL := 18;   -- Width of the embedded multipliers in Stratix IV (and Arria 10 for 2 multipliers per DSP block)
+  CONSTANT c_dsp_mult_arria10_w   : NATURAL := 27;   -- Width of the embedded multipliers in Arria 10
   
   -- TYPE DECLARATIONS --------------------------------------------------------
   TYPE t_boolean_arr     IS ARRAY (INTEGER RANGE <>) OF BOOLEAN;   -- INTEGER left index starts default at -2**31
diff --git a/libraries/dsp/rTwoSDF/src/vhdl/rTwoWMul.vhd b/libraries/dsp/rTwoSDF/src/vhdl/rTwoWMul.vhd
index 31822aabfe..ab08dfeb93 100644
--- a/libraries/dsp/rTwoSDF/src/vhdl/rTwoWMul.vhd
+++ b/libraries/dsp/rTwoSDF/src/vhdl/rTwoWMul.vhd
@@ -22,6 +22,7 @@
 library ieee, common_lib, common_mult_lib, technology_lib;
 use IEEE.std_logic_1164.all;
 USE technology_lib.technology_select_pkg.ALL;
+USE technology_lib.technology_pkg.ALL;
 use common_lib.common_pkg.all;
 
 entity rTwoWMul is
@@ -69,7 +70,8 @@ architecture str of rTwoWMul is
   constant c_mult_extra_lat   : natural := sel_a_b(c_lat>3, c_lat-3, 0);               -- remaining extra pipelining in logic
   constant c_mult_output_lat  : natural := sel_a_b(c_lat>0, 1, 0) + c_mult_extra_lat;  -- first priority use DSP pipeline output
   constant c_mult_lat         : natural := c_mult_input_lat + c_mult_product_lat + c_mult_adder_lat + c_mult_output_lat;
-  
+  constant c_max_dsp_mult_w   : natural := sel_a_b(g_technology = c_tech_stratixiv, c_dsp_mult_w, c_dsp_mult_arria10_w);
+ 
   -- Total input to output latency
   constant c_total_lat   : natural := c_mult_lat + c_round_lat;
   
@@ -107,7 +109,7 @@ begin
   --   . for c_lat >= 3 default best use the FPGA multiplier IP block.
   ------------------------------------------------------------------------------
 
-  gen_rtl : if g_stage=1 or c_in_dat_w>c_dsp_mult_w or c_weight_w>c_dsp_mult_w or c_lat<c_dsp_mult_lat generate
+  gen_rtl : if g_stage=1 or c_in_dat_w>c_max_dsp_mult_w or c_weight_w>c_max_dsp_mult_w or c_lat<c_dsp_mult_lat generate
     u_CmplxMul : entity common_mult_lib.common_complex_mult
     generic map (
       g_technology       => g_technology,
@@ -135,7 +137,7 @@ begin
     );
   end generate;
   
-  gen_ip : if g_stage>1 and c_in_dat_w<=c_dsp_mult_w and c_weight_w<=c_dsp_mult_w and c_lat>=c_dsp_mult_lat generate
+  gen_ip : if g_stage>1 and c_in_dat_w<=c_max_dsp_mult_w and c_weight_w<=c_max_dsp_mult_w and c_lat>=c_dsp_mult_lat generate
     u_cmplx_mul : entity common_mult_lib.common_complex_mult
     generic map (
       g_technology       => g_technology,
-- 
GitLab