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 // ---------------------------------------------------------------------------
59 // sc_event_queue_if
60 // ---------------------------------------------------------------------------
61 
62 class sc_event_queue_if : public virtual sc_interface
63 {
64 public:
65  virtual void notify (double when, sc_time_unit base) =0;
66  virtual void notify (const sc_time& when) =0;
67  virtual void cancel_all() =0;
68 };
69 
70 // ---------------------------------------------------------------------------
71 // sc_event_queue: a queue that can contain any number of pending
72 // delta, or timed events.
73 // ---------------------------------------------------------------------------
74 
76  public sc_event_queue_if,
77  public sc_module
78 {
79  public:
80 
82 
83  sc_event_queue( sc_module_name name_ = sc_gen_unique_name("event_queue") );
85 
86  // API of sc_object
87  inline virtual const char* kind() const { return "sc_event_queue"; }
88 
89  //
90  // API of sc_event_queue_if
91  //
92  inline virtual void notify (double when, sc_time_unit base);
93  virtual void notify (const sc_time& when);
94  virtual void cancel_all();
95 
96  //
97  // API for using the event queue in processes
98  //
99 
100  // get the default event
101  inline virtual const sc_event& default_event() const;
102 
103 /*
104  //
105  // Possible extensions:
106  //
107 
108  // Cancel an events at a specific time
109  void cancel (const sc_time& when);
110  void cancel (double when, sc_time_unit base);
111 
112  // How many events are pending altogether?
113  unsigned pending() const;
114 
115  // How many events are pending at the specific time?
116  unsigned pending(const sc_time& when) const;
117  unsigned pending(double when, sc_time_unit base) const;
118 */
119 
120  private:
121  void fire_event();
122 
123  private:
124  sc_ppq<sc_time*> m_ppq;
125  sc_event m_e;
126  sc_dt::uint64 m_change_stamp;
127  unsigned m_pending_delta;
128 };
129 
130 inline
131 void sc_event_queue::notify (double when, sc_time_unit base )
132 {
133  notify( sc_time(when,base) );
134 }
135 
136 inline
138 {
139  return m_e;
140 }
141 
142 
143 //
144 // Using event queue as a port
145 //
147 
148 } // namespace sc_core
149 
150 // $Log: sc_event_queue.h,v $
151 // Revision 1.5 2011/08/26 20:45:40 acg
152 // Andy Goodrich: moved the modification log to the end of the file to
153 // eliminate source line number skew when check-ins are done.
154 //
155 // Revision 1.4 2011/04/05 20:48:09 acg
156 // Andy Goodrich: changes to make sure that event(), posedge() and negedge()
157 // only return true if the clock has not moved.
158 //
159 // Revision 1.3 2011/02/18 20:23:45 acg
160 // Andy Goodrich: Copyright update.
161 //
162 // Revision 1.2 2008/05/20 16:45:52 acg
163 // Andy Goodrich: changed which unique name generator is used from the
164 // global one to the one for sc_modules.
165 //
166 // Revision 1.1.1.1 2006/12/15 20:20:04 acg
167 // SystemC 2.3
168 //
169 // Revision 1.4 2006/11/28 20:30:48 acg
170 // Andy Goodrich: updated from 2.2 source. sc_event_queue constructors
171 // collapsed into a single constructor with an optional argument to get
172 // the sc_module_name stack done correctly. Class name prefixing added
173 // to sc_semaphore calls to wait() to keep gcc 4.x happy.
174 //
175 // Revision 1.3 2006/01/13 18:47:42 acg
176 // Added $Log command so that CVS comments are reproduced in the source.
177 //
178 
179 #endif // SC_EVENT_QUEUE_H
virtual void cancel_all()
sc_time_unit
Definition: sc_time.h:56
uint64_t uint64
Definition: sc_nbdefs.h:183
sc_port< sc_event_queue_if, 1, SC_ONE_OR_MORE_BOUND > sc_event_queue_port
virtual void cancel_all()=0
SC_HAS_PROCESS(sc_event_queue)
virtual const sc_event & default_event() const
const char * sc_gen_unique_name(const char *, bool preserve_first)
virtual void notify(double when, sc_time_unit base)=0
virtual void notify(double when, sc_time_unit base)
sc_event_queue(sc_module_name name_=sc_gen_unique_name("event_queue"))
virtual const char * kind() const