aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-12-29 18:32:36 +0100
committerTristan Gingold <tgingold@free.fr>2020-12-29 18:33:58 +0100
commit61315151bc011a063d6a07937fd36068bdff53b6 (patch)
tree2d1fd8cf2e7ac0b0359ffd3a94918963fa0ba31b
parent7ca54117b8f757396ba5ef04c83ff1228ca94384 (diff)
downloadghdl-61315151bc011a063d6a07937fd36068bdff53b6.tar.gz
ghdl-61315151bc011a063d6a07937fd36068bdff53b6.tar.bz2
ghdl-61315151bc011a063d6a07937fd36068bdff53b6.zip
trans-chap3: compute size of subelements for unconstrained parent subtypes
Fix #1549
-rw-r--r--src/synth/synth-insts.adb1
-rw-r--r--src/vhdl/translate/trans-chap3.adb47
2 files changed, 40 insertions, 8 deletions
diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb
index 5c95dce07..3598d594b 100644
--- a/src/synth/synth-insts.adb
+++ b/src/synth/synth-insts.adb
@@ -837,6 +837,7 @@ package body Synth.Insts is
end loop;
if Inst_Obj.Encoding = Name_Parameters then
+ -- Copy values of the generics to module parameters.
declare
Inter : Node;
Vt : Valtyp;
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb
index 0e2474085..6892cad99 100644
--- a/src/vhdl/translate/trans-chap3.adb
+++ b/src/vhdl/translate/trans-chap3.adb
@@ -798,6 +798,42 @@ package body Trans.Chap3 is
Close_Temp;
end Elab_Composite_Subtype_Layout;
+ procedure Elab_Composite_Subtype_Size (Def : Iir; Target : Mnode)
+ is
+ Info : constant Type_Info_Acc := Get_Info (Def);
+ T : Mnode;
+ begin
+ case Type_Mode_Composite (Info.Type_Mode) is
+ when Type_Mode_Static_Record
+ | Type_Mode_Static_Array =>
+ -- Precomputed.
+ null;
+ when Type_Mode_Complex_Record
+ | Type_Mode_Complex_Array =>
+ Open_Temp;
+ T := Stabilize (Target);
+ Gen_Call_Type_Builder (T, Def, Mode_Value);
+ if Get_Has_Signal_Flag (Def) then
+ Gen_Call_Type_Builder (T, Def, Mode_Signal);
+ end if;
+ Close_Temp;
+ when Type_Mode_Unbounded_Record =>
+ null;
+ when Type_Mode_Unbounded_Array =>
+ if Get_Array_Element_Constraint (Def) = Null_Iir then
+ -- Element is defined by the subtype.
+ return;
+ end if;
+ Elab_Composite_Subtype_Size
+ (Get_Element_Subtype (Def),
+ Array_Bounds_To_Element_Layout (Layout_To_Bounds (Target),
+ Def));
+ when Type_Mode_Protected =>
+ -- Not expected.
+ raise Internal_Error;
+ end case;
+ end Elab_Composite_Subtype_Size;
+
procedure Elab_Composite_Subtype_Layout (Def : Iir)
is
Info : constant Type_Info_Acc := Get_Info (Def);
@@ -807,16 +843,11 @@ package body Trans.Chap3 is
return;
end if;
+ -- Fill ranges and length.
Elab_Composite_Subtype_Layout (Def, Get_Composite_Type_Layout (Info));
- if Is_Complex_Type (Info) then
- Gen_Call_Type_Builder
- (Get_Composite_Type_Layout (Info), Def, Mode_Value);
- if Get_Has_Signal_Flag (Def) then
- Gen_Call_Type_Builder
- (Get_Composite_Type_Layout (Info), Def, Mode_Signal);
- end if;
- end if;
+ -- Compute sizes.
+ Elab_Composite_Subtype_Size (Def, Get_Composite_Type_Layout (Info));
end Elab_Composite_Subtype_Layout;
-- Create a variable containing the layout for composite subtype DEF.