sc_module.cc revision 12953
16915SN/A/* 26915SN/A * Copyright 2018 Google, Inc. 36915SN/A * 46915SN/A * Redistribution and use in source and binary forms, with or without 56915SN/A * modification, are permitted provided that the following conditions are 66915SN/A * met: redistributions of source code must retain the above copyright 76915SN/A * notice, this list of conditions and the following disclaimer; 86915SN/A * redistributions in binary form must reproduce the above copyright 96915SN/A * notice, this list of conditions and the following disclaimer in the 106915SN/A * documentation and/or other materials provided with the distribution; 116915SN/A * neither the name of the copyright holders nor the names of its 126915SN/A * contributors may be used to endorse or promote products derived from 136915SN/A * this software without specific prior written permission. 146915SN/A * 156915SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 166915SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 176915SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 186915SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 196915SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 206915SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 216915SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 226915SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 236915SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 246915SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 256915SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 266915SN/A * 276915SN/A * Authors: Gabe Black 286915SN/A */ 296915SN/A 306915SN/A#include <memory> 316915SN/A#include <vector> 326915SN/A 336915SN/A#include "base/logging.hh" 349100SN/A#include "systemc/core/module.hh" 356915SN/A#include "systemc/core/process_types.hh" 366915SN/A#include "systemc/ext/core/sc_module.hh" 376915SN/A#include "systemc/ext/core/sc_module_name.hh" 386915SN/A 396915SN/Anamespace sc_gem5 406915SN/A{ 416915SN/A 426915SN/AProcess * 436915SN/AnewMethodProcess(const char *name, ProcessFuncWrapper *func) 446915SN/A{ 456915SN/A return new Method(name, func); 466915SN/A} 476915SN/A 487538SN/AProcess * 497538SN/AnewThreadProcess(const char *name, ProcessFuncWrapper *func) 507538SN/A{ 5110116Snilay@cs.wisc.edu return new Thread(name, func); 5210007Snilay@cs.wisc.edu} 5310007Snilay@cs.wisc.edu 5410007Snilay@cs.wisc.eduProcess * 556915SN/AnewCThreadProcess(const char *name, ProcessFuncWrapper *func) 566915SN/A{ 5710007Snilay@cs.wisc.edu return new CThread(name, func); 586915SN/A} 596915SN/A 606915SN/A} // namespace sc_gem5 616915SN/A 626915SN/Anamespace sc_core 636915SN/A{ 646915SN/A 656915SN/Asc_bind_proxy::sc_bind_proxy(const sc_interface &_interface) : 666915SN/A _interface(&_interface), _port(nullptr) 676915SN/A{} 686915SN/A 696915SN/Asc_bind_proxy::sc_bind_proxy(const sc_port_base &_port) : 706915SN/A _interface(nullptr), _port(&_port) 716915SN/A{} 728180SN/A 738180SN/Aconst sc_bind_proxy SC_BIND_PROXY_NUL(*(const sc_port_base *)nullptr); 7410007Snilay@cs.wisc.edu 756915SN/Asc_module::~sc_module() {} 766915SN/A 776915SN/Aconst sc_bind_proxy SC_BIND_PROXY_NIL(*(const sc_port_base *)nullptr); 786915SN/A 796915SN/Avoid 808180SN/Asc_module::operator () (const sc_bind_proxy &p001, 819319SN/A const sc_bind_proxy &p002, 829319SN/A const sc_bind_proxy &p003, 836915SN/A const sc_bind_proxy &p004, 848180SN/A const sc_bind_proxy &p005, 859319SN/A const sc_bind_proxy &p006, 869319SN/A const sc_bind_proxy &p007, 876915SN/A const sc_bind_proxy &p008, 889366SN/A const sc_bind_proxy &p009, 899366SN/A const sc_bind_proxy &p010, 908322SN/A const sc_bind_proxy &p011, 919696SN/A const sc_bind_proxy &p012, 929696SN/A const sc_bind_proxy &p013, 938436SN/A const sc_bind_proxy &p014, 948717SN/A const sc_bind_proxy &p015, 958717SN/A const sc_bind_proxy &p016, 969366SN/A const sc_bind_proxy &p017, 979366SN/A const sc_bind_proxy &p018, 9810300Scastilloe@unican.es const sc_bind_proxy &p019, 999841SN/A const sc_bind_proxy &p020, 1009366SN/A const sc_bind_proxy &p021, 1018322SN/A const sc_bind_proxy &p022, 1027015SN/A const sc_bind_proxy &p023, 1037015SN/A const sc_bind_proxy &p024, 1046915SN/A const sc_bind_proxy &p025, 10510300Scastilloe@unican.es const sc_bind_proxy &p026, 1068436SN/A const sc_bind_proxy &p027, 1076915SN/A const sc_bind_proxy &p028, 1088322SN/A const sc_bind_proxy &p029, 1099468SN/A const sc_bind_proxy &p030, 11010007Snilay@cs.wisc.edu const sc_bind_proxy &p031, 1116915SN/A const sc_bind_proxy &p032, 1126915SN/A const sc_bind_proxy &p033, 1136915SN/A const sc_bind_proxy &p034, 11410007Snilay@cs.wisc.edu const sc_bind_proxy &p035, 11510311Snilay@cs.wisc.edu const sc_bind_proxy &p036, 11610311Snilay@cs.wisc.edu const sc_bind_proxy &p037, 11710311Snilay@cs.wisc.edu const sc_bind_proxy &p038, 11810311Snilay@cs.wisc.edu const sc_bind_proxy &p039, 11910311Snilay@cs.wisc.edu const sc_bind_proxy &p040, 12010311Snilay@cs.wisc.edu const sc_bind_proxy &p041, 12110311Snilay@cs.wisc.edu const sc_bind_proxy &p042, 12210311Snilay@cs.wisc.edu const sc_bind_proxy &p043, 12310311Snilay@cs.wisc.edu const sc_bind_proxy &p044, 1248180SN/A const sc_bind_proxy &p045, 1258180SN/A const sc_bind_proxy &p046, 1266915SN/A const sc_bind_proxy &p047, 1276915SN/A const sc_bind_proxy &p048, 1286915SN/A const sc_bind_proxy &p049, 1296915SN/A const sc_bind_proxy &p050, 1306915SN/A const sc_bind_proxy &p051, 1318180SN/A const sc_bind_proxy &p052, 1328180SN/A const sc_bind_proxy &p053, 1336915SN/A const sc_bind_proxy &p054, 1346915SN/A const sc_bind_proxy &p055, 1359696SN/A const sc_bind_proxy &p056, 1369841SN/A const sc_bind_proxy &p057, 1378436SN/A const sc_bind_proxy &p058, 13810007Snilay@cs.wisc.edu const sc_bind_proxy &p059, 1399468SN/A const sc_bind_proxy &p060, 1406915SN/A const sc_bind_proxy &p061, 14110007Snilay@cs.wisc.edu const sc_bind_proxy &p062, 14210311Snilay@cs.wisc.edu const sc_bind_proxy &p063, 14310311Snilay@cs.wisc.edu const sc_bind_proxy &p064) 14410311Snilay@cs.wisc.edu{ 14510311Snilay@cs.wisc.edu warn("%s not implemented.\n", __PRETTY_FUNCTION__); 14610311Snilay@cs.wisc.edu} 14710311Snilay@cs.wisc.edu 14810311Snilay@cs.wisc.educonst std::vector<sc_object *> & 14910311Snilay@cs.wisc.edusc_module::get_child_objects() const 15010311Snilay@cs.wisc.edu{ 15110311Snilay@cs.wisc.edu return _gem5_module->obj()->get_child_objects(); 1529826SN/A} 1539798SN/A 1546915SN/Aconst std::vector<sc_event *> & 1556915SN/Asc_module::get_child_events() const 15610311Snilay@cs.wisc.edu{ 1579793SN/A return _gem5_module->obj()->get_child_events(); 1589793SN/A} 1599793SN/A 1609793SN/Asc_module::sc_module() : 1619793SN/A sc_object(sc_gem5::newModule()->name()), 1629793SN/A _gem5_module(sc_gem5::currentModule()) 1639793SN/A{} 1646915SN/A 1656915SN/Asc_module::sc_module(const sc_module_name &) : sc_module() {} 1666915SN/Asc_module::sc_module(const char *_name) : sc_module(sc_module_name(_name)) {} 1676915SN/Asc_module::sc_module(const std::string &_name) : 1686915SN/A sc_module(sc_module_name(_name.c_str())) 1699793SN/A{} 1709793SN/A 1719793SN/Avoid 1729793SN/Asc_module::reset_signal_is(const sc_in<bool> &, bool) 1736915SN/A{ 1746915SN/A warn("%s not implemented.\n", __PRETTY_FUNCTION__); 1756915SN/A} 1766915SN/A 1776915SN/Avoid 1786915SN/Asc_module::reset_signal_is(const sc_inout<bool> &, bool) 1796915SN/A{ 1808718SN/A warn("%s not implemented.\n", __PRETTY_FUNCTION__); 1818718SN/A} 1828718SN/A 1838436SN/Avoid 1849841SN/Asc_module::reset_signal_is(const sc_out<bool> &, bool) 1858436SN/A{ 1866915SN/A warn("%s not implemented.\n", __PRETTY_FUNCTION__); 1879468SN/A} 1886915SN/A 1896915SN/Avoid 19010311Snilay@cs.wisc.edusc_module::reset_signal_is(const sc_signal_in_if<bool> &, bool) 19110311Snilay@cs.wisc.edu{ 19210311Snilay@cs.wisc.edu warn("%s not implemented.\n", __PRETTY_FUNCTION__); 19310311Snilay@cs.wisc.edu} 19410311Snilay@cs.wisc.edu 19510311Snilay@cs.wisc.edu 1968929SN/Avoid 1976915SN/Asc_module::async_reset_signal_is(const sc_in<bool> &, bool) 1986915SN/A{ 1998477SN/A warn("%s not implemented.\n", __PRETTY_FUNCTION__); 20010007Snilay@cs.wisc.edu} 2016915SN/A 2028477SN/Avoid 2039841SN/Asc_module::async_reset_signal_is(const sc_inout<bool> &, bool) 2048477SN/A{ 2056915SN/A warn("%s not implemented.\n", __PRETTY_FUNCTION__); 2069468SN/A} 2079468SN/A 2086915SN/Avoid 2098257SN/Asc_module::async_reset_signal_is(const sc_out<bool> &, bool) 21010311Snilay@cs.wisc.edu{ 21110311Snilay@cs.wisc.edu warn("%s not implemented.\n", __PRETTY_FUNCTION__); 21210311Snilay@cs.wisc.edu} 21310311Snilay@cs.wisc.edu 21410311Snilay@cs.wisc.eduvoid 2156915SN/Asc_module::async_reset_signal_is(const sc_signal_in_if<bool> &, bool) 2166915SN/A{ 2176915SN/A warn("%s not implemented.\n", __PRETTY_FUNCTION__); 2186915SN/A} 2196915SN/A 2209100SN/A 2219100SN/Avoid 2229100SN/Asc_module::dont_initialize() 223{ 224 ::sc_gem5::Process::newest()->dontInitialize(); 225} 226 227void 228sc_module::set_stack_size(size_t size) 229{ 230 ::sc_gem5::Process::newest()->setStackSize(size); 231} 232 233 234void sc_module::next_trigger() { ::sc_core::next_trigger(); } 235 236void 237sc_module::next_trigger(const sc_event &e) 238{ 239 ::sc_core::next_trigger(e); 240} 241 242void 243sc_module::next_trigger(const sc_event_or_list &eol) 244{ 245 ::sc_core::next_trigger(eol); 246} 247 248void 249sc_module::next_trigger(const sc_event_and_list &eal) 250{ 251 ::sc_core::next_trigger(eal); 252} 253 254void 255sc_module::next_trigger(const sc_time &t) 256{ 257 ::sc_core::next_trigger(t); 258} 259 260void 261sc_module::next_trigger(double d, sc_time_unit u) 262{ 263 ::sc_core::next_trigger(d, u); 264} 265 266void 267sc_module::next_trigger(const sc_time &t, const sc_event &e) 268{ 269 ::sc_core::next_trigger(t, e); 270} 271 272void 273sc_module::next_trigger(double d, sc_time_unit u, const sc_event &e) 274{ 275 ::sc_core::next_trigger(d, u, e); 276} 277 278void 279sc_module::next_trigger(const sc_time &t, const sc_event_or_list &eol) 280{ 281 ::sc_core::next_trigger(t, eol); 282} 283 284void 285sc_module::next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) 286{ 287 ::sc_core::next_trigger(d, u, eol); 288} 289 290void 291sc_module::next_trigger(const sc_time &t, const sc_event_and_list &eal) 292{ 293 ::sc_core::next_trigger(t, eal); 294} 295 296void 297sc_module::next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) 298{ 299 ::sc_core::next_trigger(d, u, eal); 300} 301 302 303bool 304sc_module::timed_out() 305{ 306 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 307 return false; 308} 309 310 311void 312sc_module::wait() 313{ 314 ::sc_core::wait(); 315} 316 317void 318sc_module::wait(int i) 319{ 320 ::sc_core::wait(i); 321} 322 323void 324sc_module::wait(const sc_event &e) 325{ 326 ::sc_core::wait(e); 327} 328 329void 330sc_module::wait(const sc_event_or_list &eol) 331{ 332 ::sc_core::wait(eol); 333} 334 335void 336sc_module::wait(const sc_event_and_list &eal) 337{ 338 ::sc_core::wait(eal); 339} 340 341void 342sc_module::wait(const sc_time &t) 343{ 344 ::sc_core::wait(t); 345} 346 347void 348sc_module::wait(double d, sc_time_unit u) 349{ 350 ::sc_core::wait(d, u); 351} 352 353void 354sc_module::wait(const sc_time &t, const sc_event &e) 355{ 356 ::sc_core::wait(t, e); 357} 358 359void 360sc_module::wait(double d, sc_time_unit u, const sc_event &e) 361{ 362 ::sc_core::wait(d, u, e); 363} 364 365void 366sc_module::wait(const sc_time &t, const sc_event_or_list &eol) 367{ 368 ::sc_core::wait(t, eol); 369} 370 371void 372sc_module::wait(double d, sc_time_unit u, const sc_event_or_list &eol) 373{ 374 ::sc_core::wait(d, u, eol); 375} 376 377void 378sc_module::wait(const sc_time &t, const sc_event_and_list &eal) 379{ 380 ::sc_core::wait(t, eal); 381} 382 383void 384sc_module::wait(double d, sc_time_unit u, const sc_event_and_list &eal) 385{ 386 ::sc_core::wait(d, u, eal); 387} 388 389 390void 391sc_module::halt() 392{ 393 ::sc_core::halt(); 394} 395 396void 397sc_module::at_posedge(const sc_signal_in_if<bool> &s) 398{ 399 ::sc_core::at_posedge(s); 400} 401 402void 403sc_module::at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 404{ 405 ::sc_core::at_posedge(s); 406} 407 408void 409sc_module::at_negedge(const sc_signal_in_if<bool> &s) 410{ 411 ::sc_core::at_negedge(s); 412} 413 414void 415sc_module::at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s) 416{ 417 ::sc_core::at_negedge(s); 418} 419 420 421void 422next_trigger() 423{ 424 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 425} 426 427void 428next_trigger(const sc_event &) 429{ 430 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 431} 432 433void 434next_trigger(const sc_event_or_list &) 435{ 436 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 437} 438 439void 440next_trigger(const sc_event_and_list &) 441{ 442 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 443} 444 445void 446next_trigger(const sc_time &) 447{ 448 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 449} 450 451void 452next_trigger(double d, sc_time_unit u) 453{ 454 next_trigger(sc_time(d, u)); 455} 456 457void 458next_trigger(const sc_time &, const sc_event &) 459{ 460 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 461} 462 463void 464next_trigger(double d, sc_time_unit u, const sc_event &e) 465{ 466 next_trigger(sc_time(d, u), e); 467} 468 469void 470next_trigger(const sc_time &, const sc_event_or_list &) 471{ 472 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 473} 474 475void 476next_trigger(double d, sc_time_unit u, const sc_event_or_list &eol) 477{ 478 next_trigger(sc_time(d, u), eol); 479} 480 481void 482next_trigger(const sc_time &, const sc_event_and_list &) 483{ 484 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 485} 486 487void 488next_trigger(double d, sc_time_unit u, const sc_event_and_list &eal) 489{ 490 next_trigger(sc_time(d, u), eal); 491} 492 493bool 494timed_out() 495{ 496 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 497 return false; 498} 499 500 501void 502wait() 503{ 504 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 505} 506 507void 508wait(int) 509{ 510 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 511} 512 513void 514wait(const sc_event &) 515{ 516 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 517} 518 519void 520wait(const sc_event_or_list &) 521{ 522 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 523} 524 525void 526wait(const sc_event_and_list &) 527{ 528 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 529} 530 531void 532wait(const sc_time &) 533{ 534 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 535} 536 537void 538wait(double d, sc_time_unit u) 539{ 540 wait(sc_time(d, u)); 541} 542 543void 544wait(const sc_time &, const sc_event &) 545{ 546 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 547} 548 549void 550wait(double d, sc_time_unit u, const sc_event &e) 551{ 552 wait(sc_time(d, u), e); 553} 554 555void 556wait(const sc_time &, const sc_event_or_list &) 557{ 558 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 559} 560 561void 562wait(double d, sc_time_unit u, const sc_event_or_list &eol) 563{ 564 wait(sc_time(d, u), eol); 565} 566 567void 568wait(const sc_time &, const sc_event_and_list &) 569{ 570 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 571} 572 573void 574wait(double d, sc_time_unit u, const sc_event_and_list &eal) 575{ 576 wait(sc_time(d, u), eal); 577} 578 579void 580halt() 581{ 582 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 583} 584 585void 586at_posedge(const sc_signal_in_if<bool> &) 587{ 588 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 589} 590 591void 592at_posedge(const sc_signal_in_if<sc_dt::sc_logic> &) 593{ 594 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 595} 596 597void 598at_negedge(const sc_signal_in_if<bool> &) 599{ 600 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 601} 602 603void 604at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &) 605{ 606 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 607} 608 609const char * 610sc_gen_unique_name(const char *) 611{ 612 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 613 return ""; 614} 615 616bool 617sc_hierarchical_name_exists(const char *name) 618{ 619 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 620 return false; 621} 622 623bool 624sc_start_of_simulation_invoked() 625{ 626 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 627 return false; 628} 629 630bool 631sc_end_of_simulation_invoked() 632{ 633 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 634 return false; 635} 636 637sc_module * 638sc_module_sc_new(sc_module *mod) 639{ 640 static std::vector<std::unique_ptr<sc_module> > modules; 641 modules.emplace_back(mod); 642 return mod; 643} 644 645} // namespace sc_core 646