aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vhdl/translate/trans-chap3.adb80
-rw-r--r--src/vhdl/translate/trans-chap6.adb17
-rw-r--r--testsuite/gna/issue418/repro3.vhdl37
-rwxr-xr-xtestsuite/gna/issue418/testsuite.sh3
4 files changed, 95 insertions, 42 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb
index bcb5d5d95..4819083a8 100644
--- a/src/vhdl/translate/trans-chap3.adb
+++ b/src/vhdl/translate/trans-chap3.adb
@@ -1219,44 +1219,44 @@ package body Trans.Chap3 is
-- Base type is complex (unbounded record)
Copy_Complex_Type (Info, Base_Info);
- -- Then create the record type.
- if Get_Type_Staticness (Def) = Locally then
- -- Record is locally constrained: create a new record, containing the
- -- base record and all the fields.
- Info.Ortho_Type (Mode_Signal) := O_Tnode_Null;
- for Kind in Mode_Value .. Type_To_Last_Object_Kind (Def) loop
- Start_Record_Type (Rec);
- New_Record_Field (Rec, Info.S.Box_Field (Kind), Wki_Base,
- Info.B.Base_Type (Kind));
- for I in Natural loop
- B_El := Get_Nth_Element (El_Blist, I);
- exit when B_El = Null_Iir;
+ -- Then create the record type, containing the base record and the
+ -- fields.
+ Info.Ortho_Type (Mode_Signal) := O_Tnode_Null;
+ for Kind in Mode_Value .. Type_To_Last_Object_Kind (Def) loop
+ Start_Record_Type (Rec);
+ New_Record_Field (Rec, Info.S.Box_Field (Kind), Wki_Base,
+ Info.B.Base_Type (Kind));
+ for I in Natural loop
+ B_El := Get_Nth_Element (El_Blist, I);
+ exit when B_El = Null_Iir;
- if Is_Unbounded_Type (Get_Info (Get_Type (B_El))) then
- El := Get_Nth_Element (El_List, I);
- if Kind = Mode_Value then
- Field_Info := Add_Info (El, Kind_Field);
- else
- Field_Info := Get_Info (El);
- end if;
- El := Get_Nth_Element (El_List, I);
- El_Tinfo := Get_Info (Get_Type (El));
- El_Tnode := El_Tinfo.Ortho_Type (Kind);
- New_Record_Field (Rec, Field_Info.Field_Node (Kind),
- Create_Identifier_Without_Prefix (El),
- El_Tnode);
+ El := Get_Nth_Element (El_List, I);
+
+ -- This element has been locally constrained.
+ if Is_Unbounded_Type (Get_Info (Get_Type (B_El)))
+ and then
+ Get_Type_Staticness (Get_Type(El)) = Locally
+ then
+ if Kind = Mode_Value then
+ Field_Info := Add_Info (El, Kind_Field);
+ else
+ Field_Info := Get_Info (El);
end if;
- end loop;
- Finish_Record_Type (Rec, Info.Ortho_Type (Kind));
+ El := Get_Nth_Element (El_List, I);
+ El_Tinfo := Get_Info (Get_Type (El));
+ El_Tnode := El_Tinfo.Ortho_Type (Kind);
+ New_Record_Field (Rec, Field_Info.Field_Node (Kind),
+ Create_Identifier_Without_Prefix (El),
+ El_Tnode);
+ end if;
end loop;
+ Finish_Record_Type (Rec, Info.Ortho_Type (Kind));
+ end loop;
- Finish_Type_Definition (Info);
- else
- -- Not locally constrained, but still constrained.
- -- Objects have to be dynamically allocated and built.
+ Finish_Type_Definition (Info);
+
+ if Get_Type_Staticness (Def) /= Locally then
Create_Size_Var (Def, Info);
- Info.Ortho_Type := Info.B.Base_Type;
- Info.Ortho_Ptr_Type := Info.B.Base_Ptr_Type;
end if;
if With_Vars then
@@ -2011,7 +2011,7 @@ package body Trans.Chap3 is
-- Start with the size of the 'base' record, that
-- contains all non-complex types and an offset for
-- each complex types.
- Res := New_Lit (New_Sizeof (Info.B.Base_Type (Kind), Ghdl_Index_Type));
+ Res := New_Lit (New_Sizeof (Info.Ortho_Type (Kind), Ghdl_Index_Type));
-- Start with alignment of the record.
-- ALIGN = ALIGNOF (record)
@@ -2020,7 +2020,7 @@ package body Trans.Chap3 is
Align_Var := Create_Temp (Ghdl_Index_Type);
New_Assign_Stmt
(New_Obj (Align_Var),
- Get_Type_Alignmask (Info.B.Base_Type (Kind)));
+ Get_Type_Alignmask (Info.Ortho_Type (Kind)));
when Mode_Signal =>
Res := Realign (Res, Ghdl_Signal_Ptr);
end case;
@@ -2030,8 +2030,10 @@ package body Trans.Chap3 is
exit when El = Null_Iir;
El_Type := Get_Type (El);
El_Tinfo := Get_Info (El_Type);
- if Is_Complex_Type (El_Tinfo)
- or else Get_Kind (El) = Iir_Kind_Record_Element_Constraint
+ if Get_Type_Staticness (El_Type) /= Locally
+ and then
+ (Is_Complex_Type (El_Tinfo)
+ or else Get_Kind (El) = Iir_Kind_Record_Element_Constraint)
then
Inner_Type := Get_Innermost_Non_Array_Element (El_Type);
@@ -2048,10 +2050,10 @@ package body Trans.Chap3 is
(Get_Ortho_Type (Inner_Type, Mode_Value))));
Res := Realign (Res, Inner_Type);
end if;
+
Res := New_Dyadic_Op
(ON_Add_Ov,
- New_Value (Get_Var (El_Tinfo.C (Kind).Size_Var)),
- Res);
+ Res, New_Value (Get_Var (El_Tinfo.C (Kind).Size_Var)));
end if;
end loop;
if Kind = Mode_Value then
diff --git a/src/vhdl/translate/trans-chap6.adb b/src/vhdl/translate/trans-chap6.adb
index 3c2b55cf1..5838562f3 100644
--- a/src/vhdl/translate/trans-chap6.adb
+++ b/src/vhdl/translate/trans-chap6.adb
@@ -855,11 +855,22 @@ package body Trans.Chap6 is
Base_Tinfo := Get_Type_Info (Base);
Box_Field := Base_Tinfo.S.Box_Field (Kind);
- if Box_Field = O_Fnode_Null
+ if (Box_Field = O_Fnode_Null
+ or else Get_Type_Staticness (El_Type) /= Locally)
and then (Is_Complex_Type (El_Tinfo) or Is_Unbounded_Type (El_Tinfo))
then
- -- The element is complex: it's an offset.
Stabilize (Base);
+
+ if Box_Field /= O_Fnode_Null
+ and then Get_Type_Staticness (El_Type) /= Locally
+ then
+ -- Unbox.
+ B := New_Selected_Element (M2Lv (Base), Box_Field);
+ else
+ B := M2Lv (Base);
+ end if;
+
+ -- The element is complex: it's an offset.
Res := E2M
(New_Unchecked_Address
(New_Slice
@@ -867,7 +878,7 @@ package body Trans.Chap6 is
(New_Unchecked_Address (M2Lv (Base), Char_Ptr_Type)),
Chararray_Type,
New_Value
- (New_Selected_Element (M2Lv (Base),
+ (New_Selected_Element (B,
El_Info.Field_Node (Kind)))),
El_Tinfo.B.Base_Ptr_Type (Kind)),
El_Tinfo, Kind);
diff --git a/testsuite/gna/issue418/repro3.vhdl b/testsuite/gna/issue418/repro3.vhdl
new file mode 100644
index 000000000..b9f2182e9
--- /dev/null
+++ b/testsuite/gna/issue418/repro3.vhdl
@@ -0,0 +1,37 @@
+entity repro3 is
+ generic (blen : natural := 8);
+end;
+
+architecture behav of repro3 is
+ -- AXI-Lite Interface signals
+ type address_channel is record
+ --DUT inputs
+ awaddr : bit_vector;
+ awvalid : bit;
+ end record;
+
+
+ type t_if is record
+ write_channel : address_channel;
+ data : bit_vector (blen - 1 downto 0);
+ end record;
+
+ subtype ST_IF_32 is t_if (
+ write_channel (
+ awaddr(31 downto 0) )
+ );
+
+ signal s : st_if_32;
+begin
+ s.write_channel.awaddr <= x"0000_1000", x"1000_ffff" after 2 ns;
+ s.data <= (others => '1');
+ process
+ begin
+ wait for 1 ns;
+ assert s.write_channel.awvalid = '0';
+ assert s.write_channel.awaddr(12) = '1';
+ wait for 2 ns;
+ assert s.write_channel.awaddr(14) = '1';
+ wait;
+ end process;
+end;
diff --git a/testsuite/gna/issue418/testsuite.sh b/testsuite/gna/issue418/testsuite.sh
index 111e0e6d6..ffbba4d1c 100755
--- a/testsuite/gna/issue418/testsuite.sh
+++ b/testsuite/gna/issue418/testsuite.sh
@@ -19,6 +19,9 @@ if ghdl_has_feature repro2 ghw; then
# How to test the ghw ? Use ghwdump ?
fi
+analyze repro3.vhdl
+elab_simulate repro3
+
clean
rm -f repro.ghw repro2.ghw tc749.ghw