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