aboutsummaryrefslogtreecommitdiffstats
path: root/src/simul
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-10-05 20:47:16 +0200
committerTristan Gingold <tgingold@free.fr>2022-10-05 20:47:16 +0200
commit04f4f5139962f51dd87e8ff5f497deef10caef17 (patch)
tree233dc3e72e82047c5cbac2e591b9071d5195dd30 /src/simul
parent2ae368913e5e000ab40f48468cbc6981217861cc (diff)
downloadghdl-04f4f5139962f51dd87e8ff5f497deef10caef17.tar.gz
ghdl-04f4f5139962f51dd87e8ff5f497deef10caef17.tar.bz2
ghdl-04f4f5139962f51dd87e8ff5f497deef10caef17.zip
simul: handle suspendable procedure call from sensitized process.
Diffstat (limited to 'src/simul')
-rw-r--r--src/simul/simul-vhdl_simul.adb10
-rw-r--r--src/simul/simul-vhdl_simul.ads4
2 files changed, 11 insertions, 3 deletions
diff --git a/src/simul/simul-vhdl_simul.adb b/src/simul/simul-vhdl_simul.adb
index a17488fbf..26c2179ea 100644
--- a/src/simul/simul-vhdl_simul.adb
+++ b/src/simul/simul-vhdl_simul.adb
@@ -512,7 +512,7 @@ package body Simul.Vhdl_Simul is
Get_Caller_Instance (Process.Instance);
Resume : Boolean;
begin
- if not Get_Suspend_Flag (Bod) then
+ if not Get_Suspend_Flag (Bod) or else not Process.Has_State then
Process.Instance := Caller_Inst;
-- TODO: free old inst.
Stmt := Null_Node;
@@ -801,7 +801,8 @@ package body Simul.Vhdl_Simul is
Synth.Vhdl_Decls.Synth_Declarations
(Sub_Inst, Get_Declaration_Chain (Bod), True);
- if Get_Suspend_Flag (Bod) then
+ if Process.Has_State and then Get_Suspend_Flag (Bod) then
+ -- The procedure may suspend, in a suspendable process.
Next_Stmt := Get_Sequential_Statement_Chain (Bod);
if Next_Stmt /= Null_Node then
return;
@@ -1892,6 +1893,7 @@ package body Simul.Vhdl_Simul is
Proc := Processes_Table.Table (I).Proc;
Processes_State (I) := (Kind => Kind_Process,
+ Has_State => False,
Top_Instance => Instance,
Proc => Proc,
Idx => I,
@@ -1927,7 +1929,8 @@ package body Simul.Vhdl_Simul is
| Iir_Kind_Concurrent_Procedure_Call_Statement =>
-- As those processes can suspend, they need a dedicated
-- stack.
- Processes_State (I).Pool := new Areapools.Areapool;
+ Current_Process.Pool := new Areapools.Areapool;
+ Current_Process.Has_State := True;
if Get_Postponed_Flag (Proc) then
Ghdl_Postponed_Process_Register (Instance_Grt,
@@ -1942,6 +1945,7 @@ package body Simul.Vhdl_Simul is
when Iir_Kind_Psl_Assert_Directive =>
Processes_State (I) := (Kind => Kind_PSL,
+ Has_State => False,
Top_Instance => Instance,
Proc => Proc,
Idx => I,
diff --git a/src/simul/simul-vhdl_simul.ads b/src/simul/simul-vhdl_simul.ads
index f2cf98212..66a032f22 100644
--- a/src/simul/simul-vhdl_simul.ads
+++ b/src/simul/simul-vhdl_simul.ads
@@ -48,6 +48,10 @@ package Simul.Vhdl_Simul is
-- State associed with each process.
type Process_State_Type (Kind : Process_Kind := Kind_Process) is record
+ -- True if the process has a suspend state.
+ -- (Used for procedure calls)
+ Has_State : Boolean;
+
-- The process instance.
Top_Instance : Synth_Instance_Acc := null;
Proc : Node := Null_Node;