diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-03-07 05:50:08 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-03-09 20:42:57 +0100 |
commit | 101dd876888f9531cea6657e63706cb43d7c7a67 (patch) | |
tree | 18718838c39f7985bcbf3c9842f31ab79ca5d735 /src/grt | |
parent | 0b7ccf5869d61528d1a7dbb4fed98b0e300bc7a3 (diff) | |
download | ghdl-101dd876888f9531cea6657e63706cb43d7c7a67.tar.gz ghdl-101dd876888f9531cea6657e63706cb43d7c7a67.tar.bz2 ghdl-101dd876888f9531cea6657e63706cb43d7c7a67.zip |
Add start_of_processes callback, used by grt-waves
Fix #300
Diffstat (limited to 'src/grt')
-rw-r--r-- | src/grt/grt-hooks.ads | 11 | ||||
-rw-r--r-- | src/grt/grt-processes.adb | 6 | ||||
-rw-r--r-- | src/grt/grt-waves.adb | 19 |
3 files changed, 29 insertions, 7 deletions
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); |