aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-06-23 18:13:26 +0200
committerTristan Gingold <tgingold@free.fr>2019-06-23 18:13:26 +0200
commit4d7e1c0107a4656d76d9dbdddcd7cb34781d6d21 (patch)
treebb8b8056e6daec2224e997e22de2cf210ef5bee7
parentab9c1d8425d2bc4d1d8993b9004f6c36e2a646c8 (diff)
downloadghdl-4d7e1c0107a4656d76d9dbdddcd7cb34781d6d21.tar.gz
ghdl-4d7e1c0107a4656d76d9dbdddcd7cb34781d6d21.tar.bz2
ghdl-4d7e1c0107a4656d76d9dbdddcd7cb34781d6d21.zip
synth: handle more operators.
-rw-r--r--src/synth/synth-context.adb11
-rw-r--r--src/synth/synth-expr.adb19
2 files changed, 18 insertions, 12 deletions
diff --git a/src/synth/synth-context.adb b/src/synth/synth-context.adb
index a4b6add54..1b170b490 100644
--- a/src/synth/synth-context.adb
+++ b/src/synth/synth-context.adb
@@ -257,14 +257,9 @@ package body Synth.Context is
Get_Info (Btype).Width);
else
if Val.Scal >= 0 then
- for I in 1 .. 32 loop
- if Val.Scal < (2**I) then
- return Build_Const_UB32
- (Build_Context, Uns32 (Val.Scal), Width (I));
- end if;
- end loop;
- -- Need Uconst64
- raise Internal_Error;
+ -- FIXME: check width.
+ return Build_Const_UB32
+ (Build_Context, Uns32 (Val.Scal), 32);
else
-- Need Sconst32/Sconst64
raise Internal_Error;
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index fe9f83cda..7dd97588c 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -770,16 +770,21 @@ package body Synth.Expr is
if Is_Const (Left) and then Is_Const (Right) then
return Create_Value_Discrete (Left.Scal + Right.Scal);
else
- -- TODO: non-const.
- raise Internal_Error;
+ return Synth_Vec_Dyadic (Id_Add);
end if;
when Iir_Predefined_Integer_Minus =>
if Is_Const (Left) and then Is_Const (Right) then
return Create_Value_Discrete (Left.Scal - Right.Scal);
else
- -- TODO: non-const.
- raise Internal_Error;
+ return Synth_Vec_Dyadic (Id_Sub);
end if;
+ when Iir_Predefined_Integer_Mul =>
+ if Is_Const (Left) and then Is_Const (Right) then
+ return Create_Value_Discrete (Left.Scal * Right.Scal);
+ else
+ return Synth_Vec_Dyadic (Id_Mul);
+ end if;
+
when others =>
Error_Msg_Synth (+Expr, "synth_dyadic_operation: unhandled "
& Iir_Predefined_Functions'Image (Def));
@@ -1186,6 +1191,12 @@ package body Synth.Expr is
end if;
end if;
end;
+ when Iir_Predefined_Ieee_Numeric_Std_Toint_Uns_Nat =>
+ -- UNSIGNED to Natural.
+ return Create_Value_Net
+ (Synth_Uresize (Get_Net (Subprg_Inst.Objects (1),
+ Get_Type (Inter_Chain)), 32),
+ null);
when others =>
Error_Msg_Synth
(+Expr,