aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-12-03 20:56:44 +0100
committerTristan Gingold <tgingold@free.fr>2017-12-03 20:56:44 +0100
commit57cc5b5215f018ac0e5d9c5c16a5ad7c39c67cf1 (patch)
treece3b92c1926bad6547f535383dfd250454bb219c /src
parent68c02ac97cbb64be2fcf99a4050fd8ae4066be48 (diff)
downloadghdl-57cc5b5215f018ac0e5d9c5c16a5ad7c39c67cf1.tar.gz
ghdl-57cc5b5215f018ac0e5d9c5c16a5ad7c39c67cf1.tar.bz2
ghdl-57cc5b5215f018ac0e5d9c5c16a5ad7c39c67cf1.zip
simul: add iir_value_instance, remove package_instances.
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/simulate/simul-debugger.adb14
-rw-r--r--src/vhdl/simulate/simul-elaboration.adb58
-rw-r--r--src/vhdl/simulate/simul-elaboration.ads7
-rw-r--r--src/vhdl/simulate/simul-environments.adb27
-rw-r--r--src/vhdl/simulate/simul-environments.ads5
-rw-r--r--src/vhdl/simulate/simul-execution.adb2
-rw-r--r--src/vhdl/simulate/simul-simulation-main.adb2
-rw-r--r--src/vhdl/simulate/simul-simulation.adb1
8 files changed, 81 insertions, 35 deletions
diff --git a/src/vhdl/simulate/simul-debugger.adb b/src/vhdl/simulate/simul-debugger.adb
index 08e96320f..74c46c017 100644
--- a/src/vhdl/simulate/simul-debugger.adb
+++ b/src/vhdl/simulate/simul-debugger.adb
@@ -300,9 +300,9 @@ package body Simul.Debugger is
procedure Disp_Instances_Tree is
begin
- for I in Package_Instances'Range loop
- if Package_Instances (I) /= null then
- Disp_Instances_Tree_Name (Package_Instances (I));
+ for I in Global_Instances.Objects'Range loop
+ if Global_Instances.Objects (I) /= null then
+ Disp_Instances_Tree_Name (Global_Instances.Objects (I).Instance);
end if;
end loop;
Disp_Instances_Tree_Name (Top_Instance);
@@ -386,6 +386,7 @@ package body Simul.Debugger is
| Iir_Value_Protected
| Iir_Value_Quantity
| Iir_Value_Terminal
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;
@@ -1298,9 +1299,10 @@ package body Simul.Debugger is
Put_Line ("design not yet fully elaborated");
return;
end if;
- for I in Package_Instances'Range loop
- if Package_Instances (I) /= null then
- Put (Get_Instance_Local_Name (Package_Instances (I)));
+ for I in Global_Instances.Objects'Range loop
+ if Global_Instances.Objects (I) /= null then
+ Put (Get_Instance_Local_Name
+ (Global_Instances.Objects (I).Instance));
Put_Line (" [package]");
end if;
end loop;
diff --git a/src/vhdl/simulate/simul-elaboration.adb b/src/vhdl/simulate/simul-elaboration.adb
index 5300046a3..bd4d3f875 100644
--- a/src/vhdl/simulate/simul-elaboration.adb
+++ b/src/vhdl/simulate/simul-elaboration.adb
@@ -64,10 +64,9 @@ package body Simul.Elaboration is
Port_Map : Iir)
return Block_Instance_Acc;
- procedure Create_Object
- (Instance : Block_Instance_Acc;
- Slot : Object_Slot_Type;
- Num : Object_Slot_Type := 1) is
+ procedure Create_Object (Instance : Block_Instance_Acc;
+ Slot : Object_Slot_Type;
+ Num : Object_Slot_Type := 1) is
begin
-- Check elaboration order.
-- Note: this is not done for package since objects from package are
@@ -150,6 +149,7 @@ package body Simul.Elaboration is
| Iir_Value_Protected
| Iir_Value_Quantity
| Iir_Value_Terminal
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;
@@ -373,14 +373,17 @@ package body Simul.Elaboration is
return Res;
end Create_Block_Instance;
- procedure Elaborate_Package (Decl: Iir)
+ procedure Elaborate_Package (Block : Block_Instance_Acc; Decl : Iir)
is
Package_Info : constant Sim_Info_Acc := Get_Info (Decl);
Instance : Block_Instance_Acc;
begin
- Instance := Create_Block_Instance (null, Decl, Decl);
+ Instance := Create_Block_Instance (Block, Decl, Decl);
- Package_Instances (Package_Info.Pkg_Slot) := Instance;
+ pragma Assert (Block.Block_Scope = Package_Info.Pkg_Parent);
+ pragma Assert (Block.Objects (Package_Info.Pkg_Slot) = null);
+ Block.Objects (Package_Info.Pkg_Slot) :=
+ Create_Instance_Value (Instance);
if Trace_Elaboration then
Report_Msg (Msgid_Note, Errorout.Elaboration, No_Location,
@@ -409,13 +412,12 @@ package body Simul.Elaboration is
end if;
end Elaborate_Package;
- procedure Elaborate_Package_Body (Decl: Iir)
+ procedure Elaborate_Package_Body (Block : Block_Instance_Acc; Decl: Iir)
is
Package_Info : constant Sim_Info_Acc := Get_Info (Decl);
- Instance : Block_Instance_Acc;
+ Instance : constant Block_Instance_Acc :=
+ Block.Objects (Package_Info.Pkg_Slot).Instance;
begin
- Instance := Package_Instances (Package_Info.Pkg_Slot);
-
if Trace_Elaboration then
Report_Msg (Msgid_Note, Errorout.Elaboration, No_Location,
"elaborating %n", (1 => +Decl));
@@ -436,9 +438,10 @@ package body Simul.Elaboration is
return;
end if;
- Instance := Create_Block_Instance (null, Decl, Decl);
+ Instance := Create_Block_Instance (Global_Instances, Decl, Decl);
- Package_Instances (Config_Info.Pkg_Slot) := Instance;
+ Global_Instances.Objects (Config_Info.Pkg_Slot) :=
+ Create_Instance_Value (Instance);
-- Elaborate objects declarations.
Elaborate_Declarative_Part (Instance, Get_Declaration_Chain (Decl));
@@ -485,7 +488,7 @@ package body Simul.Elaboration is
Body_Design: Iir_Design_Unit;
begin
if not Is_Uninstantiated_Package (Library_Unit)
- and then Package_Instances (Info.Pkg_Slot) = null
+ and then Global_Instances.Objects (Info.Pkg_Slot) = null
then
-- Package not yet elaborated.
@@ -508,7 +511,7 @@ package body Simul.Elaboration is
Elaborate_Dependence (Design);
-- Then the declaration.
- Elaborate_Package (Library_Unit);
+ Elaborate_Package (Global_Instances, Library_Unit);
-- And then the body (if any).
if Body_Design = Null_Iir then
@@ -522,7 +525,7 @@ package body Simul.Elaboration is
Elaborate_Dependence (Body_Design);
Elaborate_Package_Body
- (Get_Library_Unit (Body_Design));
+ (Global_Instances, Get_Library_Unit (Body_Design));
end if;
end if;
end;
@@ -530,14 +533,14 @@ package body Simul.Elaboration is
declare
Info : constant Sim_Info_Acc := Get_Info (Library_Unit);
begin
- if Package_Instances (Info.Pkg_Slot) = null then
+ if Global_Instances.Objects (Info.Pkg_Slot) = null then
-- Package not yet elaborated.
-- First the packages on which DESIGN depends.
Elaborate_Dependence (Design);
-- Then the declaration.
- Elaborate_Package (Library_Unit);
+ Elaborate_Package (Global_Instances, Library_Unit);
end if;
end;
when Iir_Kind_Entity_Declaration
@@ -2908,8 +2911,23 @@ package body Simul.Elaboration is
Generic_Map : Iir;
Port_Map : Iir;
begin
- Package_Instances :=
- new Package_Instances_Array (1 .. Global_Info.Nbr_Objects);
+ Global_Instances :=
+ new Block_Instance_Type'(Max_Objs => Global_Info.Nbr_Objects,
+ In_Wait_Flag => False,
+ Id => 0,
+ Block_Scope => Global_Info,
+ Up_Block => null,
+ Label => Null_Iir,
+ Stmt => Null_Iir,
+ Parent => null,
+ Children => null,
+ Brother => null,
+ Ports_Map => Null_Iir,
+ Marker => Empty_Marker,
+ Actuals_Ref => null,
+ Result => null,
+ Elab_Objects => 0,
+ Objects => (others => null));
-- 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 66a3cba19..50c7fdfb4 100644
--- a/src/vhdl/simulate/simul-elaboration.ads
+++ b/src/vhdl/simulate/simul-elaboration.ads
@@ -77,17 +77,12 @@ package Simul.Elaboration is
procedure Create_Object (Instance : Block_Instance_Acc; Decl : Iir);
procedure Create_Signal (Instance : Block_Instance_Acc; Decl : Iir);
+ Global_Instances : Block_Instance_Acc;
Top_Instance: Block_Instance_Acc;
type Block_Instance_Acc_Array is array (Instance_Slot_Type range <>) of
Block_Instance_Acc;
- type Package_Instances_Array is array (Object_Slot_Type range <>) of
- Block_Instance_Acc;
- type Package_Instances_Array_Acc is access Package_Instances_Array;
-
- Package_Instances : Package_Instances_Array_Acc;
-
-- Disconnections. For each disconnection specification, the elaborator
-- adds an entry in the table.
type Disconnection_Entry is record
diff --git a/src/vhdl/simulate/simul-environments.adb b/src/vhdl/simulate/simul-environments.adb
index 16f9bc3f0..aaf44e562 100644
--- a/src/vhdl/simulate/simul-environments.adb
+++ b/src/vhdl/simulate/simul-environments.adb
@@ -87,6 +87,7 @@ package body Simul.Environments is
| Iir_Value_Protected
| Iir_Value_Quantity
| Iir_Value_Terminal
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;
@@ -194,6 +195,7 @@ package body Simul.Environments is
| Iir_Value_Protected
| Iir_Value_Quantity
| Iir_Value_Terminal
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;
@@ -237,6 +239,7 @@ package body Simul.Environments is
| Iir_Value_Protected
| Iir_Value_Quantity
| Iir_Value_Terminal
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;
@@ -285,6 +288,7 @@ package body Simul.Environments is
when Iir_Value_Range
| Iir_Value_Quantity
| Iir_Value_Terminal
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;
@@ -328,6 +332,7 @@ package body Simul.Environments is
| Iir_Value_Protected
| Iir_Value_Quantity
| Iir_Value_Terminal
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;
@@ -393,9 +398,20 @@ package body Simul.Environments is
(Kind => Iir_Value_Environment, Environment => Env)));
end Create_Environment_Value;
- function Create_Protected_Value (Prot : Protected_Index_Type)
+ function Create_Instance_Value (Inst : Block_Instance_Acc)
return Iir_Value_Literal_Acc
is
+ subtype Instance_Value is Iir_Value_Literal (Iir_Value_Instance);
+ function Alloc is new Alloc_On_Pool_Addr (Instance_Value);
+ begin
+ return To_Iir_Value_Literal_Acc
+ (Alloc (Global_Pool'Access,
+ (Kind => Iir_Value_Instance, Instance => Inst)));
+ end Create_Instance_Value;
+
+ function Create_Protected_Value (Prot : Protected_Index_Type)
+ return Iir_Value_Literal_Acc
+ is
subtype Protected_Value is Iir_Value_Literal (Iir_Value_Protected);
function Alloc is new Alloc_On_Pool_Addr (Protected_Value);
begin
@@ -691,7 +707,8 @@ package body Simul.Environments is
return Create_Environment_Value (Src.Environment);
when Iir_Value_Quantity
- | Iir_Value_Terminal =>
+ | Iir_Value_Terminal
+ | Iir_Value_Instance =>
raise Internal_Error;
end case;
end Copy;
@@ -791,6 +808,7 @@ package body Simul.Environments is
| Iir_Value_Protected
| Iir_Value_Terminal
| Iir_Value_Quantity
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;
@@ -915,6 +933,8 @@ package body Simul.Environments is
Put_Line ("quantity");
when Iir_Value_Terminal =>
Put_Line ("terminal");
+ when Iir_Value_Instance =>
+ Put_Line ("instance");
when Iir_Value_Environment =>
Put_Line ("environment");
end case;
@@ -935,6 +955,7 @@ package body Simul.Environments is
| Iir_Value_Protected
| Iir_Value_Quantity
| Iir_Value_Terminal
+ | Iir_Value_Instance
| Iir_Value_Environment =>
return False;
when Iir_Value_Range =>
@@ -1120,6 +1141,8 @@ package body Simul.Environments is
Put ("[signal]");
when Iir_Value_Protected =>
Put ("[protected]");
+ when Iir_Value_Instance =>
+ Put ("[instance]");
when Iir_Value_Environment =>
Put ("[environment]");
end case;
diff --git a/src/vhdl/simulate/simul-environments.ads b/src/vhdl/simulate/simul-environments.ads
index bdfa4bfe4..5369c477a 100644
--- a/src/vhdl/simulate/simul-environments.ads
+++ b/src/vhdl/simulate/simul-environments.ads
@@ -113,6 +113,7 @@ package Simul.Environments is
Iir_Value_Signal,
Iir_Value_Terminal,
Iir_Value_Quantity,
+ Iir_Value_Instance,
Iir_Value_Environment);
-- Uniq identifier for scalar signal. First identifier is 'First + 1.
@@ -200,6 +201,8 @@ package Simul.Environments is
Quantity : Quantity_Index_Type;
when Iir_Value_Terminal =>
Terminal : Terminal_Index_Type;
+ when Iir_Value_Instance =>
+ Instance : Block_Instance_Acc;
when Iir_Value_Environment =>
Environment : Environment_Index_Type;
when Iir_Value_Range =>
@@ -375,6 +378,8 @@ package Simul.Environments is
return Iir_Value_Literal_Acc;
function Create_Environment_Value (Env : Environment_Index_Type)
return Iir_Value_Literal_Acc;
+ function Create_Instance_Value (Inst : Block_Instance_Acc)
+ return Iir_Value_Literal_Acc;
function Create_B1_Value (Val : Ghdl_B1) return Iir_Value_Literal_Acc;
function Create_E8_Value (Val : Ghdl_E8) return Iir_Value_Literal_Acc;
diff --git a/src/vhdl/simulate/simul-execution.adb b/src/vhdl/simulate/simul-execution.adb
index d07b927a7..7876c04ba 100644
--- a/src/vhdl/simulate/simul-execution.adb
+++ b/src/vhdl/simulate/simul-execution.adb
@@ -95,7 +95,7 @@ package body Simul.Execution is
end;
when Kind_Package =>
pragma Assert (Scope.Pkg_Parent = Global_Info);
- return Package_Instances (Scope.Pkg_Slot);
+ return Global_Instances.Objects (Scope.Pkg_Slot).Instance;
when others =>
raise Internal_Error;
end case;
diff --git a/src/vhdl/simulate/simul-simulation-main.adb b/src/vhdl/simulate/simul-simulation-main.adb
index 4614b2746..f55705d2c 100644
--- a/src/vhdl/simulate/simul-simulation-main.adb
+++ b/src/vhdl/simulate/simul-simulation-main.adb
@@ -570,6 +570,7 @@ package body Simul.Simulation.Main is
| Iir_Value_Terminal
| Iir_Value_Quantity
| Iir_Value_File
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;
@@ -1040,6 +1041,7 @@ package body Simul.Simulation.Main is
| Iir_Value_Protected
| Iir_Value_Quantity
| Iir_Value_Terminal
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;
diff --git a/src/vhdl/simulate/simul-simulation.adb b/src/vhdl/simulate/simul-simulation.adb
index cc8c4aa51..73036c4a3 100644
--- a/src/vhdl/simulate/simul-simulation.adb
+++ b/src/vhdl/simulate/simul-simulation.adb
@@ -458,6 +458,7 @@ package body Simul.Simulation is
| Iir_Value_Protected
| Iir_Value_Quantity
| Iir_Value_Terminal
+ | Iir_Value_Instance
| Iir_Value_Environment =>
raise Internal_Error;
end case;