scc 2025.09
SystemC components library
axi_rec_sockets.h
1/*
2 * Copyright 2020 Arteris IP
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include "axi_recorder.h"
20#include <axi/axi_tlm.h>
21
22namespace axi {
23namespace scv {
24
25template <unsigned int BUSWIDTH = 32, typename TYPES = axi::axi_protocol_types, int N = 1,
26 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
27class axi_rec_initiator_socket : public axi::axi_initiator_socket<BUSWIDTH, TYPES, N, POL> {
28 static std::string gen_name(const char* first, const char* second) {
29 std::stringstream ss;
30 ss << first << "_" << second;
31 return ss.str();
32 }
33
34public:
35 using fw_interface_type = axi::axi_fw_transport_if<TYPES>;
36 using bw_interface_type = axi::axi_bw_transport_if<TYPES>;
37 using port_type = sc_core::sc_port<fw_interface_type, N, POL>;
38 using export_type = sc_core::sc_export<bw_interface_type>;
39 using base_target_socket_type = tlm::tlm_base_target_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type>;
40 using base_type = tlm::tlm_base_initiator_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type>;
41
42 axi_rec_initiator_socket()
44 , recorder(gen_name(this->name(), "tx").c_str()) {
45 this->add_attribute(recorder.enableTracing);
46 this->add_attribute(recorder.enableTimed);
47 }
48
49 explicit axi_rec_initiator_socket(const char* name)
51 , recorder(gen_name(this->name(), "tx").c_str()) {}
52
53 virtual ~axi_rec_initiator_socket() {}
54
55 virtual const char* kind() const { return "axi_rec_initiator_socket"; }
56 //
57 // Bind initiator socket to target socket
58 // - Binds the port of the initiator socket to the export of the target
59 // socket
60 // - Binds the port of the target socket to the export of the initiator
61 // socket
62 //
63 virtual void bind(base_target_socket_type& s) {
64 // initiator.port -> target.export
65 (this->get_base_port())(recorder);
66 recorder.fw_port(s.get_base_interface());
67 // target.port -> initiator.export
68 (s.get_base_port())(recorder);
69 recorder.bw_port(this->get_base_interface());
70 }
71 //
72 // Bind initiator socket to initiator socket (hierarchical bind)
73 // - Binds both the export and the port
74 //
75 virtual void bind(base_type& s) {
76 // port
77 (this->get_base_port())(recorder);
78 recorder.fw_port(s.get_base_port());
79 // export
80 (s.get_base_export())(recorder);
81 recorder.bw_port(this->get_base_export());
82 }
83
84 //
85 // Bind interface to socket
86 // - Binds the interface to the export of this socket
87 //
88 virtual void bind(bw_interface_type& ifs) { (this->get_base_export())(ifs); }
89
90 void setExtensionRecording(tlm::scc::scv::tlm_extensions_recording_if<TYPES>* extensionRecording) {
91 recorder.setExtensionRecording(extensionRecording);
92 }
93
94protected:
96};
97
98template <unsigned int BUSWIDTH = 32, typename TYPES = axi::axi_protocol_types, int N = 1,
99 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
100class axi_rec_target_socket : public axi::axi_target_socket<BUSWIDTH, TYPES, N, POL> {
101 static std::string gen_name(const char* first, const char* second) {
102 std::stringstream ss;
103 ss << first << "_" << second;
104 return ss.str();
105 }
106
107public:
108 using fw_interface_type = axi::axi_fw_transport_if<TYPES>;
109 using bw_interface_type = axi::axi_bw_transport_if<TYPES>;
110 using port_type = sc_core::sc_port<bw_interface_type, N, POL>;
111 using export_type = sc_core::sc_export<fw_interface_type>;
112 using base_initiator_socket_type = tlm::tlm_base_initiator_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type>;
113 using base_type = tlm::tlm_base_target_socket_b<BUSWIDTH, fw_interface_type, bw_interface_type>;
114
115 axi_rec_target_socket()
117 , recorder(gen_name(this->name(), "tx").c_str()) {
118 this->add_attribute(recorder.enableTracing);
119 this->add_attribute(recorder.enableTimed);
120 }
121
122 explicit axi_rec_target_socket(const char* name)
124 , recorder(gen_name(this->name(), "tx").c_str()) {}
125
126 virtual ~axi_rec_target_socket() {}
127
128 virtual const char* kind() const { return "axi_rec_target_socket"; }
129 //
130 // Bind target socket to target socket (hierarchical bind)
131 // - Binds both the export and the port
132 //
133 virtual void bind(base_type& s) {
134 // export
135 (this->get_base_export())(s.get_base_export()); // will be handled by bind(fw_interface_type& ifs)
136 // port
137 (s.get_base_port())(recorder); // bind the recording interface to the port, recording will use the m_port
138 }
139
140 //
141 // Bind interface to socket
142 // - Binds the interface to the export
143 //
144 virtual void bind(fw_interface_type& ifs) {
145 export_type* exp = &this->get_base_export();
146 if(this == exp) {
147 export_type::bind(recorder); // non-virtual function call
148 recorder.fw_port(ifs);
149 recorder.bw_port(this->m_port);
150 } else {
151 exp->bind(ifs);
152 }
153 }
154
155 sc_core::sc_port_b<bw_interface_type>& get_base_port() override { return recorder.bw_port; }
156
157 sc_core::sc_port_b<bw_interface_type> const& get_base_port() const override { return recorder.bw_port; }
158 //
159 // Forward to 'operator->()' of port class
160 //
161 bw_interface_type* operator->() { return &recorder; }
162
163 void setExtensionRecording(tlm::scc::scv::tlm_extensions_recording_if<TYPES>* extensionRecording) {
164 recorder.setExtensionRecording(extensionRecording);
165 }
166
167protected:
169};
170} // namespace scv
171} // namespace axi
The TLM2 transaction recorder.
The TLM transaction extensions recorder interface.
TLM2.0 components modeling AHB.
tlm::tlm_bw_transport_if< TYPES > axi_bw_transport_if
alias declaration for the backward interface:
Definition axi_tlm.h:956
tlm::tlm_fw_transport_if< TYPES > axi_fw_transport_if
alias declaration for the forward interface
Definition axi_tlm.h:954
The AXI protocol traits class. Since the protocoll defines additional non-ignorable phases a dedicate...
Definition axi_tlm.h:920