summaryrefslogtreecommitdiff
path: root/translate/grt
diff options
context:
space:
mode:
authorgingold2005-12-10 17:09:48 +0000
committergingold2005-12-10 17:09:48 +0000
commit2d043208bfa397b5aa984e29acbaf28b43b539f9 (patch)
treeab6b365be56829a51617ae154ecd58a3b2d57513 /translate/grt
parent04a30cb2c2182dd6f60ef1005d3232f0b802283f (diff)
downloadghdl-2d043208bfa397b5aa984e29acbaf28b43b539f9.tar.gz
ghdl-2d043208bfa397b5aa984e29acbaf28b43b539f9.tar.bz2
ghdl-2d043208bfa397b5aa984e29acbaf28b43b539f9.zip
grt.arch not used anymore
Diffstat (limited to 'translate/grt')
-rw-r--r--translate/grt/grt-processes.adb69
-rw-r--r--translate/grt/grt-processes.ads20
2 files changed, 55 insertions, 34 deletions
diff --git a/translate/grt/grt-processes.adb b/translate/grt/grt-processes.adb
index a4cf318..1bb0be8 100644
--- a/translate/grt/grt-processes.adb
+++ b/translate/grt/grt-processes.adb
@@ -15,6 +15,7 @@
-- along with GCC; see the file COPYING. If not, write to the Free
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
+with GNAT.Table;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with System.Storage_Elements; -- Work around GNAT bug.
@@ -32,11 +33,18 @@ with Grt.Disp_Signals;
with Grt.Stdio;
with Grt.Stats;
with Grt.Threads; use Grt.Threads;
-with Grt.Arch;
package body Grt.Processes is
Last_Time : constant Std_Time := Std_Time'Last;
+ -- Table of processes.
+ package Process_Table is new GNAT.Table
+ (Table_Component_Type => Process_Type,
+ Table_Index_Type => Process_Id,
+ Table_Low_Bound => 1,
+ Table_Initial => 16,
+ Table_Increment => 100);
+
-- List of non_sensitized processes.
package Non_Sensitized_Process_Table is new GNAT.Table
(Table_Component_Type => Process_Id,
@@ -116,9 +124,7 @@ package body Grt.Processes is
Postponed => Postponed,
State => State,
Timeout => Bad_Time,
- Stack => Stack,
- Stats_Time => 0,
- Stats_Run => 0);
+ Stack => Stack);
-- Used to create drivers.
Set_Current_Process (Process_Table.Last, null);
@@ -189,9 +195,7 @@ package body Grt.Processes is
Timeout => Bad_Time,
Subprg => To_Proc_Acc (Proc),
This => This,
- Stack => Null_Stack,
- Stats_Time => 0,
- Stats_Run => 0);
+ Stack => Null_Stack);
-- Used to create drivers.
Set_Current_Process (Process_Table.Last, null);
end Verilog_Process_Register;
@@ -503,12 +507,13 @@ package body Grt.Processes is
loop
-- Atomically get a process to be executed
Idx := Grt.Threads.Atomic_Inc (Mt_Index'Access);
- exit when Idx > Mt_Last;
+ if Idx > Mt_Last then
+ return;
+ end if;
Pid := Mt_Table (Idx);
declare
Proc : Process_Type renames Process_Table.Table (Pid);
- Ts_Start, Ts_End : Ghdl_U64;
begin
if Grt.Options.Trace_Processes then
Grt.Astdio.Put ("run process ");
@@ -522,7 +527,6 @@ package body Grt.Processes is
Internal_Error ("run non-resumed process");
end if;
Proc.Resumed := False;
- Ts_Start := Grt.Arch.Get_Time_Stamp;
Set_Current_Process
(Pid, To_Acc (Process_Table.Table (Pid)'Address));
if Proc.State = State_Sensitized then
@@ -530,9 +534,6 @@ package body Grt.Processes is
else
Stack_Switch (Proc.Stack, Get_Main_Stack);
end if;
- Ts_End := Grt.Arch.Get_Time_Stamp;
- Proc.Stats_Time := Proc.Stats_Time + (Ts_End - Ts_Start);
- Proc.Stats_Run := Proc.Stats_Run + 1;
if Grt.Options.Checks then
Ghdl_Signal_Internal_Checks;
Grt.Stack2.Check_Empty (Get_Stack2);
@@ -543,28 +544,60 @@ package body Grt.Processes is
function Run_Processes (Postponed : Boolean) return Integer
is
+ Table : Process_Id_Array_Acc;
Last : Natural;
begin
if Options.Flag_Stats then
Stats.Start_Processes;
end if;
- Mt_Index := 1;
if Postponed then
- Mt_Table := Postponed_Resume_Process_Table;
+ Table := Postponed_Resume_Process_Table;
Last := Last_Postponed_Resume_Process;
Last_Postponed_Resume_Process := 0;
else
- Mt_Table := Resume_Process_Table;
+ Table := Resume_Process_Table;
Last := Last_Resume_Process;
Last_Resume_Process := 0;
end if;
Nbr_Resumed_Processes := Nbr_Resumed_Processes + Last;
- Mt_Last := Last;
if Options.Nbr_Threads = 1 then
- Run_Processes_Threads;
+ for I in 1 .. Last loop
+ declare
+ Pid : constant Process_Id := Table (I);
+ Proc : Process_Type renames Process_Table.Table (Pid);
+ begin
+ if not Proc.Resumed then
+ Internal_Error ("run non-resumed process");
+ end if;
+ if Grt.Options.Trace_Processes then
+ Grt.Astdio.Put ("run process ");
+ Disp_Process_Name (Stdio.stdout, Pid);
+ Grt.Astdio.Put (" [");
+ Grt.Astdio.Put (Stdio.stdout, Proc.This);
+ Grt.Astdio.Put ("]");
+ Grt.Astdio.New_Line;
+ end if;
+
+ Proc.Resumed := False;
+ Set_Current_Process
+ (Pid, To_Acc (Process_Table.Table (Pid)'Address));
+ if Proc.State = State_Sensitized then
+ Proc.Subprg.all (Proc.This);
+ else
+ Stack_Switch (Proc.Stack, Get_Main_Stack);
+ end if;
+ if Grt.Options.Checks then
+ Ghdl_Signal_Internal_Checks;
+ Grt.Stack2.Check_Empty (Get_Stack2);
+ end if;
+ end;
+ end loop;
else
+ Mt_Last := Last;
+ Mt_Table := Table;
+ Mt_Index := 1;
Threads.Run_Parallel (Run_Processes_Threads'Access);
end if;
diff --git a/translate/grt/grt-processes.ads b/translate/grt/grt-processes.ads
index 777b9dd..2ef0653 100644
--- a/translate/grt/grt-processes.ads
+++ b/translate/grt/grt-processes.ads
@@ -16,7 +16,6 @@
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
with System;
-with GNAT.Table;
with Grt.Stack2; use Grt.Stack2;
with Grt.Types; use Grt.Types;
with Grt.Signals; use Grt.Signals;
@@ -119,7 +118,10 @@ package Grt.Processes is
procedure Ghdl_Protected_Init (Obj : System.Address);
procedure Ghdl_Protected_Fini (Obj : System.Address);
- -- Access to a process subprogram.
+ type Process_Type is private;
+ type Process_Acc is access all Process_Type;
+private
+ -- Access to a process subprogram.
type Proc_Acc is access procedure (Self : System.Address);
-- Simply linked list for sensitivity.
@@ -178,22 +180,8 @@ package Grt.Processes is
-- Sensitivity list.
Sensitivity : Sensitivity_Acc;
-
- Stats_Time : Ghdl_U64;
- Stats_Run : Ghdl_U32;
end record;
- type Process_Acc is access all Process_Type;
-
- -- Table of processes.
- package Process_Table is new GNAT.Table
- (Table_Component_Type => Process_Type,
- Table_Index_Type => Process_Id,
- Table_Low_Bound => 1,
- Table_Initial => 16,
- Table_Increment => 100);
-private
-
pragma Export (C, Ghdl_Process_Register,
"__ghdl_process_register");
pragma Export (C, Ghdl_Sensitized_Process_Register,