aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-12-05 04:19:31 +0100
committerTristan Gingold <tgingold@free.fr>2017-12-05 04:19:31 +0100
commit6fa695890d8ccae675f3606d25e2bb58bbfb243e (patch)
tree6b3814438df8372f66705b3426add91802f7af6a /src
parenta3a8739ce5e5cf51e32366c8fbc6eb47ed562964 (diff)
downloadghdl-6fa695890d8ccae675f3606d25e2bb58bbfb243e.tar.gz
ghdl-6fa695890d8ccae675f3606d25e2bb58bbfb243e.tar.bz2
ghdl-6fa695890d8ccae675f3606d25e2bb58bbfb243e.zip
simul: handle instantiated package.
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/simulate/simul-annotations.adb15
-rw-r--r--src/vhdl/simulate/simul-elaboration.adb7
-rw-r--r--src/vhdl/simulate/simul-environments.ads5
-rw-r--r--src/vhdl/simulate/simul-execution.adb30
4 files changed, 46 insertions, 11 deletions
diff --git a/src/vhdl/simulate/simul-annotations.adb b/src/vhdl/simulate/simul-annotations.adb
index 5999b694d..f270b9bc7 100644
--- a/src/vhdl/simulate/simul-annotations.adb
+++ b/src/vhdl/simulate/simul-annotations.adb
@@ -531,18 +531,25 @@ package body Simul.Annotations is
Annotate_Interface_List (Info, Get_Port_Chain (Comp), True);
end Annotate_Component_Declaration;
+ -- For package declaration or package instantiation declaration.
procedure Annotate_Package_Declaration
- (Block_Info : Sim_Info_Acc; Decl: Iir_Package_Declaration)
+ (Block_Info : Sim_Info_Acc; Decl: Iir)
is
Package_Info : Sim_Info_Acc;
Header : Iir;
begin
- Block_Info.Nbr_Objects := Block_Info.Nbr_Objects + 1;
Package_Info := new Sim_Info_Type'
(Kind => Kind_Package,
Nbr_Objects => 0,
- Pkg_Slot => Block_Info.Nbr_Objects,
- Pkg_Parent => Block_Info);
+ Pkg_Slot => Invalid_Object_Slot,
+ Pkg_Parent => null);
+ if Get_Kind (Decl) = Iir_Kind_Package_Instantiation_Declaration
+ or else not Is_Uninstantiated_Package (Decl)
+ then
+ Block_Info.Nbr_Objects := Block_Info.Nbr_Objects + 1;
+ Package_Info.Pkg_Slot := Block_Info.Nbr_Objects;
+ Package_Info.Pkg_Parent := Block_Info;
+ end if;
Set_Info (Decl, Package_Info);
diff --git a/src/vhdl/simulate/simul-elaboration.adb b/src/vhdl/simulate/simul-elaboration.adb
index d60e643af..9ca1e5eaf 100644
--- a/src/vhdl/simulate/simul-elaboration.adb
+++ b/src/vhdl/simulate/simul-elaboration.adb
@@ -345,6 +345,7 @@ package body Simul.Elaboration is
(Max_Objs => Obj_Info.Nbr_Objects,
Id => Nbr_Block_Instances,
Block_Scope => Obj_Info,
+ Uninst_Scope => null,
Up_Block => Father,
Label => Stmt,
Stmt => Obj,
@@ -406,9 +407,12 @@ package body Simul.Elaboration is
-- Elaborate the body now.
declare
Uninst : constant Iir := Get_Uninstantiated_Package_Decl (Decl);
+ Uninst_Info : constant Sim_Info_Acc := Get_Info (Uninst);
+ Bod : constant Iir := Get_Package_Body (Uninst);
begin
+ Instance.Uninst_Scope := Uninst_Info;
Elaborate_Declarative_Part
- (Instance, Get_Declaration_Chain (Get_Package_Body (Uninst)));
+ (Instance, Get_Declaration_Chain (Bod));
end;
end if;
end Elaborate_Package_Declaration;
@@ -2958,6 +2962,7 @@ package body Simul.Elaboration is
In_Wait_Flag => False,
Id => 0,
Block_Scope => Global_Info,
+ Uninst_Scope => null,
Up_Block => null,
Label => Null_Iir,
Stmt => Null_Iir,
diff --git a/src/vhdl/simulate/simul-environments.ads b/src/vhdl/simulate/simul-environments.ads
index 5369c477a..be20e402a 100644
--- a/src/vhdl/simulate/simul-environments.ads
+++ b/src/vhdl/simulate/simul-environments.ads
@@ -214,6 +214,10 @@ package Simul.Environments is
end record;
type Object_Slot_Type is new Natural;
+
+ -- This slot is not used.
+ Invalid_Object_Slot : constant Object_Slot_Type := 0;
+
subtype Parameter_Slot_Type is Object_Slot_Type range 0 .. 2**15;
type Pkg_Index_Type is new Natural;
@@ -308,6 +312,7 @@ package Simul.Environments is
-- Useful informations for a dynamic block (ie, a frame).
-- The scope level and an access to the block of upper scope level.
Block_Scope : Sim_Info_Acc;
+ Uninst_Scope : Sim_Info_Acc;
Up_Block : Block_Instance_Acc;
-- Block, architecture, package, process, component instantiation for
diff --git a/src/vhdl/simulate/simul-execution.adb b/src/vhdl/simulate/simul-execution.adb
index e49ea69df..9622b98c7 100644
--- a/src/vhdl/simulate/simul-execution.adb
+++ b/src/vhdl/simulate/simul-execution.adb
@@ -94,12 +94,29 @@ package body Simul.Execution is
raise Internal_Error;
end;
when Kind_Package =>
- declare
- Parent : Block_Instance_Acc;
- begin
- Parent := Get_Instance_By_Scope (Instance, Scope.Pkg_Parent);
- return Parent.Objects (Scope.Pkg_Slot).Instance;
- end;
+ if Scope.Pkg_Parent = null then
+ -- This is a scope for an uninstantiated package.
+ declare
+ Current : Block_Instance_Acc;
+ begin
+ Current := Instance;
+ while Current /= null loop
+ if Current.Uninst_Scope = Scope then
+ return Current;
+ end if;
+ Current := Current.Up_Block;
+ end loop;
+ raise Internal_Error;
+ end;
+ else
+ -- Instantiated package.
+ declare
+ Parent : Block_Instance_Acc;
+ begin
+ Parent := Get_Instance_By_Scope (Instance, Scope.Pkg_Parent);
+ return Parent.Objects (Scope.Pkg_Slot).Instance;
+ end;
+ end if;
when others =>
raise Internal_Error;
end case;
@@ -3309,6 +3326,7 @@ package body Simul.Execution is
Block_Instance_Type'(Max_Objs => Func_Info.Nbr_Objects,
Id => No_Block_Instance_Id,
Block_Scope => Get_Info (Label),
+ Uninst_Scope => null,
Up_Block => Up_Block,
Label => Label,
Stmt => Null_Iir,