Deleted Added
sdiff udiff text old ( 13315:baeb753a3f10 ) new ( 13317:36c574a4036e )
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

--- 29 unchanged lines hidden (view full) ---

38#include "systemc/core/object.hh"
39#include "systemc/core/port.hh"
40#include "systemc/core/process_types.hh"
41#include "systemc/core/sensitivity.hh"
42#include "systemc/ext/channel/sc_in.hh"
43#include "systemc/ext/channel/sc_inout.hh"
44#include "systemc/ext/channel/sc_out.hh"
45#include "systemc/ext/channel/sc_signal_in_if.hh"
46#include "systemc/ext/core/sc_module.hh"
47#include "systemc/ext/core/sc_module_name.hh"
48#include "systemc/ext/dt/bit/sc_logic.hh"
49#include "systemc/ext/utils/sc_report_handler.hh"
50
51namespace sc_gem5
52{
53
54Process *
55newMethodProcess(const char *name, ProcessFuncWrapper *func)
56{
57 Method *p = new Method(name, func);
58 if (::sc_core::sc_is_running()) {
59 std::string name = p->name();
60 delete p;
61 SC_REPORT_ERROR("(E541) call to SC_METHOD in sc_module while "
62 "simulation running", name.c_str());
63 return nullptr;
64 }
65 scheduler.reg(p);
66 return p;
67}
68
69Process *
70newThreadProcess(const char *name, ProcessFuncWrapper *func)
71{
72 Thread *p = new Thread(name, func);
73 if (::sc_core::sc_is_running()) {
74 std::string name = p->name();
75 delete p;
76 SC_REPORT_ERROR("(E542) call to SC_THREAD in sc_module while "
77 "simulation running", name.c_str());
78 return nullptr;
79 }
80 scheduler.reg(p);
81 return p;
82}
83
84Process *
85newCThreadProcess(const char *name, ProcessFuncWrapper *func)
86{
87 CThread *p = new CThread(name, func);
88 if (::sc_core::sc_is_running()) {
89 std::string name = p->name();
90 delete p;
91 SC_REPORT_ERROR("(E543) call to SC_CTHREAD in sc_module while "
92 "simulation running", name.c_str());
93 return nullptr;
94 }
95 scheduler.reg(p);
96 p->dontInitialize(true);
97 return p;
98}
99
100} // namespace sc_gem5

--- 146 unchanged lines hidden (view full) ---

247{
248 return _gem5_module->obj()->get_child_events();
249}
250
251sc_module::sc_module() :
252 sc_object(sc_gem5::newModuleChecked()->name()),
253 _gem5_module(sc_gem5::currentModule())
254{
255 if (sc_is_running()) {
256 SC_REPORT_ERROR("(E529) insert module failed", "simulation running");
257 std::cout << "Running!\n";
258 }
259 if (::sc_gem5::scheduler.elaborationDone()) {
260 SC_REPORT_ERROR("(E529) insert module failed", "elaboration done");
261 std::cout << "Elaboration done!\n";
262 }
263}
264
265sc_module::sc_module(const sc_module_name &) : sc_module() {}
266sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name))
267{
268 _gem5_module->deprecatedConstructor();
269 SC_REPORT_WARNING("(W569) sc_module(const char*), "
270 "sc_module(const std::string&) have been deprecated, use "
271 "sc_module(const sc_module_name&)", _name);
272}
273sc_module::sc_module(const std::string &_name) :
274 sc_module(sc_module_name(_name.c_str()))
275{
276 _gem5_module->deprecatedConstructor();
277 SC_REPORT_WARNING("(W569) sc_module(const char*), "
278 "sc_module(const std::string&) have been deprecated, use "
279 "sc_module(const sc_module_name&)", _name.c_str());
280}
281
282void
283sc_module::end_module()
284{
285 _gem5_module->endModule();
286}
287

--- 46 unchanged lines hidden (view full) ---

334 ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), false, val);
335}
336
337
338void
339sc_module::dont_initialize()
340{
341 ::sc_gem5::Process *p = ::sc_gem5::Process::newest();
342 if (p->procKind() == SC_CTHREAD_PROC_) {
343 SC_REPORT_WARNING("(W524) dont_initialize() has no effect for "
344 "SC_CTHREADs", "");
345 }
346 p->dontInitialize(true);
347}
348
349void
350sc_module::set_stack_size(size_t size)
351{
352 ::sc_gem5::Process::newest()->setStackSize(size);
353}

--- 286 unchanged lines hidden (view full) ---

640
641namespace
642{
643
644bool
645waitErrorCheck(sc_gem5::Process *p)
646{
647 if (p->procKind() == SC_METHOD_PROC_) {
648 SC_REPORT_ERROR(
649 "(E519) wait() is only allowed in SC_THREADs and SC_CTHREADs",
650 "\n in SC_METHODs use next_trigger() instead");
651 return true;
652 }
653 return false;
654}
655
656} // anonymous namespace
657

--- 8 unchanged lines hidden (view full) ---

666 sc_gem5::scheduler.yield();
667}
668
669void
670wait(int n)
671{
672 if (n <= 0) {
673 std::string msg = csprintf("n = %d", n);
674 SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str());
675 }
676 sc_gem5::Process *p = sc_gem5::scheduler.current();
677 p->waitCount(n - 1);
678 wait();
679}
680
681void
682wait(const sc_event &e)

--- 138 unchanged lines hidden (view full) ---

821 while (s.read() == sc_dt::Log_1)
822 wait();
823}
824
825const char *
826sc_gen_unique_name(const char *seed)
827{
828 if (!seed || seed[0] == '\0') {
829 SC_REPORT_ERROR(
830 "(E532) cannot generate unique name from null string", "");
831 seed = "unnamed";
832 }
833
834 auto mod = sc_gem5::pickParentModule();
835 if (mod)
836 return mod->uniqueName(seed);
837
838 sc_gem5::Process *p = sc_gem5::scheduler.current();

--- 34 unchanged lines hidden ---