convenience_socket_bases.cc (13514:75569a60a0be) convenience_socket_bases.cc (13586:008fe87c1ad4)
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20#include <tlm_utils/convenience_socket_bases.h>
21
22#include <sstream>
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20#include <tlm_utils/convenience_socket_bases.h>
21
22#include <sstream>
23#include <systemc>
24
23
24#include "systemc/ext/core/sc_object.hh"
25#include "systemc/ext/core/sc_simcontext.hh"
26#include "systemc/ext/utils/sc_report_handler.hh"
27
25namespace tlm_utils
26{
27
28void
29convenience_socket_base::display_warning(const char *text) const
30{
31 std::stringstream s;
32 s << get_socket()->name() << ": " << text;
33 SC_REPORT_WARNING(get_report_type(), s.str().c_str());
34}
35
36void
37convenience_socket_base::display_error(const char *text) const
38{
39 std::stringstream s;
40 s << get_socket()->name() << ": " << text;
41 SC_REPORT_ERROR(get_report_type(), s.str().c_str());
42}
43
44// Simple helpers for warnings an errors to shorten in code notation.
45
46void
47convenience_socket_cb_holder::display_warning(const char *msg) const
48{
49 m_owner->display_warning(msg);
50}
51
52void
53convenience_socket_cb_holder::display_error(const char *msg) const
54{
55 m_owner->display_error(msg);
56}
57
58const char *
59simple_socket_base::get_report_type() const
60{
61 return "/OSCI_TLM-2/simple_socket";
62}
63
64void
65simple_socket_base::elaboration_check(const char *action) const
66{
67 if (sc_core::sc_get_curr_simcontext()->elaboration_done()) {
68 std::stringstream s;
69 s << " elaboration completed, " << action << " not allowed";
70 display_error(s.str().c_str());
71 }
72}
73
74const char *
75passthrough_socket_base::get_report_type() const
76{
77 return "/OSCI_TLM-2/passthrough_socket";
78}
79
80const char *
81multi_socket_base::get_report_type() const
82{
83 return "/OSCI_TLM-2/multi_socket";
84}
85
86} // namespace tlm_utils
28namespace tlm_utils
29{
30
31void
32convenience_socket_base::display_warning(const char *text) const
33{
34 std::stringstream s;
35 s << get_socket()->name() << ": " << text;
36 SC_REPORT_WARNING(get_report_type(), s.str().c_str());
37}
38
39void
40convenience_socket_base::display_error(const char *text) const
41{
42 std::stringstream s;
43 s << get_socket()->name() << ": " << text;
44 SC_REPORT_ERROR(get_report_type(), s.str().c_str());
45}
46
47// Simple helpers for warnings an errors to shorten in code notation.
48
49void
50convenience_socket_cb_holder::display_warning(const char *msg) const
51{
52 m_owner->display_warning(msg);
53}
54
55void
56convenience_socket_cb_holder::display_error(const char *msg) const
57{
58 m_owner->display_error(msg);
59}
60
61const char *
62simple_socket_base::get_report_type() const
63{
64 return "/OSCI_TLM-2/simple_socket";
65}
66
67void
68simple_socket_base::elaboration_check(const char *action) const
69{
70 if (sc_core::sc_get_curr_simcontext()->elaboration_done()) {
71 std::stringstream s;
72 s << " elaboration completed, " << action << " not allowed";
73 display_error(s.str().c_str());
74 }
75}
76
77const char *
78passthrough_socket_base::get_report_type() const
79{
80 return "/OSCI_TLM-2/passthrough_socket";
81}
82
83const char *
84multi_socket_base::get_report_type() const
85{
86 return "/OSCI_TLM-2/multi_socket";
87}
88
89} // namespace tlm_utils