diff options
-rw-r--r-- | src/synth/synth-aggr.adb | 30 | ||||
-rw-r--r-- | src/synth/synth-aggr.ads | 6 | ||||
-rw-r--r-- | src/synth/synth-decls.adb | 66 | ||||
-rw-r--r-- | src/synth/synth-decls.ads | 13 | ||||
-rw-r--r-- | src/synth/synth-expr.adb | 114 | ||||
-rw-r--r-- | src/synth/synth-expr.ads | 25 | ||||
-rw-r--r-- | src/synth/synth-files_operations.adb | 7 | ||||
-rw-r--r-- | src/synth/synth-insts.adb | 40 | ||||
-rw-r--r-- | src/synth/synth-oper.adb | 26 | ||||
-rw-r--r-- | src/synth/synth-oper.ads | 15 | ||||
-rw-r--r-- | src/synth/synth-stmts.adb | 260 | ||||
-rw-r--r-- | src/synth/synth-stmts.ads | 12 |
12 files changed, 364 insertions, 250 deletions
diff --git a/src/synth/synth-aggr.adb b/src/synth/synth-aggr.adb index beaab3aa9..103a62681 100644 --- a/src/synth/synth-aggr.adb +++ b/src/synth/synth-aggr.adb @@ -20,7 +20,6 @@ with Types; use Types; -with Netlists; use Netlists; with Netlists.Utils; use Netlists.Utils; with Vhdl.Errors; use Vhdl.Errors; @@ -98,6 +97,7 @@ package body Synth.Aggr is procedure Fill_Array_Aggregate (Syn_Inst : Synth_Instance_Acc; Aggr : Node; + En : Net; Res : Valtyp_Array_Acc; Typ : Type_Acc; First_Pos : Nat32; @@ -123,7 +123,7 @@ package body Synth.Aggr is Nbr_Els := Nbr_Els + 1; if Dim = Strides'Last then - Val := Synth_Expression_With_Type (Syn_Inst, Value, El_Typ); + Val := Synth_Expression_With_Type (Syn_Inst, Value, El_Typ, En); Val := Synth_Subtype_Conversion (Val, El_Typ, False, Value); pragma Assert (Res (Pos) = No_Valtyp); Res (Pos) := Val; @@ -136,7 +136,7 @@ package body Synth.Aggr is end if; else Fill_Array_Aggregate - (Syn_Inst, Value, Res, Typ, Pos, Strides, Dim + 1, + (Syn_Inst, Value, En, Res, Typ, Pos, Strides, Dim + 1, Sub_Const, Sub_Err); Const_P := Const_P and Sub_Const; Err_P := Err_P or Sub_Err; @@ -190,7 +190,7 @@ package body Synth.Aggr is Val_Len : Uns32; begin Val := Synth_Expression_With_Basetype - (Syn_Inst, Value); + (Syn_Inst, Value, En); Val_Len := Get_Bound_Length (Val.Typ, 1); pragma Assert (Stride = 1); if Pos - First_Pos > Nat32 (Bound.Len - Val_Len) then @@ -224,7 +224,7 @@ package body Synth.Aggr is Idx : Valtyp; Off : Uns32; begin - Idx := Synth_Expression (Syn_Inst, Ch); + Idx := Synth_Expression (Syn_Inst, Ch, No_Net); if not Is_Static (Idx.Val) then Error_Msg_Synth (+Ch, "choice is not static"); else @@ -265,7 +265,7 @@ package body Synth.Aggr is end if; -- FIXME: can the expression be unbounded ? Val := Synth_Expression_With_Basetype - (Syn_Inst, Value); + (Syn_Inst, Value, En); -- The length must match the range. Rng_Len := Get_Range_Length (Rng); if Get_Bound_Length (Val.Typ, 1) /= Rng_Len then @@ -299,6 +299,7 @@ package body Synth.Aggr is procedure Fill_Record_Aggregate (Syn_Inst : Synth_Instance_Acc; Aggr : Node; + En : Net; Rec : Valtyp_Array_Acc; Const_P : out Boolean) is @@ -316,7 +317,7 @@ package body Synth.Aggr is begin El_Type := Get_Subtype_Object (Syn_Inst, Get_Type (Get_Nth_Element (El_List, Natural (Pos)))); - Val := Synth_Expression_With_Type (Syn_Inst, Value, El_Type); + Val := Synth_Expression_With_Type (Syn_Inst, Value, El_Type, En); if Const_P and not Is_Static (Val.Val) then Const_P := False; end if; @@ -379,6 +380,7 @@ package body Synth.Aggr is function Synth_Aggregate_Array (Syn_Inst : Synth_Instance_Acc; Aggr : Node; + En : Net; Aggr_Type : Type_Acc) return Valtyp is Strides : constant Stride_Array := Fill_Stride (Aggr_Type); @@ -390,8 +392,8 @@ package body Synth.Aggr is begin Tab_Res := new Valtyp_Array'(1 .. Nat32 (Flen) => No_Valtyp); - Fill_Array_Aggregate - (Syn_Inst, Aggr, Tab_Res, Aggr_Type, 1, Strides, 1, Const_P, Err_P); + Fill_Array_Aggregate (Syn_Inst, Aggr, En, Tab_Res, + Aggr_Type, 1, Strides, 1, Const_P, Err_P); if Err_P then return No_Valtyp; end if; @@ -425,6 +427,7 @@ package body Synth.Aggr is function Synth_Aggregate_Record (Syn_Inst : Synth_Instance_Acc; Aggr : Node; + En : Net; Aggr_Type : Type_Acc) return Valtyp is Tab_Res : Valtyp_Array_Acc; @@ -435,7 +438,7 @@ package body Synth.Aggr is Tab_Res := new Valtyp_Array'(1 .. Nat32 (Aggr_Type.Rec.Len) => No_Valtyp); - Fill_Record_Aggregate (Syn_Inst, Aggr, Tab_Res, Const_P); + Fill_Record_Aggregate (Syn_Inst, Aggr, En, Tab_Res, Const_P); if Const_P then Res := Create_Value_Memory (Aggr_Type); @@ -456,6 +459,7 @@ package body Synth.Aggr is -- Aggr_Type is the type from the context. function Synth_Aggregate (Syn_Inst : Synth_Instance_Acc; Aggr : Node; + En : Net; Aggr_Type : Type_Acc) return Valtyp is begin case Aggr_Type.Kind is @@ -465,13 +469,13 @@ package body Synth.Aggr is begin Res_Type := Decls.Synth_Array_Subtype_Indication (Syn_Inst, Get_Type (Aggr)); - return Synth_Aggregate_Array (Syn_Inst, Aggr, Res_Type); + return Synth_Aggregate_Array (Syn_Inst, Aggr, En, Res_Type); end; when Type_Vector | Type_Array => - return Synth_Aggregate_Array (Syn_Inst, Aggr, Aggr_Type); + return Synth_Aggregate_Array (Syn_Inst, Aggr, En, Aggr_Type); when Type_Record => - return Synth_Aggregate_Record (Syn_Inst, Aggr, Aggr_Type); + return Synth_Aggregate_Record (Syn_Inst, Aggr, En, Aggr_Type); when others => raise Internal_Error; end case; diff --git a/src/synth/synth-aggr.ads b/src/synth/synth-aggr.ads index 4b5cf6418..1d700c620 100644 --- a/src/synth/synth-aggr.ads +++ b/src/synth/synth-aggr.ads @@ -18,14 +18,18 @@ -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. +with Vhdl.Nodes; use Vhdl.Nodes; + +with Netlists; use Netlists; + with Synth.Objtypes; use Synth.Objtypes; with Synth.Values; use Synth.Values; with Synth.Context; use Synth.Context; -with Vhdl.Nodes; use Vhdl.Nodes; package Synth.Aggr is -- Aggr_Type is the type from the context. function Synth_Aggregate (Syn_Inst : Synth_Instance_Acc; Aggr : Node; + En : Net; Aggr_Type : Type_Acc) return Valtyp; end Synth.Aggr; diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb index 2bf525559..5bd535215 100644 --- a/src/synth/synth-decls.adb +++ b/src/synth/synth-decls.adb @@ -21,7 +21,6 @@ with Types; use Types; with Mutils; use Mutils; -with Netlists; use Netlists; with Netlists.Builders; use Netlists.Builders; with Netlists.Folds; use Netlists.Folds; with Netlists.Utils; use Netlists.Utils; @@ -217,7 +216,7 @@ package body Synth.Decls is Synth_Record_Elements_Definition (Syn_Inst, Def); Typ := Synth_Record_Type_Definition (Syn_Inst, Def); when Iir_Kind_Protected_Type_Declaration => - Synth_Declarations (Syn_Inst, Get_Declaration_Chain (Def)); + Synth_Declarations (Syn_Inst, Get_Declaration_Chain (Def), No_Net); when others => Vhdl.Errors.Error_Kind ("synth_type_definition", Def); end case; @@ -464,6 +463,7 @@ package body Synth.Decls is procedure Synth_Constant_Declaration (Syn_Inst : Synth_Instance_Acc; Decl : Node; + En : Net; Is_Subprg : Boolean; Last_Type : in out Node) is @@ -509,7 +509,7 @@ package body Synth.Decls is end if; Obj_Type := Get_Subtype_Object (Syn_Inst, Decl_Type); Val := Synth_Expression_With_Type - (Syn_Inst, Get_Default_Value (Decl), Obj_Type); + (Syn_Inst, Get_Default_Value (Decl), Obj_Type, En); if Val = No_Valtyp then Set_Error (Syn_Inst); return; @@ -539,7 +539,7 @@ package body Synth.Decls is end Synth_Constant_Declaration; procedure Synth_Attribute_Specification - (Syn_Inst : Synth_Instance_Acc; Spec : Node) + (Syn_Inst : Synth_Instance_Acc; Spec : Node; En : Net) is Decl : constant Node := Get_Attribute_Designator (Spec); Value : Iir_Attribute_Value; @@ -559,7 +559,7 @@ package body Synth.Decls is -- unless the attribute's subtype indication denotes an -- unconstrained array type. Val := Synth_Expression_With_Type - (Syn_Inst, Get_Expression (Spec), Val_Type); + (Syn_Inst, Get_Expression (Spec), Val_Type, En); -- Check_Constraints (Instance, Val, Attr_Type, Decl); -- 3. A new instance of the designated attribute is created @@ -621,7 +621,7 @@ package body Synth.Decls is end Create_Package_Instance; procedure Synth_Package_Declaration - (Parent_Inst : Synth_Instance_Acc; Pkg : Node) + (Parent_Inst : Synth_Instance_Acc; Pkg : Node; En : Net) is Syn_Inst : Synth_Instance_Acc; begin @@ -632,14 +632,14 @@ package body Synth.Decls is Syn_Inst := Create_Package_Instance (Parent_Inst, Pkg); - Synth_Declarations (Syn_Inst, Get_Declaration_Chain (Pkg)); + Synth_Declarations (Syn_Inst, Get_Declaration_Chain (Pkg), En); if Pkg = Vhdl.Std_Package.Standard_Package then Synth_Convertible_Declarations (Syn_Inst); end if; end Synth_Package_Declaration; procedure Synth_Package_Body - (Parent_Inst : Synth_Instance_Acc; Pkg : Node; Bod : Node) + (Parent_Inst : Synth_Instance_Acc; Pkg : Node; Bod : Node; En : Net) is Pkg_Inst : Synth_Instance_Acc; begin @@ -650,13 +650,14 @@ package body Synth.Decls is Pkg_Inst := Get_Package_Object (Parent_Inst, Pkg); - Synth_Declarations (Pkg_Inst, Get_Declaration_Chain (Bod)); + Synth_Declarations (Pkg_Inst, Get_Declaration_Chain (Bod), En); end Synth_Package_Body; procedure Synth_Generics_Association (Sub_Inst : Synth_Instance_Acc; Syn_Inst : Synth_Instance_Acc; Inter_Chain : Node; - Assoc_Chain : Node) + Assoc_Chain : Node; + En : Net) is Inter : Node; Inter_Type : Type_Acc; @@ -678,11 +679,11 @@ package body Synth.Decls is when Iir_Kind_Association_Element_Open => Actual := Get_Default_Value (Inter); Val := Synth_Expression_With_Type - (Sub_Inst, Actual, Inter_Type); + (Sub_Inst, Actual, Inter_Type, En); when Iir_Kind_Association_Element_By_Expression => Actual := Get_Actual (Assoc); Val := Synth_Expression_With_Type - (Syn_Inst, Actual, Inter_Type); + (Syn_Inst, Actual, Inter_Type, En); when others => raise Internal_Error; end case; @@ -698,7 +699,7 @@ package body Synth.Decls is end Synth_Generics_Association; procedure Synth_Package_Instantiation - (Parent_Inst : Synth_Instance_Acc; Pkg : Node) + (Parent_Inst : Synth_Instance_Acc; Pkg : Node; En : Net) is Bod : constant Node := Get_Instance_Package_Body (Pkg); Sub_Inst : Synth_Instance_Acc; @@ -707,9 +708,9 @@ package body Synth.Decls is Synth_Generics_Association (Sub_Inst, Parent_Inst, - Get_Generic_Chain (Pkg), Get_Generic_Map_Aspect_Chain (Pkg)); + Get_Generic_Chain (Pkg), Get_Generic_Map_Aspect_Chain (Pkg), En); - Synth_Declarations (Sub_Inst, Get_Declaration_Chain (Pkg)); + Synth_Declarations (Sub_Inst, Get_Declaration_Chain (Pkg), En); if Bod /= Null_Node then -- Macro expended package instantiation. @@ -724,14 +725,16 @@ package body Synth.Decls is -- Synth declarations of (optional) body. if Uninst_Bod /= Null_Node then Synth_Declarations - (Sub_Inst, Get_Declaration_Chain (Uninst_Bod)); + (Sub_Inst, Get_Declaration_Chain (Uninst_Bod), En); end if; end; end if; end Synth_Package_Instantiation; - procedure Synth_Variable_Declaration - (Syn_Inst : Synth_Instance_Acc; Decl : Node; Is_Subprg : Boolean) + procedure Synth_Variable_Declaration (Syn_Inst : Synth_Instance_Acc; + Decl : Node; + En : Net; + Is_Subprg : Boolean) is Def : constant Node := Get_Default_Value (Decl); Decl_Type : constant Node := Get_Type (Decl); @@ -758,7 +761,7 @@ package body Synth.Decls is Create_Object (Syn_Inst, Decl, Create_Value_Default (Obj_Typ)); else if Is_Valid (Def) then - Init := Synth_Expression_With_Type (Syn_Inst, Def, Obj_Typ); + Init := Synth_Expression_With_Type (Syn_Inst, Def, Obj_Typ, En); Init := Synth_Subtype_Conversion (Init, Obj_Typ, False, Decl); if not Is_Subprg and then not Is_Static (Init.Val) @@ -801,7 +804,7 @@ package body Synth.Decls is Create_Wire_Object (Syn_Inst, Wire_Signal, Decl); if Is_Valid (Def) then Obj_Typ := Get_Subtype_Object (Syn_Inst, Get_Type (Decl)); - Init := Synth_Expression_With_Type (Syn_Inst, Def, Obj_Typ); + Init := Synth_Expression_With_Type (Syn_Inst, Def, Obj_Typ, No_Net); Init := Synth_Subtype_Conversion (Init, Obj_Typ, False, Decl); if not Is_Static (Init.Val) then Error_Msg_Synth (+Decl, "signals cannot be used in default value " @@ -814,7 +817,7 @@ package body Synth.Decls is end Synth_Signal_Declaration; procedure Synth_Object_Alias_Declaration - (Syn_Inst : Synth_Instance_Acc; Decl : Node) + (Syn_Inst : Synth_Instance_Acc; Decl : Node; En : Net) is Atype : constant Node := Get_Declaration_Type (Decl); Off : Value_Offsets; @@ -832,7 +835,7 @@ package body Synth.Decls is Obj_Typ := null; end if; - Stmts.Synth_Assignment_Prefix (Syn_Inst, Get_Name (Decl), + Stmts.Synth_Assignment_Prefix (Syn_Inst, Get_Name (Decl), En, Base, Typ, Off, Dyn); pragma Assert (Dyn.Voff = No_Net); if Base.Val.Kind = Value_Net then @@ -853,23 +856,26 @@ package body Synth.Decls is procedure Synth_Declaration (Syn_Inst : Synth_Instance_Acc; Decl : Node; + En : Net; Is_Subprg : Boolean; Last_Type : in out Node) is begin case Get_Kind (Decl) is when Iir_Kind_Variable_Declaration => - Synth_Variable_Declaration (Syn_Inst, Decl, Is_Subprg); + Synth_Variable_Declaration (Syn_Inst, Decl, En, Is_Subprg); when Iir_Kind_Interface_Variable_Declaration => -- Ignore default value. Create_Wire_Object (Syn_Inst, Wire_Variable, Decl); Create_Var_Wire (Syn_Inst, Decl, No_Valtyp); when Iir_Kind_Constant_Declaration => - Synth_Constant_Declaration (Syn_Inst, Decl, Is_Subprg, Last_Type); + Synth_Constant_Declaration + (Syn_Inst, Decl, En, Is_Subprg, Last_Type); when Iir_Kind_Signal_Declaration => pragma Assert (not Is_Subprg); + pragma Assert (En = No_Net); Synth_Signal_Declaration (Syn_Inst, Decl); when Iir_Kind_Object_Alias_Declaration => - Synth_Object_Alias_Declaration (Syn_Inst, Decl); + Synth_Object_Alias_Declaration (Syn_Inst, Decl, En); when Iir_Kind_Anonymous_Signal_Declaration => -- Anonymous signals created by inertial associations are -- simply ignored. @@ -887,7 +893,7 @@ package body Synth.Decls is -- indication. null; when Iir_Kind_Attribute_Specification => - Synth_Attribute_Specification (Syn_Inst, Decl); + Synth_Attribute_Specification (Syn_Inst, Decl, En); when Iir_Kind_Type_Declaration => Synth_Type_Definition (Syn_Inst, Get_Type_Definition (Decl)); when Iir_Kind_Anonymous_Type_Declaration => @@ -927,8 +933,10 @@ package body Synth.Decls is end case; end Synth_Declaration; - procedure Synth_Declarations - (Syn_Inst : Synth_Instance_Acc; Decls : Iir; Is_Subprg : Boolean := False) + procedure Synth_Declarations (Syn_Inst : Synth_Instance_Acc; + Decls : Iir; + En : Net; + Is_Subprg : Boolean := False) is Decl : Node; Last_Type : Node; @@ -936,7 +944,7 @@ package body Synth.Decls is Last_Type := Null_Node; Decl := Decls; while Is_Valid (Decl) loop - Synth_Declaration (Syn_Inst, Decl, Is_Subprg, Last_Type); + Synth_Declaration (Syn_Inst, Decl, En, Is_Subprg, Last_Type); exit when Is_Error (Syn_Inst); diff --git a/src/synth/synth-decls.ads b/src/synth/synth-decls.ads index 68b7fea08..a42305771 100644 --- a/src/synth/synth-decls.ads +++ b/src/synth/synth-decls.ads @@ -20,6 +20,8 @@ with Vhdl.Nodes; use Vhdl.Nodes; +with Netlists; use Netlists; + with Synth.Context; use Synth.Context; with Synth.Objtypes; use Synth.Objtypes; @@ -42,11 +44,13 @@ package Synth.Decls is procedure Synth_Declaration (Syn_Inst : Synth_Instance_Acc; Decl : Node; + En : Net; Is_Subprg : Boolean; Last_Type : in out Node); procedure Synth_Declarations (Syn_Inst : Synth_Instance_Acc; Decls : Iir; + En : Net; Is_Subprg : Boolean := False); procedure Finalize_Declarations (Syn_Inst : Synth_Instance_Acc; @@ -54,15 +58,16 @@ package Synth.Decls is Is_Subprg : Boolean := False); procedure Synth_Package_Declaration - (Parent_Inst : Synth_Instance_Acc; Pkg : Node); + (Parent_Inst : Synth_Instance_Acc; Pkg : Node; En : Net); procedure Synth_Package_Body - (Parent_Inst : Synth_Instance_Acc; Pkg : Node; Bod : Node); + (Parent_Inst : Synth_Instance_Acc; Pkg : Node; Bod : Node; En : Net); procedure Synth_Generics_Association (Sub_Inst : Synth_Instance_Acc; Syn_Inst : Synth_Instance_Acc; Inter_Chain : Node; - Assoc_Chain : Node); + Assoc_Chain : Node; + En : Net); procedure Synth_Package_Instantiation - (Parent_Inst : Synth_Instance_Acc; Pkg : Node); + (Parent_Inst : Synth_Instance_Acc; Pkg : Node; En : Net); end Synth.Decls; diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 5eca7d125..b3b286d78 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -432,8 +432,11 @@ package body Synth.Expr is L, R : Valtyp; Lval, Rval : Int64; begin - L := Synth_Expression_With_Basetype (Syn_Inst, Get_Left_Limit (Rng)); - R := Synth_Expression_With_Basetype (Syn_Inst, Get_Right_Limit (Rng)); + -- Static values. + L := Synth_Expression_With_Basetype + (Syn_Inst, Get_Left_Limit (Rng), No_Net); + R := Synth_Expression_With_Basetype + (Syn_Inst, Get_Right_Limit (Rng), No_Net); Strip_Const (L); Strip_Const (R); @@ -455,8 +458,9 @@ package body Synth.Expr is is L, R : Valtyp; begin - L := Synth_Expression (Syn_Inst, Get_Left_Limit (Rng)); - R := Synth_Expression (Syn_Inst, Get_Right_Limit (Rng)); + -- Static values (so no enable). + L := Synth_Expression (Syn_Inst, Get_Left_Limit (Rng), No_Net); + R := Synth_Expression (Syn_Inst, Get_Right_Limit (Rng), No_Net); return (Get_Direction (Rng), Read_Fp64 (L), Read_Fp64 (R)); end Synth_Float_Range_Expression; @@ -484,7 +488,7 @@ package body Synth.Expr is begin Pfx_Typ := Synth_Type_Of_Object (Syn_Inst, Get_Prefix (Expr)); Get_Onedimensional_Array_Bounds (Pfx_Typ, Pfx_Bnd, El_Typ); - Synth_Slice_Suffix (Syn_Inst, Expr, Pfx_Bnd, El_Typ, + Synth_Slice_Suffix (Syn_Inst, Expr, No_Net, Pfx_Bnd, El_Typ, Res_Bnd, Sl_Voff, Sl_Off); if Sl_Voff /= No_Net then @@ -516,7 +520,7 @@ package body Synth.Expr is Res : Valtyp; begin -- Maybe do not dereference it if its type is known ? - Val := Synth_Expression (Syn_Inst, Get_Prefix (Expr)); + Val := Synth_Expression (Syn_Inst, Get_Prefix (Expr), No_Net); Res := Heap.Synth_Dereference (Read_Access (Val)); return Res.Typ; end; @@ -676,8 +680,9 @@ package body Synth.Expr is Res := Create_Value_Memory (Res_Type); for I in Flist_First .. Last loop + -- Elements are supposed to be static, so no need for enable. Val := Synth_Expression_With_Type - (Syn_Inst, Get_Nth_Element (Els, I), El_Typ); + (Syn_Inst, Get_Nth_Element (Els, I), El_Typ, No_Net); pragma Assert (Is_Static (Val.Val)); Write_Value (Res.Val.Mem + Size_Type (I) * El_Typ.Sz, Val); end loop; @@ -832,7 +837,8 @@ package body Synth.Expr is V : Valtyp; Dtype : Type_Acc; begin - V := Synth_Expression (Syn_Inst, Param); + -- The value is supposed to be static. + V := Synth_Expression (Syn_Inst, Param, No_Net); if V = No_Valtyp then return No_Valtyp; end if; @@ -944,7 +950,8 @@ package body Synth.Expr is V : Valtyp; Dtype : Type_Acc; begin - V := Synth_Expression (Syn_Inst, Param); + -- The parameter is expected to be static. + V := Synth_Expression (Syn_Inst, Param, No_Net); if V = No_Valtyp then return No_Valtyp; end if; @@ -1000,7 +1007,7 @@ package body Synth.Expr is declare Val : Valtyp; begin - Val := Synth_Expression (Syn_Inst, Get_Prefix (Name)); + Val := Synth_Expression (Syn_Inst, Get_Prefix (Name), No_Net); return Heap.Synth_Dereference (Read_Access (Val)); end; when others => @@ -1123,6 +1130,7 @@ package body Synth.Expr is procedure Synth_Indexed_Name (Syn_Inst : Synth_Instance_Acc; Name : Node; + En : Net; Pfx_Type : Type_Acc; Voff : out Net; Off : out Value_Offsets) @@ -1150,7 +1158,7 @@ package body Synth.Expr is end loop; -- Use the base type as the subtype of the index is not synth-ed. - Idx_Val := Synth_Expression_With_Basetype (Syn_Inst, Idx_Expr); + Idx_Val := Synth_Expression_With_Basetype (Syn_Inst, Idx_Expr, En); Strip_Const (Idx_Val); Bnd := Get_Array_Bound (Pfx_Type, Dim_Type (I + 1)); @@ -1393,6 +1401,7 @@ package body Synth.Expr is procedure Synth_Slice_Suffix (Syn_Inst : Synth_Instance_Acc; Name : Node; + En : Net; Pfx_Bnd : Bound_Type; El_Typ : Type_Acc; Res_Bnd : out Bound_Type; @@ -1411,9 +1420,9 @@ package body Synth.Expr is case Get_Kind (Expr) is when Iir_Kind_Range_Expression => Left := Synth_Expression_With_Basetype - (Syn_Inst, Get_Left_Limit (Expr)); + (Syn_Inst, Get_Left_Limit (Expr), En); Right := Synth_Expression_With_Basetype - (Syn_Inst, Get_Right_Limit (Expr)); + (Syn_Inst, Get_Right_Limit (Expr), En); Dir := Get_Direction (Expr); when Iir_Kind_Range_Array_Attribute => declare @@ -1595,15 +1604,15 @@ package body Synth.Expr is return No_Net; end Synth_Clock_Edge; - function Synth_Type_Conversion (Syn_Inst : Synth_Instance_Acc; Conv : Node) - return Valtyp + function Synth_Type_Conversion + (Syn_Inst : Synth_Instance_Acc; Conv : Node; En : Net) return Valtyp is Expr : constant Node := Get_Expression (Conv); Conv_Type : constant Node := Get_Type (Conv); Conv_Typ : constant Type_Acc := Get_Subtype_Object (Syn_Inst, Conv_Type); Val : Valtyp; begin - Val := Synth_Expression_With_Basetype (Syn_Inst, Expr); + Val := Synth_Expression_With_Basetype (Syn_Inst, Expr, En); if Val = No_Valtyp then return No_Valtyp; end if; @@ -1738,7 +1747,8 @@ package body Synth.Expr is Left_Expr : Node; Right_Expr : Node; Typ : Type_Acc; - Expr : Node) return Valtyp + Expr : Node; + En : Net) return Valtyp is Left : Valtyp; Right : Valtyp; @@ -1753,7 +1763,7 @@ package body Synth.Expr is Val := 1; end case; - Left := Synth_Expression_With_Type (Syn_Inst, Left_Expr, Typ); + Left := Synth_Expression_With_Type (Syn_Inst, Left_Expr, Typ, En); if Left = No_Valtyp then return No_Valtyp; end if; @@ -1764,7 +1774,7 @@ package body Synth.Expr is end if; Strip_Const (Left); - Right := Synth_Expression_With_Type (Syn_Inst, Right_Expr, Typ); + Right := Synth_Expression_With_Type (Syn_Inst, Right_Expr, Typ, En); if Right = No_Valtyp then return No_Valtyp; end if; @@ -1782,9 +1792,10 @@ package body Synth.Expr is return Create_Value_Net (N, Boolean_Type); end Synth_Short_Circuit; - function Synth_Expression_With_Type - (Syn_Inst : Synth_Instance_Acc; Expr : Node; Expr_Type : Type_Acc) - return Valtyp is + function Synth_Expression_With_Type (Syn_Inst : Synth_Instance_Acc; + Expr : Node; + Expr_Type : Type_Acc; + En : Net) return Valtyp is begin case Get_Kind (Expr) is when Iir_Kinds_Dyadic_Operator => @@ -1808,27 +1819,27 @@ package body Synth.Expr is when Iir_Predefined_Boolean_And => return Synth_Short_Circuit (Syn_Inst, Id_And, Get_Left (Expr), Get_Right (Expr), - Boolean_Type, Expr); + Boolean_Type, Expr, En); when Iir_Predefined_Boolean_Or => return Synth_Short_Circuit (Syn_Inst, Id_Or, Get_Left (Expr), Get_Right (Expr), - Boolean_Type, Expr); + Boolean_Type, Expr, En); when Iir_Predefined_Bit_And => return Synth_Short_Circuit (Syn_Inst, Id_And, Get_Left (Expr), Get_Right (Expr), - Bit_Type, Expr); + Bit_Type, Expr, En); when Iir_Predefined_Bit_Or => return Synth_Short_Circuit (Syn_Inst, Id_Or, Get_Left (Expr), Get_Right (Expr), - Bit_Type, Expr); + Bit_Type, Expr, En); when Iir_Predefined_None => Error_Ieee_Operator (Imp, Expr); return Synth_User_Operator - (Syn_Inst, Get_Left (Expr), Get_Right (Expr), Expr); + (Syn_Inst, Get_Left (Expr), Get_Right (Expr), Expr, En); when others => return Synth_Dyadic_Operation (Syn_Inst, Imp, - Get_Left (Expr), Get_Right (Expr), Expr); + Get_Left (Expr), Get_Right (Expr), Expr, En); end case; end; when Iir_Kinds_Monadic_Operator => @@ -1840,10 +1851,10 @@ package body Synth.Expr is if Def = Iir_Predefined_None then Error_Ieee_Operator (Imp, Expr); return Synth_User_Operator - (Syn_Inst, Get_Operand (Expr), Null_Node, Expr); + (Syn_Inst, Get_Operand (Expr), Null_Node, Expr, En); else return Synth_Monadic_Operation - (Syn_Inst, Imp, Get_Operand (Expr), Expr); + (Syn_Inst, Imp, Get_Operand (Expr), Expr, En); end if; end; when Iir_Kind_Simple_Name @@ -1856,10 +1867,10 @@ package body Synth.Expr is when Iir_Kind_Reference_Name => -- Only used for anonymous signals in internal association. return Synth_Expression_With_Type - (Syn_Inst, Get_Named_Entity (Expr), Expr_Type); + (Syn_Inst, Get_Named_Entity (Expr), Expr_Type, En); when Iir_Kind_Anonymous_Signal_Declaration => return Synth_Expression_With_Type - (Syn_Inst, Get_Expression (Expr), Expr_Type); + (Syn_Inst, Get_Expression (Expr), Expr_Type, En); when Iir_Kind_Indexed_Name | Iir_Kind_Slice_Name => declare @@ -1870,7 +1881,8 @@ package body Synth.Expr is Dyn : Dyn_Name; begin - Synth_Assignment_Prefix (Syn_Inst, Expr, Base, Typ, Off, Dyn); + Synth_Assignment_Prefix + (Syn_Inst, Expr, En, Base, Typ, Off, Dyn); if Dyn.Voff = No_Net and then Is_Static (Base.Val) then Res := Create_Value_Memory (Typ); Copy_Memory @@ -1890,7 +1902,7 @@ package body Synth.Expr is Val : Valtyp; Res : Valtyp; begin - Val := Synth_Expression (Syn_Inst, Pfx); + Val := Synth_Expression (Syn_Inst, Pfx, En); Strip_Const (Val); Res_Typ := Val.Typ.Rec.E (Idx + 1).Typ; if Is_Static (Val.Val) then @@ -1909,7 +1921,7 @@ package body Synth.Expr is end; when Iir_Kind_Character_Literal => return Synth_Expression_With_Type - (Syn_Inst, Get_Named_Entity (Expr), Expr_Type); + (Syn_Inst, Get_Named_Entity (Expr), Expr_Type, No_Net); when Iir_Kind_Integer_Literal => declare Res : Valtyp; @@ -1929,31 +1941,33 @@ package body Synth.Expr is when Iir_Kind_Enumeration_Literal => return Synth_Name (Syn_Inst, Expr); when Iir_Kind_Type_Conversion => - return Synth_Type_Conversion (Syn_Inst, Expr); + return Synth_Type_Conversion (Syn_Inst, Expr, En); when Iir_Kind_Qualified_Expression => return Synth_Expression_With_Type (Syn_Inst, Get_Expression (Expr), - Get_Subtype_Object (Syn_Inst, Get_Type (Get_Type_Mark (Expr)))); + Get_Subtype_Object (Syn_Inst, Get_Type (Get_Type_Mark (Expr))), + En); when Iir_Kind_Function_Call => declare Imp : constant Node := Get_Implementation (Expr); begin case Get_Implicit_Definition (Imp) is when Iir_Predefined_Pure_Functions => - return Synth_Operator_Function_Call (Syn_Inst, Expr); + return Synth_Operator_Function_Call (Syn_Inst, Expr, En); when Iir_Predefined_None => - return Synth_User_Function_Call (Syn_Inst, Expr); + return Synth_User_Function_Call (Syn_Inst, Expr, En); when others => - return Synth_Predefined_Function_Call (Syn_Inst, Expr); + return Synth_Predefined_Function_Call + (Syn_Inst, Expr, En); end case; end; when Iir_Kind_Aggregate => - return Synth.Aggr.Synth_Aggregate (Syn_Inst, Expr, Expr_Type); + return Synth.Aggr.Synth_Aggregate (Syn_Inst, Expr, En, Expr_Type); when Iir_Kind_Simple_Aggregate => return Synth_Simple_Aggregate (Syn_Inst, Expr); when Iir_Kind_Parenthesis_Expression => return Synth_Expression_With_Type - (Syn_Inst, Get_Expression (Expr), Expr_Type); + (Syn_Inst, Get_Expression (Expr), Expr_Type, En); when Iir_Kind_Left_Array_Attribute => declare B : Bound_Type; @@ -2010,7 +2024,7 @@ package body Synth.Expr is V : Valtyp; Dtype : Type_Acc; begin - V := Synth_Expression (Syn_Inst, Param); + V := Synth_Expression (Syn_Inst, Param, En); Dtype := Get_Subtype_Object (Syn_Inst, Get_Type (Expr)); -- FIXME: to be generalized. Not always as simple as a -- subtype conversion. @@ -2031,6 +2045,7 @@ package body Synth.Expr is T : Type_Acc; Acc : Heap_Index; begin + pragma Assert (En = No_Net); T := Synth.Decls.Synth_Subtype_Indication (Syn_Inst, Get_Subtype_Indication (Expr)); Acc := Allocate_By_Type (T); @@ -2041,8 +2056,9 @@ package body Synth.Expr is V : Valtyp; Acc : Heap_Index; begin + pragma Assert (En = No_Net); V := Synth_Expression_With_Type - (Syn_Inst, Get_Expression (Expr), Expr_Type.Acc_Acc); + (Syn_Inst, Get_Expression (Expr), Expr_Type.Acc_Acc, No_Net); Acc := Allocate_By_Value (V); return Create_Value_Access (Acc, Expr_Type); end; @@ -2057,8 +2073,8 @@ package body Synth.Expr is end case; end Synth_Expression_With_Type; - function Synth_Expression (Syn_Inst : Synth_Instance_Acc; Expr : Node) - return Valtyp + function Synth_Expression + (Syn_Inst : Synth_Instance_Acc; Expr : Node; En : Net) return Valtyp is Etype : Node; begin @@ -2078,16 +2094,16 @@ package body Synth.Expr is end case; return Synth_Expression_With_Type - (Syn_Inst, Expr, Get_Subtype_Object (Syn_Inst, Etype)); + (Syn_Inst, Expr, Get_Subtype_Object (Syn_Inst, Etype), En); end Synth_Expression; function Synth_Expression_With_Basetype - (Syn_Inst : Synth_Instance_Acc; Expr : Node) return Valtyp + (Syn_Inst : Synth_Instance_Acc; Expr : Node; En : Net) return Valtyp is Basetype : Type_Acc; begin Basetype := Get_Subtype_Object (Syn_Inst, Get_Base_Type (Get_Type (Expr))); - return Synth_Expression_With_Type (Syn_Inst, Expr, Basetype); + return Synth_Expression_With_Type (Syn_Inst, Expr, Basetype, En); end Synth_Expression_With_Basetype; end Synth.Expr; diff --git a/src/synth/synth-expr.ads b/src/synth/synth-expr.ads index ef0499dc1..5104bcaaf 100644 --- a/src/synth/synth-expr.ads +++ b/src/synth/synth-expr.ads @@ -70,17 +70,24 @@ package Synth.Expr is procedure Concat_Array (Arr : in out Net_Array; N : out Net); - function Synth_Expression_With_Type - (Syn_Inst : Synth_Instance_Acc; Expr : Node; Expr_Type : Type_Acc) - return Valtyp; - - function Synth_Expression (Syn_Inst : Synth_Instance_Acc; Expr : Node) - return Valtyp; + -- Synthesize EXPR. The expression must be self-constrained. + -- If EN is not No_Net, the execution is controlled by EN. This is used + -- for assertions and checks. + function Synth_Expression + (Syn_Inst : Synth_Instance_Acc; Expr : Node; En : Net) return Valtyp; + + -- Same as Synth_Expression, but the expression may be constrained by + -- EXPR_TYPE. + function Synth_Expression_With_Type (Syn_Inst : Synth_Instance_Acc; + Expr : Node; + Expr_Type : Type_Acc; + En : Net) return Valtyp; -- Use base type of EXPR to synthesize EXPR. Useful when the type of -- EXPR is defined by itself or a range. - function Synth_Expression_With_Basetype - (Syn_Inst : Synth_Instance_Acc; Expr : Node) return Valtyp; + function Synth_Expression_With_Basetype (Syn_Inst : Synth_Instance_Acc; + Expr : Node; + En : Net) return Valtyp; function Synth_Bounds_From_Range (Syn_Inst : Synth_Instance_Acc; Atype : Node) return Bound_Type; @@ -102,6 +109,7 @@ package Synth.Expr is procedure Synth_Slice_Suffix (Syn_Inst : Synth_Instance_Acc; Name : Node; + En : Net; Pfx_Bnd : Bound_Type; El_Typ : Type_Acc; Res_Bnd : out Bound_Type; @@ -112,6 +120,7 @@ package Synth.Expr is -- OFF is 0. procedure Synth_Indexed_Name (Syn_Inst : Synth_Instance_Acc; Name : Node; + En : Net; Pfx_Type : Type_Acc; Voff : out Net; Off : out Value_Offsets); diff --git a/src/synth/synth-files_operations.adb b/src/synth/synth-files_operations.adb index 98fa6a5b8..52abbd7aa 100644 --- a/src/synth/synth-files_operations.adb +++ b/src/synth/synth-files_operations.adb @@ -28,6 +28,8 @@ with Grt.Stdio; with Vhdl.Annotations; +with Netlists; use Netlists; + with Synth.Objtypes; use Synth.Objtypes; with Synth.Expr; use Synth.Expr; with Synth.Errors; use Synth.Errors; @@ -214,10 +216,11 @@ package body Synth.Files_Operations is return F; end if; - File_Name := Synth_Expression_With_Basetype (Syn_Inst, External_Name); + File_Name := Synth_Expression_With_Basetype + (Syn_Inst, External_Name, No_Net); if Open_Kind /= Null_Node then - Mode := Synth_Expression (Syn_Inst, Open_Kind); + Mode := Synth_Expression (Syn_Inst, Open_Kind, No_Net); File_Mode := Ghdl_I32 (Read_Discrete (Mode)); else case Get_Mode (Decl) is diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb index 090760168..2f674883d 100644 --- a/src/synth/synth-insts.adb +++ b/src/synth/synth-insts.adb @@ -563,7 +563,8 @@ package body Synth.Insts is begin Synth_Individual_Prefix (Syn_Inst, Inter_Inst, Get_Prefix (Formal), Off, Typ); - Synth_Indexed_Name (Syn_Inst, Formal, Typ, Voff, Arr_Off); + Synth_Indexed_Name + (Syn_Inst, Formal, No_Net, Typ, Voff, Arr_Off); if Voff /= No_Net then raise Internal_Error; end if; @@ -582,7 +583,7 @@ package body Synth.Insts is (Syn_Inst, Inter_Inst, Get_Prefix (Formal), Off, Typ); Get_Onedimensional_Array_Bounds (Typ, Pfx_Bnd, El_Typ); - Synth_Slice_Suffix (Syn_Inst, Formal, Pfx_Bnd, El_Typ, + Synth_Slice_Suffix (Syn_Inst, Formal, No_Net, Pfx_Bnd, El_Typ, Res_Bnd, Sl_Voff, Sl_Off); if Sl_Voff /= No_Net then raise Internal_Error; @@ -652,7 +653,8 @@ package body Synth.Insts is (Syn_Inst, Inter_Inst, Get_Formal (Iassoc), Off, Typ); -- 2. synth expression - V := Synth_Expression_With_Type (Syn_Inst, Get_Actual (Iassoc), Typ); + V := Synth_Expression_With_Type + (Syn_Inst, Get_Actual (Iassoc), Typ, No_Net); -- 3. save in a table Value_Offset_Tables.Append (Els, (Off, V)); @@ -712,7 +714,8 @@ package body Synth.Insts is Formal_Typ := Get_Subtype_Object (Inter_Inst, Get_Type (Inter)); - Act := Synth_Expression_With_Type (Act_Inst, Actual, Formal_Typ); + Act := Synth_Expression_With_Type + (Act_Inst, Actual, Formal_Typ, No_Net); return Get_Net (Act); end Synth_Input_Assoc; @@ -744,7 +747,7 @@ package body Synth.Insts is V := Create_Value_Net (O, Typ); -- 3. Assign. - Synth_Assignment (Syn_Inst, Get_Actual (Iassoc), V, Iassoc); + Synth_Assignment (Syn_Inst, Get_Actual (Iassoc), V, Iassoc, No_Net); Iassoc := Get_Chain (Iassoc); end loop; @@ -779,7 +782,7 @@ package body Synth.Insts is Port := Builders.Build_Port (Get_Build (Syn_Inst), Outp); O := Create_Value_Net (Port, Formal_Typ); -- Assign the port output to the actual (a net). - Synth_Assignment (Syn_Inst, Actual, O, Assoc); + Synth_Assignment (Syn_Inst, Actual, O, Assoc, No_Net); end Synth_Output_Assoc; -- Subprogram used for instantiation (direct or by component). @@ -939,7 +942,8 @@ package body Synth.Insts is Synth_Generics_Association (Sub_Inst, Syn_Inst, Get_Generic_Chain (Ent), - Get_Generic_Map_Aspect_Chain (Stmt)); + Get_Generic_Map_Aspect_Chain (Stmt), + No_Net); -- Elaborate port types. Synth_Ports_Association_Type (Sub_Inst, Syn_Inst, @@ -1074,7 +1078,8 @@ package body Synth.Insts is Synth_Generics_Association (Comp_Inst, Syn_Inst, Get_Generic_Chain (Component), - Get_Generic_Map_Aspect_Chain (Stmt)); + Get_Generic_Map_Aspect_Chain (Stmt), + No_Net); -- Create objects for the inputs and the outputs of the component, -- assign inputs (that's nets) and create wires for outputs. @@ -1137,7 +1142,8 @@ package body Synth.Insts is (Comp_Inst, Ent, New_Sname_User (Get_Identifier (Ent), No_Sname)); Synth_Generics_Association (Sub_Inst, Comp_Inst, Get_Generic_Chain (Ent), - Get_Generic_Map_Aspect_Chain (Bind)); + Get_Generic_Map_Aspect_Chain (Bind), + No_Net); Synth_Ports_Association_Type (Sub_Inst, Comp_Inst, Get_Port_Chain (Ent), @@ -1222,7 +1228,8 @@ package body Synth.Insts is Bod : constant Node := Get_Package_Body (Dep_Unit); Bod_Unit : Node; begin - Synth_Package_Declaration (Parent_Inst, Dep_Unit); + Synth_Package_Declaration + (Parent_Inst, Dep_Unit, No_Net); -- Do not try to elaborate math_real body: there are -- functions with loop. Currently, try create signals, -- which is not possible during package elaboration. @@ -1231,11 +1238,12 @@ package body Synth.Insts is then Bod_Unit := Get_Design_Unit (Bod); Synth_Dependencies (Parent_Inst, Bod_Unit); - Synth_Package_Body (Parent_Inst, Dep_Unit, Bod); + Synth_Package_Body + (Parent_Inst, Dep_Unit, Bod, No_Net); end if; end; when Iir_Kind_Package_Instantiation_Declaration => - Synth_Package_Instantiation (Parent_Inst, Dep_Unit); + Synth_Package_Instantiation (Parent_Inst, Dep_Unit, No_Net); when Iir_Kind_Package_Body => null; when Iir_Kind_Architecture_Body => @@ -1287,7 +1295,7 @@ package body Synth.Insts is begin Inter_Typ := Get_Subtype_Object (Syn_Inst, Get_Type (Inter)); Val := Synth_Expression_With_Type - (Syn_Inst, Get_Default_Value (Inter), Inter_Typ); + (Syn_Inst, Get_Default_Value (Inter), Inter_Typ, No_Net); pragma Assert (Is_Static (Val.Val)); Create_Object (Syn_Inst, Inter, Val); end; @@ -1378,7 +1386,7 @@ package body Synth.Insts is if Default /= Null_Node then Inter_Typ := Get_Subtype_Object (Syn_Inst, Get_Type (Inter)); Init := Synth_Expression_With_Type - (Syn_Inst, Default, Inter_Typ); + (Syn_Inst, Default, Inter_Typ, No_Net); Init := Synth_Subtype_Conversion (Init, Inter_Typ, False, Inter); Value := Builders.Build_Ioutput (Build_Context, Get_Net (Init)); @@ -1513,14 +1521,14 @@ package body Synth.Insts is pragma Assert (Get_Kind (Inst.Config) = Iir_Kind_Block_Configuration); Apply_Block_Configuration (Inst.Config, Arch); - Synth_Declarations (Syn_Inst, Get_Declaration_Chain (Entity)); + Synth_Declarations (Syn_Inst, Get_Declaration_Chain (Entity), No_Net); if not Is_Error (Syn_Inst) then Synth_Concurrent_Statements (Syn_Inst, Get_Concurrent_Statement_Chain (Entity)); end if; if not Is_Error (Syn_Inst) then - Synth_Declarations (Syn_Inst, Get_Declaration_Chain (Arch)); + Synth_Declarations (Syn_Inst, Get_Declaration_Chain (Arch), No_Net); end if; if not Is_Error (Syn_Inst) then Synth_Concurrent_Statements diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb index 148886688..2dc5a10aa 100644 --- a/src/synth/synth-oper.adb +++ b/src/synth/synth-oper.adb @@ -28,7 +28,6 @@ with Vhdl.Utils; use Vhdl.Utils; with Areapools; -with Netlists; use Netlists; with Netlists.Gates; use Netlists.Gates; with Netlists.Builders; use Netlists.Builders; with Netlists.Folds; use Netlists.Folds; @@ -364,7 +363,8 @@ package body Synth.Oper is Imp : Node; Left_Expr : Node; Right_Expr : Node; - Expr : Node) return Valtyp + Expr : Node; + En : Net) return Valtyp is Ctxt : constant Context_Acc := Get_Build (Syn_Inst); Def : constant Iir_Predefined_Functions := @@ -660,12 +660,14 @@ package body Synth.Oper is return Create_Value_Net (N, Create_Res_Bound (Left)); end Synth_Rotation; begin - Left := Synth_Expression_With_Type (Syn_Inst, Left_Expr, Left_Typ); + Left := Synth_Expression_With_Type + (Syn_Inst, Left_Expr, Left_Typ, En); if Left = No_Valtyp then return No_Valtyp; end if; Left := Synth_Subtype_Conversion (Left, Left_Typ, False, Expr); - Right := Synth_Expression_With_Type (Syn_Inst, Right_Expr, Right_Typ); + Right := Synth_Expression_With_Type + (Syn_Inst, Right_Expr, Right_Typ, En); if Right = No_Valtyp then return No_Valtyp; end if; @@ -1381,7 +1383,8 @@ package body Synth.Oper is function Synth_Monadic_Operation (Syn_Inst : Synth_Instance_Acc; Imp : Node; Operand_Expr : Node; - Loc : Node) return Valtyp + Loc : Node; + En : Net) return Valtyp is Def : constant Iir_Predefined_Functions := Get_Implicit_Definition (Imp); @@ -1420,7 +1423,8 @@ package body Synth.Oper is return Create_Value_Net (N, Operand.Typ.Vec_El); end Synth_Vec_Reduce_Monadic; begin - Operand := Synth_Expression_With_Type (Syn_Inst, Operand_Expr, Oper_Typ); + Operand := Synth_Expression_With_Type + (Syn_Inst, Operand_Expr, Oper_Typ, En); if Operand = No_Valtyp then return No_Valtyp; end if; @@ -1702,7 +1706,7 @@ package body Synth.Oper is end Synth_Dynamic_Predefined_Function_Call; function Synth_Predefined_Function_Call - (Syn_Inst : Synth_Instance_Acc; Expr : Node) return Valtyp + (Syn_Inst : Synth_Instance_Acc; Expr : Node; En : Net) return Valtyp is Imp : constant Node := Get_Implementation (Expr); Assoc_Chain : constant Node := Get_Parameter_Association_Chain (Expr); @@ -1717,7 +1721,7 @@ package body Synth.Oper is Subprg_Inst := Make_Instance (Syn_Inst, Imp); Synth_Subprogram_Association - (Subprg_Inst, Syn_Inst, Inter_Chain, Assoc_Chain); + (Subprg_Inst, Syn_Inst, Inter_Chain, Assoc_Chain, En); if Is_Error (Subprg_Inst) then Res := No_Valtyp; @@ -1748,7 +1752,7 @@ package body Synth.Oper is end Synth_Predefined_Function_Call; function Synth_Operator_Function_Call - (Syn_Inst : Synth_Instance_Acc; Expr : Node) return Valtyp + (Syn_Inst : Synth_Instance_Acc; Expr : Node; En : Net) return Valtyp is Imp : constant Node := Get_Implementation (Expr); Assoc : Node; @@ -1760,10 +1764,10 @@ package body Synth.Oper is Op1 := Get_Actual (Assoc); if Get_Chain (Inter) = Null_Node then - return Synth_Monadic_Operation (Syn_Inst, Imp, Op1, Expr); + return Synth_Monadic_Operation (Syn_Inst, Imp, Op1, Expr, En); else Op2 := Get_Actual (Get_Chain (Assoc)); - return Synth_Dyadic_Operation (Syn_Inst, Imp, Op1, Op2, Expr); + return Synth_Dyadic_Operation (Syn_Inst, Imp, Op1, Op2, Expr, En); end if; end Synth_Operator_Function_Call; end Synth.Oper; diff --git a/src/synth/synth-oper.ads b/src/synth/synth-oper.ads index 297c698e3..6ec51fbc6 100644 --- a/src/synth/synth-oper.ads +++ b/src/synth/synth-oper.ads @@ -18,27 +18,32 @@ -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. +with Vhdl.Nodes; use Vhdl.Nodes; + +with Netlists; use Netlists; + with Synth.Objtypes; use Synth.Objtypes; with Synth.Values; use Synth.Values; with Synth.Context; use Synth.Context; -with Vhdl.Nodes; use Vhdl.Nodes; package Synth.Oper is function Synth_Predefined_Function_Call - (Syn_Inst : Synth_Instance_Acc; Expr : Node) return Valtyp; + (Syn_Inst : Synth_Instance_Acc; Expr : Node; En : Net) return Valtyp; function Synth_Operator_Function_Call - (Syn_Inst : Synth_Instance_Acc; Expr : Node) return Valtyp; + (Syn_Inst : Synth_Instance_Acc; Expr : Node; En : Net) return Valtyp; function Synth_Dyadic_Operation (Syn_Inst : Synth_Instance_Acc; Imp : Node; Left_Expr : Node; Right_Expr : Node; - Expr : Node) return Valtyp; + Expr : Node; + En : Net) return Valtyp; function Synth_Monadic_Operation (Syn_Inst : Synth_Instance_Acc; Imp : Node; Operand_Expr : Node; - Loc : Node) return Valtyp; + Loc : Node; + En : Net) return Valtyp; function Create_Bounds_From_Length (Syn_Inst : Synth_Instance_Acc; Atype : Iir; Len : Iir_Index32) diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index 838f19270..1dffe6083 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -67,7 +67,8 @@ package body Synth.Stmts is function Synth_Waveform (Syn_Inst : Synth_Instance_Acc; Wf : Node; - Targ_Type : Type_Acc) return Valtyp is + Targ_Type : Type_Acc; + En : Net) return Valtyp is begin if Get_Kind (Wf) = Iir_Kind_Unaffected_Waveform then -- TODO @@ -82,15 +83,16 @@ package body Synth.Stmts is null; end if; if Targ_Type = null then - return Synth_Expression (Syn_Inst, Get_We_Value (Wf)); + return Synth_Expression (Syn_Inst, Get_We_Value (Wf), En); else return Synth_Expression_With_Type - (Syn_Inst, Get_We_Value (Wf), Targ_Type); + (Syn_Inst, Get_We_Value (Wf), Targ_Type, En); end if; end Synth_Waveform; procedure Synth_Assignment_Prefix (Syn_Inst : Synth_Instance_Acc; Pfx : Node; + En : Net; Dest_Base : out Valtyp; Dest_Typ : out Type_Acc; Dest_Off : out Value_Offsets; @@ -98,7 +100,7 @@ package body Synth.Stmts is begin case Get_Kind (Pfx) is when Iir_Kind_Simple_Name => - Synth_Assignment_Prefix (Syn_Inst, Get_Named_Entity (Pfx), + Synth_Assignment_Prefix (Syn_Inst, Get_Named_Entity (Pfx), En, Dest_Base, Dest_Typ, Dest_Off, Dest_Dyn); when Iir_Kind_Interface_Signal_Declaration | Iir_Kind_Variable_Declaration @@ -126,8 +128,7 @@ package body Synth.Stmts is end if; end; when Iir_Kind_Function_Call => - -- Can be the prefix of .all - Dest_Base := Synth_Expression (Syn_Inst, Pfx); + Dest_Base := Synth_Expression (Syn_Inst, Pfx, En); Dest_Typ := Dest_Base.Typ; Dest_Off := (0, 0); Dest_Dyn := No_Dyn_Name; @@ -138,10 +139,10 @@ package body Synth.Stmts is Off : Value_Offsets; begin Synth_Assignment_Prefix - (Syn_Inst, Get_Prefix (Pfx), + (Syn_Inst, Get_Prefix (Pfx), En, Dest_Base, Dest_Typ, Dest_Off, Dest_Dyn); Strip_Const (Dest_Base); - Synth_Indexed_Name (Syn_Inst, Pfx, Dest_Typ, Voff, Off); + Synth_Indexed_Name (Syn_Inst, Pfx, En, Dest_Typ, Voff, Off); if Voff = No_Net then -- Static index. @@ -176,7 +177,7 @@ package body Synth.Stmts is Get_Element_Position (Get_Named_Entity (Pfx)); begin Synth_Assignment_Prefix - (Syn_Inst, Get_Prefix (Pfx), + (Syn_Inst, Get_Prefix (Pfx), En, Dest_Base, Dest_Typ, Dest_Off, Dest_Dyn); Dest_Off.Net_Off := Dest_Off.Net_Off + Dest_Typ.Rec.E (Idx + 1).Boff; @@ -195,12 +196,12 @@ package body Synth.Stmts is Sl_Off : Value_Offsets; begin Synth_Assignment_Prefix - (Syn_Inst, Get_Prefix (Pfx), + (Syn_Inst, Get_Prefix (Pfx), En, Dest_Base, Dest_Typ, Dest_Off, Dest_Dyn); Strip_Const (Dest_Base); Get_Onedimensional_Array_Bounds (Dest_Typ, Pfx_Bnd, El_Typ); - Synth_Slice_Suffix (Syn_Inst, Pfx, Pfx_Bnd, El_Typ, + Synth_Slice_Suffix (Syn_Inst, Pfx, En, Pfx_Bnd, El_Typ, Res_Bnd, Sl_Voff, Sl_Off); @@ -234,7 +235,7 @@ package body Synth.Stmts is when Iir_Kind_Implicit_Dereference | Iir_Kind_Dereference => Synth_Assignment_Prefix - (Syn_Inst, Get_Prefix (Pfx), + (Syn_Inst, Get_Prefix (Pfx), En, Dest_Base, Dest_Typ, Dest_Off, Dest_Dyn); if Dest_Off /= (0, 0) and then Dest_Dyn.Voff /= No_Net then raise Internal_Error; @@ -285,7 +286,8 @@ package body Synth.Stmts is type Target_Info_Array is array (Natural range <>) of Target_Info; function Synth_Target (Syn_Inst : Synth_Instance_Acc; - Target : Node) return Target_Info is + Target : Node; + En : Net) return Target_Info is begin case Get_Kind (Target) is when Iir_Kind_Aggregate => @@ -323,7 +325,8 @@ package body Synth.Stmts is Dyn : Dyn_Name; begin - Synth_Assignment_Prefix (Syn_Inst, Target, Base, Typ, Off, Dyn); + Synth_Assignment_Prefix + (Syn_Inst, Target, En, Base, Typ, Off, Dyn); if Dyn.Voff = No_Net then -- FIXME: check index. return Target_Info'(Kind => Target_Simple, @@ -346,7 +349,8 @@ package body Synth.Stmts is procedure Synth_Assignment (Syn_Inst : Synth_Instance_Acc; Target : Target_Info; Val : Valtyp; - Loc : Node); + Loc : Node; + En : Net); -- Extract a part of VAL from a target aggregate at offset OFF (offset -- in the array). @@ -388,7 +392,8 @@ package body Synth.Stmts is Target : Node; Target_Typ : Type_Acc; Val : Valtyp; - Loc : Node) + Loc : Node; + En : Net) is Targ_Bnd : constant Bound_Type := Get_Array_Bound (Target_Typ, 1); Choice : Node; @@ -402,7 +407,7 @@ package body Synth.Stmts is Assoc := Get_Associated_Expr (Choice); case Get_Kind (Choice) is when Iir_Kind_Choice_By_None => - Targ_Info := Synth_Target (Syn_Inst, Assoc); + Targ_Info := Synth_Target (Syn_Inst, Assoc, En); if Get_Element_Type_Flag (Choice) then Pos := Pos - 1; else @@ -411,7 +416,7 @@ package body Synth.Stmts is Synth_Assignment (Syn_Inst, Targ_Info, Aggregate_Extract (Val, Pos, Targ_Info.Targ_Type, Assoc), - Loc); + Loc, En); when others => Error_Kind ("synth_assignment_aggregate", Choice); end case; @@ -422,7 +427,8 @@ package body Synth.Stmts is procedure Synth_Assignment (Syn_Inst : Synth_Instance_Acc; Target : Target_Info; Val : Valtyp; - Loc : Node) + Loc : Node; + En : Net) is V : Valtyp; begin @@ -436,7 +442,7 @@ package body Synth.Stmts is case Target.Kind is when Target_Aggregate => Synth_Assignment_Aggregate - (Syn_Inst, Target.Aggr, Target.Targ_Type, V, Loc); + (Syn_Inst, Target.Aggr, Target.Targ_Type, V, Loc, En); when Target_Simple => if V.Typ.Sz = 0 then -- If there is nothing to assign (like a null slice), @@ -489,12 +495,13 @@ package body Synth.Stmts is procedure Synth_Assignment (Syn_Inst : Synth_Instance_Acc; Target : Node; Val : Valtyp; - Loc : Node) + Loc : Node; + En : Net) is Info : Target_Info; begin - Info := Synth_Target (Syn_Inst, Target); - Synth_Assignment (Syn_Inst, Info, Val, Loc); + Info := Synth_Target (Syn_Inst, Target, En); + Synth_Assignment (Syn_Inst, Info, Val, Loc, En); end Synth_Assignment; function Synth_Read_Memory (Syn_Inst : Synth_Instance_Acc; @@ -541,19 +548,19 @@ package body Synth.Stmts is -- Concurrent or sequential simple signal assignment procedure Synth_Simple_Signal_Assignment - (Syn_Inst : Synth_Instance_Acc; Stmt : Node) + (Syn_Inst : Synth_Instance_Acc; Stmt : Node; En : Net) is Targ : Target_Info; Val : Valtyp; begin - Targ := Synth_Target (Syn_Inst, Get_Target (Stmt)); + Targ := Synth_Target (Syn_Inst, Get_Target (Stmt), En); Val := Synth_Waveform - (Syn_Inst, Get_Waveform_Chain (Stmt), Targ.Targ_Type); - Synth_Assignment (Syn_Inst, Targ, Val, Stmt); + (Syn_Inst, Get_Waveform_Chain (Stmt), Targ.Targ_Type, En); + Synth_Assignment (Syn_Inst, Targ, Val, Stmt, En); end Synth_Simple_Signal_Assignment; procedure Synth_Conditional_Signal_Assignment - (Syn_Inst : Synth_Instance_Acc; Stmt : Node) + (Syn_Inst : Synth_Instance_Acc; Stmt : Node; En : Net) is Targ : Target_Info; Cond : Node; @@ -564,13 +571,13 @@ package body Synth.Stmts is First, Last : Net; V : Net; begin - Targ := Synth_Target (Syn_Inst, Get_Target (Stmt)); + Targ := Synth_Target (Syn_Inst, Get_Target (Stmt), En); Last := No_Net; Cwf := Get_Conditional_Waveform_Chain (Stmt); Cond := Null_Node; while Cwf /= Null_Node loop Val := Synth_Waveform - (Syn_Inst, Get_Waveform_Chain (Cwf), Targ.Targ_Type); + (Syn_Inst, Get_Waveform_Chain (Cwf), Targ.Targ_Type, En); if Val = No_Valtyp then -- Mark the error, but try to continue. Set_Error (Syn_Inst); @@ -578,7 +585,7 @@ package body Synth.Stmts is V := Get_Net (Val); Cond := Get_Condition (Cwf); if Cond /= Null_Node then - Cond_Val := Synth_Expression (Syn_Inst, Cond); + Cond_Val := Synth_Expression (Syn_Inst, Cond, En); if Cond_Val = No_Valtyp then Cond_Net := Build_Const_UB32 (Build_Context, 0, 1); else @@ -609,29 +616,44 @@ package body Synth.Stmts is end if; end if; Val := Create_Value_Net (First, Targ.Targ_Type); - Synth_Assignment (Syn_Inst, Targ, Val, Stmt); + Synth_Assignment (Syn_Inst, Targ, Val, Stmt, En); end Synth_Conditional_Signal_Assignment; - procedure Synth_Variable_Assignment - (Syn_Inst : Synth_Instance_Acc; Stmt : Node) + -- Return the enable net from C. + function Get_En (C : Seq_Context) return Net is + begin + if C.Mode = Mode_Static then + return No_Net; + end if; + if Is_Static_Wire (C.W_En) then + -- Must be True! + return No_Net; + else + return Get_Current_Value (Get_Build (C.Inst), C.W_En); + end if; + end Get_En; + + procedure Synth_Variable_Assignment (C : Seq_Context; Stmt : Node) is + En : constant Net := Get_En (C); Targ : Target_Info; Val : Valtyp; begin - Targ := Synth_Target (Syn_Inst, Get_Target (Stmt)); + Targ := Synth_Target (C.Inst, Get_Target (Stmt), En); Val := Synth_Expression_With_Type - (Syn_Inst, Get_Expression (Stmt), Targ.Targ_Type); + (C.Inst, Get_Expression (Stmt), Targ.Targ_Type, En); if Val = No_Valtyp then - Set_Error (Syn_Inst); + Set_Error (C.Inst); return; end if; - Synth_Assignment (Syn_Inst, Targ, Val, Stmt); + Synth_Assignment (C.Inst, Targ, Val, Stmt, En); end Synth_Variable_Assignment; procedure Synth_Conditional_Variable_Assignment - (Syn_Inst : Synth_Instance_Acc; Stmt : Node) + (C : Seq_Context; Stmt : Node) is Target : constant Node := Get_Target (Stmt); + En : constant Net := Get_En (C); Targ_Type : Type_Acc; Cond : Node; Ce : Node; @@ -639,16 +661,16 @@ package body Synth.Stmts is V : Net; First, Last : Net; begin - Targ_Type := Get_Subtype_Object (Syn_Inst, Get_Type (Target)); + Targ_Type := Get_Subtype_Object (C.Inst, Get_Type (Target)); Last := No_Net; Ce := Get_Conditional_Expression_Chain (Stmt); while Ce /= Null_Node loop Val := Synth_Expression_With_Type - (Syn_Inst, Get_Expression (Ce), Targ_Type); + (C.Inst, Get_Expression (Ce), Targ_Type, En); V := Get_Net (Val); Cond := Get_Condition (Ce); if Cond /= Null_Node then - Cond_Val := Synth_Expression (Syn_Inst, Cond); + Cond_Val := Synth_Expression (C.Inst, Cond, En); V := Build_Mux2 (Build_Context, Get_Net (Cond_Val), No_Net, V); Set_Location (V, Ce); end if; @@ -662,7 +684,7 @@ package body Synth.Stmts is Ce := Get_Chain (Ce); end loop; Val := Create_Value_Net (First, Targ_Type); - Synth_Assignment (Syn_Inst, Target, Val, Stmt); + Synth_Assignment (C.Inst, Target, Val, Stmt, En); end Synth_Conditional_Variable_Assignment; procedure Synth_If_Statement (C : in out Seq_Context; Stmt : Node) @@ -673,7 +695,7 @@ package body Synth.Stmts is Phi_True : Phi_Type; Phi_False : Phi_Type; begin - Cond_Val := Synth_Expression (C.Inst, Cond); + Cond_Val := Synth_Expression (C.Inst, Cond, Get_En (C)); if Cond_Val = No_Valtyp then Set_Error (C.Inst); return; @@ -723,15 +745,15 @@ package body Synth.Stmts is end Synth_If_Statement; -- EXPR is a choice, so a locally static literal. - function Convert_To_Uns64 (Syn_Inst : Synth_Instance_Acc; Expr : Node) - return Uns64 + function Convert_To_Uns64 + (Syn_Inst : Synth_Instance_Acc; Expr : Node; En : Net) return Uns64 is Expr_Val : Valtyp; Vec : Logvec_Array (0 .. 1); Off : Uns32; Has_Zx : Boolean; begin - Expr_Val := Synth_Expression_With_Basetype (Syn_Inst, Expr); + Expr_Val := Synth_Expression_With_Basetype (Syn_Inst, Expr, En); Off := 0; Has_Zx := False; Vec := (others => (0, 0)); @@ -930,7 +952,8 @@ package body Synth.Stmts is Annex_Arr (Choice_Idx) := Int32 (Choice_Idx); Choice_Data (Choice_Idx) := (Val => Convert_To_Uns64 (C.Inst, - Get_Choice_Expression (Choice)), + Get_Choice_Expression (Choice), + Get_En (C)), Alt => Alt_Idx); when Iir_Kind_Choice_By_Others => Others_Alt_Idx := Alt_Idx; @@ -1069,7 +1092,8 @@ package body Synth.Stmts is case Get_Kind (Choice) is when Iir_Kind_Choice_By_Expression => Sel_Expr := Get_Choice_Expression (Choice); - Sel_Val := Synth_Expression_With_Basetype (C.Inst, Sel_Expr); + Sel_Val := Synth_Expression_With_Basetype + (C.Inst, Sel_Expr, No_Net); if Is_Equal (Sel_Val, Sel) then Synth_Sequential_Statements (C, Stmts); exit; @@ -1141,7 +1165,7 @@ package body Synth.Stmts is Expr : constant Node := Get_Expression (Stmt); Sel : Valtyp; begin - Sel := Synth_Expression_With_Basetype (C.Inst, Expr); + Sel := Synth_Expression_With_Basetype (C.Inst, Expr, Get_En (C)); Strip_Const (Sel); if Is_Static (Sel.Val) then case Sel.Typ.Kind is @@ -1162,7 +1186,7 @@ package body Synth.Stmts is end Synth_Case_Statement; procedure Synth_Selected_Signal_Assignment - (Syn_Inst : Synth_Instance_Acc; Stmt : Node) + (Syn_Inst : Synth_Instance_Acc; Stmt : Node; En : Net) is use Vhdl.Sem_Expr; @@ -1190,11 +1214,11 @@ package body Synth.Stmts is Sel : Valtyp; Sel_Net : Net; begin - Targ := Synth_Target (Syn_Inst, Get_Target (Stmt)); + Targ := Synth_Target (Syn_Inst, Get_Target (Stmt), En); Targ_Type := Targ.Targ_Type; -- Create a net for the expression. - Sel := Synth_Expression_With_Basetype (Syn_Inst, Expr); + Sel := Synth_Expression_With_Basetype (Syn_Inst, Expr, En); -- Count choices and alternatives. Count_Choices (Case_Info, Choices); @@ -1220,7 +1244,7 @@ package body Synth.Stmts is Alts (Alt_Idx).Val := Get_Net (Synth_Waveform - (Syn_Inst, Get_Associated_Chain (Choice), Targ_Type)); + (Syn_Inst, Get_Associated_Chain (Choice), Targ_Type, En)); end if; case Get_Kind (Choice) is @@ -1229,7 +1253,8 @@ package body Synth.Stmts is Annex_Arr (Choice_Idx) := Int32 (Choice_Idx); Choice_Data (Choice_Idx) := (Val => Convert_To_Uns64 (Syn_Inst, - Get_Choice_Expression (Choice)), + Get_Choice_Expression (Choice), + No_Net), Alt => Alt_Idx); when Iir_Kind_Choice_By_Others => Others_Alt_Idx := Alt_Idx; @@ -1278,7 +1303,7 @@ package body Synth.Stmts is Sel_Net, Case_El.all, Default, Res, Get_Location (Expr)); Synth_Assignment - (Syn_Inst, Targ, Create_Value_Net (Res, Targ_Type), Stmt); + (Syn_Inst, Targ, Create_Value_Net (Res, Targ_Type), Stmt, En); end; -- free. @@ -1473,6 +1498,7 @@ package body Synth.Stmts is procedure Synth_Subprogram_Association (Subprg_Inst : Synth_Instance_Acc; Caller_Inst : Synth_Instance_Acc; + En : Net; Init : Association_Iterator_Init; Infos : out Target_Info_Array) is @@ -1505,7 +1531,7 @@ package body Synth.Stmts is then Actual := Get_Default_Value (Inter); Val := Synth_Expression_With_Type - (Subprg_Inst, Actual, Inter_Type); + (Subprg_Inst, Actual, Inter_Type, En); else if Get_Kind (Assoc) = Iir_Kind_Association_Element_By_Expression @@ -1515,11 +1541,11 @@ package body Synth.Stmts is Actual := Assoc; end if; Val := Synth_Expression_With_Type - (Caller_Inst, Actual, Inter_Type); + (Caller_Inst, Actual, Inter_Type, En); end if; when Iir_Out_Mode | Iir_Inout_Mode => Actual := Get_Actual (Assoc); - Info := Synth_Target (Caller_Inst, Actual); + Info := Synth_Target (Caller_Inst, Actual, En); case Iir_Kinds_Interface_Object_Declaration (Get_Kind (Inter)) is @@ -1593,14 +1619,15 @@ package body Synth.Stmts is procedure Synth_Subprogram_Association (Subprg_Inst : Synth_Instance_Acc; Caller_Inst : Synth_Instance_Acc; Inter_Chain : Node; - Assoc_Chain : Node) + Assoc_Chain : Node; + En : Net) is Infos : Target_Info_Array (1 .. 0); pragma Unreferenced (Infos); Init : Association_Iterator_Init; begin Init := Association_Iterator_Build (Inter_Chain, Assoc_Chain); - Synth_Subprogram_Association (Subprg_Inst, Caller_Inst, Init, Infos); + Synth_Subprogram_Association (Subprg_Inst, Caller_Inst, En, Init, Infos); end Synth_Subprogram_Association; -- Create wires for out and inout interface variables. @@ -1637,6 +1664,7 @@ package body Synth.Stmts is procedure Synth_Subprogram_Back_Association (Subprg_Inst : Synth_Instance_Acc; Caller_Inst : Synth_Instance_Acc; + En : Net; Init : Association_Iterator_Init; Infos : Target_Info_Array) is @@ -1660,7 +1688,7 @@ package body Synth.Stmts is end if; Nbr_Inout := Nbr_Inout + 1; Val := Get_Value (Subprg_Inst, Inter); - Synth_Assignment (Caller_Inst, Infos (Nbr_Inout), Val, Assoc); + Synth_Assignment (Caller_Inst, Infos (Nbr_Inout), Val, Assoc, En); -- Free wire used for out/inout interface variables. if Val.Val.Kind = Value_Wire then @@ -1689,6 +1717,7 @@ package body Synth.Stmts is function Synth_Dynamic_Subprogram_Call (Syn_Inst : Synth_Instance_Acc; Sub_Inst : Synth_Instance_Acc; Call : Node; + En : Net; Init : Association_Iterator_Init; Infos : Target_Info_Array) return Valtyp @@ -1736,13 +1765,17 @@ package body Synth.Stmts is Set_Wire_Gate (C.W_En, Build_Control_Signal (Sub_Inst, 1, Imp)); - Phi_Assign_Net (Build_Context, C.W_En, Get_Inst_Bit1 (Syn_Inst), 0); + if En = No_Net then + Phi_Assign_Net (Build_Context, C.W_En, Get_Inst_Bit1 (Syn_Inst), 0); + else + Phi_Assign_Net (Build_Context, C.W_En, En, 0); + end if; Set_Wire_Gate (C.W_Ret, Build_Control_Signal (Sub_Inst, 1, Imp)); Phi_Assign_Net (Build_Context, C.W_Ret, Get_Inst_Bit1 (Syn_Inst), 0); - Decls.Synth_Declarations (C.Inst, Get_Declaration_Chain (Bod), True); + Decls.Synth_Declarations (C.Inst, Get_Declaration_Chain (Bod), En, True); if not Is_Error (C.Inst) then Synth_Sequential_Statements (C, Get_Sequential_Statement_Chain (Bod)); end if; @@ -1761,7 +1794,8 @@ package body Synth.Stmts is end if; else Res := No_Valtyp; - Synth_Subprogram_Back_Association (C.Inst, Syn_Inst, Init, Infos); + Synth_Subprogram_Back_Association + (C.Inst, Syn_Inst, En, Init, Infos); end if; end if; @@ -1815,7 +1849,7 @@ package body Synth.Stmts is C.Ret_Typ := Get_Subtype_Object (Syn_Inst, Get_Return_Type (Imp)); end if; - Decls.Synth_Declarations (C.Inst, Get_Declaration_Chain (Bod), True); + Synth_Declarations (C.Inst, Get_Declaration_Chain (Bod), No_Net, True); if not Is_Error (C.Inst) then Synth_Sequential_Statements (C, Get_Sequential_Statement_Chain (Bod)); @@ -1836,7 +1870,8 @@ package body Synth.Stmts is end if; else Res := No_Valtyp; - Synth_Subprogram_Back_Association (C.Inst, Syn_Inst, Init, Infos); + Synth_Subprogram_Back_Association + (C.Inst, Syn_Inst, No_Net, Init, Infos); end if; end if; @@ -1848,6 +1883,7 @@ package body Synth.Stmts is function Synth_Subprogram_Call (Syn_Inst : Synth_Instance_Acc; Call : Node; + En : Net; Init : Association_Iterator_Init) return Valtyp is @@ -1868,7 +1904,7 @@ package body Synth.Stmts is New_Internal_Name (Build_Context)); Set_Instance_Base (Sub_Inst, Syn_Inst); - Synth_Subprogram_Association (Sub_Inst, Syn_Inst, Init, Infos); + Synth_Subprogram_Association (Sub_Inst, Syn_Inst, En, Init, Infos); if Is_Error (Sub_Inst) then Res := No_Valtyp; @@ -1884,7 +1920,7 @@ package body Synth.Stmts is (Syn_Inst, Sub_Inst, Call, Init, Infos); else Res := Synth_Dynamic_Subprogram_Call - (Syn_Inst, Sub_Inst, Call, Init, Infos); + (Syn_Inst, Sub_Inst, Call, En, Init, Infos); end if; end if; @@ -1904,7 +1940,7 @@ package body Synth.Stmts is end Synth_Subprogram_Call; function Synth_Subprogram_Call - (Syn_Inst : Synth_Instance_Acc; Call : Node) return Valtyp + (Syn_Inst : Synth_Instance_Acc; Call : Node; En : Net) return Valtyp is Imp : constant Node := Get_Implementation (Call); Assoc_Chain : constant Node := Get_Parameter_Association_Chain (Call); @@ -1912,20 +1948,21 @@ package body Synth.Stmts is Init : Association_Iterator_Init; begin Init := Association_Iterator_Build (Inter_Chain, Assoc_Chain); - return Synth_Subprogram_Call (Syn_Inst, Call, Init); + return Synth_Subprogram_Call (Syn_Inst, Call, En, Init); end Synth_Subprogram_Call; function Synth_User_Operator (Syn_Inst : Synth_Instance_Acc; Left_Expr : Node; Right_Expr : Node; - Expr : Node) return Valtyp + Expr : Node; + En : Net) return Valtyp is Imp : constant Node := Get_Implementation (Expr); Inter_Chain : constant Node := Get_Interface_Declaration_Chain (Imp); Init : Association_Iterator_Init; begin Init := Association_Iterator_Build (Inter_Chain, Left_Expr, Right_Expr); - return Synth_Subprogram_Call (Syn_Inst, Expr, Init); + return Synth_Subprogram_Call (Syn_Inst, Expr, En, Init); end Synth_User_Operator; procedure Synth_Implicit_Procedure_Call @@ -1945,17 +1982,19 @@ package body Synth.Stmts is Sub_Inst := Make_Instance (Syn_Inst, Imp, New_Internal_Name (Build_Context)); - Synth_Subprogram_Association (Sub_Inst, Syn_Inst, Init, Infos); + Synth_Subprogram_Association (Sub_Inst, Syn_Inst, No_Net, Init, Infos); Synth.Static_Proc.Synth_Static_Procedure (Sub_Inst, Imp, Call); - Synth_Subprogram_Back_Association (Sub_Inst, Syn_Inst, Init, Infos); + Synth_Subprogram_Back_Association + (Sub_Inst, Syn_Inst, No_Net, Init, Infos); Free_Instance (Sub_Inst); Areapools.Release (Area_Mark, Instance_Pool.all); end Synth_Implicit_Procedure_Call; - procedure Synth_Procedure_Call (Syn_Inst : Synth_Instance_Acc; Stmt : Node) + procedure Synth_Procedure_Call + (Syn_Inst : Synth_Instance_Acc; Stmt : Node; En : Net) is Call : constant Node := Get_Procedure_Call (Stmt); Imp : constant Node := Get_Implementation (Call); @@ -1967,7 +2006,7 @@ package body Synth.Stmts is Error_Msg_Synth (+Stmt, "call to foreign %n is not supported", +Imp); else - Res := Synth_Subprogram_Call (Syn_Inst, Call); + Res := Synth_Subprogram_Call (Syn_Inst, Call, En); pragma Assert (Res = No_Valtyp); end if; when others => @@ -2126,7 +2165,7 @@ package body Synth.Stmts is Phi_False : Phi_Type; begin if Cond /= Null_Node then - Cond_Val := Synth_Expression (C.Inst, Cond); + Cond_Val := Synth_Expression (C.Inst, Cond, Get_En (C)); Static_Cond := Is_Static_Val (Cond_Val.Val); if Static_Cond then if Get_Static_Discrete (Cond_Val) = 0 then @@ -2191,7 +2230,7 @@ package body Synth.Stmts is Cond_Val : Valtyp; begin if Cond /= Null_Node then - Cond_Val := Synth_Expression (C.Inst, Cond); + Cond_Val := Synth_Expression (C.Inst, Cond, No_Net); if Cond_Val = No_Valtyp then Set_Error (C.Inst); return; @@ -2353,7 +2392,8 @@ package body Synth.Stmts is loop if Cond /= Null_Node then - Val := Synth_Expression_With_Type (C.Inst, Cond, Boolean_Type); + Val := Synth_Expression_With_Type + (C.Inst, Cond, Boolean_Type, No_Net); if not Is_Static (Val.Val) then Error_Msg_Synth (+Cond, "loop condition must be static"); exit; @@ -2412,7 +2452,8 @@ package body Synth.Stmts is loop if Cond /= Null_Node then - Val := Synth_Expression_With_Type (C.Inst, Cond, Boolean_Type); + Val := Synth_Expression_With_Type + (C.Inst, Cond, Boolean_Type, No_Net); pragma Assert (Is_Static (Val.Val)); exit when Read_Discrete (Val) = 0; end if; @@ -2435,7 +2476,8 @@ package body Synth.Stmts is begin if Expr /= Null_Node then -- Return in function. - Val := Synth_Expression_With_Type (C.Inst, Expr, C.Ret_Typ); + Val := Synth_Expression_With_Type + (C.Inst, Expr, C.Ret_Typ, Get_En (C)); if Val = No_Valtyp then Set_Error (C.Inst); return; @@ -2490,7 +2532,7 @@ package body Synth.Stmts is Sev_V : Natural; begin if Rep_Expr /= Null_Node then - Rep := Synth_Expression_With_Basetype (C.Inst, Rep_Expr); + Rep := Synth_Expression_With_Basetype (C.Inst, Rep_Expr, No_Net); if Rep = No_Valtyp then Set_Error (C.Inst); return; @@ -2498,7 +2540,7 @@ package body Synth.Stmts is Strip_Const (Rep); end if; if Sev_Expr /= Null_Node then - Sev := Synth_Expression (C.Inst, Sev_Expr); + Sev := Synth_Expression (C.Inst, Sev_Expr, No_Net); if Sev = No_Valtyp then Set_Error (C.Inst); return; @@ -2551,7 +2593,8 @@ package body Synth.Stmts is is Cond : Valtyp; begin - Cond := Synth_Expression (C.Inst, Get_Assertion_Condition (Stmt)); + Cond := Synth_Expression + (C.Inst, Get_Assertion_Condition (Stmt), No_Net); if Cond = No_Valtyp then Set_Error (C.Inst); return; @@ -2605,13 +2648,13 @@ package body Synth.Stmts is when Iir_Kind_If_Statement => Synth_If_Statement (C, Stmt); when Iir_Kind_Simple_Signal_Assignment_Statement => - Synth_Simple_Signal_Assignment (C.Inst, Stmt); + Synth_Simple_Signal_Assignment (C.Inst, Stmt, Get_En (C)); when Iir_Kind_Conditional_Signal_Assignment_Statement => - Synth_Conditional_Signal_Assignment (C.Inst, Stmt); + Synth_Conditional_Signal_Assignment (C.Inst, Stmt, Get_En (C)); when Iir_Kind_Variable_Assignment_Statement => - Synth_Variable_Assignment (C.Inst, Stmt); + Synth_Variable_Assignment (C, Stmt); when Iir_Kind_Conditional_Variable_Assignment_Statement => - Synth_Conditional_Variable_Assignment (C.Inst, Stmt); + Synth_Conditional_Variable_Assignment (C, Stmt); when Iir_Kind_Case_Statement => Synth_Case_Statement (C, Stmt); when Iir_Kind_For_Loop_Statement => @@ -2632,7 +2675,7 @@ package body Synth.Stmts is when Iir_Kind_Return_Statement => Synth_Return_Statement (C, Stmt); when Iir_Kind_Procedure_Call_Statement => - Synth_Procedure_Call (C.Inst, Stmt); + Synth_Procedure_Call (C.Inst, Stmt, Get_En (C)); when Iir_Kind_Report_Statement => if not Is_Dyn then Synth_Static_Report_Statement (C, Stmt); @@ -2698,7 +2741,7 @@ package body Synth.Stmts is Error_Msg_Synth (+Stmt, "expect wait condition"); return; end if; - Cond_Val := Synth_Expression (C.Inst, Cond); + Cond_Val := Synth_Expression (C.Inst, Cond, No_Net); Push_Phi; Synth_Sequential_Statements (C, Get_Chain (Stmt)); @@ -2742,7 +2785,7 @@ package body Synth.Stmts is Instance_Pool := Proc_Pool'Access; if Is_Valid (Decls_Chain) then - Synth_Declarations (C.Inst, Decls_Chain); + Synth_Declarations (C.Inst, Decls_Chain, No_Net); end if; Set_Wire_Gate (C.W_En, Build_Control_Signal (Syn_Inst, 1, Proc)); @@ -2765,7 +2808,7 @@ package body Synth.Stmts is end Synth_Process_Statement; function Synth_User_Function_Call - (Syn_Inst : Synth_Instance_Acc; Expr : Node) return Valtyp is + (Syn_Inst : Synth_Instance_Acc; Expr : Node; En : Net) return Valtyp is begin -- Is it a call to an ieee function ? declare @@ -2790,9 +2833,10 @@ package body Synth.Stmts is end if; end; - return Synth_Subprogram_Call (Syn_Inst, Expr); + return Synth_Subprogram_Call (Syn_Inst, Expr, En); end Synth_User_Function_Call; + -- Report an assertion failure (that is known to failed). procedure Synth_Failed_Assertion (Syn_Inst : Synth_Instance_Acc; Stmt : Node) is @@ -2800,7 +2844,7 @@ package body Synth.Stmts is Str : Valtyp; begin if Msg /= Null_Node then - Str := Synth_Expression_With_Basetype (Syn_Inst, Msg); + Str := Synth_Expression_With_Basetype (Syn_Inst, Msg, No_Net); else Str := No_Valtyp; end if; @@ -2819,7 +2863,7 @@ package body Synth.Stmts is Val : Valtyp; Inst : Instance; begin - Val := Synth_Expression (Syn_Inst, Cond); + Val := Synth_Expression (Syn_Inst, Cond, No_Net); if Val = No_Valtyp then Set_Error (Syn_Inst); return; @@ -2857,7 +2901,7 @@ package body Synth.Stmts is Mark (M, Proc_Pool); Instance_Pool := Proc_Pool'Access; - Synth_Declarations (Blk_Inst, Get_Declaration_Chain (Blk)); + Synth_Declarations (Blk_Inst, Get_Declaration_Chain (Blk), No_Net); Synth_Concurrent_Statements (Blk_Inst, Get_Concurrent_Statement_Chain (Blk)); @@ -2881,7 +2925,7 @@ package body Synth.Stmts is declare E : constant Vhdl.Types.Vhdl_Node := Get_HDL_Node (Expr); begin - return Get_Net (Synth_Expression (Syn_Inst, E)); + return Get_Net (Synth_Expression (Syn_Inst, E, No_Net)); end; when N_Not_Bool => pragma Assert (Loc /= No_Location); @@ -3173,7 +3217,7 @@ package body Synth.Stmts is Create_Object (Bod_Inst, Iterator, Iterator_Val); end if; - Synth_Declarations (Bod_Inst, Decls_Chain); + Synth_Declarations (Bod_Inst, Decls_Chain, No_Net); Synth_Concurrent_Statements (Bod_Inst, Get_Concurrent_Statement_Chain (Bod)); @@ -3197,7 +3241,7 @@ package body Synth.Stmts is loop Icond := Get_Condition (Gen); if Icond /= Null_Node then - Cond := Synth_Expression (Syn_Inst, Icond); + Cond := Synth_Expression (Syn_Inst, Icond, No_Net); Strip_Const (Cond); else -- It is the else generate. @@ -3274,19 +3318,19 @@ package body Synth.Stmts is case Get_Kind (Stmt) is when Iir_Kind_Concurrent_Simple_Signal_Assignment => Push_Phi; - Synth_Simple_Signal_Assignment (Syn_Inst, Stmt); + Synth_Simple_Signal_Assignment (Syn_Inst, Stmt, No_Net); Pop_And_Merge_Phi (Build_Context, Stmt); when Iir_Kind_Concurrent_Conditional_Signal_Assignment => Push_Phi; - Synth_Conditional_Signal_Assignment (Syn_Inst, Stmt); + Synth_Conditional_Signal_Assignment (Syn_Inst, Stmt, No_Net); Pop_And_Merge_Phi (Build_Context, Stmt); when Iir_Kind_Concurrent_Selected_Signal_Assignment => Push_Phi; - Synth_Selected_Signal_Assignment (Syn_Inst, Stmt); + Synth_Selected_Signal_Assignment (Syn_Inst, Stmt, No_Net); Pop_And_Merge_Phi (Build_Context, Stmt); when Iir_Kind_Concurrent_Procedure_Call_Statement => Push_Phi; - Synth_Procedure_Call (Syn_Inst, Stmt); + Synth_Procedure_Call (Syn_Inst, Stmt, No_Net); Pop_And_Merge_Phi (Build_Context, Stmt); when Iir_Kinds_Process_Statement => Push_Phi; @@ -3348,6 +3392,7 @@ package body Synth.Stmts is end loop; end Synth_Concurrent_Statements; + -- For allconst/allseq/... procedure Synth_Attribute_Formal (Syn_Inst : Synth_Instance_Acc; Val : Node; Id : Netlists.Gates.Formal_Module_Id) @@ -3374,7 +3419,7 @@ package body Synth.Stmts is -- The value must be true V := Synth_Expression_With_Type - (Syn_Inst, Get_Expression (Spec), Boolean_Type); + (Syn_Inst, Get_Expression (Spec), Boolean_Type, No_Net); if Read_Discrete (V) /= 1 then return; end if; @@ -3386,7 +3431,7 @@ package body Synth.Stmts is Base : Valtyp; Typ : Type_Acc; begin - Synth_Assignment_Prefix (Syn_Inst, Sig, Base, Typ, Off, Dyn); + Synth_Assignment_Prefix (Syn_Inst, Sig, No_Net, Base, Typ, Off, Dyn); pragma Assert (Off = (0, 0)); pragma Assert (Dyn.Voff = No_Net); pragma Assert (Base.Val.Kind = Value_Wire); @@ -3395,7 +3440,6 @@ package body Synth.Stmts is N := Build_Formal_Input (Get_Build (Syn_Inst), Id, Typ.W); Add_Conc_Assign (Base.Val.W, N, 0, Val); end; - end Synth_Attribute_Formal; procedure Synth_Attribute_Values @@ -3466,7 +3510,7 @@ package body Synth.Stmts is | Iir_Kind_Procedure_Body | Iir_Kind_Attribute_Declaration | Iir_Kind_Attribute_Specification => - Synth_Declaration (Unit_Inst, Item, False, Last_Type); + Synth_Declaration (Unit_Inst, Item, No_Net, False, Last_Type); when Iir_Kind_Concurrent_Simple_Signal_Assignment => Synth_Concurrent_Statement (Unit_Inst, Item); when others => diff --git a/src/synth/synth-stmts.ads b/src/synth/synth-stmts.ads index 7f449e90c..4710ebb38 100644 --- a/src/synth/synth-stmts.ads +++ b/src/synth/synth-stmts.ads @@ -32,7 +32,8 @@ package Synth.Stmts is procedure Synth_Subprogram_Association (Subprg_Inst : Synth_Instance_Acc; Caller_Inst : Synth_Instance_Acc; Inter_Chain : Node; - Assoc_Chain : Node); + Assoc_Chain : Node; + En : Net); -- Dynamic index for Synth_Assignment_Prefix. -- As dynamic is about dynamic (!) index, the index is a net. @@ -58,6 +59,7 @@ package Synth.Stmts is -- DEST_DYN is set (Voff field set) when there is a non-static index. procedure Synth_Assignment_Prefix (Syn_Inst : Synth_Instance_Acc; Pfx : Node; + En : Net; Dest_Base : out Valtyp; Dest_Typ : out Type_Acc; Dest_Off : out Value_Offsets; @@ -66,7 +68,8 @@ package Synth.Stmts is procedure Synth_Assignment (Syn_Inst : Synth_Instance_Acc; Target : Node; Val : Valtyp; - Loc : Node); + Loc : Node; + En : Net); function Synth_Read_Memory (Syn_Inst : Synth_Instance_Acc; Obj : Valtyp; @@ -76,13 +79,14 @@ package Synth.Stmts is Loc : Node) return Valtyp; function Synth_User_Function_Call - (Syn_Inst : Synth_Instance_Acc; Expr : Node) return Valtyp; + (Syn_Inst : Synth_Instance_Acc; Expr : Node; En : Net) return Valtyp; -- Operation implemented by a user function. function Synth_User_Operator (Syn_Inst : Synth_Instance_Acc; Left_Expr : Node; Right_Expr : Node; - Expr : Node) return Valtyp; + Expr : Node; + En : Net) return Valtyp; -- Generate netlists for concurrent statements STMTS. procedure Synth_Concurrent_Statements |