aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbwimm <be.wimm@gmail.com>2020-04-07 21:05:32 +0200
committerGitHub <noreply@github.com>2020-04-07 21:05:32 +0200
commit921e989f6e638cd655835040839b2c003385ec38 (patch)
tree5fc93437e27dd433733cb29de2045d51af5e6d62 /src
parentdd36b3a7c22edeb73a821b1cd9f43c997920b3ef (diff)
downloadghdl-921e989f6e638cd655835040839b2c003385ec38.tar.gz
ghdl-921e989f6e638cd655835040839b2c003385ec38.tar.bz2
ghdl-921e989f6e638cd655835040839b2c003385ec38.zip
synth-static_oper: handle mul uns nat. (#1200)
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-ieee-numeric_std.adb13
-rw-r--r--src/synth/synth-ieee-numeric_std.ads2
-rw-r--r--src/synth/synth-static_oper.adb16
3 files changed, 31 insertions, 0 deletions
diff --git a/src/synth/synth-ieee-numeric_std.adb b/src/synth/synth-ieee-numeric_std.adb
index d997c93b8..96a228bb3 100644
--- a/src/synth/synth-ieee-numeric_std.adb
+++ b/src/synth/synth-ieee-numeric_std.adb
@@ -279,6 +279,19 @@ package body Synth.Ieee.Numeric_Std is
return Mul_Uns_Uns (T, R);
end Mul_Nat_Uns;
+ function Mul_Uns_Nat (L : Std_Logic_Vector; R : Uns64)
+ return Std_Logic_Vector
+ is
+ pragma Assert (L'First = 1);
+ T : Std_Logic_Vector (1 .. L'Last);
+ begin
+ if L'Last < 1 then
+ return Null_Vec;
+ end if;
+ To_Unsigned (T, R);
+ return Mul_Uns_Uns (L, T);
+ end Mul_Uns_Nat;
+
function Mul_Sgn_Sgn (L, R : Std_Logic_Vector) return Std_Logic_Vector
is
pragma Assert (L'First = 1);
diff --git a/src/synth/synth-ieee-numeric_std.ads b/src/synth/synth-ieee-numeric_std.ads
index f0004c846..7e85f04a0 100644
--- a/src/synth/synth-ieee-numeric_std.ads
+++ b/src/synth/synth-ieee-numeric_std.ads
@@ -42,6 +42,8 @@ package Synth.Ieee.Numeric_Std is
function Mul_Uns_Uns (L, R : Std_Logic_Vector) return Std_Logic_Vector;
function Mul_Nat_Uns (L : Uns64; R : Std_Logic_Vector)
return Std_Logic_Vector;
+ function Mul_Uns_Nat (L : Std_Logic_Vector; R : Uns64)
+ return Std_Logic_Vector;
function Mul_Sgn_Sgn (L, R : Std_Logic_Vector) return Std_Logic_Vector;
end Synth.Ieee.Numeric_Std;
diff --git a/src/synth/synth-static_oper.adb b/src/synth/synth-static_oper.adb
index 4d4ff8305..4712dd844 100644
--- a/src/synth/synth-static_oper.adb
+++ b/src/synth/synth-static_oper.adb
@@ -462,6 +462,20 @@ package body Synth.Static_Oper is
end;
end Synth_Mul_Nat_Uns;
+ function Synth_Mul_Uns_Nat (L, R : Valtyp; Loc : Syn_Src) return Valtyp
+ is
+ pragma Unreferenced (Loc);
+ L_Arr : Std_Logic_Vector (1 .. Natural (Vec_Length (L.Typ)));
+ R_Val : constant Uns64 := Uns64 (Read_Discrete (R));
+ begin
+ To_Std_Logic_Vector (L, L_Arr);
+ declare
+ Res_Arr : constant Std_Logic_Vector := Mul_Uns_Nat (L_Arr, R_Val);
+ begin
+ return To_Valtyp (Res_Arr, L.Typ.Vec_El);
+ end;
+ end Synth_Mul_Uns_Nat;
+
function Synth_Mul_Sgn_Sgn (L, R : Valtyp; Loc : Syn_Src) return Valtyp
is
pragma Unreferenced (Loc);
@@ -904,6 +918,8 @@ package body Synth.Static_Oper is
return Synth_Mul_Uns_Uns (Left, Right, Expr);
when Iir_Predefined_Ieee_Numeric_Std_Mul_Nat_Uns =>
return Synth_Mul_Nat_Uns (Left, Right, Expr);
+ when Iir_Predefined_Ieee_Numeric_Std_Mul_Uns_Nat =>
+ return Synth_Mul_Uns_Nat (Left, Right, Expr);
when Iir_Predefined_Ieee_Numeric_Std_Mul_Sgn_Sgn =>
return Synth_Mul_Sgn_Sgn (Left, Right, Expr);