aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/synth-ieee-numeric_std.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-03-13 18:41:53 +0100
committerTristan Gingold <tgingold@free.fr>2020-03-13 18:41:53 +0100
commit2143539b0943bc0917cb485c4571b8f9efe9df7f (patch)
tree557010d8ca34ef24f47fcdb2be78512decb64220 /src/synth/synth-ieee-numeric_std.adb
parent8b062ed9ee5107400d176d703dd8bb22eaf0138e (diff)
downloadghdl-2143539b0943bc0917cb485c4571b8f9efe9df7f.tar.gz
ghdl-2143539b0943bc0917cb485c4571b8f9efe9df7f.tar.bz2
ghdl-2143539b0943bc0917cb485c4571b8f9efe9df7f.zip
synth: handle static sub uns/nat.
Diffstat (limited to 'src/synth/synth-ieee-numeric_std.adb')
-rw-r--r--src/synth/synth-ieee-numeric_std.adb31
1 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 f308a2cc5..ca0f48362 100644
--- a/src/synth/synth-ieee-numeric_std.adb
+++ b/src/synth/synth-ieee-numeric_std.adb
@@ -180,6 +180,37 @@ package body Synth.Ieee.Numeric_Std is
return Res;
end Sub_Uns_Uns;
+ function Sub_Uns_Nat (L : Std_Logic_Vector; R : Uns64)
+ return Std_Logic_Vector
+ is
+ pragma Assert (L'First = 1);
+ Res : Std_Logic_Vector (1 .. L'Last);
+ V : Uns64;
+ Lb, Rb, Carry : Sl_X01;
+ begin
+ if L'Last < 1 then
+ return Null_Vec;
+ end if;
+ V := R;
+ Carry := '1';
+ for I in reverse Res'Range loop
+ Lb := Sl_To_X01 (L (I));
+ Rb := Uns_To_01 (V and 1);
+ Rb := Not_Table (Rb);
+ if Lb = 'X' then
+ --assert NO_WARNING
+ -- report "NUMERIC_STD.""+"": non logical value detected"
+ -- severity warning;
+ Res := (others => 'X');
+ exit;
+ end if;
+ Res (I) := Compute_Sum (Carry, Rb, Lb);
+ Carry := Compute_Carry (Carry, Rb, Lb);
+ V := Shift_Right (V, 1);
+ end loop;
+ return Res;
+ end Sub_Uns_Nat;
+
function Mul_Uns_Uns (L, R : Std_Logic_Vector) return Std_Logic_Vector
is
pragma Assert (L'First = 1);