aboutsummaryrefslogtreecommitdiffstats
path: root/src/grt/grt-processes.ads
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2015-09-04 21:52:38 +0200
committerTristan Gingold <tgingold@free.fr>2015-09-04 21:52:38 +0200
commit8520993b4d1eadefa488dfc96dff25333f1b19db (patch)
tree818d4fe917d3e6b765932ed3d1ab1ee70dc3c508 /src/grt/grt-processes.ads
parent2d8f611cb63b72aa0373efe0ffa0df47e25519c9 (diff)
downloadghdl-8520993b4d1eadefa488dfc96dff25333f1b19db.tar.gz
ghdl-8520993b4d1eadefa488dfc96dff25333f1b19db.tar.bz2
ghdl-8520993b4d1eadefa488dfc96dff25333f1b19db.zip
Suppress stack switching; save process state in secondary stack.
Diffstat (limited to 'src/grt/grt-processes.ads')
-rw-r--r--src/grt/grt-processes.ads67
1 files changed, 35 insertions, 32 deletions
diff --git a/src/grt/grt-processes.ads b/src/grt/grt-processes.ads
index 2d953ecf1..ecef800d4 100644
--- a/src/grt/grt-processes.ads
+++ b/src/grt/grt-processes.ads
@@ -23,10 +23,10 @@
-- however invalidate any other reasons why the executable file might be
-- covered by the GNU Public License.
with System;
+with Ada.Unchecked_Conversion;
with Grt.Stack2; use Grt.Stack2;
with Grt.Types; use Grt.Types;
with Grt.Signals; use Grt.Signals;
-with Grt.Stacks; use Grt.Stacks;
with Grt.Rtis; use Grt.Rtis;
with Grt.Rtis_Addr;
with Grt.Stdio;
@@ -51,10 +51,6 @@ package Grt.Processes is
-- If true, the simulation should be stopped.
Break_Simulation : Boolean;
- -- If true, there is one stack for all processes. Non-sensitized
- -- processes must save their state.
- One_Stack : Boolean := False;
-
type Process_Type is private;
-- type Process_Acc is access all Process_Type;
@@ -74,6 +70,21 @@ package Grt.Processes is
-- Disp the name of process PROC.
procedure Disp_Process_Name (Stream : Grt.Stdio.FILEs; Proc : Process_Acc);
+ -- Instance is the parameter of the process procedure.
+ -- This is in fact a fully opaque type whose content is private to the
+ -- process.
+ type Instance is limited private;
+ type Instance_Acc is access all Instance;
+ pragma Convention (C, Instance_Acc);
+
+ -- A process is identified by a procedure having a single private
+ -- parameter (its instance).
+ type Proc_Acc is access procedure (Self : Instance_Acc);
+ pragma Convention (C, Proc_Acc);
+
+ function To_Address is new Ada.Unchecked_Conversion
+ (Instance_Acc, System.Address);
+
-- Register a process during elaboration.
-- This procedure is called by vhdl elaboration code.
procedure Ghdl_Process_Register (Instance : Instance_Acc;
@@ -131,16 +142,12 @@ package Grt.Processes is
-- Add a sensitivity for a wait.
procedure Ghdl_Process_Wait_Add_Sensitivity (Sig : Ghdl_Signal_Ptr);
-- Wait until timeout or sensitivity.
- -- Return TRUE in case of timeout.
- function Ghdl_Process_Wait_Suspend return Boolean;
+ procedure Ghdl_Process_Wait_Suspend;
+ -- Return TRUE if woken up by a timeout.
+ function Ghdl_Process_Wait_Timed_Out return Boolean;
-- Finish a wait statement.
procedure Ghdl_Process_Wait_Close;
- -- For one stack setups, wait_suspend is decomposed into the suspension
- -- procedure and the function to get resume status.
- procedure Ghdl_Process_Wait_Wait;
- function Ghdl_Process_Wait_Has_Timeout return Boolean;
-
-- Verilog.
procedure Ghdl_Process_Delay (Del : Ghdl_U32);
@@ -156,14 +163,9 @@ package Grt.Processes is
procedure Ghdl_Protected_Init (Obj : System.Address);
procedure Ghdl_Protected_Fini (Obj : System.Address);
- type Run_Handler is access function return Integer;
-
- -- Run HAND through a wrapper that catch some errors (in particular on
- -- windows). Returns < 0 in case of error.
- function Run_Through_Longjump (Hand : Run_Handler) return Integer;
- pragma Import (Ada, Run_Through_Longjump, "__ghdl_run_through_longjump");
-
private
+ type Instance is null record;
+
-- State of a process.
type Process_State is
(
@@ -173,10 +175,11 @@ private
-- Non-sensitized process, ready to run.
State_Ready,
- -- Verilog process, being suspended.
+ -- Non-sensitized process being suspended on a timeout (without
+ -- sensitivity).
State_Delayed,
- -- Non-sensitized process being suspended.
+ -- Non-sensitized process being suspended, with sensitivity.
State_Wait,
-- Non-sensitized process being awaked by a wait timeout. This state
@@ -189,35 +192,33 @@ private
State_Dead);
type Process_Type is record
- -- Stack for the process.
- -- This must be the first field of the record (and this is the only
- -- part visible).
- -- Must be NULL_STACK for sensitized processes.
- Stack : Stacks.Stack_Type;
-
-- Subprogram containing process code.
Subprg : Proc_Acc;
-- Instance (THIS parameter) for the subprogram.
This : Instance_Acc;
- -- Name of the process.
- Rti : Rtis_Addr.Rti_Context;
-
-- True if the process is resumed and will be run at next cycle.
Resumed : Boolean;
-- True if the process is postponed.
Postponed : Boolean;
+ -- State of the process.
State : Process_State;
- -- Timeout value for wait.
- Timeout : Std_Time;
+ -- Secondary stack for this process.
+ Stack2 : Stack2_Ptr;
-- Sensitivity list while the (non-sensitized) process is waiting.
Sensitivity : Action_List_Acc;
+ -- Name of the process.
+ Rti : Rtis_Addr.Rti_Context;
+
+ -- Timeout value for wait.
+ Timeout : Std_Time;
+
Timeout_Chain_Next : Process_Acc;
Timeout_Chain_Prev : Process_Acc;
end record;
@@ -249,6 +250,8 @@ private
"__ghdl_process_wait_set_timeout");
pragma Export (Ada, Ghdl_Process_Wait_Suspend,
"__ghdl_process_wait_suspend");
+ pragma Export (Ada, Ghdl_Process_Wait_Timed_Out,
+ "__ghdl_process_wait_timed_out");
pragma Export (C, Ghdl_Process_Wait_Close,
"__ghdl_process_wait_close");