aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-06-12 06:09:02 +0200
committerTristan Gingold <tgingold@free.fr>2022-06-12 06:32:01 +0200
commitf8ca10e9d4e851ef9e29fb97f1fd7a0956a60a77 (patch)
treea6d456be15120d20581e3cfa8c2491a52f00e1ab
parent4dc88dabe739571c3a8e5136fe7c97f8cc7c0bf3 (diff)
downloadghdl-f8ca10e9d4e851ef9e29fb97f1fd7a0956a60a77.tar.gz
ghdl-f8ca10e9d4e851ef9e29fb97f1fd7a0956a60a77.tar.bz2
ghdl-f8ca10e9d4e851ef9e29fb97f1fd7a0956a60a77.zip
elab-vhdl_insts: eval inertial expressions to get the type. Fix #2089
-rw-r--r--src/synth/elab-vhdl_expr.adb2
-rw-r--r--src/synth/elab-vhdl_insts.adb23
2 files changed, 18 insertions, 7 deletions
diff --git a/src/synth/elab-vhdl_expr.adb b/src/synth/elab-vhdl_expr.adb
index f2f24e5c4..3693f3249 100644
--- a/src/synth/elab-vhdl_expr.adb
+++ b/src/synth/elab-vhdl_expr.adb
@@ -859,7 +859,7 @@ package body Elab.Vhdl_Expr is
return Synth_Subtype_Indication (Syn_Inst, Get_Type (Expr));
when others =>
- Vhdl.Errors.Error_Kind ("synth_type_of_object", Expr);
+ Vhdl.Errors.Error_Kind ("exec_type_of_object", Expr);
end case;
return null;
end Exec_Type_Of_Object;
diff --git a/src/synth/elab-vhdl_insts.adb b/src/synth/elab-vhdl_insts.adb
index d03f75154..a86c94eb1 100644
--- a/src/synth/elab-vhdl_insts.adb
+++ b/src/synth/elab-vhdl_insts.adb
@@ -325,7 +325,10 @@ package body Elab.Vhdl_Insts is
function Elab_Port_Association_Type (Sub_Inst : Synth_Instance_Acc;
Syn_Inst : Synth_Instance_Acc;
Inter : Node;
- Assoc : Node) return Type_Acc is
+ Assoc : Node) return Type_Acc
+ is
+ Inter_Typ : Type_Acc;
+ Val : Valtyp;
begin
if not Is_Fully_Constrained_Type (Get_Type (Inter)) then
-- TODO
@@ -335,7 +338,18 @@ package body Elab.Vhdl_Insts is
if Assoc = Null_Node then
raise Internal_Error;
end if;
- case Get_Kind (Assoc) is
+
+ if Get_Kind (Assoc) = Iir_Kind_Association_Element_By_Expression
+ and then not Get_Inertial_Flag (Assoc)
+ then
+ -- For expression: just compute the expression and associate.
+ Inter_Typ := Elab_Declaration_Type (Sub_Inst, Inter);
+ Val := Exec_Expression_With_Type
+ (Syn_Inst, Get_Actual (Assoc), Inter_Typ);
+ return Val.Typ;
+ end if;
+
+ case Iir_Kinds_Association_Element_Parameters (Get_Kind (Assoc)) is
when Iir_Kinds_Association_Element_By_Actual =>
return Exec_Type_Of_Object (Syn_Inst, Get_Actual (Assoc));
when Iir_Kind_Association_Element_By_Individual =>
@@ -344,8 +358,6 @@ package body Elab.Vhdl_Insts is
when Iir_Kind_Association_Element_Open =>
return Exec_Type_Of_Object
(Syn_Inst, Get_Default_Value (Inter));
- when others =>
- raise Internal_Error;
end case;
else
return Elab_Declaration_Type (Sub_Inst, Inter);
@@ -657,8 +669,7 @@ package body Elab.Vhdl_Insts is
Inter_Typ := Elab_Port_Association_Type
(Comp_Inst, Syn_Inst, Inter, Assoc);
-
- Create_Signal (Comp_Inst, Assoc_Inter, Inter_Typ, null);
+ Create_Signal (Comp_Inst, Inter, Inter_Typ, null);
end if;
Next_Association_Interface (Assoc, Assoc_Inter);
end loop;