00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2014 by all Contributors. 00005 All Rights reserved. 00006 00007 The contents of this file are subject to the restrictions and limitations 00008 set forth in the SystemC Open Source License (the "License"); 00009 You may not use this file except in compliance with such restrictions and 00010 limitations. You may obtain instructions on how to receive a copy of the 00011 License at http://www.accellera.org/. Software distributed by Contributors 00012 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF 00013 ANY KIND, either express or implied. See the License for the specific 00014 language governing rights and limitations under the License. 00015 00016 *****************************************************************************/ 00017 00018 /***************************************************************************** 00019 00020 sc_event_queue.h -- Event Queue Facility Definitions 00021 00022 Original Author: Ulli Holtmann, Synopsys, Inc. 00023 00024 CHANGE LOG IS AT THE END OF THE FILE 00025 *****************************************************************************/ 00026 00027 #ifndef SC_EVENT_QUEUE_H 00028 #define SC_EVENT_QUEUE_H 00029 00030 00031 /* 00032 Class sc_event_queue 00033 00034 A queue that can contain any number of pending notifications. 00035 The queue has a similiar interface like an sc_event but has different 00036 semantics: it can carry any number of pending notification. The 00037 general rule is that _every_ call to notify() will cause a 00038 corresponding trigger at the specified wall-clock time that can be 00039 observed (the only exception is when notifications are explicitly 00040 cancelled). 00041 00042 If multiple notifications are pending at the same wall-clock 00043 time, then the event queue will trigger in different delta cycles 00044 in order to ensure that sensitive processes can notice each 00045 trigger. The first trigger happens in the earliest delta cycle 00046 possible which is the same behavior as a normal timed event. 00047 00048 */ 00049 00050 #include "sysc/communication/sc_interface.h" 00051 #include "sysc/kernel/sc_module.h" 00052 #include "sysc/kernel/sc_event.h" 00053 #include "sysc/communication/sc_port.h" 00054 00055 namespace sc_core { 00056 00057 00058 /**************************************************************************/ 00064 class sc_event_queue_if : public virtual sc_interface 00065 { 00066 public: 00067 virtual void notify (double when, sc_time_unit base) =0; 00068 virtual void notify (const sc_time& when) =0; 00069 virtual void cancel_all() =0; 00070 }; 00071 00072 /**************************************************************************/ 00079 class sc_event_queue: 00080 public sc_event_queue_if, 00081 public sc_module 00082 { 00083 public: 00084 00085 SC_HAS_PROCESS( sc_event_queue ); 00086 00091 // 08/20/2015 GL. 00092 sc_event_queue( sc_module_name name_ = sc_gen_unique_name("event_queue") ); 00093 00094 ~sc_event_queue(); 00095 00096 // API of sc_object 00097 inline virtual const char* kind() const { return "sc_event_queue"; } 00098 00099 // 00100 // API of sc_event_queue_if 00101 // 00102 inline virtual void notify (double when, sc_time_unit base); 00103 virtual void notify (const sc_time& when); 00104 virtual void cancel_all(); 00105 00106 // 00107 // API for using the event queue in processes 00108 // 00109 00110 // get the default event 00111 inline virtual const sc_event& default_event() const; 00112 00113 /* 00114 // 00115 // Possible extensions: 00116 // 00117 00118 // Cancel an events at a specific time 00119 void cancel (const sc_time& when); 00120 void cancel (double when, sc_time_unit base); 00121 00122 // How many events are pending altogether? 00123 unsigned pending() const; 00124 00125 // How many events are pending at the specific time? 00126 unsigned pending(const sc_time& when) const; 00127 unsigned pending(double when, sc_time_unit base) const; 00128 */ 00129 00130 private: 00131 void fire_event(); 00132 00133 private: 00134 sc_ppq<sc_time*> m_ppq; 00135 sc_event m_e; 00136 sc_dt::uint64 m_change_stamp; 00137 unsigned m_pending_delta; 00138 }; 00139 00140 inline 00141 void sc_event_queue::notify (double when, sc_time_unit base ) 00142 { 00143 notify( sc_time(when,base) ); 00144 } 00145 00146 inline 00147 const sc_event& sc_event_queue::default_event() const 00148 { 00149 return m_e; 00150 } 00151 00152 00153 // 00154 // Using event queue as a port 00155 // 00156 typedef sc_port<sc_event_queue_if,1,SC_ONE_OR_MORE_BOUND> sc_event_queue_port; 00157 00158 } // namespace sc_core 00159 00160 // $Log: sc_event_queue.h,v $ 00161 // Revision 1.5 2011/08/26 20:45:40 acg 00162 // Andy Goodrich: moved the modification log to the end of the file to 00163 // eliminate source line number skew when check-ins are done. 00164 // 00165 // Revision 1.4 2011/04/05 20:48:09 acg 00166 // Andy Goodrich: changes to make sure that event(), posedge() and negedge() 00167 // only return true if the clock has not moved. 00168 // 00169 // Revision 1.3 2011/02/18 20:23:45 acg 00170 // Andy Goodrich: Copyright update. 00171 // 00172 // Revision 1.2 2008/05/20 16:45:52 acg 00173 // Andy Goodrich: changed which unique name generator is used from the 00174 // global one to the one for sc_modules. 00175 // 00176 // Revision 1.1.1.1 2006/12/15 20:20:04 acg 00177 // SystemC 2.3 00178 // 00179 // Revision 1.4 2006/11/28 20:30:48 acg 00180 // Andy Goodrich: updated from 2.2 source. sc_event_queue constructors 00181 // collapsed into a single constructor with an optional argument to get 00182 // the sc_module_name stack done correctly. Class name prefixing added 00183 // to sc_semaphore calls to wait() to keep gcc 4.x happy. 00184 // 00185 // Revision 1.3 2006/01/13 18:47:42 acg 00186 // Added $Log command so that CVS comments are reproduced in the source. 00187 // 00188 00189 #endif // SC_EVENT_QUEUE_H