SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_event_queue.h
Go to the documentation of this file.
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 */
33 #ifndef SC_EVENT_QUEUE_H
34 #define SC_EVENT_QUEUE_H
35 
36 
37 /*
38  Class sc_event_queue
39 
40  A queue that can contain any number of pending notifications.
41  The queue has a similiar interface like an sc_event but has different
42  semantics: it can carry any number of pending notification. The
43  general rule is that _every_ call to notify() will cause a
44  corresponding trigger at the specified wall-clock time that can be
45  observed (the only exception is when notifications are explicitly
46  cancelled).
47 
48  If multiple notifications are pending at the same wall-clock
49  time, then the event queue will trigger in different delta cycles
50  in order to ensure that sensitive processes can notice each
51  trigger. The first trigger happens in the earliest delta cycle
52  possible which is the same behavior as a normal timed event.
53 
54 */
55 
57 #include "sysc/kernel/sc_module.h"
58 #include "sysc/kernel/sc_event.h"
60 
61 namespace sc_core {
62 
64 
69 class SC_API sc_event_queue_if : public virtual sc_interface
70 {
71 public:
72  virtual void notify (double when, sc_time_unit base) =0;
73  virtual void notify (const sc_time& when) =0;
74  virtual void cancel_all() =0;
75 };
76 
83  public sc_event_queue_if,
84  public sc_module
85 {
86  public:
87 
89 
90  sc_event_queue( sc_module_name name_ = sc_gen_unique_name("event_queue") );
91  ~sc_event_queue();
92 
93  // API of sc_object
94  inline virtual const char* kind() const { return "sc_event_queue"; }
95 
96  //
97  // API of sc_event_queue_if
98  //
99  inline virtual void notify (double when, sc_time_unit base);
100  virtual void notify (const sc_time& when);
101  virtual void cancel_all();
102 
103  //
104  // API for using the event queue in processes
105  //
106 
107  // get the default event
108  inline virtual const sc_event& default_event() const;
109 
110 /*
111  //
112  // Possible extensions:
113  //
114 
115  // Cancel an events at a specific time
116  void cancel (const sc_time& when);
117  void cancel (double when, sc_time_unit base);
118 
119  // How many events are pending altogether?
120  unsigned pending() const;
121 
122  // How many events are pending at the specific time?
123  unsigned pending(const sc_time& when) const;
124  unsigned pending(double when, sc_time_unit base) const;
125 */
126 
127  private:
128  void fire_event();
129 
130  private:
131  sc_ppq<sc_time*> m_ppq;
132  sc_event m_e;
133  sc_dt::uint64 m_change_stamp;
134  unsigned m_pending_delta;
135 };
136 
137 inline
138 void sc_event_queue::notify (double when, sc_time_unit base )
139 {
140  notify( sc_time(when,base) );
141 }
142 
143 inline
145 {
146  return m_e;
147 }
148 
149 
150 //
151 // Using event queue as a port
152 //
155 
156 } // namespace sc_core
157 
158 // $Log: sc_event_queue.h,v $
159 // Revision 1.5 2011/08/26 20:45:40 acg
160 // Andy Goodrich: moved the modification log to the end of the file to
161 // eliminate source line number skew when check-ins are done.
162 //
163 // Revision 1.4 2011/04/05 20:48:09 acg
164 // Andy Goodrich: changes to make sure that event(), posedge() and negedge()
165 // only return true if the clock has not moved.
166 //
167 // Revision 1.3 2011/02/18 20:23:45 acg
168 // Andy Goodrich: Copyright update.
169 //
170 // Revision 1.2 2008/05/20 16:45:52 acg
171 // Andy Goodrich: changed which unique name generator is used from the
172 // global one to the one for sc_modules.
173 //
174 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
175 // SystemC 2.3
176 //
177 // Revision 1.4 2006/11/28 20:30:48 acg
178 // Andy Goodrich: updated from 2.2 source. sc_event_queue constructors
179 // collapsed into a single constructor with an optional argument to get
180 // the sc_module_name stack done correctly. Class name prefixing added
181 // to sc_semaphore calls to wait() to keep gcc 4.x happy.
182 //
183 // Revision 1.3 2006/01/13 18:47:42 acg
184 // Added $Log command so that CVS comments are reproduced in the source.
185 //
186 
187 #endif // SC_EVENT_QUEUE_H
Base classes of all port classes.
virtual const sc_event & default_event() const
Generic port class and base class for other port classes.
Definition: sc_port.h:391
The event class.
Definition: sc_event.h:256
Module name class.
uint64_t uint64
Definition: sc_nbdefs.h:189
virtual void notify(double when, sc_time_unit base)
sc_port< sc_event_queue_if, 1, SC_ONE_OR_MORE_BOUND > sc_event_queue_port
Abstract base class of all interface classes.
Base class for all structural entities.
Definition: sc_module.h:83
Abstract base class of all interface classes.
Definition: sc_interface.h:51
The time class.
Definition: sc_time.h:82
SC_API const char * sc_gen_unique_name(const char *, bool preserve_first)
virtual const char * kind() const
Base class of all hierarchical modules and channels.
#define SC_API_TEMPLATE_DECL_
Definition: sc_cmnhdr.h:177
void notify(sc_event &e)
#define SC_API
Definition: sc_cmnhdr.h:168
Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21.
sc_time_unit
Enumeration of time units.
Definition: sc_time.h:64
#define SC_HAS_PROCESS(user_module_name)
Definition: sc_module.h:412