diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-12-08 06:23:21 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-12-08 19:32:22 +0100 |
commit | 07a7f419eea89b3ab901642291650f49dfb24a36 (patch) | |
tree | 9b822b1730535ebcc5b5e26492aa4d86e0b4ab1d /src/vhdl/translate | |
parent | ebba3c77dc798f2e20ad6ba8a560a569faf1526b (diff) | |
download | ghdl-07a7f419eea89b3ab901642291650f49dfb24a36.tar.gz ghdl-07a7f419eea89b3ab901642291650f49dfb24a36.tar.bz2 ghdl-07a7f419eea89b3ab901642291650f49dfb24a36.zip |
vhdl: handle locally static attributes on entity/architecture/configurations
Attributes of entity/architecture/configurations are expected to be locally
static so that they can be referenced from outside (so on the non-instantiated
entity).
But many designs break this assumption. In relaxed mode, non-locally static
attributes are allowed but now cannot be referenced outside the entity.
Locally static attributes can be referenced from outside.
Fix #1528
Diffstat (limited to 'src/vhdl/translate')
-rw-r--r-- | src/vhdl/translate/trans-chap5.adb | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/vhdl/translate/trans-chap5.adb b/src/vhdl/translate/trans-chap5.adb index 990392dea..60c44b208 100644 --- a/src/vhdl/translate/trans-chap5.adb +++ b/src/vhdl/translate/trans-chap5.adb @@ -61,13 +61,14 @@ package body Trans.Chap5 is is Spec_Expr : constant Iir := Get_Expression (Spec); Spec_Type : constant Iir := Get_Type (Spec_Expr); - Attr : constant Iir_Attribute_Declaration := + Attr : constant Iir_Attribute_Declaration := Get_Named_Entity (Get_Attribute_Designator (Spec)); - Mark : Id_Mark_Type; - Mark2 : Id_Mark_Type; - Info : Object_Info_Acc; - Val : Iir; - Num : Natural; + Mark : Id_Mark_Type; + Mark2 : Id_Mark_Type; + Info : Object_Info_Acc; + Val : Iir; + Num : Natural; + Vtype : O_Tnode; begin Push_Identifier_Prefix_Uniq (Mark); if Is_Anonymous_Type_Definition (Spec_Type) then @@ -80,10 +81,19 @@ package body Trans.Chap5 is Val := Get_Attribute_Value_Spec_Chain (Spec); while Is_Valid (Val) loop Info := Add_Info (Val, Kind_Object); - Info.Object_Var := Create_Var - (Create_Var_Identifier (Attr, "V", Num), - Chap4.Get_Object_Type (Get_Info (Spec_Type), Mode_Value), - Global_Storage); + Vtype := Chap4.Get_Object_Type (Get_Info (Spec_Type), Mode_Value); + if Get_Static_Attribute_Flag (Spec) + and then Get_Expr_Staticness (Spec_Expr) = Locally + then + -- Create a global var so that the attribute can be referenced + -- from outside. This is possible only if the attribute is + -- locally static. + Info.Object_Var := Create_Global_Var + (Create_Identifier (Attr, "V"), Vtype, Global_Storage); + else + Info.Object_Var := Create_Var + (Create_Var_Identifier (Attr, "V", Num), Vtype, Global_Storage); + end if; -- Create only one object if the expression is static. exit when Get_Expr_Staticness (Spec_Expr) /= None; |