From 429ad59652a8bbb16871525e0317b41f8ae9e9b1 Mon Sep 17 00:00:00 2001
From: David Brouwer <dbrouwer@astron.nl>
Date: Mon, 23 Oct 2023 08:54:07 +0200
Subject: [PATCH] =?UTF-8?q?Updated=20headerinformation=20to=20recent=20sta?=
 =?UTF-8?q?ndard.=20There=20is=20a=20small=20error=20in=20the=20header=20i?=
 =?UTF-8?q?nformation,=20namely=20=E2=80=9CThe=20largest=20pi=20=3D=202=20?=
 =?UTF-8?q?*=20min**2=20=3D=202**(c=5Fdsp=5Fdat=5Fw-1)=20=E2=80=A6?=
 =?UTF-8?q?=E2=80=9D=20is=20not=20the=20right=20equation.=20It=20should=20?=
 =?UTF-8?q?be=20=3D=202**(c=5Fdsp=5Fprod=5Fw-1)=20or=20=3D=202=20*=20((-2)?=
 =?UTF-8?q?**(c=5Fdsp=5Fdat=5Fw-1))**2,=20and=20that=20is=20equal=20to=20?=
 =?UTF-8?q?=3D=20(-2)**(2*(c=5Fdsp=5Fdat=5Fw-1))=20=3D=202*=204*(c=5Fdsp?=
 =?UTF-8?q?=5Fdat=5Fw-1).=20I=20updated=20it=20to=202**(c=5Fdsp=5Fprod=5Fw?=
 =?UTF-8?q?-1).=20Added=20five=20(extra)=20libraries=20with=20two=20commen?=
 =?UTF-8?q?ted=20out:=20--LIBRARY=20ip=5Fagi027=5Fxxxx=5Fmult=5Flib;=20--L?=
 =?UTF-8?q?IBRARY=20ip=5Fagi027=5Fxxxx=5Fmult=5Frtl=5Flib;=20library=20ip?=
 =?UTF-8?q?=5Fagi027=5Fxxxx=5Fcomplex=5Fmult=5Faltmult=5Fcomplex=5F1910;?=
 =?UTF-8?q?=20library=20ip=5Fagi027=5Fxxxx=5Fcomplex=5Fmult=5Frtl=5Flib;?=
 =?UTF-8?q?=20library=20ip=5Fagi027=5Fxxxx=5Fcomplex=5Fmult=5Frtl=5Fcanoni?=
 =?UTF-8?q?cal=5Flib;=20Add=20generate-block=20inclusive=20the=20instantia?=
 =?UTF-8?q?tion=20of=20a=20module=20for=20the=20agi027=5Fxxxx:=20--=20IP?=
 =?UTF-8?q?=20variants=20for=20<=3D=2018=20bit:=20ip=5Fagi027=5Fxxxx=5Fcom?=
 =?UTF-8?q?plex=5Fmult=20--=20IP=20variants=20for=20>=2018=20bit=20and=20<?=
 =?UTF-8?q?=3D=2027=20bit:=20ip=5Fagi027=5Fxxxx=5Fcomplex=5Fmult=5F27b=20-?=
 =?UTF-8?q?-=20RTL=20variants=20that=20can=20infer=20multipliers=20for=20a?=
 =?UTF-8?q?=20technology,=20fits=20all=20widths:=20ip=5Fagi027=5Fxxxx=5Fco?=
 =?UTF-8?q?mplex=5Fmult=5Frtl=20--=20RTL=20variants=20that=20can=20infer?=
 =?UTF-8?q?=20multipliers=20for=20a=20technology,=20fits=20all=20widths:?=
 =?UTF-8?q?=20ip=5Fagi027=5Fxxxx=5Fcomplex=5Fmult=5Frtl=5Fcanonical.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../technology/mult/tech_complex_mult.vhd     | 115 +++++++++++++++++-
 1 file changed, 112 insertions(+), 3 deletions(-)

diff --git a/libraries/technology/mult/tech_complex_mult.vhd b/libraries/technology/mult/tech_complex_mult.vhd
index d11e36bb05..ee1f20fb1a 100644
--- a/libraries/technology/mult/tech_complex_mult.vhd
+++ b/libraries/technology/mult/tech_complex_mult.vhd
@@ -1,6 +1,6 @@
 -------------------------------------------------------------------------------
 --
--- Copyright (C) 2009
+-- Copyright (C) 2009-2023
 -- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
 -- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
 --
@@ -20,6 +20,7 @@
 -------------------------------------------------------------------------------
 --
 -- Author : E. Kooistra
+-- Changed by : D.F. Brouwer
 -- Purpose : Wrapper for complex multiplier IP
 -- Decription :
 --
@@ -42,7 +43,7 @@
 --   The largest value for pi = min**2 + min**2.
 --   The largest value for pr = min**2 - min*max < largest pi.
 --
---   The largest pi = 2 * min**2 = 2**(c_dsp_dat_w-1), so it just does not
+--   The largest pi = 2 * min**2 = 2**(c_dsp_prod_w-1), so it just does not
 --   fit in c_dsp_prod_w, but largest pi - 1 = 2**(c_dsp_dat_w-1) - 1 does
 --   fit, so all other input values fit. In DSP systems the input value
 --   (min + j*min) typically never occurs.
@@ -64,12 +65,17 @@ use work.tech_mult_component_pkg.all;
 -- Declare IP libraries to ensure default binding in simulation. The IP library clause is ignored by synthesis.
 library ip_stratixiv_mult_lib;
 --LIBRARY ip_arria10_mult_lib;
+--LIBRARY ip_agi027_xxxx_mult_lib;
 --LIBRARY ip_arria10_mult_rtl_lib;
+--LIBRARY ip_agi027_xxxx_mult_rtl_lib;
 library ip_arria10_complex_mult_altmult_complex_150;
 library ip_arria10_e1sg_complex_mult_altmult_complex_180;
 library ip_arria10_e2sg_complex_mult_altmult_complex_1910;
+library ip_agi027_xxxx_complex_mult_altmult_complex_1910;
 library ip_arria10_complex_mult_rtl_lib;
+library ip_agi027_xxxx_complex_mult_rtl_lib;
 library ip_arria10_complex_mult_rtl_canonical_lib;
+library ip_agi027_xxxx_complex_mult_rtl_canonical_lib;
 
 entity tech_complex_mult is
   generic (
@@ -212,6 +218,31 @@ begin
     result_im <= RESIZE_SVEC(mult_im, g_out_p_w);
   end generate;
 
+  gen_ip_agi027_xxxx_ip : if g_variant = "IP" and g_technology = c_tech_agi027_xxxx and c_dsp_dat_w <= c_dsp_mult_18_w generate
+    -- Adapt DSP input widths
+    ar <= RESIZE_SVEC(in_ar, c_dsp_mult_18_w);
+    ai <= RESIZE_SVEC(in_ai, c_dsp_mult_18_w);
+    br <= RESIZE_SVEC(in_br, c_dsp_mult_18_w);
+    bi <= RESIZE_SVEC(in_bi, c_dsp_mult_18_w) when g_conjugate_b = false else TO_SVEC(-TO_SINT(in_bi), c_dsp_mult_18_w);
+
+    u0 : ip_agi027_xxxx_complex_mult
+    port map (
+      aclr        => rst,
+      clock       => clk,
+      dataa_imag  => ai,
+      dataa_real  => ar,
+      datab_imag  => bi,
+      datab_real  => br,
+      ena         => clken,
+      result_imag => mult_im,
+      result_real => mult_re
+    );
+
+    -- Back to true input widths and then resize for output width
+    result_re <= RESIZE_SVEC(mult_re, g_out_p_w);
+    result_im <= RESIZE_SVEC(mult_im, g_out_p_w);
+  end generate;
+
   -----------------------------------------------------------------------------
   -- IP variants for > 18 bit and <= 27 bit
   -----------------------------------------------------------------------------
@@ -266,6 +297,31 @@ begin
     result_im <= RESIZE_SVEC(mult_im, g_out_p_w);
   end generate;
 
+  gen_ip_agi027_xxxx_ip_27b : if g_variant = "IP" and g_technology = c_tech_agi027_xxxx and c_dsp_dat_w > c_dsp_mult_18_w and c_dsp_dat_w <= c_dsp_mult_27_w generate
+    -- Adapt DSP input widths
+    ar <= RESIZE_SVEC(in_ar, c_dsp_mult_27_w);
+    ai <= RESIZE_SVEC(in_ai, c_dsp_mult_27_w);
+    br <= RESIZE_SVEC(in_br, c_dsp_mult_27_w);
+    bi <= RESIZE_SVEC(in_bi, c_dsp_mult_27_w) when g_conjugate_b = false else TO_SVEC(-TO_SINT(in_bi), c_dsp_mult_27_w);
+
+    u0 : ip_agi027_xxxx_complex_mult_27b
+    port map (
+      aclr        => rst,
+      clock       => clk,
+      dataa_imag  => ai,
+      dataa_real  => ar,
+      datab_imag  => bi,
+      datab_real  => br,
+      ena         => clken,
+      result_imag => mult_im,
+      result_real => mult_re
+    );
+
+    -- Back to true input widths and then resize for output width
+    result_re <= RESIZE_SVEC(mult_re, g_out_p_w);
+    result_im <= RESIZE_SVEC(mult_im, g_out_p_w);
+  end generate;
+
   -----------------------------------------------------------------------------
   -- RTL variants that can infer multipliers for a technology, fits all widths
   -----------------------------------------------------------------------------
@@ -328,7 +384,6 @@ begin
   gen_ip_arria10_rtl_canonical : if g_variant = "RTL_C" and (g_technology = c_tech_arria10_proto or
                                                            g_technology = c_tech_arria10_e3sge3 or
                                                            g_technology = c_tech_arria10_e1sg or
-
                                                            g_technology = c_tech_arria10_e2sg) generate
     -- support g_conjugate_b
     bi <= in_bi when g_conjugate_b = false else TO_SVEC(-TO_SINT(in_bi), g_in_b_w);
@@ -356,4 +411,58 @@ begin
     );
   end generate;
 
+  -- RTL variant is for iwave
+  gen_ip_agi027_xxxx_rtl : if g_variant = "RTL" and (g_technology = c_tech_agi027_xxxx) generate
+    u0 : ip_agi027_xxxx_complex_mult_rtl
+    generic map (
+      g_in_a_w           => g_in_a_w,
+      g_in_b_w           => g_in_b_w,
+      g_out_p_w          => g_out_p_w,
+      g_conjugate_b      => g_conjugate_b,
+      g_pipeline_input   => g_pipeline_input,
+      g_pipeline_product => g_pipeline_product,
+      g_pipeline_adder   => g_pipeline_adder,
+      g_pipeline_output  => g_pipeline_output
+    )
+    port map (
+      rst        => rst,
+      clk        => clk,
+      clken      => clken,
+      in_ar      => in_ar,
+      in_ai      => in_ai,
+      in_br      => in_br,
+      in_bi      => in_bi,
+      result_re  => result_re,
+      result_im  => result_im
+    );
+  end generate;
+
+  -- RTL variant is for iwave
+  gen_ip_agi027_xxxx_rtl_canonical : if g_variant = "RTL_C" and (g_technology = c_tech_agi027_xxxx) generate
+    -- support g_conjugate_b
+    bi <= in_bi when g_conjugate_b = false else TO_SVEC(-TO_SINT(in_bi), g_in_b_w);
+
+    u0 : ip_agi027_xxxx_complex_mult_rtl_canonical
+    generic map (
+      g_in_a_w           => g_in_a_w,
+      g_in_b_w           => g_in_b_w,
+      g_out_p_w          => g_out_p_w,
+      g_pipeline_input   => g_pipeline_input,
+      g_pipeline_product => g_pipeline_product,
+      g_pipeline_adder   => g_pipeline_adder,
+      g_pipeline_output  => g_pipeline_output
+    )
+    port map (
+      rst        => rst,
+      clk        => clk,
+      clken      => clken,
+      in_ar      => in_ar,
+      in_ai      => in_ai,
+      in_br      => in_br,
+      in_bi      => bi,
+      result_re  => result_re,
+      result_im  => result_im
+    );
+  end generate;
+
 end str;
-- 
GitLab