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> 32#include <vector> 33 34#include "base/logging.hh" 35#include "systemc/core/event.hh" 36#include "systemc/core/kernel.hh" 37#include "systemc/core/module.hh" 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;
|
61 SC_REPORT_ERROR("(E541) call to SC_METHOD in sc_module while "
62 "simulation running", name.c_str());
|
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;
|
76 SC_REPORT_ERROR("(E542) call to SC_THREAD in sc_module while "
77 "simulation running", name.c_str());
|
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;
|
91 SC_REPORT_ERROR("(E543) call to SC_CTHREAD in sc_module while "
92 "simulation running", name.c_str());
|
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 102 103namespace sc_core 104{ 105 106sc_bind_proxy::sc_bind_proxy(sc_interface &_interface) : 107 _interface(&_interface), _port(nullptr) 108{} 109 110sc_bind_proxy::sc_bind_proxy(sc_port_base &_port) : 111 _interface(nullptr), _port(&_port) 112{} 113 114const sc_bind_proxy SC_BIND_PROXY_NUL(*(sc_port_base *)nullptr); 115 116sc_module::~sc_module() { delete _gem5_module; } 117 118const sc_bind_proxy SC_BIND_PROXY_NIL(*(sc_port_base *)nullptr); 119 120void 121sc_module::operator () (const sc_bind_proxy &p001, 122 const sc_bind_proxy &p002, 123 const sc_bind_proxy &p003, 124 const sc_bind_proxy &p004, 125 const sc_bind_proxy &p005, 126 const sc_bind_proxy &p006, 127 const sc_bind_proxy &p007, 128 const sc_bind_proxy &p008, 129 const sc_bind_proxy &p009, 130 const sc_bind_proxy &p010, 131 const sc_bind_proxy &p011, 132 const sc_bind_proxy &p012, 133 const sc_bind_proxy &p013, 134 const sc_bind_proxy &p014, 135 const sc_bind_proxy &p015, 136 const sc_bind_proxy &p016, 137 const sc_bind_proxy &p017, 138 const sc_bind_proxy &p018, 139 const sc_bind_proxy &p019, 140 const sc_bind_proxy &p020, 141 const sc_bind_proxy &p021, 142 const sc_bind_proxy &p022, 143 const sc_bind_proxy &p023, 144 const sc_bind_proxy &p024, 145 const sc_bind_proxy &p025, 146 const sc_bind_proxy &p026, 147 const sc_bind_proxy &p027, 148 const sc_bind_proxy &p028, 149 const sc_bind_proxy &p029, 150 const sc_bind_proxy &p030, 151 const sc_bind_proxy &p031, 152 const sc_bind_proxy &p032, 153 const sc_bind_proxy &p033, 154 const sc_bind_proxy &p034, 155 const sc_bind_proxy &p035, 156 const sc_bind_proxy &p036, 157 const sc_bind_proxy &p037, 158 const sc_bind_proxy &p038, 159 const sc_bind_proxy &p039, 160 const sc_bind_proxy &p040, 161 const sc_bind_proxy &p041, 162 const sc_bind_proxy &p042, 163 const sc_bind_proxy &p043, 164 const sc_bind_proxy &p044, 165 const sc_bind_proxy &p045, 166 const sc_bind_proxy &p046, 167 const sc_bind_proxy &p047, 168 const sc_bind_proxy &p048, 169 const sc_bind_proxy &p049, 170 const sc_bind_proxy &p050, 171 const sc_bind_proxy &p051, 172 const sc_bind_proxy &p052, 173 const sc_bind_proxy &p053, 174 const sc_bind_proxy &p054, 175 const sc_bind_proxy &p055, 176 const sc_bind_proxy &p056, 177 const sc_bind_proxy &p057, 178 const sc_bind_proxy &p058, 179 const sc_bind_proxy &p059, 180 const sc_bind_proxy &p060, 181 const sc_bind_proxy &p061, 182 const sc_bind_proxy &p062, 183 const sc_bind_proxy &p063, 184 const sc_bind_proxy &p064) 185{ 186 std::vector<const ::sc_core::sc_bind_proxy *> proxies; 187 auto insert = [&proxies](const ::sc_core::sc_bind_proxy &p) -> bool { 188 if (!p.port() && !p.interface()) 189 return false; 190 proxies.push_back(&p); 191 return true; 192 }; 193 insert(p001) && insert(p002) && insert(p003) && insert(p004) && 194 insert(p005) && insert(p006) && insert(p007) && insert(p008) && 195 insert(p009) && insert(p010) && insert(p011) && insert(p012) && 196 insert(p013) && insert(p014) && insert(p015) && insert(p016) && 197 insert(p017) && insert(p018) && insert(p019) && insert(p020) && 198 insert(p021) && insert(p022) && insert(p023) && insert(p024) && 199 insert(p025) && insert(p026) && insert(p027) && insert(p028) && 200 insert(p029) && insert(p030) && insert(p031) && insert(p032) && 201 insert(p033) && insert(p034) && insert(p035) && insert(p036) && 202 insert(p037) && insert(p038) && insert(p039) && insert(p040) && 203 insert(p041) && insert(p042) && insert(p043) && insert(p044) && 204 insert(p045) && insert(p046) && insert(p047) && insert(p048) && 205 insert(p049) && insert(p050) && insert(p051) && insert(p052) && 206 insert(p053) && insert(p054) && insert(p055) && insert(p056) && 207 insert(p057) && insert(p058) && insert(p059) && insert(p060) && 208 insert(p061) && insert(p062) && insert(p063) && insert(p064); 209 _gem5_module->bindPorts(proxies); 210} 211 212sc_module & 213sc_module::operator << (sc_interface &iface) 214{ 215 (*this)(iface); 216 return *this; 217} 218 219sc_module & 220sc_module::operator << (sc_port_base &pb) 221{ 222 (*this)(pb); 223 return *this; 224} 225 226sc_module & 227sc_module::operator , (sc_interface &iface) 228{ 229 (*this)(iface); 230 return *this; 231} 232 233sc_module & 234sc_module::operator , (sc_port_base &pb) 235{ 236 (*this)(pb); 237 return *this; 238} 239 240const std::vector<sc_object *> & 241sc_module::get_child_objects() const 242{ 243 return _gem5_module->obj()->get_child_objects(); 244} 245 246const std::vector<sc_event *> & 247sc_module::get_child_events() const 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{
|
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 }
|
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();
|
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);
|
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();
|
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());
|
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 281void 282sc_module::reset_signal_is(const sc_in<bool> &port, bool val) 283{ 284 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val); 285} 286 287void 288sc_module::reset_signal_is(const sc_inout<bool> &port, bool val) 289{ 290 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val); 291} 292 293void 294sc_module::reset_signal_is(const sc_out<bool> &port, bool val) 295{ 296 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), true, val); 297} 298 299void 300sc_module::reset_signal_is(const sc_signal_in_if<bool> &signal, bool val) 301{ 302 ::sc_gem5::newReset(&signal, ::sc_gem5::Process::newest(), true, val); 303} 304 305 306void 307sc_module::async_reset_signal_is(const sc_in<bool> &port, bool val) 308{ 309 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val); 310} 311 312void 313sc_module::async_reset_signal_is(const sc_inout<bool> &port, bool val) 314{ 315 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val); 316} 317 318void 319sc_module::async_reset_signal_is(const sc_out<bool> &port, bool val) 320{ 321 ::sc_gem5::newReset(&port, ::sc_gem5::Process::newest(), false, val); 322} 323 324void 325sc_module::async_reset_signal_is(const sc_signal_in_if<bool> &signal, bool val) 326{ 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();
|
342 if (p->procKind() == SC_CTHREAD_PROC_) {
343 SC_REPORT_WARNING("(W524) dont_initialize() has no effect for "
344 "SC_CTHREADs", "");
345 }
|
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} 345 346 347void sc_module::next_trigger() { ::sc_core::next_trigger(); } 348 349void 350sc_module::next_trigger(const sc_event &e) 351{ 352 ::sc_core::next_trigger(e); 353} 354 355void 356sc_module::next_trigger(const sc_event_or_list &eol) 357{ 358 ::sc_core::next_trigger(eol); 359} 360 361void 362sc_module::next_trigger(const sc_event_and_list &eal) 363{ 364 ::sc_core::next_trigger(eal); 365} 366 367void 368sc_module::next_trigger(const sc_time &t) 369{ 370 ::sc_core::next_trigger(t); 371} 372 373void 374sc_module::next_trigger(double d, sc_time_unit u) 375{ 376 ::sc_core::next_trigger(d, u); 377} 378 379void 380sc_module::next_trigger(const sc_time &t, const sc_event &e) 381{ 382 ::sc_core::next_trigger(t, e); 383} 384 385void 386sc_module::next_trigger(double d, sc_time_unit u, const sc_event &e) 387{ 388 ::sc_core::next_trigger(d, u, e); 389} 390 391void 392sc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol) 393{ 394 ::sc_core::next_trigger(t, eol); 395} 396 397void 398sc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) 399{ 400 ::sc_core::next_trigger(d, u, eol); 401} 402 403void 404sc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal) 405{ 406 ::sc_core::next_trigger(t, eal); 407} 408 409void 410sc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) 411{ 412 ::sc_core::next_trigger(d, u, eal); 413} 414 415 416bool 417sc_module::timed_out() 418{ 419 return ::sc_core::timed_out(); 420} 421 422 423void 424sc_module::wait() 425{ 426 ::sc_core::wait(); 427} 428 429void 430sc_module::wait(int i) 431{ 432 ::sc_core::wait(i); 433} 434 435void 436sc_module::wait(const sc_event &e) 437{ 438 ::sc_core::wait(e); 439} 440 441void 442sc_module::wait(const sc_event_or_list &eol) 443{ 444 ::sc_core::wait(eol); 445} 446 447void 448sc_module::wait(const sc_event_and_list &eal) 449{ 450 ::sc_core::wait(eal); 451} 452 453void 454sc_module::wait(const sc_time &t) 455{ 456 ::sc_core::wait(t); 457} 458 459void 460sc_module::wait(double d, sc_time_unit u) 461{ 462 ::sc_core::wait(d, u); 463} 464 465void 466sc_module::wait(const sc_time &t, const sc_event &e) 467{ 468 ::sc_core::wait(t, e); 469} 470 471void 472sc_module::wait(double d, sc_time_unit u, const sc_event &e) 473{ 474 ::sc_core::wait(d, u, e); 475} 476 477void 478sc_module::wait(const sc_time &t, const sc_event_or_list &eol) 479{ 480 ::sc_core::wait(t, eol); 481} 482 483void 484sc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol) 485{ 486 ::sc_core::wait(d, u, eol); 487} 488 489void 490sc_module::wait(const sc_time &t, const sc_event_and_list &eal) 491{ 492 ::sc_core::wait(t, eal); 493} 494 495void 496sc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal) 497{ 498 ::sc_core::wait(d, u, eal); 499} 500 501 502void 503sc_module::halt() 504{ 505 ::sc_core::halt(); 506} 507 508void 509sc_module::at_posedge(const sc_signal_in_if<bool> &s) 510{ 511 ::sc_core::at_posedge(s); 512} 513 514void 515sc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 516{ 517 ::sc_core::at_posedge(s); 518} 519 520void 521sc_module::at_negedge(const sc_signal_in_if<bool> &s) 522{ 523 ::sc_core::at_negedge(s); 524} 525 526void 527sc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 528{ 529 ::sc_core::at_negedge(s); 530} 531 532 533void 534next_trigger() 535{ 536 sc_gem5::Process *p = sc_gem5::scheduler.current(); 537 p->cancelTimeout(); 538 p->clearDynamic(); 539} 540 541void 542next_trigger(const sc_event &e) 543{ 544 sc_gem5::Process *p = sc_gem5::scheduler.current(); 545 p->cancelTimeout(); 546 ::sc_gem5::newDynamicSensitivityEvent(p, &e); 547} 548 549void 550next_trigger(const sc_event_or_list &eol) 551{ 552 sc_gem5::Process *p = sc_gem5::scheduler.current(); 553 p->cancelTimeout(); 554 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol); 555} 556 557void 558next_trigger(const sc_event_and_list &eal) 559{ 560 sc_gem5::Process *p = sc_gem5::scheduler.current(); 561 p->cancelTimeout(); 562 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal); 563} 564 565void 566next_trigger(const sc_time &t) 567{ 568 sc_gem5::Process *p = sc_gem5::scheduler.current(); 569 p->setTimeout(t); 570 p->clearDynamic(); 571} 572 573void 574next_trigger(double d, sc_time_unit u) 575{ 576 next_trigger(sc_time(d, u)); 577} 578 579void 580next_trigger(const sc_time &t, const sc_event &e) 581{ 582 sc_gem5::Process *p = sc_gem5::scheduler.current(); 583 p->setTimeout(t); 584 ::sc_gem5::newDynamicSensitivityEvent(p, &e); 585} 586 587void 588next_trigger(double d, sc_time_unit u, const sc_event &e) 589{ 590 next_trigger(sc_time(d, u), e); 591} 592 593void 594next_trigger(const sc_time &t, const sc_event_or_list &eol) 595{ 596 sc_gem5::Process *p = sc_gem5::scheduler.current(); 597 p->setTimeout(t); 598 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol); 599} 600 601void 602next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) 603{ 604 next_trigger(sc_time(d, u), eol); 605} 606 607void 608next_trigger(const sc_time &t, const sc_event_and_list &eal) 609{ 610 sc_gem5::Process *p = sc_gem5::scheduler.current(); 611 p->setTimeout(t); 612 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal); 613} 614 615void 616next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) 617{ 618 next_trigger(sc_time(d, u), eal); 619} 620 621bool 622timed_out() 623{ 624 ::sc_gem5::Process *p = sc_gem5::scheduler.current(); 625 if (!p) 626 return false; 627 else 628 return p->timedOut(); 629} 630 631 632namespace 633{ 634 635bool 636waitErrorCheck(sc_gem5::Process *p) 637{ 638 if (p->procKind() == SC_METHOD_PROC_) {
|
648 SC_REPORT_ERROR(
649 "(E519) wait() is only allowed in SC_THREADs and SC_CTHREADs",
|
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 648void 649wait() 650{ 651 sc_gem5::Process *p = sc_gem5::scheduler.current(); 652 if (waitErrorCheck(p)) 653 return; 654 p->cancelTimeout(); 655 p->clearDynamic(); 656 sc_gem5::scheduler.yield(); 657} 658 659void 660wait(int n) 661{ 662 if (n <= 0) { 663 std::string msg = csprintf("n = %d", n);
|
674 SC_REPORT_ERROR("(E525) wait(n) is only valid for n > 0", msg.c_str());
|
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) 673{ 674 sc_gem5::Process *p = sc_gem5::scheduler.current(); 675 if (waitErrorCheck(p)) 676 return; 677 p->cancelTimeout(); 678 ::sc_gem5::newDynamicSensitivityEvent(p, &e); 679 sc_gem5::scheduler.yield(); 680} 681 682void 683wait(const sc_event_or_list &eol) 684{ 685 sc_gem5::Process *p = sc_gem5::scheduler.current(); 686 if (waitErrorCheck(p)) 687 return; 688 p->cancelTimeout(); 689 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol); 690 sc_gem5::scheduler.yield(); 691} 692 693void 694wait(const sc_event_and_list &eal) 695{ 696 sc_gem5::Process *p = sc_gem5::scheduler.current(); 697 if (waitErrorCheck(p)) 698 return; 699 p->cancelTimeout(); 700 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal); 701 sc_gem5::scheduler.yield(); 702} 703 704void 705wait(const sc_time &t) 706{ 707 sc_gem5::Process *p = sc_gem5::scheduler.current(); 708 if (waitErrorCheck(p)) 709 return; 710 p->setTimeout(t); 711 p->clearDynamic(); 712 sc_gem5::scheduler.yield(); 713} 714 715void 716wait(double d, sc_time_unit u) 717{ 718 wait(sc_time(d, u)); 719} 720 721void 722wait(const sc_time &t, const sc_event &e) 723{ 724 sc_gem5::Process *p = sc_gem5::scheduler.current(); 725 if (waitErrorCheck(p)) 726 return; 727 p->setTimeout(t); 728 ::sc_gem5::newDynamicSensitivityEvent(p, &e); 729 sc_gem5::scheduler.yield(); 730} 731 732void 733wait(double d, sc_time_unit u, const sc_event &e) 734{ 735 wait(sc_time(d, u), e); 736} 737 738void 739wait(const sc_time &t, const sc_event_or_list &eol) 740{ 741 sc_gem5::Process *p = sc_gem5::scheduler.current(); 742 if (waitErrorCheck(p)) 743 return; 744 p->setTimeout(t); 745 ::sc_gem5::newDynamicSensitivityEventOrList(p, &eol); 746 sc_gem5::scheduler.yield(); 747} 748 749void 750wait(double d, sc_time_unit u, const sc_event_or_list &eol) 751{ 752 wait(sc_time(d, u), eol); 753} 754 755void 756wait(const sc_time &t, const sc_event_and_list &eal) 757{ 758 sc_gem5::Process *p = sc_gem5::scheduler.current(); 759 if (waitErrorCheck(p)) 760 return; 761 p->setTimeout(t); 762 ::sc_gem5::newDynamicSensitivityEventAndList(p, &eal); 763 sc_gem5::scheduler.yield(); 764} 765 766void 767wait(double d, sc_time_unit u, const sc_event_and_list &eal) 768{ 769 wait(sc_time(d, u), eal); 770} 771 772void 773halt() 774{ 775 ::sc_core::wait(); 776 throw ::sc_gem5::ScHalt(); 777} 778 779void 780at_posedge(const sc_signal_in_if<bool> &s) 781{ 782 while (s.read()) 783 wait(); 784 while (!s.read()) 785 wait(); 786} 787 788void 789at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 790{ 791 while (s.read() == sc_dt::Log_1) 792 wait(); 793 while (s.read() == sc_dt::Log_0) 794 wait(); 795} 796 797void 798at_negedge(const sc_signal_in_if<bool> &s) 799{ 800 while (!s.read()) 801 wait(); 802 while (s.read()) 803 wait(); 804} 805 806void 807at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 808{ 809 while (s.read() == sc_dt::Log_0) 810 wait(); 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') {
|
829 SC_REPORT_ERROR(
830 "(E532) cannot generate unique name from null string", "");
|
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(); 828 if (p) 829 return p->uniqueName(seed); 830 831 return ::sc_gem5::globalNameGen.gen(seed); 832} 833 834bool 835sc_hierarchical_name_exists(const char *name) 836{ 837 return sc_gem5::findEvent(name) != sc_gem5::allEvents.end() || 838 ::sc_gem5::findObject(name, sc_gem5::allObjects); 839} 840 841bool 842sc_start_of_simulation_invoked() 843{ 844 return ::sc_gem5::kernel->startOfSimulationComplete(); 845} 846 847bool 848sc_end_of_simulation_invoked() 849{ 850 return ::sc_gem5::kernel->endOfSimulationComplete(); 851} 852 853sc_module * 854sc_module_sc_new(sc_module *mod) 855{ 856 static std::vector<std::unique_ptr<sc_module> > modules; 857 modules.emplace_back(mod); 858 return mod; 859} 860 861} // namespace sc_core
|