diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/synth/synth-context.adb | 8 | ||||
-rw-r--r-- | src/synth/synth-decls.adb | 19 | ||||
-rw-r--r-- | src/synth/synth-expr.adb | 3 | ||||
-rw-r--r-- | src/synth/synth-stmts.adb | 37 | ||||
-rw-r--r-- | src/synth/synth-stmts.ads | 7 | ||||
-rw-r--r-- | src/synth/synth-values.adb | 13 | ||||
-rw-r--r-- | src/synth/synth-values.ads | 11 |
7 files changed, 86 insertions, 12 deletions
diff --git a/src/synth/synth-context.adb b/src/synth/synth-context.adb index 48a0114b3..d7af882b5 100644 --- a/src/synth/synth-context.adb +++ b/src/synth/synth-context.adb @@ -436,6 +436,14 @@ package body Synth.Context is Build (Build_Context, C, Res); return Res; end; + when Value_Alias => + declare + Res : Net; + begin + Res := Get_Current_Value (Build_Context, Val.A_Wid); + return Build_Extract (Build_Context, Res, Val.A_Off, + Get_Type_Width (Val.Typ)); + end; when others => raise Internal_Error; end case; diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb index 2382558bd..d411ded68 100644 --- a/src/synth/synth-decls.adb +++ b/src/synth/synth-decls.adb @@ -22,14 +22,17 @@ with Types; use Types; with Mutils; use Mutils; with Netlists; use Netlists; with Netlists.Builders; use Netlists.Builders; + with Vhdl.Errors; use Vhdl.Errors; with Vhdl.Utils; use Vhdl.Utils; -with Vhdl.Ieee.Std_Logic_1164; with Vhdl.Std_Package; +with Vhdl.Ieee.Std_Logic_1164; +with Vhdl.Annotations; use Vhdl.Annotations; + with Synth.Values; use Synth.Values; with Synth.Environment; use Synth.Environment; with Synth.Expr; use Synth.Expr; -with Vhdl.Annotations; use Vhdl.Annotations; +with Synth.Stmts; package body Synth.Decls is procedure Synth_Anonymous_Subtype_Indication @@ -464,6 +467,18 @@ package body Synth.Decls is end if; Create_Var_Wire (Syn_Inst, Decl, Init); end; + when Iir_Kind_Object_Alias_Declaration => + Synth_Declaration_Type (Syn_Inst, Decl); + declare + Wid : Wire_Id; + Off : Uns32; + Typ : Type_Acc; + begin + Stmts.Synth_Assignment_Prefix (Syn_Inst, Get_Name (Decl), + Wid, Off, Typ); + Create_Object (Syn_Inst, Decl, + Create_Value_Alias (Wid, Off, Typ)); + end; when Iir_Kind_Anonymous_Signal_Declaration => Make_Object (Syn_Inst, Wire_Signal, Decl); Create_Var_Wire (Syn_Inst, Decl, null); diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index da6ea7190..d0abeec7b 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -1532,7 +1532,8 @@ package body Synth.Expr is | Iir_Kind_Anonymous_Signal_Declaration | Iir_Kind_Interface_Constant_Declaration | Iir_Kind_Constant_Declaration - | Iir_Kind_Iterator_Declaration => + | Iir_Kind_Iterator_Declaration + | Iir_Kind_Object_Alias_Declaration => return Get_Value (Syn_Inst, Name); when Iir_Kind_Enumeration_Literal => return Create_Value_Discrete diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index a97a00558..a651f5e07 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -39,7 +39,6 @@ with Synth.Types; use Synth.Types; with Synth.Errors; use Synth.Errors; with Synth.Decls; use Synth.Decls; with Synth.Expr; use Synth.Expr; -with Synth.Environment; use Synth.Environment; with Synth.Insts; use Synth.Insts; with Synth.Source; @@ -121,14 +120,13 @@ package body Synth.Stmts is procedure Synth_Assignment_Prefix (Syn_Inst : Synth_Instance_Acc; Pfx : Node; - Loc : Node; Dest_Wid : out Wire_Id; Dest_Off : out Uns32; Dest_Type : out Type_Acc) is begin case Get_Kind (Pfx) is when Iir_Kind_Simple_Name => - Synth_Assignment_Prefix (Syn_Inst, Get_Named_Entity (Pfx), Loc, + Synth_Assignment_Prefix (Syn_Inst, Get_Named_Entity (Pfx), Dest_Wid, Dest_Off, Dest_Type); when Iir_Kind_Interface_Signal_Declaration | Iir_Kind_Variable_Declaration @@ -148,7 +146,7 @@ package body Synth.Stmts is Off : Uns32; W : Width; begin - Synth_Assignment_Prefix (Syn_Inst, Get_Prefix (Pfx), Loc, + Synth_Assignment_Prefix (Syn_Inst, Get_Prefix (Pfx), Dest_Wid, Dest_Off, Dest_Type); Synth_Indexed_Name (Syn_Inst, Pfx, Dest_Type, Voff, Mul, Off, W); @@ -171,12 +169,35 @@ package body Synth.Stmts is Idx : constant Iir_Index32 := Get_Element_Position (Get_Named_Entity (Pfx)); begin - Synth_Assignment_Prefix (Syn_Inst, Get_Prefix (Pfx), Loc, + Synth_Assignment_Prefix (Syn_Inst, Get_Prefix (Pfx), Dest_Wid, Dest_Off, Dest_Type); Dest_Off := Dest_Off + Dest_Type.Rec.E (Idx + 1).Off; Dest_Type := Dest_Type.Rec.E (Idx + 1).Typ; end; + when Iir_Kind_Slice_Name => + declare + Res_Bnd : Bound_Type; + Inp : Net; + Step : Uns32; + Sl_Off : Int32; + Wd : Uns32; + begin + Synth_Assignment_Prefix (Syn_Inst, Get_Prefix (Pfx), + Dest_Wid, Dest_Off, Dest_Type); + Synth_Slice_Suffix (Syn_Inst, Pfx, Dest_Type.Vbound, + Res_Bnd, Inp, Step, Sl_Off, Wd); + + if Inp /= No_Net then + Error_Msg_Synth + (+Pfx, "dynamic index must be the last suffix"); + return; + end if; + + Dest_Type := Create_Vector_Type (Res_Bnd, Dest_Type.Vec_El); + Dest_Off := Dest_Off + Uns32 (Sl_Off); + end; + when others => Error_Kind ("synth_assignment_prefix", Pfx); end case; @@ -201,7 +222,7 @@ package body Synth.Stmts is Off : Uns32; Typ : Type_Acc; begin - Synth_Assignment_Prefix (Syn_Inst, Target, Loc, Wid, Off, Typ); + Synth_Assignment_Prefix (Syn_Inst, Target, Wid, Off, Typ); Synth_Assign (Wid, Typ, Val, Off, Loc); end; when Iir_Kind_Indexed_Name => @@ -218,7 +239,7 @@ package body Synth.Stmts is Targ_Net : Net; V : Net; begin - Synth_Assignment_Prefix (Syn_Inst, Get_Prefix (Target), Loc, + Synth_Assignment_Prefix (Syn_Inst, Get_Prefix (Target), Wid, Off, Typ); Synth_Indexed_Name (Syn_Inst, Target, Typ, Voff, Mul, Idx_Off, W); @@ -254,7 +275,7 @@ package body Synth.Stmts is Res_Type : Type_Acc; V : Net; begin - Synth_Assignment_Prefix (Syn_Inst, Get_Prefix (Target), Loc, + Synth_Assignment_Prefix (Syn_Inst, Get_Prefix (Target), Wid, Off, Typ); Synth_Slice_Suffix (Syn_Inst, Target, Typ.Vbound, Res_Bnd, Inp, Step, Sl_Off, Wd); diff --git a/src/synth/synth-stmts.ads b/src/synth/synth-stmts.ads index cdd26e8eb..884ea299b 100644 --- a/src/synth/synth-stmts.ads +++ b/src/synth/synth-stmts.ads @@ -22,6 +22,7 @@ with Types; use Types; with Vhdl.Nodes; use Vhdl.Nodes; with Synth.Values; use Synth.Values; with Synth.Context; use Synth.Context; +with Synth.Environment; use Synth.Environment; package Synth.Stmts is procedure Synth_Subprogram_Association (Subprg_Inst : Synth_Instance_Acc; @@ -29,6 +30,12 @@ package Synth.Stmts is Inter_Chain : Node; Assoc_Chain : Node); + procedure Synth_Assignment_Prefix (Syn_Inst : Synth_Instance_Acc; + Pfx : Node; + Dest_Wid : out Wire_Id; + Dest_Off : out Uns32; + Dest_Type : out Type_Acc); + procedure Synth_Assignment (Syn_Inst : Synth_Instance_Acc; Target : Node; Val : Value_Acc; diff --git a/src/synth/synth-values.adb b/src/synth/synth-values.adb index ded8e6a1b..6265a64dd 100644 --- a/src/synth/synth-values.adb +++ b/src/synth/synth-values.adb @@ -401,6 +401,19 @@ package body Synth.Values is (Kind => Value_Subtype, Typ => Typ))); end Create_Value_Subtype; + function Create_Value_Alias (Wid : Wire_Id; Off : Uns32; Typ : Type_Acc) + return Value_Acc + is + subtype Value_Type_Alias is Value_Type (Value_Alias); + function Alloc is new Areapools.Alloc_On_Pool_Addr (Value_Type_Alias); + begin + return To_Value_Acc (Alloc (Current_Pool, + (Kind => Value_Alias, + A_Wid => Wid, + A_Off => Off, + Typ => Typ))); + end Create_Value_Alias; + function Copy (Src: in Value_Acc) return Value_Acc is Res: Value_Acc; diff --git a/src/synth/synth-values.ads b/src/synth/synth-values.ads index e7d5acc20..a0db0f5fb 100644 --- a/src/synth/synth-values.ads +++ b/src/synth/synth-values.ads @@ -147,7 +147,10 @@ package Synth.Values is -- A package. Value_Instance, - -- A subtype. + -- An alias + Value_Alias, + + -- A subtype. Contains only a type. Value_Subtype ); @@ -191,6 +194,9 @@ package Synth.Values is Rec : Value_Array_Acc; when Value_Instance => Instance : Instance_Id; + when Value_Alias => + A_Wid : Wire_Id; + A_Off : Uns32; end case; end record; @@ -262,6 +268,9 @@ package Synth.Values is function Create_Value_Instance (Inst : Instance_Id) return Value_Acc; + function Create_Value_Alias (Wid : Wire_Id; Off : Uns32; Typ : Type_Acc) + return Value_Acc; + function Unshare (Src : Value_Acc; Pool : Areapool_Acc) return Value_Acc; |