00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2006 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 Version 2.4 (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.systemc.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 *****************************************************************************/ 00025 00026 /***************************************************************************** 00027 00028 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00029 changes you are making here. 00030 00031 Name, Affiliation, Date: 00032 Description of Modification: 00033 00034 *****************************************************************************/ 00035 00036 // $Log: sc_event_queue.h,v $ 00037 // Revision 1.1.1.1 2006/12/15 20:31:35 acg 00038 // SystemC 2.2 00039 // 00040 // Revision 1.3 2006/01/13 18:47:42 acg 00041 // Added $Log command so that CVS comments are reproduced in the source. 00042 // 00043 00044 #ifndef SC_EVENT_QUEUE_H 00045 #define SC_EVENT_QUEUE_H 00046 00047 00048 /* 00049 Class sc_event_queue 00050 00051 A queue that can contain any number of pending notifications. 00052 The queue has a similiar interface like an sc_event but has different 00053 semantics: it can carry any number of pending notification. The 00054 general rule is that _every_ call to notify() will cause a 00055 corresponding trigger at the specified wall-clock time that can be 00056 observed (the only exception is when notifications are explicitly 00057 cancelled). 00058 00059 If multiple notifications are pending at the same wall-clock 00060 time, then the event queue will trigger in different delta cycles 00061 in order to ensure that sensitive processes can notice each 00062 trigger. The first trigger happens in the earliest delta cycle 00063 possible which is the same behavior as a normal timed event. 00064 00065 */ 00066 00067 #include "sysc/communication/sc_interface.h" 00068 #include "sysc/kernel/sc_module.h" 00069 #include "sysc/kernel/sc_event.h" 00070 #include "sysc/communication/sc_port.h" 00071 00072 namespace sc_core { 00073 00074 00075 // --------------------------------------------------------------------------- 00076 // sc_event_queue_if 00077 // --------------------------------------------------------------------------- 00078 00079 class sc_event_queue_if : public virtual sc_interface 00080 { 00081 public: 00082 virtual void notify (double when, sc_time_unit base) =0; 00083 virtual void notify (const sc_time& when) =0; 00084 virtual void cancel_all() =0; 00085 }; 00086 00087 // --------------------------------------------------------------------------- 00088 // sc_event_queue: a queue that can contain any number of pending 00089 // delta, or timed events. 00090 // --------------------------------------------------------------------------- 00091 00092 class sc_event_queue: 00093 public sc_event_queue_if, 00094 public sc_module 00095 { 00096 public: 00097 00098 SC_HAS_PROCESS( sc_event_queue ); 00099 00100 sc_event_queue( sc_module_name name_ = sc_gen_unique_name("event_queue") ); 00101 ~sc_event_queue(); 00102 00103 // API of sc_object 00104 inline virtual const char* kind() const { return "sc_event_queue"; } 00105 00106 // 00107 // API of sc_event_queue_if 00108 // 00109 inline virtual void notify (double when, sc_time_unit base); 00110 virtual void notify (const sc_time& when); 00111 virtual void cancel_all(); 00112 00113 // 00114 // API for using the event queue in processes 00115 // 00116 00117 // get the default event 00118 inline virtual const sc_event& default_event() const; 00119 00120 /* 00121 // 00122 // Possible extensions: 00123 // 00124 00125 // Cancel an events at a specific time 00126 void cancel (const sc_time& when); 00127 void cancel (double when, sc_time_unit base); 00128 00129 // How many events are pending altogether? 00130 unsigned pending() const; 00131 00132 // How many events are pending at the specific time? 00133 unsigned pending(const sc_time& when) const; 00134 unsigned pending(double when, sc_time_unit base) const; 00135 */ 00136 00137 private: 00138 void fire_event(); 00139 00140 private: 00141 sc_ppq<sc_time*> m_ppq; 00142 sc_event m_e; 00143 sc_dt::uint64 m_delta; 00144 unsigned m_pending_delta; 00145 }; 00146 00147 inline 00148 void sc_event_queue::notify (double when, sc_time_unit base ) 00149 { 00150 notify( sc_time(when,base) ); 00151 } 00152 00153 inline 00154 const sc_event& sc_event_queue::default_event() const 00155 { 00156 return m_e; 00157 } 00158 00159 00160 // 00161 // Using event queue as a port 00162 // 00163 typedef sc_port<sc_event_queue_if,1,SC_ONE_OR_MORE_BOUND> sc_event_queue_port; 00164 00165 } // namespace sc_core 00166 00167 #endif // SC_EVENT_QUEUE_H