diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-11-13 22:14:46 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-11-13 22:14:46 +0100 |
commit | d4e80643bc015d6404d9ac23a32cf9c5ff084976 (patch) | |
tree | cfe8c062e2815c2fffcaeb0d1049502b8aa96f69 /src/synth | |
parent | 56735b0d1e92b4246ef53442236e89afe07aacdc (diff) | |
download | ghdl-d4e80643bc015d6404d9ac23a32cf9c5ff084976.tar.gz ghdl-d4e80643bc015d6404d9ac23a32cf9c5ff084976.tar.bz2 ghdl-d4e80643bc015d6404d9ac23a32cf9c5ff084976.zip |
synth: add exec_name_subtype. Fix #1911
Diffstat (limited to 'src/synth')
-rw-r--r-- | src/synth/elab-vhdl_expr.adb | 48 | ||||
-rw-r--r-- | src/synth/elab-vhdl_expr.ads | 4 | ||||
-rw-r--r-- | src/synth/elab-vhdl_types.adb | 4 |
3 files changed, 52 insertions, 4 deletions
diff --git a/src/synth/elab-vhdl_expr.adb b/src/synth/elab-vhdl_expr.adb index 35a92c39d..ff2ef3c9d 100644 --- a/src/synth/elab-vhdl_expr.adb +++ b/src/synth/elab-vhdl_expr.adb @@ -709,10 +709,56 @@ package body Elab.Vhdl_Expr is return Elab.Vhdl_Heap.Synth_Dereference (Read_Access (Val)); end; when others => - Error_Kind ("synth_name", Name); + Error_Kind ("exec_name", Name); end case; end Exec_Name; + function Exec_Name_Subtype (Syn_Inst : Synth_Instance_Acc; Name : Node) + return Type_Acc is + begin + case Get_Kind (Name) is + when Iir_Kind_Simple_Name + | Iir_Kind_Selected_Name => + return Exec_Name_Subtype (Syn_Inst, Get_Named_Entity (Name)); + when Iir_Kind_Interface_Signal_Declaration + | Iir_Kind_Variable_Declaration + | Iir_Kind_Interface_Variable_Declaration + | Iir_Kind_Signal_Declaration + | Iir_Kind_Interface_Constant_Declaration + | Iir_Kind_Constant_Declaration + | Iir_Kind_Iterator_Declaration + | Iir_Kind_Object_Alias_Declaration + | Iir_Kind_File_Declaration + | Iir_Kind_Interface_File_Declaration => + return Get_Value (Syn_Inst, Name).Typ; + when Iir_Kind_Selected_Element => + declare + Idx : constant Iir_Index32 := + Get_Element_Position (Get_Named_Entity (Name)); + Pfx : constant Node := Get_Prefix (Name); + Res : Type_Acc; + begin + Res := Exec_Name_Subtype (Syn_Inst, Pfx); + Res := Res.Rec.E (Idx + 1).Typ; + return Res; + end; + when Iir_Kind_Enumeration_Literal + | Iir_Kind_Unit_Declaration => + return Get_Subtype_Object (Syn_Inst, Get_Type (Name)); + when Iir_Kind_Implicit_Dereference + | Iir_Kind_Dereference => + declare + Val : Valtyp; + begin + Val := Exec_Expression (Syn_Inst, Get_Prefix (Name)); + Val := Elab.Vhdl_Heap.Synth_Dereference (Read_Access (Val)); + return Val.Typ; + end; + when others => + Error_Kind ("exec_name_subtype", Name); + end case; + end Exec_Name_Subtype; + procedure Exec_Assignment_Prefix (Syn_Inst : Synth_Instance_Acc; Pfx : Node; Dest_Base : out Valtyp; diff --git a/src/synth/elab-vhdl_expr.ads b/src/synth/elab-vhdl_expr.ads index 2eac33f1c..77231b1a4 100644 --- a/src/synth/elab-vhdl_expr.ads +++ b/src/synth/elab-vhdl_expr.ads @@ -53,6 +53,10 @@ package Elab.Vhdl_Expr is function Exec_Name (Syn_Inst : Synth_Instance_Acc; Name : Node) return Valtyp; + -- Get the type of NAME. No expressions are expected to be evaluated. + function Exec_Name_Subtype (Syn_Inst : Synth_Instance_Acc; Name : Node) + return Type_Acc; + -- 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. diff --git a/src/synth/elab-vhdl_types.adb b/src/synth/elab-vhdl_types.adb index 1238bec39..300f57427 100644 --- a/src/synth/elab-vhdl_types.adb +++ b/src/synth/elab-vhdl_types.adb @@ -76,15 +76,13 @@ package body Elab.Vhdl_Types is Dim : constant Natural := Vhdl.Evaluation.Eval_Attribute_Parameter_Or_1 (Attr); Typ : Type_Acc; - Val : Valtyp; begin -- Prefix is an array object or an array subtype. if Get_Kind (Prefix) = Iir_Kind_Subtype_Declaration then -- TODO: does this cover all the cases ? Typ := Get_Subtype_Object (Syn_Inst, Get_Subtype_Indication (Prefix)); else - Val := Exec_Name (Syn_Inst, Prefix_Name); - Typ := Val.Typ; + Typ := Exec_Name_Subtype (Syn_Inst, Prefix_Name); end if; return Get_Array_Bound (Typ, Dim_Type (Dim)); |