From 101dd876888f9531cea6657e63706cb43d7c7a67 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 7 Mar 2017 05:50:08 +0100 Subject: Add start_of_processes callback, used by grt-waves Fix #300 --- src/grt/grt-hooks.ads | 11 ++++++++--- src/grt/grt-processes.adb | 6 ++++++ src/grt/grt-waves.adb | 19 +++++++++++++++---- 3 files changed, 29 insertions(+), 7 deletions(-) (limited to 'src/grt') diff --git a/src/grt/grt-hooks.ads b/src/grt/grt-hooks.ads index 576ab4823..bb7ee605b 100644 --- a/src/grt/grt-hooks.ads +++ b/src/grt/grt-hooks.ads @@ -86,11 +86,15 @@ package Grt.Hooks is -- Callbacks. - -- Called at the beginning of the cycle at time T. + -- Called at the beginning of a non-delta simulation cycle. + Cb_Next_Time_Step : Callbacks.Callback_List; + + -- Called at the beginning of the cycle at time T. Can create a new + -- simulation cycle, and called after Cb_Next_Time_Step. Cb_After_Delay : Callbacks.Callback_Time_List; - -- Called at the beginning of a non-delta cycle. - Cb_Next_Time_Step : Callbacks.Callback_List; + -- Called before running processes. + Cb_Start_Of_Processes : Callbacks.Callback_List; -- Called after updating the signals. For value change detection. Cb_Signals_Updated : Callbacks.Callback_List; @@ -101,6 +105,7 @@ package Grt.Hooks is -- cycle. Cb_Last_Known_Delta : Callbacks.Callback_List; + -- Called after postponed processes, may change the next time. Cb_End_Of_Time_Step : Callbacks.Callback_List; end Grt.Hooks; diff --git a/src/grt/grt-processes.adb b/src/grt/grt-processes.adb index 935b74121..208a99b18 100644 --- a/src/grt/grt-processes.adb +++ b/src/grt/grt-processes.adb @@ -739,6 +739,12 @@ package body Grt.Processes is Table : Process_Acc_Array_Acc; Last : Natural; begin + if Postponed then + null; + else + Call_Callbacks (Hooks.Cb_Start_Of_Processes); + end if; + if Options.Flag_Stats then Stats.Start_Processes; end if; diff --git a/src/grt/grt-waves.adb b/src/grt/grt-waves.adb index 8e2751268..025f2195e 100644 --- a/src/grt/grt-waves.adb +++ b/src/grt/grt-waves.adb @@ -22,17 +22,18 @@ -- covered by the GNU General Public License. This exception does not -- however invalidate any other reasons why the executable file might be -- covered by the GNU Public License. + +with System; use System; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with Interfaces; use Interfaces; -with System.Storage_Elements; -- Work around GNAT bug. -pragma Unreferenced (System.Storage_Elements); with Grt.Types; use Grt.Types; with Grt.Avhpi; use Grt.Avhpi; with Grt.Stdio; use Grt.Stdio; with Grt.C; use Grt.C; with Grt.Errors; use Grt.Errors; with Grt.Astdio; use Grt.Astdio; +with Grt.Callbacks; use Grt.Callbacks; with Grt.Hooks; use Grt.Hooks; with Grt.Table; with Grt.Avls; use Grt.Avls; @@ -41,7 +42,6 @@ with Grt.Rtis_Addr; use Grt.Rtis_Addr; with Grt.Rtis_Utils; with Grt.Rtis_Types; with Grt.Signals; use Grt.Signals; -with System; use System; with Grt.Vstrings; use Grt.Vstrings; with Grt.Ghw; use Grt.Ghw; with Grt.Wave_Opt; use Grt.Wave_Opt; @@ -1573,12 +1573,20 @@ package body Grt.Waves is Wave_Put ("ESN" & NUL); end Write_Snapshot; + procedure Wave_Start_Cb (Arg : System.Address) + is + pragma Unreferenced (Arg); + begin + Write_Snapshot; + end Wave_Start_Cb; + procedure Wave_Cycle; -- Called after elaboration. procedure Wave_Start is Root : VhpiHandleT; + H : Callback_Handle; begin -- Do nothing if there is no VCD file to generate. if Wave_Stream = NULL_Stream then @@ -1615,7 +1623,10 @@ package body Grt.Waves is -- End of header mark. Wave_Section ("EOH" & NUL); - Write_Snapshot; + -- Write the first snapshot just before running processes for the first + -- time. At that point, signals are fully initialized. + Register_Callback (Cb_Start_Of_Processes, H, Oneshot, + Wave_Start_Cb'Access); Register_Cycle_Hook (Wave_Cycle'Access); -- cgit v1.2.3