From aef7921f6c3b375a881945e21e55453d761303a3 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 5 Jul 2019 18:37:26 +0200 Subject: synth: support top-level generics. --- src/synth/synth-expr.adb | 8 ++++++++ src/synth/synthesis.adb | 15 +++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'src/synth') 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; -- cgit v1.2.3