convenience_socket_bases.cc revision 13586
14981SN/A/***************************************************************************** 24981SN/A 34981SN/A Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 44981SN/A more contributor license agreements. See the NOTICE file distributed 54981SN/A with this work for additional information regarding copyright ownership. 64981SN/A Accellera licenses this file to you under the Apache License, Version 2.0 74981SN/A (the "License"); you may not use this file except in compliance with the 84981SN/A License. You may obtain a copy of the License at 94981SN/A 104981SN/A http://www.apache.org/licenses/LICENSE-2.0 114981SN/A 124981SN/A Unless required by applicable law or agreed to in writing, software 134981SN/A distributed under the License is distributed on an "AS IS" BASIS, 144981SN/A WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 154981SN/A implied. See the License for the specific language governing 164981SN/A permissions and limitations under the License. 174981SN/A 184981SN/A *****************************************************************************/ 194981SN/A 204981SN/A#include <tlm_utils/convenience_socket_bases.h> 214981SN/A 224981SN/A#include <sstream> 234981SN/A 244981SN/A#include "systemc/ext/core/sc_object.hh" 254981SN/A#include "systemc/ext/core/sc_simcontext.hh" 264981SN/A#include "systemc/ext/utils/sc_report_handler.hh" 274981SN/A 284981SN/Anamespace tlm_utils 294981SN/A{ 304981SN/A 314981SN/Avoid 324981SN/Aconvenience_socket_base::display_warning(const char *text) const 334981SN/A{ 344981SN/A std::stringstream s; 354981SN/A s << get_socket()->name() << ": " << text; 3611263Sandreas.sandberg@arm.com SC_REPORT_WARNING(get_report_type(), s.str().c_str()); 3711263Sandreas.sandberg@arm.com} 384981SN/A 395485SN/Avoid 4011260SN/Aconvenience_socket_base::display_error(const char *text) const 4111263Sandreas.sandberg@arm.com{ 424981SN/A std::stringstream s; 434981SN/A s << get_socket()->name() << ": " << text; 444981SN/A SC_REPORT_ERROR(get_report_type(), s.str().c_str()); 454981SN/A} 464981SN/A 4713784Sgabeblack@google.com// Simple helpers for warnings an errors to shorten in code notation. 484981SN/A 494981SN/Avoid 504981SN/Aconvenience_socket_cb_holder::display_warning(const char *msg) const 514981SN/A{ 529807SN/A m_owner->display_warning(msg); 534981SN/A} 544981SN/A 554981SN/Avoid 564981SN/Aconvenience_socket_cb_holder::display_error(const char *msg) const 574981SN/A{ 584981SN/A m_owner->display_error(msg); 594981SN/A} 604981SN/A 614981SN/Aconst char * 625485SN/Asimple_socket_base::get_report_type() const 635485SN/A{ 645485SN/A return "/OSCI_TLM-2/simple_socket"; 655999SN/A} 665999SN/A 675999SN/Avoid 685999SN/Asimple_socket_base::elaboration_check(const char *action) const 695999SN/A{ 705999SN/A if (sc_core::sc_get_curr_simcontext()->elaboration_done()) { 715999SN/A std::stringstream s; 725999SN/A s << " elaboration completed, " << action << " not allowed"; 735999SN/A display_error(s.str().c_str()); 745999SN/A } 755999SN/A} 765999SN/A 775999SN/Aconst char * 785999SN/Apassthrough_socket_base::get_report_type() const 795485SN/A{ 805485SN/A return "/OSCI_TLM-2/passthrough_socket"; 815485SN/A} 825485SN/A 835485SN/Aconst char * 845485SN/Amulti_socket_base::get_report_type() const 855485SN/A{ 865485SN/A return "/OSCI_TLM-2/multi_socket"; 875999SN/A} 885485SN/A 895999SN/A} // namespace tlm_utils 905999SN/A