SystemC  Recoding Infrastructure for SystemC v0.6.2 derived from Accellera SystemC 2.3.1
Accellera SystemC proof-of-concept library
sc_event_queue.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_event_queue.h -- Event Queue Facility Definitions
21 
22  Original Author: Ulli Holtmann, Synopsys, Inc.
23 
24  CHANGE LOG IS AT THE END OF THE FILE
25  *****************************************************************************/
26 
27 #ifndef SC_EVENT_QUEUE_H
28 #define SC_EVENT_QUEUE_H
29 
30 
31 /*
32  Class sc_event_queue
33 
34  A queue that can contain any number of pending notifications.
35  The queue has a similiar interface like an sc_event but has different
36  semantics: it can carry any number of pending notification. The
37  general rule is that _every_ call to notify() will cause a
38  corresponding trigger at the specified wall-clock time that can be
39  observed (the only exception is when notifications are explicitly
40  cancelled).
41 
42  If multiple notifications are pending at the same wall-clock
43  time, then the event queue will trigger in different delta cycles
44  in order to ensure that sensitive processes can notice each
45  trigger. The first trigger happens in the earliest delta cycle
46  possible which is the same behavior as a normal timed event.
47 
48 */
49 
51 #include "sysc/kernel/sc_module.h"
52 #include "sysc/kernel/sc_event.h"
54 
55 namespace sc_core {
56 
57 
58 /**************************************************************************/
64 class sc_event_queue_if : public virtual sc_interface
65 {
66 public:
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 /**************************************************************************/
80  public sc_event_queue_if,
81  public sc_module
82 {
83  public:
84 
86 
91  // 08/20/2015 GL.
92  sc_event_queue( sc_module_name name_ = sc_gen_unique_name("event_queue") );
93 
95 
96  // API of sc_object
97  inline virtual const char* kind() const { return "sc_event_queue"; }
98 
99  //
100  // API of sc_event_queue_if
101  //
102  inline virtual void notify (double when, sc_time_unit base);
103  virtual void notify (const sc_time& when);
104  virtual void cancel_all();
105 
106  //
107  // API for using the event queue in processes
108  //
109 
110  // get the default event
111  inline virtual const sc_event& default_event() const;
112 
113 /*
114  //
115  // Possible extensions:
116  //
117 
118  // Cancel an events at a specific time
119  void cancel (const sc_time& when);
120  void cancel (double when, sc_time_unit base);
121 
122  // How many events are pending altogether?
123  unsigned pending() const;
124 
125  // How many events are pending at the specific time?
126  unsigned pending(const sc_time& when) const;
127  unsigned pending(double when, sc_time_unit base) const;
128 */
129 
130  private:
131  void fire_event();
132 
133  private:
134  sc_ppq<sc_time*> m_ppq;
135  sc_event m_e;
136  sc_dt::uint64 m_change_stamp;
137  unsigned m_pending_delta;
138 };
139 
140 inline
141 void sc_event_queue::notify (double when, sc_time_unit base )
142 {
143  notify( sc_time(when,base) );
144 }
145 
146 inline
148 {
149  return m_e;
150 }
151 
152 
153 //
154 // Using event queue as a port
155 //
157 
158 } // namespace sc_core
159 
160 // $Log: sc_event_queue.h,v $
161 // Revision 1.5 2011/08/26 20:45:40 acg
162 // Andy Goodrich: moved the modification log to the end of the file to
163 // eliminate source line number skew when check-ins are done.
164 //
165 // Revision 1.4 2011/04/05 20:48:09 acg
166 // Andy Goodrich: changes to make sure that event(), posedge() and negedge()
167 // only return true if the clock has not moved.
168 //
169 // Revision 1.3 2011/02/18 20:23:45 acg
170 // Andy Goodrich: Copyright update.
171 //
172 // Revision 1.2 2008/05/20 16:45:52 acg
173 // Andy Goodrich: changed which unique name generator is used from the
174 // global one to the one for sc_modules.
175 //
176 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
177 // SystemC 2.3
178 //
179 // Revision 1.4 2006/11/28 20:30:48 acg
180 // Andy Goodrich: updated from 2.2 source. sc_event_queue constructors
181 // collapsed into a single constructor with an optional argument to get
182 // the sc_module_name stack done correctly. Class name prefixing added
183 // to sc_semaphore calls to wait() to keep gcc 4.x happy.
184 //
185 // Revision 1.3 2006/01/13 18:47:42 acg
186 // Added $Log command so that CVS comments are reproduced in the source.
187 //
188 
189 #endif // SC_EVENT_QUEUE_H
Generic port class and base class for other port classes.
Definition: sc_port.h:375
SC_HAS_PROCESS(sc_event_queue)
Module name class.
virtual const sc_event & default_event() const
sc_event_queue(sc_module_name name_=sc_gen_unique_name("event_queue"))
This constructor function is not supported by the out-of-order simulation in the current release...
virtual const char * kind() const
const char * sc_gen_unique_name(const char *, bool preserve_first)
The sc_event_queue interface class.
sc_port< sc_event_queue_if, 1, SC_ONE_OR_MORE_BOUND > sc_event_queue_port
virtual void cancel_all()=0
virtual void notify(double when, sc_time_unit base)
virtual void cancel_all()
The event class.
Definition: sc_event.h:260
uint64_t uint64
Definition: sc_nbdefs.h:183
Abstract base class of all interface classes.
Definition: sc_interface.h:44
Base class for all structural entities.
Definition: sc_module.h:83
A queue that can contain any number of pending delta, or timed events.
virtual void notify(double when, sc_time_unit base)=0
sc_time_unit
Definition: sc_time.h:56