diff options
Diffstat (limited to 'src/synth/synth-environment.ads')
-rw-r--r-- | src/synth/synth-environment.ads | 96 |
1 files changed, 54 insertions, 42 deletions
diff --git a/src/synth/synth-environment.ads b/src/synth/synth-environment.ads index 90842ef03..70e472ac9 100644 --- a/src/synth/synth-environment.ads +++ b/src/synth/synth-environment.ads @@ -22,9 +22,25 @@ with Tables; with Netlists; use Netlists; with Netlists.Builders; -with Synth.Source; -with Synth.Objtypes; use Synth.Objtypes; +generic + -- Declaration type use for reporting errors. + type Decl_Type is private; + + -- Static value + type Static_Type is private; + + with function Is_Equal (L, R : Static_Type) return Boolean; + with function Get_Width (Val : Static_Type) return Uns32; + with function Static_To_Net (Ctxt : Builders.Context_Acc; Val : Static_Type) + return Net; + with function Partial_Static_To_Net + (Ctxt : Builders.Context_Acc; Val : Static_Type; Off : Uns32; Wd : Uns32) + return Net; + with procedure Warning_No_Assignment + (Decl : Decl_Type; First_Off : Uns32; Last_Off : Uns32); + with procedure Error_Multiple_Assignments + (Decl : Decl_Type; First_Off : Uns32; Last_Off : Uns32); package Synth.Environment is -- This package declares the type Wire_Id and its methods. -- @@ -66,8 +82,7 @@ package Synth.Environment is ); -- Create a wire. - function Alloc_Wire (Kind : Wire_Kind; Typ : Type_Acc; Obj : Source.Syn_Src) - return Wire_Id; + function Alloc_Wire (Kind : Wire_Kind; Decl : Decl_Type) return Wire_Id; -- Mark the wire as free. procedure Free_Wire (Wid : Wire_Id); @@ -117,7 +132,7 @@ package Synth.Environment is (Ctxt : Builders.Context_Acc; Dest : Wire_Id; Val : Net; Offset : Uns32); -- Assign a static value to DEST. VAL is copied. - procedure Phi_Assign_Static (Dest : Wire_Id; Val : Memtyp); + procedure Phi_Assign_Static (Dest : Wire_Id; Val : Static_Type); -- A Phi represent a split in the control flow (two or more branches). type Phi_Type is private; @@ -130,7 +145,7 @@ package Synth.Environment is -- Destroy the current phi context and merge it. Can apply only for the -- first non-top level phi context. procedure Pop_And_Merge_Phi (Ctxt : Builders.Context_Acc; - Stmt : Source.Syn_Src); + Loc : Location_Type); -- All assignments in PHI to wires below MARK are propagated to the -- current phi. Used to propagate assignments to wires defined out of @@ -144,14 +159,17 @@ package Synth.Environment is procedure Merge_Phis (Ctxt : Builders.Context_Acc; Sel : Net; T, F : Phi_Type; - Stmt : Source.Syn_Src); + Loc : Location_Type); -- Create or get (if already created) a net that is true iff the current -- phi is selected. Used to enable sequential assertions. -- Because a wire is created, inference will run on it and therefore -- a dff is created if needed. - function Phi_Enable (Ctxt : Builders.Context_Acc; Loc : Source.Syn_Src) - return Net; + function Phi_Enable (Ctxt : Builders.Context_Acc; + Decl : Decl_Type; + Val_0 : Static_Type; + Val_1 : Static_Type; + Loc : Location_Type) return Net; -- Lower level part. -- Currently public to handle case statements. @@ -175,8 +193,25 @@ package Synth.Environment is type Partial_Assign is private; No_Partial_Assign : constant Partial_Assign; - type Seq_Assign_Value is private; - No_Seq_Assign_Value : constant Seq_Assign_Value; + type Seq_Assign_Value (Is_Static : Tri_State_Type := True) is record + case Is_Static is + when Unknown => + -- Used only for no value (in that case, it will use the previous + -- value). + -- This is used only for temporary handling, and is never stored + -- in Seq_Assign. + null; + when True => + Val : Static_Type; + when False => + -- Values assigned. + Asgns : Partial_Assign; + end case; + end record; + +-- +-- type Seq_Assign_Value is private; +-- No_Seq_Assign_Value : constant Seq_Assign_Value; function Get_Assign_Partial (Asgn : Seq_Assign) return Partial_Assign; function Get_Seq_Assign_Value (Asgn : Seq_Assign) return Seq_Assign_Value; @@ -196,8 +231,8 @@ package Synth.Environment is -- 3) All the values are equal. -- then assign directly. -- WID is used in case of unknown value. - function Is_Assign_Value_Array_Static - (Wid : Wire_Id; Arr : Seq_Assign_Value_Array) return Memtyp; +-- function Is_Assign_Value_Array_Static +-- (Wid : Wire_Id; Arr : Seq_Assign_Value_Array) return Static_Type; type Partial_Assign_List is limited private; @@ -227,8 +262,7 @@ package Synth.Environment is type Conc_Assign is private; No_Conc_Assign : constant Conc_Assign; - procedure Add_Conc_Assign - (Wid : Wire_Id; Val : Net; Off : Uns32; Stmt : Source.Syn_Src); + procedure Add_Conc_Assign (Wid : Wire_Id; Val : Net; Off : Uns32); procedure Finalize_Assignment (Ctxt : Builders.Context_Acc; Wid : Wire_Id); @@ -241,7 +275,7 @@ package Synth.Environment is function Is_Static_Wire (Wid : Wire_Id) return Boolean; -- Return the corresponding net for a static wire. - function Get_Static_Wire (Wid : Wire_Id) return Memtyp; + function Get_Static_Wire (Wid : Wire_Id) return Static_Type; private type Wire_Id is new Uns32; No_Wire_Id : constant Wire_Id := 0; @@ -279,11 +313,8 @@ private -- cleared after usage. Mark_Flag : Boolean; - -- Source node that created the wire. - Decl : Source.Syn_Src; - - -- Type of the net. Only for diagnostic purposes. - Typ : Type_Acc; + -- Source node that created the wire. Only for diagnostic purposes. + Decl : Decl_Type; -- The initial net for the wire. -- This is a pseudo gate that is needed because the value of the wire @@ -301,24 +332,6 @@ private Nbr_Final_Assign : Natural; end record; - type Seq_Assign_Value (Is_Static : Tri_State_Type := True) is record - case Is_Static is - when Unknown => - -- Used only for no value (in that case, it will use the previous - -- value). - -- This is used only for temporary handling, and is never stored - -- in Seq_Assign. - null; - when True => - Val : Memtyp; - when False => - -- Values assigned. - Asgns : Partial_Assign; - end case; - end record; - - No_Seq_Assign_Value : constant Seq_Assign_Value := (Is_Static => Unknown); - type Seq_Assign_Record is record -- Target of the assignment. Id : Wire_Id; @@ -351,9 +364,6 @@ private -- Concurrent assignment at OFFSET. The width is set by value width. Value : Net; Offset : Uns32; - - -- Source of the assignment. Useful to report errors. - Stmt : Source.Syn_Src; end record; type Phi_Type is record @@ -366,6 +376,8 @@ private En : Wire_Id; end record; + No_Seq_Assign_Value : constant Seq_Assign_Value := (Is_Static => Unknown); + package Phis_Table is new Tables (Table_Component_Type => Phi_Type, Table_Index_Type => Phi_Id, |