scc 2025.09
SystemC components library
axis_tlm.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 _AXIS_AXIS_TLM_H_
18#define _AXIS_AXIS_TLM_H_
19
20#include <cci_configuration>
21#include <cstdint>
22#include <scc/fifo_w_cb.h>
23#include <scc/peq.h>
24#include <scc/report.h>
25#include <scc/sc_variable.h>
26#include <tlm/nw/tlm_network_gp.h>
28#include <tlm/scc/tlm_gp_shared.h>
29#include <tlm/scc/tlm_mm.h>
30
32namespace axis {
33enum class AXIS_PKT { DATA };
34struct axis_packet_payload : public tlm::nw::tlm_network_payload<AXIS_PKT> {
35 axis_packet_payload() = default;
36
37 explicit axis_packet_payload(tlm::nw::tlm_base_mm_interface* mm)
39
40 const sc_core::sc_time& get_sender_clk_period() const { return sender_clk_period; }
41
42 void set_sender_clk_period(sc_core::sc_time period) { this->sender_clk_period = sender_clk_period; }
43
44private:
45 sc_core::sc_time sender_clk_period{sc_core::SC_ZERO_TIME};
46};
47
49 using tlm_payload_type = axis_packet_payload;
50 using tlm_phase_type = ::tlm::tlm_phase;
51};
52
53} // namespace axis
54
55namespace tlm {
56namespace scc {
57// provide needed info for SCC memory manager
58template <> struct tlm_mm_traits<axis::axis_packet_types> {
59 using mm_if_type = tlm::nw::tlm_base_mm_interface;
60 using payload_base = tlm::nw::tlm_network_payload_base;
61};
62} // namespace scc
63} // namespace tlm
64
65namespace axis {
66template <int N = 32> using axis_pkt_initiator_socket = tlm::nw::tlm_network_initiator_socket<N, AXIS_PKT, axis_packet_types, N>;
67template <int N = 32> using axis_pkt_target_socket = tlm::nw::tlm_network_target_socket<N, AXIS_PKT, axis_packet_types, N>;
70
71struct axis_channel : public sc_core::sc_module,
72 public tlm::nw::tlm_network_fw_transport_if<axis_packet_types>,
73 public tlm::nw::tlm_network_bw_transport_if<axis_packet_types> {
74
75 using transaction_type = axis_packet_types::tlm_payload_type;
76 using phase_type = axis_packet_types::tlm_phase_type;
77
78 axis_pkt_target_socket<> tsck{"tsck"};
79
80 axis_pkt_initiator_socket<> isck{"isck"};
81
82 cci::cci_param<sc_core::sc_time> channel_delay{"channel_delay", sc_core::SC_ZERO_TIME, "delay of the AXIS channel"};
83
84 axis_channel(sc_core::sc_module_name const& nm)
85 : sc_core::sc_module(nm) {
86 isck(*this);
87 tsck(*this);
88 }
89
90 void b_transport(transaction_type& trans, sc_core::sc_time& t) override {
91 t += channel_delay;
92 isck->b_transport(trans, t);
93 }
94
95 tlm::tlm_sync_enum nb_transport_fw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t) override {
96 SCCTRACE(SCMOD) << "Received non-blocking transaction in fw path with phase " << phase.get_name();
97 if(phase == tlm::nw::REQUEST) {
98 phase_type ph = tlm::nw::INDICATION;
99 auto ret = isck->nb_transport_fw(trans, ph, t);
100 if(ph == tlm::nw::RESPONSE)
101 phase = tlm::nw::CONFIRM;
102 return ret;
103 } else {
104 trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE);
105 phase = tlm::nw::CONFIRM;
106 return tlm::TLM_COMPLETED;
107 }
108 return tlm::TLM_ACCEPTED;
109 }
110
111 tlm::tlm_sync_enum nb_transport_bw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t) override {
112 SCCTRACE(SCMOD) << "Received non-blocking transaction in bw path with phase " << phase.get_name();
113 if(phase == tlm::nw::RESPONSE) {
114 phase_type ph = tlm::nw::CONFIRM;
115 return tsck->nb_transport_bw(trans, ph, t);
116 }
117 return tlm::TLM_ACCEPTED;
118 }
119
120 unsigned int transport_dbg(transaction_type& trans) override { return isck->transport_dbg(trans); }
121};
122} // namespace axis
123#endif // _AXIS_AXIS_TLM_H_
AXIS TLM utilities.
Definition axis_tlm.h:32
SCC TLM utilities.
SystemC TLM.
Definition dmi_mgr.h:19
Definition of the tlm_network_initiator_socket class.
A base class for TLM network payloads.
A class for TLM network payloads with support for extensions and memory management.
void set_response_status(const tlm_response_status response_status)
Sets the response status in the payload.
Definition of the tlm_network_target_socket class.
a tlm memory manager
Definition tlm_mm.h:330
The SystemC Transaction Level Model (TLM) Network TLM utilities.