summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Gingold2016-01-17 06:55:46 +0100
committerTristan Gingold2016-01-19 19:54:41 +0100
commit22d04ec32c8c0457cfa5043c10f0d6f0575e5720 (patch)
tree6344225c686a1082e4e05560fca90ad69953e3a2
parent1e2aeb2a4635f24c60384232e319b682b0d99f3c (diff)
downloadghdl-22d04ec32c8c0457cfa5043c10f0d6f0575e5720.tar.gz
ghdl-22d04ec32c8c0457cfa5043c10f0d6f0575e5720.tar.bz2
ghdl-22d04ec32c8c0457cfa5043c10f0d6f0575e5720.zip
simulate: fix handling of deferred constants.
-rw-r--r--src/vhdl/simulate/annotations.adb4
-rw-r--r--src/vhdl/simulate/debugger.adb2
-rw-r--r--src/vhdl/simulate/elaboration.adb41
-rw-r--r--src/vhdl/simulate/execution.adb2
4 files changed, 30 insertions, 19 deletions
diff --git a/src/vhdl/simulate/annotations.adb b/src/vhdl/simulate/annotations.adb
index 10ca72e..b282903 100644
--- a/src/vhdl/simulate/annotations.adb
+++ b/src/vhdl/simulate/annotations.adb
@@ -583,8 +583,6 @@ package body Annotations is
Annotate_Anonymous_Type_Definition
(Block_Info, Get_Type (Decl));
Create_Object_Info (Block_Info, Decl);
- else
- Set_Info (Decl, Get_Info (Get_Deferred_Declaration (Decl)));
end if;
when Iir_Kind_File_Declaration =>
@@ -716,7 +714,7 @@ package body Annotations is
null;
when Iir_Kind_Return_Statement =>
null;
- when Iir_Kind_Signal_Assignment_Statement
+ when Iir_Kind_Simple_Signal_Assignment_Statement
| Iir_Kind_Variable_Assignment_Statement =>
null;
when Iir_Kind_Procedure_Call_Statement =>
diff --git a/src/vhdl/simulate/debugger.adb b/src/vhdl/simulate/debugger.adb
index a2532f2..c1d8460 100644
--- a/src/vhdl/simulate/debugger.adb
+++ b/src/vhdl/simulate/debugger.adb
@@ -1426,7 +1426,7 @@ package body Debugger is
Handler.all (N);
when Iir_Kind_Variable_Assignment_Statement
- | Iir_Kind_Signal_Assignment_Statement
+ | Iir_Kind_Simple_Signal_Assignment_Statement
| Iir_Kind_Null_Statement
| Iir_Kind_Assertion_Statement
| Iir_Kind_Report_Statement
diff --git a/src/vhdl/simulate/elaboration.adb b/src/vhdl/simulate/elaboration.adb
index 5e7109d..b85b452 100644
--- a/src/vhdl/simulate/elaboration.adb
+++ b/src/vhdl/simulate/elaboration.adb
@@ -2195,22 +2195,35 @@ package body Elaboration is
Instance.Objects (Get_Info (Decl).Slot) :=
Unshare (Val, Instance_Pool);
when Iir_Kind_Constant_Declaration =>
- -- Elaboration of an object declaration that declares an object
- -- other then a file object proceeds as follows:
- -- 1. The subtype indication is first elaborated.
- -- This establishes the subtype of the object.
- if Get_Deferred_Declaration_Flag (Decl) then
- Create_Object (Instance, Decl);
- else
- Elaborate_Subtype_Indication_If_Anonymous
- (Instance, Get_Type (Decl));
- Val := Elaborate_Default_Value (Instance, Decl);
- if Get_Deferred_Declaration (Decl) = Null_Iir then
+ declare
+ Deferred_Decl : constant Iir := Get_Deferred_Declaration (Decl);
+ First_Decl : Iir;
+ begin
+ if Deferred_Decl = Null_Iir
+ or else Get_Deferred_Declaration_Flag (Decl)
+ then
+ -- Create the object (except for full declaration of a
+ -- deferred constant).
+ Elaborate_Subtype_Indication_If_Anonymous
+ (Instance, Get_Type (Decl));
Create_Object (Instance, Decl);
end if;
- Instance.Objects (Get_Info (Decl).Slot) :=
- Unshare (Val, Instance_Pool);
- end if;
+ -- Initialize the value (except for a deferred declaration).
+ if Deferred_Decl = Null_Iir then
+ First_Decl := Decl;
+ elsif not Get_Deferred_Declaration_Flag (Decl) then
+ First_Decl := Deferred_Decl;
+ else
+ First_Decl := Null_Iir;
+ end if;
+ if First_Decl /= Null_Iir then
+ Val := Execute_Expression_With_Type
+ (Instance, Get_Default_Value (Decl),
+ Get_Type (First_Decl));
+ Instance.Objects (Get_Info (First_Decl).Slot) :=
+ Unshare (Val, Instance_Pool);
+ end if;
+ end;
when Iir_Kind_File_Declaration =>
-- LRM93 12.3.1.4
-- Elaboration of a file object declaration consists of the
diff --git a/src/vhdl/simulate/execution.adb b/src/vhdl/simulate/execution.adb
index ba97d3d..b19a7dd 100644
--- a/src/vhdl/simulate/execution.adb
+++ b/src/vhdl/simulate/execution.adb
@@ -4782,7 +4782,7 @@ package body Execution is
when Iir_Kind_If_Statement =>
Execute_If_Statement (Proc, Stmt);
- when Iir_Kind_Signal_Assignment_Statement =>
+ when Iir_Kind_Simple_Signal_Assignment_Statement =>
Execute_Signal_Assignment (Instance, Stmt);
Update_Next_Statement (Proc);