convenience_socket_bases.cc revision 13514
113514Sgabeblack@google.com/***************************************************************************** 213514Sgabeblack@google.com 313514Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 413514Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 513514Sgabeblack@google.com with this work for additional information regarding copyright ownership. 613514Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 713514Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 813514Sgabeblack@google.com License. You may obtain a copy of the License at 913514Sgabeblack@google.com 1013514Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1113514Sgabeblack@google.com 1213514Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1313514Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1413514Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1513514Sgabeblack@google.com implied. See the License for the specific language governing 1613514Sgabeblack@google.com permissions and limitations under the License. 1713514Sgabeblack@google.com 1813514Sgabeblack@google.com *****************************************************************************/ 1913514Sgabeblack@google.com 2013514Sgabeblack@google.com#include <tlm_utils/convenience_socket_bases.h> 2113514Sgabeblack@google.com 2213514Sgabeblack@google.com#include <sstream> 2313514Sgabeblack@google.com#include <systemc> 2413514Sgabeblack@google.com 2513514Sgabeblack@google.comnamespace tlm_utils 2613514Sgabeblack@google.com{ 2713514Sgabeblack@google.com 2813514Sgabeblack@google.comvoid 2913514Sgabeblack@google.comconvenience_socket_base::display_warning(const char *text) const 3013514Sgabeblack@google.com{ 3113514Sgabeblack@google.com std::stringstream s; 3213514Sgabeblack@google.com s << get_socket()->name() << ": " << text; 3313514Sgabeblack@google.com SC_REPORT_WARNING(get_report_type(), s.str().c_str()); 3413514Sgabeblack@google.com} 3513514Sgabeblack@google.com 3613514Sgabeblack@google.comvoid 3713514Sgabeblack@google.comconvenience_socket_base::display_error(const char *text) const 3813514Sgabeblack@google.com{ 3913514Sgabeblack@google.com std::stringstream s; 4013514Sgabeblack@google.com s << get_socket()->name() << ": " << text; 4113514Sgabeblack@google.com SC_REPORT_ERROR(get_report_type(), s.str().c_str()); 4213514Sgabeblack@google.com} 4313514Sgabeblack@google.com 4413514Sgabeblack@google.com// Simple helpers for warnings an errors to shorten in code notation. 4513514Sgabeblack@google.com 4613514Sgabeblack@google.comvoid 4713514Sgabeblack@google.comconvenience_socket_cb_holder::display_warning(const char *msg) const 4813514Sgabeblack@google.com{ 4913514Sgabeblack@google.com m_owner->display_warning(msg); 5013514Sgabeblack@google.com} 5113514Sgabeblack@google.com 5213514Sgabeblack@google.comvoid 5313514Sgabeblack@google.comconvenience_socket_cb_holder::display_error(const char *msg) const 5413514Sgabeblack@google.com{ 5513514Sgabeblack@google.com m_owner->display_error(msg); 5613514Sgabeblack@google.com} 5713514Sgabeblack@google.com 5813514Sgabeblack@google.comconst char * 5913514Sgabeblack@google.comsimple_socket_base::get_report_type() const 6013514Sgabeblack@google.com{ 6113514Sgabeblack@google.com return "/OSCI_TLM-2/simple_socket"; 6213514Sgabeblack@google.com} 6313514Sgabeblack@google.com 6413514Sgabeblack@google.comvoid 6513514Sgabeblack@google.comsimple_socket_base::elaboration_check(const char *action) const 6613514Sgabeblack@google.com{ 6713514Sgabeblack@google.com if (sc_core::sc_get_curr_simcontext()->elaboration_done()) { 6813514Sgabeblack@google.com std::stringstream s; 6913514Sgabeblack@google.com s << " elaboration completed, " << action << " not allowed"; 7013514Sgabeblack@google.com display_error(s.str().c_str()); 7113514Sgabeblack@google.com } 7213514Sgabeblack@google.com} 7313514Sgabeblack@google.com 7413514Sgabeblack@google.comconst char * 7513514Sgabeblack@google.compassthrough_socket_base::get_report_type() const 7613514Sgabeblack@google.com{ 7713514Sgabeblack@google.com return "/OSCI_TLM-2/passthrough_socket"; 7813514Sgabeblack@google.com} 7913514Sgabeblack@google.com 8013514Sgabeblack@google.comconst char * 8113514Sgabeblack@google.commulti_socket_base::get_report_type() const 8213514Sgabeblack@google.com{ 8313514Sgabeblack@google.com return "/OSCI_TLM-2/multi_socket"; 8413514Sgabeblack@google.com} 8513514Sgabeblack@google.com 8613514Sgabeblack@google.com} // namespace tlm_utils 87