aboutsummaryrefslogtreecommitdiffstats
path: root/src/grt/grt-processes.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/grt/grt-processes.adb')
-rw-r--r--src/grt/grt-processes.adb81
1 files changed, 44 insertions, 37 deletions
diff --git a/src/grt/grt-processes.adb b/src/grt/grt-processes.adb
index a1137210d..d5fcb4de7 100644
--- a/src/grt/grt-processes.adb
+++ b/src/grt/grt-processes.adb
@@ -808,10 +808,6 @@ package body Grt.Processes is
end if;
end Run_Processes;
- -- Updated by Initialization_Phase and Simulation_Cycle to the time of the
- -- next cycle. Unchanged in case of delta-cycle.
- Next_Time : Std_Time;
-
procedure Initialization_Phase
is
Status : Integer;
@@ -877,7 +873,6 @@ package body Grt.Processes is
end Initialization_Phase;
-- Launch a simulation cycle.
- -- Set FINISHED to true if this is the last cycle.
function Simulation_Cycle return Integer
is
Tn : Std_Time;
@@ -889,8 +884,11 @@ package body Grt.Processes is
-- a) The current time, Tc is set equal to Tn. Simulation is complete
-- when Tn = TIME'HIGH and there are no active drivers or process
-- resumptions at Tn.
- -- GHDL: this is done at the last step of the cycle.
- null;
+ -- GHDL: the check is done at the last step of the cycle.
+ Current_Time := Next_Time;
+ if Grt.Options.Disp_Time then
+ Grt.Disp.Disp_Now;
+ end if;
-- b) The following actions occur in the indicated order:
-- 1) If the current simulation cycle is not a delta cycle, each
@@ -1051,6 +1049,13 @@ package body Grt.Processes is
Update_Active_Chain;
Next_Time := Tn;
Current_Delta := 0;
+
+ -- Statistics.
+ Nbr_Cycles := Nbr_Cycles + 1;
+
+ -- For wave dumpers.
+ Grt.Hooks.Call_Cycle_Hooks;
+
return Run_Resumed;
end if;
@@ -1059,6 +1064,10 @@ package body Grt.Processes is
return Run_Finished;
else
Current_Delta := Current_Delta + 1;
+
+ -- Statistics.
+ Nbr_Delta_Cycles := Nbr_Delta_Cycles + 1;
+
return Run_Resumed;
end if;
end Simulation_Cycle;
@@ -1090,51 +1099,48 @@ package body Grt.Processes is
end if;
end Simulation_Init;
+ function Has_Simulation_Timeout return Boolean
+ is
+ use Options;
+ begin
+ if Next_Time > Stop_Time
+ and then Next_Time /= Std_Time'Last
+ then
+ -- FIXME: Implement with a callback instead ? This could be done
+ -- in 2 steps: an after_delay for the time and then a read_only
+ -- to finish the current cycle. Note that no message should be
+ -- printed if the simulation is already finished at the stop time.
+ Info ("simulation stopped by --stop-time");
+ return True;
+ elsif Current_Delta >= Stop_Delta then
+ Info ("simulation stopped by --stop-delta");
+ return True;
+ else
+ return False;
+ end if;
+ end Has_Simulation_Timeout;
+
function Simulation_Main_Loop return Integer
is
use Options;
Status : Integer;
begin
loop
- -- Update time. This is the only place where Current_Time is
- -- updated.
- Current_Time := Next_Time;
- if Disp_Time then
- Grt.Disp.Disp_Now;
- end if;
-
Status := Simulation_Cycle;
+
+ -- Simulation has been stopped/finished by vpi.
exit when Status = Run_Stop;
if Trace_Signals then
Grt.Disp_Signals.Disp_All_Signals;
end if;
- -- Statistics.
- if Current_Delta = 0 then
- Nbr_Cycles := Nbr_Cycles + 1;
- else
- Nbr_Delta_Cycles := Nbr_Delta_Cycles + 1;
- end if;
-
+ -- Simulation is finished.
exit when Status = Run_Finished;
- if Next_Time > Stop_Time
- and then Next_Time /= Std_Time'Last
- then
- -- FIXME: Implement with a callback instead ? This could be done
- -- in 2 steps: an after_delay for the time and then a read_only
- -- to finish the current cycle. Note that no message should be
- -- printed if the simulation is already finished at the stop time.
- Info ("simulation stopped by --stop-time");
- exit;
- end if;
-
- if Current_Delta = 0 then
- Grt.Hooks.Call_Cycle_Hooks;
- end if;
- if Current_Delta >= Stop_Delta then
- Error ("simulation stopped by --stop-delta");
+ -- Simulation is stopped by user timeout.
+ if Has_Simulation_Timeout then
+ Status := Run_Limit;
exit;
end if;
end loop;
@@ -1155,6 +1161,7 @@ package body Grt.Processes is
function Simulation return Integer
is
+ use Grt.Options;
Status : Integer;
begin
Simulation_Init;