SystemC 3.0.0
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
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
56
57namespace sc_core {
58
60
61// ---------------------------------------------------------------------------
62// sc_event_queue_if
63// ---------------------------------------------------------------------------
64
66{
67public:
68 virtual void notify (double when, sc_time_unit base) =0;
69 virtual void notify (const sc_time& when) =0;
70 virtual void cancel_all() =0;
71};
72
73// ---------------------------------------------------------------------------
74// sc_event_queue: a queue that can contain any number of pending
75// delta, or timed events.
76// ---------------------------------------------------------------------------
77
79 public sc_event_queue_if,
80 public sc_module
81{
82 public:
83
86
87 // API of sc_object
88 inline virtual const char* kind() const { return "sc_event_queue"; }
89
90 //
91 // API of sc_event_queue_if
92 //
93 inline virtual void notify (double when, sc_time_unit base);
94 virtual void notify (const sc_time& when);
95 virtual void cancel_all();
96
97 //
98 // API for using the event queue in processes
99 //
100
101 // get the default event
102 inline virtual const sc_event& default_event() const;
103
104/*
105 //
106 // Possible extensions:
107 //
108
109 // Cancel an events at a specific time
110 void cancel (const sc_time& when);
111 void cancel (double when, sc_time_unit base);
112
113 // How many events are pending altogether?
114 unsigned pending() const;
115
116 // How many events are pending at the specific time?
117 unsigned pending(const sc_time& when) const;
118 unsigned pending(double when, sc_time_unit base) const;
119*/
120
121 private:
122 void fire_event();
123
124 private:
125 sc_ppq<sc_time*> m_ppq;
126 sc_event m_e;
127 sc_dt::uint64 m_change_stamp;
128 unsigned m_pending_delta;
129};
130
131inline
132void sc_event_queue::notify (double when, sc_time_unit base )
133{
134 notify( sc_time(when,base) );
135}
136
137inline
139{
140 return m_e;
141}
142
143
144//
145// Using event queue as a port
146//
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
#define SC_API_TEMPLATE_DECL_
Definition: sc_cmnhdr.h:157
#define SC_API
Definition: sc_cmnhdr.h:148
SC_API const char * sc_gen_unique_name(const char *, bool preserve_first)
void notify(sc_event &e)
sc_time_unit
Definition: sc_time.h:82
sc_port< sc_event_queue_if, 1, SC_ONE_OR_MORE_BOUND > sc_event_queue_port
template class SC_API sc_ppq< sc_time * >
unsigned long long uint64
Definition: sc_nbdefs.h:216
virtual void notify(double when, sc_time_unit base)=0
virtual void notify(const sc_time &when)=0
virtual void cancel_all()=0
virtual const char * kind() const
sc_event_queue(sc_module_name name_=sc_gen_unique_name("event_queue"))
virtual void notify(double when, sc_time_unit base)
virtual const sc_event & default_event() const
virtual void cancel_all()
virtual void notify(const sc_time &when)