00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2004 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.3 (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: Stuart Swan, Cadence 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 "systemc/communication/sc_interface.h" 00060 #include "systemc/kernel/sc_module.h" 00061 00062 template <class IF, int N> 00063 class sc_port; 00064 00065 00066 // --------------------------------------------------------------------------- 00067 // sc_event_queue_if 00068 // --------------------------------------------------------------------------- 00069 00070 class sc_event_queue_if : public virtual sc_interface 00071 { 00072 public: 00073 virtual void notify (double when, sc_time_unit base) =0; 00074 virtual void notify (const sc_time& when) =0; 00075 virtual void cancel_all() =0; 00076 }; 00077 00078 // --------------------------------------------------------------------------- 00079 // sc_event_queue: a queue that can contain any number of pending 00080 // delta, or timed events. 00081 // --------------------------------------------------------------------------- 00082 00083 class sc_event_queue: 00084 public sc_event_queue_if, 00085 public sc_module 00086 { 00087 public: 00088 00089 SC_HAS_PROCESS( sc_event_queue ); 00090 00091 sc_event_queue(); 00092 sc_event_queue( sc_module_name name_ ); 00093 ~sc_event_queue(); 00094 00095 00096 // 00097 // API of sc_event_queue_if 00098 // 00099 inline virtual void notify (double when, sc_time_unit base); 00100 virtual void notify (const sc_time& when); 00101 virtual void cancel_all(); 00102 00103 // 00104 // API for using the event queue in processes 00105 // 00106 00107 // get the default event 00108 inline virtual const sc_event& default_event() const; 00109 00110 /* 00111 // 00112 // Possible extensions: 00113 // 00114 00115 // Cancel an events at a specific time 00116 void cancel (const sc_time& when); 00117 void cancel (double when, sc_time_unit base); 00118 00119 // How many events are pending altogether? 00120 unsigned pending() const; 00121 00122 // How many events are pending at the specific time? 00123 unsigned pending(const sc_time& when) const; 00124 unsigned pending(double when, sc_time_unit base) const; 00125 */ 00126 00127 private: 00128 void fire_event(); 00129 00130 private: 00131 sc_ppq<sc_time*> m_ppq; 00132 sc_event m_e; 00133 uint64 m_delta; 00134 unsigned m_pending_delta; 00135 }; 00136 00137 inline 00138 void sc_event_queue::notify (double when, sc_time_unit base ) 00139 { 00140 notify( sc_time(when,base) ); 00141 } 00142 00143 inline 00144 const sc_event& sc_event_queue::default_event() const 00145 { 00146 return m_e; 00147 } 00148 00149 00150 // 00151 // Using event queue as a port 00152 // 00153 typedef sc_port<sc_event_queue_if,1> sc_event_queue_port; 00154 00155 00156 #endif // SC_EVENT_QUEUE_H
1.2.18