00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2005 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 #ifndef SC_EVENT_QUEUE_H 00037 #define SC_EVENT_QUEUE_H 00038 00039 00040 /* 00041 Class sc_event_queue 00042 00043 A queue that can contain any number of pending notifications. 00044 The queue has a similiar interface like an sc_event but has different 00045 semantics: it can carry any number of pending notification. The 00046 general rule is that _every_ call to notify() will cause a 00047 corresponding trigger at the specified wall-clock time that can be 00048 observed (the only exception is when notifications are explicitly 00049 cancelled). 00050 00051 If multiple notifications are pending at the same wall-clock 00052 time, then the event queue will trigger in different delta cycles 00053 in order to ensure that sensitive processes can notice each 00054 trigger. The first trigger happens in the earliest delta cycle 00055 possible which is the same behavior as a normal timed event. 00056 00057 */ 00058 00059 #include "sysc/communication/sc_interface.h" 00060 #include "sysc/kernel/sc_module.h" 00061 #include "sysc/kernel/sc_event.h" 00062 00063 namespace sc_core { 00064 00065 template <class IF, int N> 00066 class sc_port; 00067 00068 00069 // --------------------------------------------------------------------------- 00070 // sc_event_queue_if 00071 // --------------------------------------------------------------------------- 00072 00073 class sc_event_queue_if : public virtual sc_interface 00074 { 00075 public: 00076 virtual void notify (double when, sc_time_unit base) =0; 00077 virtual void notify (const sc_time& when) =0; 00078 virtual void cancel_all() =0; 00079 }; 00080 00081 // --------------------------------------------------------------------------- 00082 // sc_event_queue: a queue that can contain any number of pending 00083 // delta, or timed events. 00084 // --------------------------------------------------------------------------- 00085 00086 class sc_event_queue: 00087 public sc_event_queue_if, 00088 public sc_module 00089 { 00090 public: 00091 00092 SC_HAS_PROCESS( sc_event_queue ); 00093 00094 sc_event_queue(); 00095 sc_event_queue( sc_module_name name_ ); 00096 ~sc_event_queue(); 00097 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_delta; 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_event_queue_port; 00157 00158 } // namespace sc_core 00159 00160 #endif // SC_EVENT_QUEUE_H
1.5.1