sc_prim.cc revision 13238:3521d1f59c22
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#include "base/logging.hh"
31#include "systemc/core/channel.hh"
32#include "systemc/core/scheduler.hh"
33#include "systemc/ext/core/sc_main.hh"
34#include "systemc/ext/core/sc_prim.hh"
35
36namespace sc_gem5
37{
38
39uint64_t getChangeStamp() { return scheduler.changeStamp(); }
40
41} // namespace sc_gem5
42
43namespace sc_core
44{
45
46sc_prim_channel::sc_prim_channel() : _gem5_channel(nullptr)
47{
48    if (sc_is_running()) {
49        SC_REPORT_ERROR("(E113) insert primitive channel failed",
50                "simulation running");
51    } else if (::sc_gem5::scheduler.elaborationDone()) {
52        SC_REPORT_ERROR("(E113) insert primitive channel failed",
53                "elaboration done");
54    } else {
55        _gem5_channel = new sc_gem5::Channel(this);
56    }
57}
58
59sc_prim_channel::sc_prim_channel(const char *_name) :
60    sc_object(_name), _gem5_channel(nullptr)
61{
62    if (sc_is_running()) {
63        SC_REPORT_ERROR("(E113) insert primitive channel failed",
64                "simulation running");
65    } else if (::sc_gem5::scheduler.elaborationDone()) {
66        SC_REPORT_ERROR("(E113) insert primitive channel failed",
67                "elaboration done");
68    } else {
69        _gem5_channel = new sc_gem5::Channel(this);
70    }
71}
72
73sc_prim_channel::~sc_prim_channel() { delete _gem5_channel; }
74
75void
76sc_prim_channel::request_update()
77{
78    _gem5_channel->requestUpdate();
79}
80
81void
82sc_prim_channel::async_request_update()
83{
84    _gem5_channel->asyncRequestUpdate();
85}
86
87void
88sc_prim_channel::next_trigger()
89{
90    ::sc_core::next_trigger();
91}
92
93void
94sc_prim_channel::next_trigger(const sc_event &e)
95{
96    ::sc_core::next_trigger(e);
97}
98
99void
100sc_prim_channel::next_trigger(const sc_event_or_list &eol)
101{
102    ::sc_core::next_trigger(eol);
103}
104
105void
106sc_prim_channel::next_trigger(const sc_event_and_list &eal)
107{
108    ::sc_core::next_trigger(eal);
109}
110
111void
112sc_prim_channel::next_trigger(const sc_time &t)
113{
114    ::sc_core::next_trigger(t);
115}
116
117void
118sc_prim_channel::next_trigger(double d, sc_time_unit u)
119{
120    ::sc_core::next_trigger(d, u);
121}
122
123void
124sc_prim_channel::next_trigger(const sc_time &t, const sc_event &e)
125{
126    ::sc_core::next_trigger(t, e);
127}
128
129void
130sc_prim_channel::next_trigger(double d, sc_time_unit u, const sc_event &e)
131{
132    ::sc_core::next_trigger(d, u, e);
133}
134
135void
136sc_prim_channel::next_trigger(const sc_time &t, const sc_event_or_list &eol)
137{
138    ::sc_core::next_trigger(t, eol);
139}
140
141void
142sc_prim_channel::next_trigger(
143        double d, sc_time_unit u, const sc_event_or_list &eol)
144{
145    ::sc_core::next_trigger(d, u, eol);
146}
147
148void
149sc_prim_channel::next_trigger(const sc_time &t, const sc_event_and_list &eal)
150{
151    ::sc_core::next_trigger(t, eal);
152}
153
154void
155sc_prim_channel::next_trigger(
156        double d, sc_time_unit u, const sc_event_and_list &eal)
157{
158    ::sc_core::next_trigger(d, u, eal);
159}
160
161bool
162sc_prim_channel::timed_out()
163{
164    return ::sc_core::timed_out();
165}
166
167void
168sc_prim_channel::wait()
169{
170    ::sc_core::wait();
171}
172
173void
174sc_prim_channel::wait(int i)
175{
176    ::sc_core::wait(i);
177}
178
179void
180sc_prim_channel::wait(const sc_event &e)
181{
182    ::sc_core::wait(e);
183}
184
185void
186sc_prim_channel::wait(const sc_event_or_list &eol)
187{
188    ::sc_core::wait(eol);
189}
190
191void
192sc_prim_channel::wait(const sc_event_and_list &eal)
193{
194    ::sc_core::wait(eal);
195}
196
197void
198sc_prim_channel::wait(const sc_time &t)
199{
200    ::sc_core::wait(t);
201}
202
203void
204sc_prim_channel::wait(double d, sc_time_unit u)
205{
206    ::sc_core::wait(d, u);
207}
208
209void
210sc_prim_channel::wait(const sc_time &t, const sc_event &e)
211{
212    ::sc_core::wait(t, e);
213}
214
215void
216sc_prim_channel::wait(double d, sc_time_unit u, const sc_event &e)
217{
218    ::sc_core::wait(d, u, e);
219}
220
221void
222sc_prim_channel::wait(const sc_time &t, const sc_event_or_list &eol)
223{
224    ::sc_core::wait(t, eol);
225}
226
227void
228sc_prim_channel::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
229{
230    ::sc_core::wait(d, u, eol);
231}
232
233void
234sc_prim_channel::wait(const sc_time &t, const sc_event_and_list &eal)
235{
236    ::sc_core::wait(t, eal);
237}
238
239void
240sc_prim_channel::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
241{
242    ::sc_core::wait(d, u, eal);
243}
244
245} // namespace sc_core
246