diff options
Diffstat (limited to 'src/vhdl/simulate')
-rw-r--r-- | src/vhdl/simulate/simul-annotations.adb | 77 | ||||
-rw-r--r-- | src/vhdl/simulate/simul-annotations.ads | 2 | ||||
-rw-r--r-- | src/vhdl/simulate/simul-elaboration.adb | 15 | ||||
-rw-r--r-- | src/vhdl/simulate/simul-elaboration.ads | 2 | ||||
-rw-r--r-- | src/vhdl/simulate/simul-environments.ads | 7 | ||||
-rw-r--r-- | src/vhdl/simulate/simul-execution.adb | 37 |
6 files changed, 77 insertions, 63 deletions
diff --git a/src/vhdl/simulate/simul-annotations.adb b/src/vhdl/simulate/simul-annotations.adb index 551974a88..50700eda7 100644 --- a/src/vhdl/simulate/simul-annotations.adb +++ b/src/vhdl/simulate/simul-annotations.adb @@ -107,6 +107,7 @@ package body Simul.Annotations is when Kind_Block | Kind_Process | Kind_Frame + | Kind_Package | Kind_Scalar_Type | Kind_File_Type | Kind_Extra => @@ -1043,29 +1044,24 @@ package body Simul.Annotations is Current_Scope := (Kind => Scope_Kind_None); end Annotate_Architecture; - procedure Annotate_Package (Decl: Iir_Package_Declaration) + procedure Annotate_Package + (Block_Info : Sim_Info_Acc; Decl: Iir_Package_Declaration) is Prev_Scope : constant Scope_Type := Current_Scope; - Package_Info: Sim_Info_Acc; + Package_Info : Sim_Info_Acc; Header : Iir; begin pragma Assert (Current_Scope.Kind = Scope_Kind_None); - if Get_Kind (Decl) = Iir_Kind_Package_Instantiation_Declaration - or else not Is_Uninstantiated_Package (Decl) - then - Nbr_Packages := Nbr_Packages + 1; - Current_Scope := (Scope_Kind_Package, Nbr_Packages); - else - Increment_Current_Scope; - end if; + Increment_Current_Scope; + Block_Info.Nbr_Objects := Block_Info.Nbr_Objects + 1; Package_Info := new Sim_Info_Type' - (Kind => Kind_Block, - Inst_Slot => Invalid_Instance_Slot, + (Kind => Kind_Package, Frame_Scope => Current_Scope, Nbr_Objects => 0, - Nbr_Instances => 0); + Pkg_Slot => Block_Info.Nbr_Objects, + Pkg_Parent => Block_Info); Set_Info (Decl, Package_Info); @@ -1146,22 +1142,19 @@ package body Simul.Annotations is end Annotate_Block_Configuration; procedure Annotate_Configuration_Declaration - (Decl : Iir_Configuration_Declaration) + (Block_Info : Sim_Info_Acc; Decl : Iir_Configuration_Declaration) is Config_Info: Sim_Info_Acc; begin pragma Assert (Current_Scope.Kind = Scope_Kind_None); - Nbr_Packages := Nbr_Packages + 1; - Current_Scope := (Scope_Kind_Package, Nbr_Packages); - + Block_Info.Nbr_Objects := Block_Info.Nbr_Objects + 1; Config_Info := new Sim_Info_Type' - (Kind => Kind_Block, - Inst_Slot => Invalid_Instance_Slot, + (Kind => Kind_Package, Frame_Scope => Current_Scope, Nbr_Objects => 0, - Nbr_Instances => 0); - + Pkg_Slot => Block_Info.Nbr_Objects, + Pkg_Parent => Block_Info); Set_Info (Decl, Config_Info); Annotate_Declaration_List (Config_Info, Get_Declaration_Chain (Decl)); @@ -1202,24 +1195,34 @@ package body Simul.Annotations is when Iir_Kind_Architecture_Body => Annotate_Architecture (El); when Iir_Kind_Package_Declaration => - Annotate_Package (El); declare use Std_Package; begin if El = Standard_Package then + pragma Assert (Global_Info = null); + Global_Info := + new Sim_Info_Type'(Kind => Kind_Block, + Frame_Scope => Current_Scope, + Nbr_Objects => 0, + Inst_Slot => Invalid_Instance_Slot, + Nbr_Instances => 0); + Annotate_Package (Global_Info, El); -- These types are not in std.standard! Annotate_Type_Definition (Get_Info (El), Convertible_Integer_Type_Definition); Annotate_Type_Definition (Get_Info (El), Convertible_Real_Type_Definition); + else + pragma Assert (Global_Info /= null); + Annotate_Package (Global_Info, El); end if; end; when Iir_Kind_Package_Body => Annotate_Package_Body (El); when Iir_Kind_Configuration_Declaration => - Annotate_Configuration_Declaration (El); + Annotate_Configuration_Declaration (Global_Info, El); when Iir_Kind_Package_Instantiation_Declaration => - Annotate_Package (El); + Annotate_Package (Global_Info, El); when Iir_Kind_Context_Declaration => null; when others => @@ -1259,7 +1262,9 @@ package body Simul.Annotations is Put_Line ("-- nbr objects:" & Object_Slot_Type'Image (Info.Nbr_Objects)); - when Kind_Frame | Kind_Process => + when Kind_Frame + | Kind_Process + | Kind_Package => Put_Line ("-- scope:" & Image (Info.Frame_Scope)); Set_Col (Indent); Put_Line @@ -1291,17 +1296,25 @@ package body Simul.Annotations is return; end if; case Info.Kind is - when Kind_Block | Kind_Frame | Kind_Process => + when Kind_Block + | Kind_Frame + | Kind_Process + | Kind_Package => Put_Line ("scope:" & Image (Info.Frame_Scope)); Set_Col (Indent); - Put_Line ("inst_slot:" - & Instance_Slot_Type'Image (Info.Inst_Slot)); - Set_Col (Indent); Put_Line ("nbr objects:" & Object_Slot_Type'Image (Info.Nbr_Objects)); - Set_Col (Indent); - Put_Line ("nbr instance:" - & Instance_Slot_Type'Image (Info.Nbr_Instances)); + case Info.Kind is + when Kind_Block => + Set_Col (Indent); + Put_Line ("inst_slot:" + & Instance_Slot_Type'Image (Info.Inst_Slot)); + Set_Col (Indent); + Put_Line ("nbr instance:" + & Instance_Slot_Type'Image (Info.Nbr_Instances)); + when others => + null; + end case; when Kind_Object | Kind_Signal | Kind_File | Kind_Terminal | Kind_Quantity | Kind_Environment | Kind_PSL => diff --git a/src/vhdl/simulate/simul-annotations.ads b/src/vhdl/simulate/simul-annotations.ads index f4991b093..3965d7b74 100644 --- a/src/vhdl/simulate/simul-annotations.ads +++ b/src/vhdl/simulate/simul-annotations.ads @@ -27,7 +27,7 @@ package Simul.Annotations is procedure Disp_Vhdl_Info (Node : Iir); procedure Disp_Tree_Info (Node : Iir); - Nbr_Packages : Pkg_Index_Type := 0; + Global_Info : Sim_Info_Acc; -- Annotations are used to collect informations for elaboration and to -- locate iir_value_literal for signals, variables or constants. diff --git a/src/vhdl/simulate/simul-elaboration.adb b/src/vhdl/simulate/simul-elaboration.adb index 21fe3001b..5300046a3 100644 --- a/src/vhdl/simulate/simul-elaboration.adb +++ b/src/vhdl/simulate/simul-elaboration.adb @@ -380,7 +380,7 @@ package body Simul.Elaboration is begin Instance := Create_Block_Instance (null, Decl, Decl); - Package_Instances (Package_Info.Frame_Scope.Pkg_Index) := Instance; + Package_Instances (Package_Info.Pkg_Slot) := Instance; if Trace_Elaboration then Report_Msg (Msgid_Note, Errorout.Elaboration, No_Location, @@ -414,7 +414,7 @@ package body Simul.Elaboration is Package_Info : constant Sim_Info_Acc := Get_Info (Decl); Instance : Block_Instance_Acc; begin - Instance := Package_Instances (Package_Info.Frame_Scope.Pkg_Index); + Instance := Package_Instances (Package_Info.Pkg_Slot); if Trace_Elaboration then Report_Msg (Msgid_Note, Errorout.Elaboration, No_Location, @@ -438,7 +438,7 @@ package body Simul.Elaboration is Instance := Create_Block_Instance (null, Decl, Decl); - Package_Instances (Config_Info.Frame_Scope.Pkg_Index) := Instance; + Package_Instances (Config_Info.Pkg_Slot) := Instance; -- Elaborate objects declarations. Elaborate_Declarative_Part (Instance, Get_Declaration_Chain (Decl)); @@ -485,8 +485,7 @@ package body Simul.Elaboration is Body_Design: Iir_Design_Unit; begin if not Is_Uninstantiated_Package (Library_Unit) - and then - Package_Instances (Info.Frame_Scope.Pkg_Index) = null + and then Package_Instances (Info.Pkg_Slot) = null then -- Package not yet elaborated. @@ -531,8 +530,7 @@ package body Simul.Elaboration is declare Info : constant Sim_Info_Acc := Get_Info (Library_Unit); begin - if Package_Instances (Info.Frame_Scope.Pkg_Index) = null - then + if Package_Instances (Info.Pkg_Slot) = null then -- Package not yet elaborated. -- First the packages on which DESIGN depends. @@ -2910,7 +2908,8 @@ package body Simul.Elaboration is Generic_Map : Iir; Port_Map : Iir; begin - Package_Instances := new Package_Instances_Array (1 .. Nbr_Packages); + Package_Instances := + new Package_Instances_Array (1 .. Global_Info.Nbr_Objects); -- Use a 'fake' process to execute code during elaboration. Current_Process := No_Process; diff --git a/src/vhdl/simulate/simul-elaboration.ads b/src/vhdl/simulate/simul-elaboration.ads index a469ead00..66a3cba19 100644 --- a/src/vhdl/simulate/simul-elaboration.ads +++ b/src/vhdl/simulate/simul-elaboration.ads @@ -82,7 +82,7 @@ package Simul.Elaboration is type Block_Instance_Acc_Array is array (Instance_Slot_Type range <>) of Block_Instance_Acc; - type Package_Instances_Array is array (Pkg_Index_Type range <>) of + type Package_Instances_Array is array (Object_Slot_Type range <>) of Block_Instance_Acc; type Package_Instances_Array_Acc is access Package_Instances_Array; diff --git a/src/vhdl/simulate/simul-environments.ads b/src/vhdl/simulate/simul-environments.ads index ad5e0b59f..c8ccd912f 100644 --- a/src/vhdl/simulate/simul-environments.ads +++ b/src/vhdl/simulate/simul-environments.ads @@ -254,7 +254,7 @@ package Simul.Environments is -- The annotation depends on the kind of the node. type Sim_Info_Kind is - (Kind_Block, Kind_Process, Kind_Frame, + (Kind_Block, Kind_Process, Kind_Frame, Kind_Package, Kind_Scalar_Type, Kind_File_Type, Kind_Object, Kind_Signal, Kind_File, @@ -275,6 +275,7 @@ package Simul.Environments is when Kind_Block | Kind_Frame | Kind_Process + | Kind_Package | Kind_Environment => -- Scope level for this frame. Frame_Scope : Scope_Type; @@ -293,6 +294,10 @@ package Simul.Environments is when Kind_Environment => Env_Slot : Object_Slot_Type; + when Kind_Package => + Pkg_Slot : Object_Slot_Type; + Pkg_Parent : Sim_Info_Acc; + when others => null; end case; diff --git a/src/vhdl/simulate/simul-execution.adb b/src/vhdl/simulate/simul-execution.adb index e7ea76fe2..d07b927a7 100644 --- a/src/vhdl/simulate/simul-execution.adb +++ b/src/vhdl/simulate/simul-execution.adb @@ -68,38 +68,35 @@ package body Simul.Execution is (Instance: Block_Instance_Acc; Scope: Sim_Info_Acc) return Block_Instance_Acc is begin - case Scope.Frame_Scope.Kind is - when Scope_Kind_Frame => + case Scope.Kind is + when Kind_Block + | Kind_Frame + | Kind_Process => declare Current : Block_Instance_Acc; - Last : Block_Instance_Acc; + -- Last : Block_Instance_Acc; begin Current := Instance; while Current /= null loop if Current.Block_Scope = Scope then return Current; end if; - Last := Current; + -- Last := Current; Current := Current.Up_Block; end loop; - if Scope.Frame_Scope.Depth = 0 - and then (Last.Block_Scope.Frame_Scope.Kind - = Scope_Kind_Package) - then - -- For instantiated packages. - return Last; - end if; + -- if Scope.Frame_Scope.Depth = 0 + -- and then (Last.Block_Scope.Frame_Scope.Kind + -- = Scope_Kind_Package) + -- then + -- -- For instantiated packages. + -- return Last; + -- end if; raise Internal_Error; end; - when Scope_Kind_Package => - -- Global scope (packages) - return Package_Instances (Scope.Frame_Scope.Pkg_Index); - when Scope_Kind_Component => - pragma Assert (Current_Component /= null); - return Current_Component; - when Scope_Kind_None => - raise Internal_Error; - when Scope_Kind_Pkg_Inst => + when Kind_Package => + pragma Assert (Scope.Pkg_Parent = Global_Info); + return Package_Instances (Scope.Pkg_Slot); + when others => raise Internal_Error; end case; end Get_Instance_By_Scope; |