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/messages.hh"
47#include "systemc/ext/core/sc_module.hh"
48#include "systemc/ext/core/sc_module_name.hh"
49#include "systemc/ext/dt/bit/sc_logic.hh"
50#include "systemc/ext/utils/sc_report_handler.hh"
51
52namespace sc_gem5
53{
54
55Process *
56newMethodProcess(const char *name, ProcessFuncWrapper *func)
57{
58 Method *p = new Method(name, func);
59 if (::sc_core::sc_is_running()) {
60 std::string name = p->name();
61 delete p;
62 SC_REPORT_ERROR(sc_core::SC_ID_MODULE_METHOD_AFTER_START_,
63 name.c_str());
64 return nullptr;
65 }
66 scheduler.reg(p);
67 return p;
68}
69
70Process *
71newThreadProcess(const char *name, ProcessFuncWrapper *func)
72{
73 Thread *p = new Thread(name, func);
74 if (::sc_core::sc_is_running()) {
75 std::string name = p->name();
76 delete p;
77 SC_REPORT_ERROR(sc_core::SC_ID_MODULE_THREAD_AFTER_START_,
78 name.c_str());
79 return nullptr;
80 }
81 scheduler.reg(p);
82 return p;
83}
84
85Process *
86newCThreadProcess(const char *name, ProcessFuncWrapper *func)
87{
88 CThread *p = new CThread(name, func);
89 if (::sc_core::sc_is_running()) {
90 std::string name = p->name();
91 delete p;
92 SC_REPORT_ERROR(sc_core::SC_ID_MODULE_CTHREAD_AFTER_START_,
93 name.c_str());
94 return nullptr;
95 }
96 scheduler.reg(p);
97 p->dontInitialize(true);
98 return p;
99}
100
101} // namespace sc_gem5

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

248{
249 return _gem5_module->obj()->get_child_events();
250}
251
252sc_module::sc_module() :
253 sc_object(sc_gem5::newModuleChecked()->name()),
254 _gem5_module(sc_gem5::currentModule())
255{
256 if (sc_is_running())
257 SC_REPORT_ERROR(SC_ID_INSERT_MODULE_, "simulation running");
258 if (::sc_gem5::scheduler.elaborationDone())
259 SC_REPORT_ERROR(SC_ID_INSERT_MODULE_, "elaboration done");
260}
261
262sc_module::sc_module(const sc_module_name &) : sc_module() {}
263sc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name))
264{
265 _gem5_module->deprecatedConstructor();
266 SC_REPORT_WARNING(SC_ID_BAD_SC_MODULE_CONSTRUCTOR_, _name);
267}
268sc_module::sc_module(const std::string &_name) :
269 sc_module(sc_module_name(_name.c_str()))
270{
271 _gem5_module->deprecatedConstructor();
272 SC_REPORT_WARNING(SC_ID_BAD_SC_MODULE_CONSTRUCTOR_, _name.c_str());
273}
274
275void
276sc_module::end_module()
277{
278 _gem5_module->endModule();
279}
280

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

327 ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), false, val);
328}
329
330
331void
332sc_module::dont_initialize()
333{
334 ::sc_gem5::Process *p = ::sc_gem5::Process::newest();
335 if (p->procKind() == SC_CTHREAD_PROC_)
336 SC_REPORT_WARNING(SC_ID_DONT_INITIALIZE_, "");
337 p->dontInitialize(true);
338}
339
340void
341sc_module::set_stack_size(size_t size)
342{
343 ::sc_gem5::Process::newest()->setStackSize(size);
344}

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

631
632namespace
633{
634
635bool
636waitErrorCheck(sc_gem5::Process *p)
637{
638 if (p->procKind() == SC_METHOD_PROC_) {
639 SC_REPORT_ERROR(SC_ID_WAIT_NOT_ALLOWED_,
640 "\n in SC_METHODs use next_trigger() instead");
641 return true;
642 }
643 return false;
644}
645
646} // anonymous namespace
647

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

656 sc_gem5::scheduler.yield();
657}
658
659void
660wait(int n)
661{
662 if (n <= 0) {
663 std::string msg = csprintf("n = %d", n);
664 SC_REPORT_ERROR(SC_ID_WAIT_N_INVALID_, msg.c_str());
665 }
666 sc_gem5::Process *p = sc_gem5::scheduler.current();
667 p->waitCount(n - 1);
668 wait();
669}
670
671void
672wait(const sc_event &e)

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

811 while (s.read() == sc_dt::Log_1)
812 wait();
813}
814
815const char *
816sc_gen_unique_name(const char *seed)
817{
818 if (!seed || seed[0] == '\0') {
819 SC_REPORT_ERROR(SC_ID_GEN_UNIQUE_NAME_, "");
820 seed = "unnamed";
821 }
822
823 auto mod = sc_gem5::pickParentModule();
824 if (mod)
825 return mod->uniqueName(seed);
826
827 sc_gem5::Process *p = sc_gem5::scheduler.current();

--- 34 unchanged lines hidden ---