aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-06-05 09:09:47 +0200
committerTristan Gingold <tgingold@free.fr>2022-06-05 09:09:47 +0200
commit9a001446dd281c47a8321ce475bcf1e79dc1b859 (patch)
treed6526143869badd307cf39ddee1c448caf18c0ca
parent315c1969f53125ce2e396285209aac085f84d7e6 (diff)
downloadghdl-9a001446dd281c47a8321ce475bcf1e79dc1b859.tar.gz
ghdl-9a001446dd281c47a8321ce475bcf1e79dc1b859.tar.bz2
ghdl-9a001446dd281c47a8321ce475bcf1e79dc1b859.zip
synth-ieee-numeric_std: fix handling of X for negation
-rw-r--r--src/synth/synth-ieee-numeric_std.adb38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/synth/synth-ieee-numeric_std.adb b/src/synth/synth-ieee-numeric_std.adb
index 0e1b4be0e..221c9da6f 100644
--- a/src/synth/synth-ieee-numeric_std.adb
+++ b/src/synth/synth-ieee-numeric_std.adb
@@ -844,6 +844,22 @@ package body Synth.Ieee.Numeric_Std is
Neg_Vec (V.Mem, V.Mem, V.Typ);
end Neg_Vec;
+ function Has_0x (V : Memtyp) return Sl_X01
+ is
+ Res : Sl_X01 := '0';
+ E : Sl_X01;
+ begin
+ for I in 0 .. V.Typ.Abound.Len - 1 loop
+ E := To_X01 (Read_Std_Logic (V.Mem, I));
+ if E = 'X' then
+ return 'X';
+ elsif E = '1' then
+ Res := '1';
+ end if;
+ end loop;
+ return Res;
+ end Has_0x;
+
function Neg_Vec (V : Memtyp; Loc : Location_Type) return Memtyp
is
Len : constant Uns32 := V.Typ.Abound.Len;
@@ -856,10 +872,12 @@ package body Synth.Ieee.Numeric_Std is
return Res;
end if;
- Neg_Vec (V.Mem, Res.Mem, V.Typ);
- if Read_Std_Logic (Res.Mem, 0) = 'X' then
+ if Has_0x (V) = 'X' then
Warning_Msg_Synth
(+Loc, "NUMERIC_STD.""-"": non logical value detected");
+ Fill (Res, 'X');
+ else
+ Neg_Vec (V.Mem, Res.Mem, V.Typ);
end if;
return Res;
end Neg_Vec;
@@ -1087,22 +1105,6 @@ package body Synth.Ieee.Numeric_Std is
end if;
end Divmod;
- function Has_0x (V : Memtyp) return Sl_X01
- is
- Res : Sl_X01 := '0';
- E : Sl_X01;
- begin
- for I in 0 .. V.Typ.Abound.Len - 1 loop
- E := To_X01 (Read_Std_Logic (V.Mem, I));
- if E = 'X' then
- return 'X';
- elsif E = '1' then
- Res := '1';
- end if;
- end loop;
- return Res;
- end Has_0x;
-
function Div_Uns_Uns (L, R : Memtyp; Loc : Location_Type) return Memtyp
is
Nlen : constant Uns32 := L.Typ.Abound.Len;