sc_module.cc (13091:81fceed26e1e) sc_module.cc (13135:4bb2f323fb1a)
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 <memory>
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 <memory>
31#include <string>
31#include <vector>
32
33#include "base/logging.hh"
34#include "systemc/core/kernel.hh"
35#include "systemc/core/module.hh"
36#include "systemc/core/process_types.hh"
37#include "systemc/ext/core/sc_module.hh"
38#include "systemc/ext/core/sc_module_name.hh"
32#include <vector>
33
34#include "base/logging.hh"
35#include "systemc/core/kernel.hh"
36#include "systemc/core/module.hh"
37#include "systemc/core/process_types.hh"
38#include "systemc/ext/core/sc_module.hh"
39#include "systemc/ext/core/sc_module_name.hh"
40#include "systemc/ext/utils/sc_report_handler.hh"
39
40namespace sc_gem5
41{
42
43Process *
44newMethodProcess(const char *name, ProcessFuncWrapper *func)
45{
41
42namespace sc_gem5
43{
44
45Process *
46newMethodProcess(const char *name, ProcessFuncWrapper *func)
47{
46 Process *p = new Method(name, func);
48 Method *p = new Method(name, func);
49 if (::sc_core::sc_is_running()) {
50 std::string name = p->name();
51 delete p;
52 SC_REPORT_ERROR("(E541) call to SC_METHOD in sc_module while "
53 "simulation running", name.c_str());
54 return nullptr;
55 }
47 scheduler.reg(p);
48 return p;
49}
50
51Process *
52newThreadProcess(const char *name, ProcessFuncWrapper *func)
53{
56 scheduler.reg(p);
57 return p;
58}
59
60Process *
61newThreadProcess(const char *name, ProcessFuncWrapper *func)
62{
54 Process *p = new Thread(name, func);
63 Thread *p = new Thread(name, func);
64 if (::sc_core::sc_is_running()) {
65 std::string name = p->name();
66 delete p;
67 SC_REPORT_ERROR("(E542) call to SC_THREAD in sc_module while "
68 "simulation running", name.c_str());
69 return nullptr;
70 }
55 scheduler.reg(p);
56 return p;
57}
58
59Process *
60newCThreadProcess(const char *name, ProcessFuncWrapper *func)
61{
71 scheduler.reg(p);
72 return p;
73}
74
75Process *
76newCThreadProcess(const char *name, ProcessFuncWrapper *func)
77{
62 Process *p = new CThread(name, func);
78 CThread *p = new CThread(name, func);
79 if (::sc_core::sc_is_running()) {
80 std::string name = p->name();
81 delete p;
82 SC_REPORT_ERROR("(E543) call to SC_CTHREAD in sc_module while "
83 "simulation running", name.c_str());
84 return nullptr;
85 }
63 scheduler.reg(p);
64 p->dontInitialize();
65 return p;
66}
67
68UniqueNameGen nameGen;
69
70} // namespace sc_gem5
71
72namespace sc_core
73{
74
75sc_bind_proxy::sc_bind_proxy(sc_interface &_interface) :
76 _interface(&_interface), _port(nullptr)
77{}
78
79sc_bind_proxy::sc_bind_proxy(sc_port_base &_port) :
80 _interface(nullptr), _port(&_port)
81{}
82
83const sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr);
84
85sc_module::~sc_module() { delete _gem5_module; }
86
87const sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr);
88
89void
90sc_module::operator () (const sc_bind_proxy &p001,
91 const sc_bind_proxy &p002,
92 const sc_bind_proxy &p003,
93 const sc_bind_proxy &p004,
94 const sc_bind_proxy &p005,
95 const sc_bind_proxy &p006,
96 const sc_bind_proxy &p007,
97 const sc_bind_proxy &p008,
98 const sc_bind_proxy &p009,
99 const sc_bind_proxy &p010,
100 const sc_bind_proxy &p011,
101 const sc_bind_proxy &p012,
102 const sc_bind_proxy &p013,
103 const sc_bind_proxy &p014,
104 const sc_bind_proxy &p015,
105 const sc_bind_proxy &p016,
106 const sc_bind_proxy &p017,
107 const sc_bind_proxy &p018,
108 const sc_bind_proxy &p019,
109 const sc_bind_proxy &p020,
110 const sc_bind_proxy &p021,
111 const sc_bind_proxy &p022,
112 const sc_bind_proxy &p023,
113 const sc_bind_proxy &p024,
114 const sc_bind_proxy &p025,
115 const sc_bind_proxy &p026,
116 const sc_bind_proxy &p027,
117 const sc_bind_proxy &p028,
118 const sc_bind_proxy &p029,
119 const sc_bind_proxy &p030,
120 const sc_bind_proxy &p031,
121 const sc_bind_proxy &p032,
122 const sc_bind_proxy &p033,
123 const sc_bind_proxy &p034,
124 const sc_bind_proxy &p035,
125 const sc_bind_proxy &p036,
126 const sc_bind_proxy &p037,
127 const sc_bind_proxy &p038,
128 const sc_bind_proxy &p039,
129 const sc_bind_proxy &p040,
130 const sc_bind_proxy &p041,
131 const sc_bind_proxy &p042,
132 const sc_bind_proxy &p043,
133 const sc_bind_proxy &p044,
134 const sc_bind_proxy &p045,
135 const sc_bind_proxy &p046,
136 const sc_bind_proxy &p047,
137 const sc_bind_proxy &p048,
138 const sc_bind_proxy &p049,
139 const sc_bind_proxy &p050,
140 const sc_bind_proxy &p051,
141 const sc_bind_proxy &p052,
142 const sc_bind_proxy &p053,
143 const sc_bind_proxy &p054,
144 const sc_bind_proxy &p055,
145 const sc_bind_proxy &p056,
146 const sc_bind_proxy &p057,
147 const sc_bind_proxy &p058,
148 const sc_bind_proxy &p059,
149 const sc_bind_proxy &p060,
150 const sc_bind_proxy &p061,
151 const sc_bind_proxy &p062,
152 const sc_bind_proxy &p063,
153 const sc_bind_proxy &p064)
154{
155 std::vector<const ::sc_core::sc_bind_proxy *> proxies;
156 auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool {
157 if (!p.port() && !p.interface())
158 return false;
159 proxies.push_back(&p);
160 return true;
161 };
162 insert(p001) && insert(p002) && insert(p003) && insert(p004) &&
163 insert(p005) && insert(p006) && insert(p007) && insert(p008) &&
164 insert(p009) && insert(p010) && insert(p011) && insert(p012) &&
165 insert(p013) && insert(p014) && insert(p015) && insert(p016) &&
166 insert(p017) && insert(p018) && insert(p019) && insert(p020) &&
167 insert(p021) && insert(p022) && insert(p023) && insert(p024) &&
168 insert(p025) && insert(p026) && insert(p027) && insert(p028) &&
169 insert(p029) && insert(p030) && insert(p031) && insert(p032) &&
170 insert(p033) && insert(p034) && insert(p035) && insert(p036) &&
171 insert(p037) && insert(p038) && insert(p039) && insert(p040) &&
172 insert(p041) && insert(p042) && insert(p043) && insert(p044) &&
173 insert(p045) && insert(p046) && insert(p047) && insert(p048) &&
174 insert(p049) && insert(p050) && insert(p051) && insert(p052) &&
175 insert(p053) && insert(p054) && insert(p055) && insert(p056) &&
176 insert(p057) && insert(p058) && insert(p059) && insert(p060) &&
177 insert(p061) && insert(p062) && insert(p063) && insert(p064);
178 _gem5_module->bindPorts(proxies);
179}
180
181const std::vector<sc_object *> &
182sc_module::get_child_objects() const
183{
184 return _gem5_module->obj()->get_child_objects();
185}
186
187const std::vector<sc_event *> &
188sc_module::get_child_events() const
189{
190 return _gem5_module->obj()->get_child_events();
191}
192
193sc_module::sc_module() :
194 sc_object(sc_gem5::newModuleChecked()->name()),
195 _gem5_module(sc_gem5::currentModule())
196{}
197
198sc_module::sc_module(const sc_module_name &) : sc_module() {}
199sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name)) {}
200sc_module::sc_module(const std::string &_name) :
201 sc_module(sc_module_name(_name.c_str()))
202{}
203
204void
205sc_module::reset_signal_is(const sc_in<bool> &, bool)
206{
207 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
208}
209
210void
211sc_module::reset_signal_is(const sc_inout<bool> &, bool)
212{
213 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
214}
215
216void
217sc_module::reset_signal_is(const sc_out<bool> &, bool)
218{
219 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
220}
221
222void
223sc_module::reset_signal_is(const sc_signal_in_if<bool> &, bool)
224{
225 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
226}
227
228
229void
230sc_module::async_reset_signal_is(const sc_in<bool> &, bool)
231{
232 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
233}
234
235void
236sc_module::async_reset_signal_is(const sc_inout<bool> &, bool)
237{
238 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
239}
240
241void
242sc_module::async_reset_signal_is(const sc_out<bool> &, bool)
243{
244 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
245}
246
247void
248sc_module::async_reset_signal_is(const sc_signal_in_if<bool> &, bool)
249{
250 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
251}
252
253
254void
255sc_module::dont_initialize()
256{
257 ::sc_gem5::Process::newest()->dontInitialize();
258}
259
260void
261sc_module::set_stack_size(size_t size)
262{
263 ::sc_gem5::Process::newest()->setStackSize(size);
264}
265
266
267void sc_module::next_trigger() { ::sc_core::next_trigger(); }
268
269void
270sc_module::next_trigger(const sc_event &e)
271{
272 ::sc_core::next_trigger(e);
273}
274
275void
276sc_module::next_trigger(const sc_event_or_list &eol)
277{
278 ::sc_core::next_trigger(eol);
279}
280
281void
282sc_module::next_trigger(const sc_event_and_list &eal)
283{
284 ::sc_core::next_trigger(eal);
285}
286
287void
288sc_module::next_trigger(const sc_time &t)
289{
290 ::sc_core::next_trigger(t);
291}
292
293void
294sc_module::next_trigger(double d, sc_time_unit u)
295{
296 ::sc_core::next_trigger(d, u);
297}
298
299void
300sc_module::next_trigger(const sc_time &t, const sc_event &e)
301{
302 ::sc_core::next_trigger(t, e);
303}
304
305void
306sc_module::next_trigger(double d, sc_time_unit u, const sc_event &e)
307{
308 ::sc_core::next_trigger(d, u, e);
309}
310
311void
312sc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol)
313{
314 ::sc_core::next_trigger(t, eol);
315}
316
317void
318sc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
319{
320 ::sc_core::next_trigger(d, u, eol);
321}
322
323void
324sc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal)
325{
326 ::sc_core::next_trigger(t, eal);
327}
328
329void
330sc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
331{
332 ::sc_core::next_trigger(d, u, eal);
333}
334
335
336bool
337sc_module::timed_out()
338{
339 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
340 return false;
341}
342
343
344void
345sc_module::wait()
346{
347 ::sc_core::wait();
348}
349
350void
351sc_module::wait(int i)
352{
353 ::sc_core::wait(i);
354}
355
356void
357sc_module::wait(const sc_event &e)
358{
359 ::sc_core::wait(e);
360}
361
362void
363sc_module::wait(const sc_event_or_list &eol)
364{
365 ::sc_core::wait(eol);
366}
367
368void
369sc_module::wait(const sc_event_and_list &eal)
370{
371 ::sc_core::wait(eal);
372}
373
374void
375sc_module::wait(const sc_time &t)
376{
377 ::sc_core::wait(t);
378}
379
380void
381sc_module::wait(double d, sc_time_unit u)
382{
383 ::sc_core::wait(d, u);
384}
385
386void
387sc_module::wait(const sc_time &t, const sc_event &e)
388{
389 ::sc_core::wait(t, e);
390}
391
392void
393sc_module::wait(double d, sc_time_unit u, const sc_event &e)
394{
395 ::sc_core::wait(d, u, e);
396}
397
398void
399sc_module::wait(const sc_time &t, const sc_event_or_list &eol)
400{
401 ::sc_core::wait(t, eol);
402}
403
404void
405sc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
406{
407 ::sc_core::wait(d, u, eol);
408}
409
410void
411sc_module::wait(const sc_time &t, const sc_event_and_list &eal)
412{
413 ::sc_core::wait(t, eal);
414}
415
416void
417sc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
418{
419 ::sc_core::wait(d, u, eal);
420}
421
422
423void
424sc_module::halt()
425{
426 ::sc_core::halt();
427}
428
429void
430sc_module::at_posedge(const sc_signal_in_if<bool> &s)
431{
432 ::sc_core::at_posedge(s);
433}
434
435void
436sc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
437{
438 ::sc_core::at_posedge(s);
439}
440
441void
442sc_module::at_negedge(const sc_signal_in_if<bool> &s)
443{
444 ::sc_core::at_negedge(s);
445}
446
447void
448sc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
449{
450 ::sc_core::at_negedge(s);
451}
452
453
454void
455next_trigger()
456{
457 sc_gem5::Process *p = sc_gem5::scheduler.current();
458 p->setDynamic(nullptr);
459}
460
461void
462next_trigger(const sc_event &e)
463{
464 sc_gem5::Process *p = sc_gem5::scheduler.current();
465 p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e));
466}
467
468void
469next_trigger(const sc_event_or_list &eol)
470{
471 sc_gem5::Process *p = sc_gem5::scheduler.current();
472 p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol));
473}
474
475void
476next_trigger(const sc_event_and_list &eal)
477{
478 sc_gem5::Process *p = sc_gem5::scheduler.current();
479 p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal));
480}
481
482void
483next_trigger(const sc_time &t)
484{
485 sc_gem5::Process *p = sc_gem5::scheduler.current();
486 p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t));
487}
488
489void
490next_trigger(double d, sc_time_unit u)
491{
492 next_trigger(sc_time(d, u));
493}
494
495void
496next_trigger(const sc_time &t, const sc_event &e)
497{
498 sc_gem5::Process *p = sc_gem5::scheduler.current();
499 p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e));
500}
501
502void
503next_trigger(double d, sc_time_unit u, const sc_event &e)
504{
505 next_trigger(sc_time(d, u), e);
506}
507
508void
509next_trigger(const sc_time &t, const sc_event_or_list &eol)
510{
511 sc_gem5::Process *p = sc_gem5::scheduler.current();
512 p->setDynamic(
513 new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol));
514}
515
516void
517next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
518{
519 next_trigger(sc_time(d, u), eol);
520}
521
522void
523next_trigger(const sc_time &t, const sc_event_and_list &eal)
524{
525 sc_gem5::Process *p = sc_gem5::scheduler.current();
526 p->setDynamic(
527 new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal));
528}
529
530void
531next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
532{
533 next_trigger(sc_time(d, u), eal);
534}
535
536bool
537timed_out()
538{
539 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
540 return false;
541}
542
543
544void
545wait()
546{
547 sc_gem5::Process *p = sc_gem5::scheduler.current();
548 p->setDynamic(nullptr);
549 sc_gem5::scheduler.yield();
550}
551
552void
553wait(int n)
554{
555 for (int i = 0; i < n; i++)
556 wait();
557}
558
559void
560wait(const sc_event &e)
561{
562 sc_gem5::Process *p = sc_gem5::scheduler.current();
563 p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e));
564 sc_gem5::scheduler.yield();
565}
566
567void
568wait(const sc_event_or_list &eol)
569{
570 sc_gem5::Process *p = sc_gem5::scheduler.current();
571 p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol));
572 sc_gem5::scheduler.yield();
573}
574
575void
576wait(const sc_event_and_list &eal)
577{
578 sc_gem5::Process *p = sc_gem5::scheduler.current();
579 p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal));
580 sc_gem5::scheduler.yield();
581}
582
583void
584wait(const sc_time &t)
585{
586 sc_gem5::Process *p = sc_gem5::scheduler.current();
587 p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t));
588 sc_gem5::scheduler.yield();
589}
590
591void
592wait(double d, sc_time_unit u)
593{
594 wait(sc_time(d, u));
595}
596
597void
598wait(const sc_time &t, const sc_event &e)
599{
600 sc_gem5::Process *p = sc_gem5::scheduler.current();
601 p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e));
602 sc_gem5::scheduler.yield();
603}
604
605void
606wait(double d, sc_time_unit u, const sc_event &e)
607{
608 wait(sc_time(d, u), e);
609}
610
611void
612wait(const sc_time &t, const sc_event_or_list &eol)
613{
614 sc_gem5::Process *p = sc_gem5::scheduler.current();
615 p->setDynamic(
616 new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol));
617 sc_gem5::scheduler.yield();
618}
619
620void
621wait(double d, sc_time_unit u, const sc_event_or_list &eol)
622{
623 wait(sc_time(d, u), eol);
624}
625
626void
627wait(const sc_time &t, const sc_event_and_list &eal)
628{
629 sc_gem5::Process *p = sc_gem5::scheduler.current();
630 p->setDynamic(
631 new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal));
632 sc_gem5::scheduler.yield();
633}
634
635void
636wait(double d, sc_time_unit u, const sc_event_and_list &eal)
637{
638 wait(sc_time(d, u), eal);
639}
640
641void
642halt()
643{
644 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
645}
646
647void
648at_posedge(const sc_signal_in_if<bool> &)
649{
650 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
651}
652
653void
654at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &)
655{
656 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
657}
658
659void
660at_negedge(const sc_signal_in_if<bool> &)
661{
662 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
663}
664
665void
666at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &)
667{
668 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
669}
670
671const char *
672sc_gen_unique_name(const char *seed)
673{
674 ::sc_gem5::Module *mod = ::sc_gem5::currentModule();
675 return mod ? mod->uniqueName(seed) :
676 ::sc_gem5::nameGen.gen(seed);
677}
678
679bool
680sc_hierarchical_name_exists(const char *name)
681{
682 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
683 return false;
684}
685
686bool
687sc_start_of_simulation_invoked()
688{
689 return ::sc_gem5::kernel->startOfSimulationComplete();
690}
691
692bool
693sc_end_of_simulation_invoked()
694{
695 return ::sc_gem5::kernel->endOfSimulationComplete();
696}
697
698sc_module *
699sc_module_sc_new(sc_module *mod)
700{
701 static std::vector<std::unique_ptr<sc_module> > modules;
702 modules.emplace_back(mod);
703 return mod;
704}
705
706} // namespace sc_core
86 scheduler.reg(p);
87 p->dontInitialize();
88 return p;
89}
90
91UniqueNameGen nameGen;
92
93} // namespace sc_gem5
94
95namespace sc_core
96{
97
98sc_bind_proxy::sc_bind_proxy(sc_interface &_interface) :
99 _interface(&_interface), _port(nullptr)
100{}
101
102sc_bind_proxy::sc_bind_proxy(sc_port_base &_port) :
103 _interface(nullptr), _port(&_port)
104{}
105
106const sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr);
107
108sc_module::~sc_module() { delete _gem5_module; }
109
110const sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr);
111
112void
113sc_module::operator () (const sc_bind_proxy &p001,
114 const sc_bind_proxy &p002,
115 const sc_bind_proxy &p003,
116 const sc_bind_proxy &p004,
117 const sc_bind_proxy &p005,
118 const sc_bind_proxy &p006,
119 const sc_bind_proxy &p007,
120 const sc_bind_proxy &p008,
121 const sc_bind_proxy &p009,
122 const sc_bind_proxy &p010,
123 const sc_bind_proxy &p011,
124 const sc_bind_proxy &p012,
125 const sc_bind_proxy &p013,
126 const sc_bind_proxy &p014,
127 const sc_bind_proxy &p015,
128 const sc_bind_proxy &p016,
129 const sc_bind_proxy &p017,
130 const sc_bind_proxy &p018,
131 const sc_bind_proxy &p019,
132 const sc_bind_proxy &p020,
133 const sc_bind_proxy &p021,
134 const sc_bind_proxy &p022,
135 const sc_bind_proxy &p023,
136 const sc_bind_proxy &p024,
137 const sc_bind_proxy &p025,
138 const sc_bind_proxy &p026,
139 const sc_bind_proxy &p027,
140 const sc_bind_proxy &p028,
141 const sc_bind_proxy &p029,
142 const sc_bind_proxy &p030,
143 const sc_bind_proxy &p031,
144 const sc_bind_proxy &p032,
145 const sc_bind_proxy &p033,
146 const sc_bind_proxy &p034,
147 const sc_bind_proxy &p035,
148 const sc_bind_proxy &p036,
149 const sc_bind_proxy &p037,
150 const sc_bind_proxy &p038,
151 const sc_bind_proxy &p039,
152 const sc_bind_proxy &p040,
153 const sc_bind_proxy &p041,
154 const sc_bind_proxy &p042,
155 const sc_bind_proxy &p043,
156 const sc_bind_proxy &p044,
157 const sc_bind_proxy &p045,
158 const sc_bind_proxy &p046,
159 const sc_bind_proxy &p047,
160 const sc_bind_proxy &p048,
161 const sc_bind_proxy &p049,
162 const sc_bind_proxy &p050,
163 const sc_bind_proxy &p051,
164 const sc_bind_proxy &p052,
165 const sc_bind_proxy &p053,
166 const sc_bind_proxy &p054,
167 const sc_bind_proxy &p055,
168 const sc_bind_proxy &p056,
169 const sc_bind_proxy &p057,
170 const sc_bind_proxy &p058,
171 const sc_bind_proxy &p059,
172 const sc_bind_proxy &p060,
173 const sc_bind_proxy &p061,
174 const sc_bind_proxy &p062,
175 const sc_bind_proxy &p063,
176 const sc_bind_proxy &p064)
177{
178 std::vector<const ::sc_core::sc_bind_proxy *> proxies;
179 auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool {
180 if (!p.port() && !p.interface())
181 return false;
182 proxies.push_back(&p);
183 return true;
184 };
185 insert(p001) && insert(p002) && insert(p003) && insert(p004) &&
186 insert(p005) && insert(p006) && insert(p007) && insert(p008) &&
187 insert(p009) && insert(p010) && insert(p011) && insert(p012) &&
188 insert(p013) && insert(p014) && insert(p015) && insert(p016) &&
189 insert(p017) && insert(p018) && insert(p019) && insert(p020) &&
190 insert(p021) && insert(p022) && insert(p023) && insert(p024) &&
191 insert(p025) && insert(p026) && insert(p027) && insert(p028) &&
192 insert(p029) && insert(p030) && insert(p031) && insert(p032) &&
193 insert(p033) && insert(p034) && insert(p035) && insert(p036) &&
194 insert(p037) && insert(p038) && insert(p039) && insert(p040) &&
195 insert(p041) && insert(p042) && insert(p043) && insert(p044) &&
196 insert(p045) && insert(p046) && insert(p047) && insert(p048) &&
197 insert(p049) && insert(p050) && insert(p051) && insert(p052) &&
198 insert(p053) && insert(p054) && insert(p055) && insert(p056) &&
199 insert(p057) && insert(p058) && insert(p059) && insert(p060) &&
200 insert(p061) && insert(p062) && insert(p063) && insert(p064);
201 _gem5_module->bindPorts(proxies);
202}
203
204const std::vector<sc_object *> &
205sc_module::get_child_objects() const
206{
207 return _gem5_module->obj()->get_child_objects();
208}
209
210const std::vector<sc_event *> &
211sc_module::get_child_events() const
212{
213 return _gem5_module->obj()->get_child_events();
214}
215
216sc_module::sc_module() :
217 sc_object(sc_gem5::newModuleChecked()->name()),
218 _gem5_module(sc_gem5::currentModule())
219{}
220
221sc_module::sc_module(const sc_module_name &) : sc_module() {}
222sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name)) {}
223sc_module::sc_module(const std::string &_name) :
224 sc_module(sc_module_name(_name.c_str()))
225{}
226
227void
228sc_module::reset_signal_is(const sc_in<bool> &, bool)
229{
230 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
231}
232
233void
234sc_module::reset_signal_is(const sc_inout<bool> &, bool)
235{
236 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
237}
238
239void
240sc_module::reset_signal_is(const sc_out<bool> &, bool)
241{
242 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
243}
244
245void
246sc_module::reset_signal_is(const sc_signal_in_if<bool> &, bool)
247{
248 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
249}
250
251
252void
253sc_module::async_reset_signal_is(const sc_in<bool> &, bool)
254{
255 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
256}
257
258void
259sc_module::async_reset_signal_is(const sc_inout<bool> &, bool)
260{
261 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
262}
263
264void
265sc_module::async_reset_signal_is(const sc_out<bool> &, bool)
266{
267 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
268}
269
270void
271sc_module::async_reset_signal_is(const sc_signal_in_if<bool> &, bool)
272{
273 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
274}
275
276
277void
278sc_module::dont_initialize()
279{
280 ::sc_gem5::Process::newest()->dontInitialize();
281}
282
283void
284sc_module::set_stack_size(size_t size)
285{
286 ::sc_gem5::Process::newest()->setStackSize(size);
287}
288
289
290void sc_module::next_trigger() { ::sc_core::next_trigger(); }
291
292void
293sc_module::next_trigger(const sc_event &e)
294{
295 ::sc_core::next_trigger(e);
296}
297
298void
299sc_module::next_trigger(const sc_event_or_list &eol)
300{
301 ::sc_core::next_trigger(eol);
302}
303
304void
305sc_module::next_trigger(const sc_event_and_list &eal)
306{
307 ::sc_core::next_trigger(eal);
308}
309
310void
311sc_module::next_trigger(const sc_time &t)
312{
313 ::sc_core::next_trigger(t);
314}
315
316void
317sc_module::next_trigger(double d, sc_time_unit u)
318{
319 ::sc_core::next_trigger(d, u);
320}
321
322void
323sc_module::next_trigger(const sc_time &t, const sc_event &e)
324{
325 ::sc_core::next_trigger(t, e);
326}
327
328void
329sc_module::next_trigger(double d, sc_time_unit u, const sc_event &e)
330{
331 ::sc_core::next_trigger(d, u, e);
332}
333
334void
335sc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol)
336{
337 ::sc_core::next_trigger(t, eol);
338}
339
340void
341sc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
342{
343 ::sc_core::next_trigger(d, u, eol);
344}
345
346void
347sc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal)
348{
349 ::sc_core::next_trigger(t, eal);
350}
351
352void
353sc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
354{
355 ::sc_core::next_trigger(d, u, eal);
356}
357
358
359bool
360sc_module::timed_out()
361{
362 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
363 return false;
364}
365
366
367void
368sc_module::wait()
369{
370 ::sc_core::wait();
371}
372
373void
374sc_module::wait(int i)
375{
376 ::sc_core::wait(i);
377}
378
379void
380sc_module::wait(const sc_event &e)
381{
382 ::sc_core::wait(e);
383}
384
385void
386sc_module::wait(const sc_event_or_list &eol)
387{
388 ::sc_core::wait(eol);
389}
390
391void
392sc_module::wait(const sc_event_and_list &eal)
393{
394 ::sc_core::wait(eal);
395}
396
397void
398sc_module::wait(const sc_time &t)
399{
400 ::sc_core::wait(t);
401}
402
403void
404sc_module::wait(double d, sc_time_unit u)
405{
406 ::sc_core::wait(d, u);
407}
408
409void
410sc_module::wait(const sc_time &t, const sc_event &e)
411{
412 ::sc_core::wait(t, e);
413}
414
415void
416sc_module::wait(double d, sc_time_unit u, const sc_event &e)
417{
418 ::sc_core::wait(d, u, e);
419}
420
421void
422sc_module::wait(const sc_time &t, const sc_event_or_list &eol)
423{
424 ::sc_core::wait(t, eol);
425}
426
427void
428sc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol)
429{
430 ::sc_core::wait(d, u, eol);
431}
432
433void
434sc_module::wait(const sc_time &t, const sc_event_and_list &eal)
435{
436 ::sc_core::wait(t, eal);
437}
438
439void
440sc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal)
441{
442 ::sc_core::wait(d, u, eal);
443}
444
445
446void
447sc_module::halt()
448{
449 ::sc_core::halt();
450}
451
452void
453sc_module::at_posedge(const sc_signal_in_if<bool> &s)
454{
455 ::sc_core::at_posedge(s);
456}
457
458void
459sc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
460{
461 ::sc_core::at_posedge(s);
462}
463
464void
465sc_module::at_negedge(const sc_signal_in_if<bool> &s)
466{
467 ::sc_core::at_negedge(s);
468}
469
470void
471sc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
472{
473 ::sc_core::at_negedge(s);
474}
475
476
477void
478next_trigger()
479{
480 sc_gem5::Process *p = sc_gem5::scheduler.current();
481 p->setDynamic(nullptr);
482}
483
484void
485next_trigger(const sc_event &e)
486{
487 sc_gem5::Process *p = sc_gem5::scheduler.current();
488 p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e));
489}
490
491void
492next_trigger(const sc_event_or_list &eol)
493{
494 sc_gem5::Process *p = sc_gem5::scheduler.current();
495 p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol));
496}
497
498void
499next_trigger(const sc_event_and_list &eal)
500{
501 sc_gem5::Process *p = sc_gem5::scheduler.current();
502 p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal));
503}
504
505void
506next_trigger(const sc_time &t)
507{
508 sc_gem5::Process *p = sc_gem5::scheduler.current();
509 p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t));
510}
511
512void
513next_trigger(double d, sc_time_unit u)
514{
515 next_trigger(sc_time(d, u));
516}
517
518void
519next_trigger(const sc_time &t, const sc_event &e)
520{
521 sc_gem5::Process *p = sc_gem5::scheduler.current();
522 p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e));
523}
524
525void
526next_trigger(double d, sc_time_unit u, const sc_event &e)
527{
528 next_trigger(sc_time(d, u), e);
529}
530
531void
532next_trigger(const sc_time &t, const sc_event_or_list &eol)
533{
534 sc_gem5::Process *p = sc_gem5::scheduler.current();
535 p->setDynamic(
536 new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol));
537}
538
539void
540next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol)
541{
542 next_trigger(sc_time(d, u), eol);
543}
544
545void
546next_trigger(const sc_time &t, const sc_event_and_list &eal)
547{
548 sc_gem5::Process *p = sc_gem5::scheduler.current();
549 p->setDynamic(
550 new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal));
551}
552
553void
554next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal)
555{
556 next_trigger(sc_time(d, u), eal);
557}
558
559bool
560timed_out()
561{
562 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
563 return false;
564}
565
566
567void
568wait()
569{
570 sc_gem5::Process *p = sc_gem5::scheduler.current();
571 p->setDynamic(nullptr);
572 sc_gem5::scheduler.yield();
573}
574
575void
576wait(int n)
577{
578 for (int i = 0; i < n; i++)
579 wait();
580}
581
582void
583wait(const sc_event &e)
584{
585 sc_gem5::Process *p = sc_gem5::scheduler.current();
586 p->setDynamic(new ::sc_gem5::SensitivityEvent(p, &e));
587 sc_gem5::scheduler.yield();
588}
589
590void
591wait(const sc_event_or_list &eol)
592{
593 sc_gem5::Process *p = sc_gem5::scheduler.current();
594 p->setDynamic(new ::sc_gem5::SensitivityEventOrList(p, &eol));
595 sc_gem5::scheduler.yield();
596}
597
598void
599wait(const sc_event_and_list &eal)
600{
601 sc_gem5::Process *p = sc_gem5::scheduler.current();
602 p->setDynamic(new ::sc_gem5::SensitivityEventAndList(p, &eal));
603 sc_gem5::scheduler.yield();
604}
605
606void
607wait(const sc_time &t)
608{
609 sc_gem5::Process *p = sc_gem5::scheduler.current();
610 p->setDynamic(new ::sc_gem5::SensitivityTimeout(p, t));
611 sc_gem5::scheduler.yield();
612}
613
614void
615wait(double d, sc_time_unit u)
616{
617 wait(sc_time(d, u));
618}
619
620void
621wait(const sc_time &t, const sc_event &e)
622{
623 sc_gem5::Process *p = sc_gem5::scheduler.current();
624 p->setDynamic(new ::sc_gem5::SensitivityTimeoutAndEvent(p, t, &e));
625 sc_gem5::scheduler.yield();
626}
627
628void
629wait(double d, sc_time_unit u, const sc_event &e)
630{
631 wait(sc_time(d, u), e);
632}
633
634void
635wait(const sc_time &t, const sc_event_or_list &eol)
636{
637 sc_gem5::Process *p = sc_gem5::scheduler.current();
638 p->setDynamic(
639 new ::sc_gem5::SensitivityTimeoutAndEventOrList(p, t, &eol));
640 sc_gem5::scheduler.yield();
641}
642
643void
644wait(double d, sc_time_unit u, const sc_event_or_list &eol)
645{
646 wait(sc_time(d, u), eol);
647}
648
649void
650wait(const sc_time &t, const sc_event_and_list &eal)
651{
652 sc_gem5::Process *p = sc_gem5::scheduler.current();
653 p->setDynamic(
654 new ::sc_gem5::SensitivityTimeoutAndEventAndList(p, t, &eal));
655 sc_gem5::scheduler.yield();
656}
657
658void
659wait(double d, sc_time_unit u, const sc_event_and_list &eal)
660{
661 wait(sc_time(d, u), eal);
662}
663
664void
665halt()
666{
667 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
668}
669
670void
671at_posedge(const sc_signal_in_if<bool> &)
672{
673 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
674}
675
676void
677at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &)
678{
679 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
680}
681
682void
683at_negedge(const sc_signal_in_if<bool> &)
684{
685 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
686}
687
688void
689at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &)
690{
691 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
692}
693
694const char *
695sc_gen_unique_name(const char *seed)
696{
697 ::sc_gem5::Module *mod = ::sc_gem5::currentModule();
698 return mod ? mod->uniqueName(seed) :
699 ::sc_gem5::nameGen.gen(seed);
700}
701
702bool
703sc_hierarchical_name_exists(const char *name)
704{
705 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
706 return false;
707}
708
709bool
710sc_start_of_simulation_invoked()
711{
712 return ::sc_gem5::kernel->startOfSimulationComplete();
713}
714
715bool
716sc_end_of_simulation_invoked()
717{
718 return ::sc_gem5::kernel->endOfSimulationComplete();
719}
720
721sc_module *
722sc_module_sc_new(sc_module *mod)
723{
724 static std::vector<std::unique_ptr<sc_module> > modules;
725 modules.emplace_back(mod);
726 return mod;
727}
728
729} // namespace sc_core