aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-10-13 20:33:23 +0200
committerTristan Gingold <tgingold@free.fr>2019-10-13 20:33:23 +0200
commit67df90261a4b74f42de1995dfc9315cd01290ba4 (patch)
tree5db8fdf9a72b8f041505048908ad658d5ad92647 /src
parent090420bd1a57ba496f0d59bf7a119d05a68ea1e3 (diff)
downloadghdl-67df90261a4b74f42de1995dfc9315cd01290ba4.tar.gz
ghdl-67df90261a4b74f42de1995dfc9315cd01290ba4.tar.bz2
ghdl-67df90261a4b74f42de1995dfc9315cd01290ba4.zip
synth: handle constants for condition operator.
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-expr.adb4
-rw-r--r--src/synth/synth-oper.adb16
-rw-r--r--src/synth/synth-stmts.adb1
3 files changed, 20 insertions, 1 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index 500d587d7..dbc172de6 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -1541,6 +1541,10 @@ package body Synth.Expr is
begin
Synth_Assignment_Prefix (Syn_Inst, Expr,
Obj, Off, Voff, Rdwd, Typ);
+ if Voff = No_Net and then Is_Const (Obj) then
+ pragma Assert (Off = 0);
+ return Obj;
+ end if;
return Synth_Read_Memory (Syn_Inst, Obj, Off, Voff, Typ, Expr);
end;
when Iir_Kind_Selected_Element =>
diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb
index b36511adf..dd36ef4aa 100644
--- a/src/synth/synth-oper.adb
+++ b/src/synth/synth-oper.adb
@@ -956,7 +956,21 @@ package body Synth.Oper is
when Iir_Predefined_Ieee_1164_Vector_Or_Reduce =>
return Synth_Vec_Reduce_Monadic(Id_Red_Or);
when Iir_Predefined_Ieee_1164_Condition_Operator =>
- return Operand;
+ if Operand.Typ.Kind = Type_Logic
+ and then Operand.Kind = Value_Discrete
+ then
+ -- Constant std_logic: need to convert.
+ declare
+ Val : Uns32;
+ Zx : Uns32;
+ begin
+ From_Std_Logic (Operand.Scal, Val, Zx);
+ return Create_Value_Discrete
+ (Boolean'Pos (Val = 1 and Zx = 0), Boolean_Type);
+ end;
+ else
+ return Operand;
+ end if;
when Iir_Predefined_Integer_Negation =>
if Is_Const (Operand) then
return Create_Value_Discrete (-Operand.Scal, Operand.Typ);
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb
index ed289ba12..7ebeb1a5b 100644
--- a/src/synth/synth-stmts.adb
+++ b/src/synth/synth-stmts.adb
@@ -405,6 +405,7 @@ package body Synth.Stmts is
N := Build_Dyn_Extract
(Get_Build (Syn_Inst), Get_Net (Obj), Voff, Off, Typ.W);
else
+ pragma Assert (not Is_Const (Obj));
if Off = 0
and then Typ.W = Obj.Typ.W
and then Typ /= Get_Array_Element (Obj.Typ)