aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-07-05 18:37:26 +0200
committerTristan Gingold <tgingold@free.fr>2019-07-06 07:18:48 +0200
commitaef7921f6c3b375a881945e21e55453d761303a3 (patch)
tree3226c736e86779b21951a2ab0b649acc3f320468 /src/synth
parentd14ef7bf8c94b4e164ae26954c4f737e2c3d655b (diff)
downloadghdl-aef7921f6c3b375a881945e21e55453d761303a3.tar.gz
ghdl-aef7921f6c3b375a881945e21e55453d761303a3.tar.bz2
ghdl-aef7921f6c3b375a881945e21e55453d761303a3.zip
synth: support top-level generics.
Diffstat (limited to 'src/synth')
-rw-r--r--src/synth/synth-expr.adb8
-rw-r--r--src/synth/synthesis.adb15
2 files changed, 23 insertions, 0 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index ecdb99cb0..477f56002 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -827,6 +827,13 @@ package body Synth.Expr is
else
return Synth_Vec_Dyadic (Id_Mul);
end if;
+ when Iir_Predefined_Integer_Div =>
+ if Is_Const (Left) and then Is_Const (Right) then
+ return Create_Value_Discrete (Left.Scal / Right.Scal);
+ else
+ Error_Msg_Synth (+Expr, "non-constant division not supported");
+ return null;
+ end if;
when others =>
Error_Msg_Synth (+Expr, "synth_dyadic_operation: unhandled "
@@ -887,6 +894,7 @@ package body Synth.Expr is
when Iir_Kind_Interface_Signal_Declaration
| Iir_Kind_Variable_Declaration
| Iir_Kind_Signal_Declaration
+ | Iir_Kind_Interface_Constant_Declaration
| Iir_Kind_Constant_Declaration
| Iir_Kind_Iterator_Declaration =>
return Get_Value (Syn_Inst, Name);
diff --git a/src/synth/synthesis.adb b/src/synth/synthesis.adb
index a9ce60085..3a90aff40 100644
--- a/src/synth/synthesis.adb
+++ b/src/synth/synthesis.adb
@@ -33,6 +33,7 @@ with Synth.Context; use Synth.Context;
with Synth.Types; use Synth.Types;
with Synth.Decls; use Synth.Decls;
with Synth.Stmts; use Synth.Stmts;
+with Synth.Expr; use Synth.Expr;
with Synth.Environment.Debug;
pragma Unreferenced (Synth.Environment.Debug);
@@ -149,6 +150,20 @@ package body Synthesis is
Syn_Inst.Block_Scope := Get_Info (Entity);
Syn_Inst.Name := New_Sname_User (Get_Identifier (Entity));
+ -- Compute generics.
+ Inter := Get_Generic_Chain (Entity);
+ while Is_Valid (Inter) loop
+ Synth_Declaration_Type (Syn_Inst, Inter);
+ declare
+ Val : Value_Acc;
+ begin
+ Val := Synth_Expression_With_Type
+ (Syn_Inst, Get_Default_Value (Inter), Get_Type (Inter));
+ Create_Object (Syn_Inst, Inter, Val);
+ end;
+ Inter := Get_Chain (Inter);
+ end loop;
+
-- Allocate values and count inputs and outputs
Inter := Get_Port_Chain (Entity);
Nbr_Inputs := 0;