sc_export.cc revision 13324
13630SN/A/* 27090SN/A * Copyright 2018 Google, Inc. 37090SN/A * 47090SN/A * Redistribution and use in source and binary forms, with or without 57090SN/A * modification, are permitted provided that the following conditions are 67090SN/A * met: redistributions of source code must retain the above copyright 77090SN/A * notice, this list of conditions and the following disclaimer; 87090SN/A * redistributions in binary form must reproduce the above copyright 97090SN/A * notice, this list of conditions and the following disclaimer in the 107090SN/A * documentation and/or other materials provided with the distribution; 117090SN/A * neither the name of the copyright holders nor the names of its 127090SN/A * contributors may be used to endorse or promote products derived from 137090SN/A * this software without specific prior written permission. 143630SN/A * 153630SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 163630SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 173630SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 183630SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 193630SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 203630SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 213630SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 223630SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 233630SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 243630SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 253630SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 263630SN/A * 273630SN/A * Authors: Gabe Black 283630SN/A */ 293630SN/A 303630SN/A#include "base/logging.hh" 313630SN/A#include "systemc/core/module.hh" 323630SN/A#include "systemc/core/scheduler.hh" 333630SN/A#include "systemc/ext/channel/messages.hh" 343630SN/A#include "systemc/ext/core/sc_export.hh" 353630SN/A#include "systemc/ext/core/sc_main.hh" 363630SN/A 373630SN/Anamespace sc_core 383630SN/A{ 393630SN/A 403630SN/Anamespace 413630SN/A{ 423630SN/A 433630SN/Avoid 447584SAli.Saidi@arm.comreportError(const char *id, const char *add_msg, 453630SN/A const char *name, const char *kind) 463630SN/A{ 473630SN/A std::string msg; 483630SN/A if (add_msg) 493630SN/A msg = csprintf("%s: export '%s' (%s)", add_msg, name, kind); 503630SN/A else 516658SN/A msg = csprintf("export '%s' (%s)", name, kind); 523630SN/A 537584SAli.Saidi@arm.com SC_REPORT_ERROR(id, msg.c_str()); 545478SN/A} 553630SN/A 563630SN/A} 573630SN/A 583630SN/Asc_export_base::sc_export_base(const char *n) : sc_object(n) 593630SN/A{ 607584SAli.Saidi@arm.com if (sc_is_running()) { 615034SN/A reportError(SC_ID_INSERT_EXPORT_, "simulation running", 623630SN/A name(), kind()); 633630SN/A } 643630SN/A if (::sc_gem5::scheduler.elaborationDone()) 653630SN/A reportError(SC_ID_INSERT_EXPORT_, "elaboration done", name(), kind()); 663630SN/A 673630SN/A auto m = sc_gem5::pickParentModule(); 687584SAli.Saidi@arm.com if (!m) 693630SN/A reportError(SC_ID_EXPORT_OUTSIDE_MODULE_, nullptr, name(), kind()); 703812SN/A else 713918SN/A m->exports.push_back(this); 723630SN/A} 733630SN/Asc_export_base::~sc_export_base() {} 743630SN/A 757584SAli.Saidi@arm.com} // namespace sc_core 763630SN/A