scc 2025.09
SystemC components library
socket_width_adapter.h
1/*******************************************************************************
2 * Copyright 2024 MINRES Technologies GmbH
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#ifndef _SCC_SOCKET_WIDTH_ADAPTER_H_
18#define _SCC_SOCKET_WIDTH_ADAPTER_H_
19
20#include <tlm>
21
23namespace scc {
41template <unsigned int TGT_BUSWIDTH = 32, unsigned int INTOR_BUSWIDTH = 32, typename TYPES = tlm::tlm_base_protocol_types, int N = 1,
42 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
43class socket_width_adapter : public sc_core::sc_module, public tlm::tlm_fw_transport_if<TYPES>, public tlm::tlm_bw_transport_if<TYPES> {
44public:
45 using tlm_payload_type = typename TYPES::tlm_payload_type;
46 using tlm_phase_type = typename TYPES::tlm_phase_type;
47 using target_socket_type = tlm::tlm_target_socket<TGT_BUSWIDTH, TYPES, N, POL>;
48 using initiator_socket_type = tlm::tlm_initiator_socket<INTOR_BUSWIDTH, TYPES, N, POL>;
54 target_socket_type tsck{"tsck"};
60 initiator_socket_type isck{"isck"};
66 socket_width_adapter(sc_core::sc_module_name const& nm)
67 : sc_core::sc_module(nm) {
68 tsck.bind(*this);
69 isck.bind(*this);
70 }
71
72 socket_width_adapter() = delete;
73
75
80 virtual ~socket_width_adapter() = default;
81
82private:
83 tlm::tlm_sync_enum nb_transport_fw(tlm_payload_type& trans, tlm_phase_type& phase, sc_core::sc_time& t) override {
84 return isck->nb_transport_fw(trans, phase, t);
85 };
86
87 void b_transport(tlm_payload_type& trans, sc_core::sc_time& t) override { isck->b_transport(trans, t); }
88
89 bool get_direct_mem_ptr(tlm_payload_type& trans, tlm::tlm_dmi& dmi_data) override { return isck->get_direct_mem_ptr(trans, dmi_data); }
90
91 unsigned int transport_dbg(tlm_payload_type& trans) override { return isck->transport_dbg(trans); }
92
93 tlm::tlm_sync_enum nb_transport_bw(tlm_payload_type& trans, tlm_phase_type& phase, sc_core::sc_time& t) override {
94 return tsck->nb_transport_bw(trans, phase, t);
95 }
96
97 void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range) override {
98 tsck->invalidate_direct_mem_ptr(start_range, end_range);
99 }
100};
101} // namespace scc
102#endif // _SCC_SOCKET_WIDTH_ADAPTER_H_
The socket_width_adapter class is a TLM (Transaction-Level Modeling) socket width adapter.
socket_width_adapter(sc_core::sc_module_name const &nm)
Constructor for the socket_width_adapter class.
target_socket_type tsck
The target socket for the adapter.
initiator_socket_type isck
The initiator socket for the adapter.
virtual ~socket_width_adapter()=default
Virtual destructor for the socket_width_adapter class.
SCC TLM utilities.