1-- GHDL Run Time (GRT) - Hooks. 2-- Copyright (C) 2002 - 2014 Tristan Gingold 3-- 4-- This program is free software: you can redistribute it and/or modify 5-- it under the terms of the GNU General Public License as published by 6-- the Free Software Foundation, either version 2 of the License, or 7-- (at your option) any later version. 8-- 9-- This program is distributed in the hope that it will be useful, 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of 11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12-- GNU General Public License for more details. 13-- 14-- You should have received a copy of the GNU General Public License 15-- along with this program. If not, see <gnu.org/licenses>. 16-- 17-- As a special exception, if other files instantiate generics from this 18-- unit, or you link this unit with other files to produce an executable, 19-- this unit does not by itself cause the resulting executable to be 20-- covered by the GNU General Public License. This exception does not 21-- however invalidate any other reasons why the executable file might be 22-- covered by the GNU Public License. 23with Grt.Callbacks; 24 25package Grt.Hooks is 26 pragma Preelaborate (Grt.Hooks); 27 28 type Option_Hook_Type is access function (Opt : String) return Boolean; 29 type Proc_Hook_Type is access procedure; 30 31 type Cst_String_Acc is access constant String; 32 33 type Hooks_Type is record 34 -- A one-line description of the hook. The format is: 35 -- "NAME: description". NAME should be uniq and is tested by the 36 -- switch --has-feature=NAME. 37 -- DESC can be null if there is no interesting feature added. 38 Desc : Cst_String_Acc; 39 40 -- Called for every unknown command line argument. 41 -- Return TRUE if handled. 42 Option : Option_Hook_Type; 43 44 -- Display command line help. 45 Help : Proc_Hook_Type; 46 47 -- Called at initialization (after decoding options). 48 Init : Proc_Hook_Type; 49 50 -- Called just after elaboration. 51 Start : Proc_Hook_Type; 52 53 -- Called at the end of execution. 54 Finish : Proc_Hook_Type; 55 end record; 56 57 type Hooks_Acc is access constant Hooks_Type; 58 59 -- Registers hook. 60 procedure Register_Hooks (Hooks : Hooks_Acc); 61 62 -- Register an hook which will call PROC after every non-delta cycles. 63 procedure Register_Cycle_Hook (Proc : Proc_Hook_Type); 64 65 -- Display the description of the hooks. 66 procedure Display_Hooks_Desc; 67 68 -- Return True if NAME is present in the list of modules. 69 function Has_Feature (Name : String) return Boolean; 70 71 -- Call hooks. 72 function Call_Option_Hooks (Opt : String) return Boolean; 73 procedure Call_Help_Hooks; 74 procedure Call_Init_Hooks; 75 procedure Call_Start_Hooks; 76 procedure Call_Finish_Hooks; 77 78 -- Call non-delta cycles hooks. 79 procedure Call_Cycle_Hooks; 80 pragma Inline_Always (Call_Cycle_Hooks); 81 82 -- Nil procedure. 83 procedure Proc_Hook_Nil; 84 85 -- Callbacks. 86 87 -- Called at the beginning of a non-delta simulation cycle. 88 Cb_Next_Time_Step : Callbacks.Callback_List; 89 90 -- Called at the beginning of the cycle at time T. Can create a new 91 -- simulation cycle, and called after Cb_Next_Time_Step. 92 Cb_After_Delay : Callbacks.Callback_Time_List; 93 94 -- Called before running processes. 95 Cb_Start_Of_Processes : Callbacks.Callback_List; 96 97 -- Called after updating the signals. For value change detection. 98 Cb_Signals_Updated : Callbacks.Callback_List; 99 100 -- Called at the last known delta cycle of a timestep, before execution 101 -- of postponed processes. 102 -- The callback may change signals and therefore generating new delta 103 -- cycle. 104 Cb_Last_Known_Delta : Callbacks.Callback_List; 105 106 -- Called after postponed processes, may change the next time. 107 Cb_End_Of_Time_Step : Callbacks.Callback_List; 108 109end Grt.Hooks; 110