From d4708cc345e3c0a11c33e1ec197285229d1fd113 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sat, 24 Nov 2018 07:26:51 +0100 Subject: trans-rtis: take into account instances in the count of packages. rtis: check number of packages. --- src/grt/grt-rtis.adb | 9 ++++++--- src/vhdl/translate/trans-rtis.adb | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/grt/grt-rtis.adb b/src/grt/grt-rtis.adb index 26d976459..7f4a00ff7 100644 --- a/src/grt/grt-rtis.adb +++ b/src/grt/grt-rtis.adb @@ -24,8 +24,11 @@ -- covered by the GNU Public License. package body Grt.Rtis is + Max_Top_Pkg : Ghdl_Index_Type := 0; + procedure Ghdl_Rti_Add_Package (Pkg : Ghdl_Rti_Access) is begin + pragma Assert (Ghdl_Rti_Top.Nbr_Child < Max_Top_Pkg); Ghdl_Rti_Top.Children (Ghdl_Rti_Top.Nbr_Child) := Pkg; Ghdl_Rti_Top.Nbr_Child := Ghdl_Rti_Top.Nbr_Child + 1; end Ghdl_Rti_Add_Package; @@ -33,10 +36,10 @@ package body Grt.Rtis is procedure Ghdl_Rti_Add_Top (Max_Pkg : Ghdl_Index_Type; Pkgs : Ghdl_Rti_Arr_Acc; Top : Ghdl_Rti_Access; - Instance : Address) - is - pragma Unreferenced (Max_Pkg); + Instance : Address) is begin + Max_Top_Pkg := Max_Pkg; + Ghdl_Rti_Top.Parent := Top; Ghdl_Rti_Top.Children := Pkgs; Ghdl_Rti_Top_Instance := Instance; diff --git a/src/vhdl/translate/trans-rtis.adb b/src/vhdl/translate/trans-rtis.adb index 00ee0a0ee..7a1baf407 100644 --- a/src/vhdl/translate/trans-rtis.adb +++ b/src/vhdl/translate/trans-rtis.adb @@ -2930,6 +2930,7 @@ package body Trans.Rtis is Unit : Iir_Design_Unit; Lib : Iir_Library_Declaration; + Lib_Unit : Iir; Prev : Rti_Block; begin Push_Rti_Node (Prev); @@ -2943,10 +2944,20 @@ package body Trans.Rtis is Lib := Get_Library (Get_Design_File (Unit)); Generate_Library (Lib, True); - if Get_Kind (Get_Library_Unit (Unit)) = Iir_Kind_Package_Declaration - then - Nbr_Pkgs := Nbr_Pkgs + 1; - end if; + -- Count the number of top-level packages. + Lib_Unit := Get_Library_Unit (Unit); + case Get_Kind (Lib_Unit) is + when Iir_Kind_Package_Declaration => + Nbr_Pkgs := Nbr_Pkgs + 1; + when Iir_Kind_Package_Instantiation_Declaration => + if Get_Macro_Expanded_Flag + (Get_Uninstantiated_Package_Decl (Lib_Unit)) + then + Nbr_Pkgs := Nbr_Pkgs + 1; + end if; + when others => + null; + end case; end loop; Pop_Rti_Node (Prev); -- cgit v1.2.3