sc_event_queue.h revision 12027
1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 sc_event_queue.h -- Event Queue Facility Definitions 23 24 Original Author: Ulli Holtmann, Synopsys, Inc. 25 26 CHANGE LOG IS AT THE END OF THE FILE 27 *****************************************************************************/ 28 29#ifndef SC_EVENT_QUEUE_H 30#define SC_EVENT_QUEUE_H 31 32 33/* 34 Class sc_event_queue 35 36 A queue that can contain any number of pending notifications. 37 The queue has a similiar interface like an sc_event but has different 38 semantics: it can carry any number of pending notification. The 39 general rule is that _every_ call to notify() will cause a 40 corresponding trigger at the specified wall-clock time that can be 41 observed (the only exception is when notifications are explicitly 42 cancelled). 43 44 If multiple notifications are pending at the same wall-clock 45 time, then the event queue will trigger in different delta cycles 46 in order to ensure that sensitive processes can notice each 47 trigger. The first trigger happens in the earliest delta cycle 48 possible which is the same behavior as a normal timed event. 49 50*/ 51 52#include "sysc/communication/sc_interface.h" 53#include "sysc/kernel/sc_module.h" 54#include "sysc/kernel/sc_event.h" 55#include "sysc/communication/sc_port.h" 56 57namespace sc_core { 58 59 60// --------------------------------------------------------------------------- 61// sc_event_queue_if 62// --------------------------------------------------------------------------- 63 64class sc_event_queue_if : public virtual sc_interface 65{ 66public: 67 virtual void notify (double when, sc_time_unit base) =0; 68 virtual void notify (const sc_time& when) =0; 69 virtual void cancel_all() =0; 70}; 71 72// --------------------------------------------------------------------------- 73// sc_event_queue: a queue that can contain any number of pending 74// delta, or timed events. 75// --------------------------------------------------------------------------- 76 77class sc_event_queue: 78 public sc_event_queue_if, 79 public sc_module 80{ 81 public: 82 83 SC_HAS_PROCESS( sc_event_queue ); 84 85 sc_event_queue( sc_module_name name_ = sc_gen_unique_name("event_queue") ); 86 ~sc_event_queue(); 87 88 // API of sc_object 89 inline virtual const char* kind() const { return "sc_event_queue"; } 90 91 // 92 // API of sc_event_queue_if 93 // 94 inline virtual void notify (double when, sc_time_unit base); 95 virtual void notify (const sc_time& when); 96 virtual void cancel_all(); 97 98 // 99 // API for using the event queue in processes 100 // 101 102 // get the default event 103 inline virtual const sc_event& default_event() const; 104 105/* 106 // 107 // Possible extensions: 108 // 109 110 // Cancel an events at a specific time 111 void cancel (const sc_time& when); 112 void cancel (double when, sc_time_unit base); 113 114 // How many events are pending altogether? 115 unsigned pending() const; 116 117 // How many events are pending at the specific time? 118 unsigned pending(const sc_time& when) const; 119 unsigned pending(double when, sc_time_unit base) const; 120*/ 121 122 private: 123 void fire_event(); 124 125 private: 126 sc_ppq<sc_time*> m_ppq; 127 sc_event m_e; 128 sc_dt::uint64 m_change_stamp; 129 unsigned m_pending_delta; 130}; 131 132inline 133void sc_event_queue::notify (double when, sc_time_unit base ) 134{ 135 notify( sc_time(when,base) ); 136} 137 138inline 139const sc_event& sc_event_queue::default_event() const 140{ 141 return m_e; 142} 143 144 145// 146// Using event queue as a port 147// 148typedef sc_port<sc_event_queue_if,1,SC_ONE_OR_MORE_BOUND> sc_event_queue_port; 149 150} // namespace sc_core 151 152// $Log: sc_event_queue.h,v $ 153// Revision 1.5 2011/08/26 20:45:40 acg 154// Andy Goodrich: moved the modification log to the end of the file to 155// eliminate source line number skew when check-ins are done. 156// 157// Revision 1.4 2011/04/05 20:48:09 acg 158// Andy Goodrich: changes to make sure that event(), posedge() and negedge() 159// only return true if the clock has not moved. 160// 161// Revision 1.3 2011/02/18 20:23:45 acg 162// Andy Goodrich: Copyright update. 163// 164// Revision 1.2 2008/05/20 16:45:52 acg 165// Andy Goodrich: changed which unique name generator is used from the 166// global one to the one for sc_modules. 167// 168// Revision 1.1.1.1 2006/12/15 20:20:04 acg 169// SystemC 2.3 170// 171// Revision 1.4 2006/11/28 20:30:48 acg 172// Andy Goodrich: updated from 2.2 source. sc_event_queue constructors 173// collapsed into a single constructor with an optional argument to get 174// the sc_module_name stack done correctly. Class name prefixing added 175// to sc_semaphore calls to wait() to keep gcc 4.x happy. 176// 177// Revision 1.3 2006/01/13 18:47:42 acg 178// Added $Log command so that CVS comments are reproduced in the source. 179// 180 181#endif // SC_EVENT_QUEUE_H 182