scc 2025.09
SystemC components library
cxs_tlm.cpp
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#include "cxs/cxs_tlm.h"
18#include <fmt/format.h>
19#include <tlm/scc/scv/tlm_extension_recording_registry.h>
20#include <tlm/scc/tlm_id.h>
21
22namespace cxs {
23
25
26 void recordBeginTx(SCVNS scv_tr_handle& h, cxs_flit_types::tlm_payload_type& trans) override {
27 if(auto ext = trans.get_extension<orig_pkt_extension>()) { // CTRL, DATA, RESP
28 auto idx = 0U;
29 for(auto& pkt : ext->orig_ext) {
30 h.record_attribute(fmt::format("flit.packet{}.size", idx++).c_str(), pkt->get_data().size());
31 if(pkt->get_extension_count())
32 for(auto& extensionRecording : tlm::scc::scv::tlm_extension_recording_registry<cxs_packet_types>::inst().get())
33 if(extensionRecording)
34 extensionRecording->recordBeginTx(h, *pkt);
35 }
36 }
37 }
38
39 void recordEndTx(SCVNS scv_tr_handle& handle, cxs_flit_types::tlm_payload_type& trans) override {}
40};
41#if defined(__GNUG__)
42__attribute__((constructor))
43#endif
44bool register_extensions() {
45 cxs::orig_pkt_extension ext; // NOLINT
46 if(!tlm::scc::scv::tlm_extension_recording_registry<cxs::cxs_flit_types>::inst().is_ext_registered(ext.ID))
47 tlm::scc::scv::tlm_extension_recording_registry<cxs::cxs_flit_types>::inst().register_ext_rec(
48 ext.ID,
49 new cxs::cxs_ext_recording()); // NOLINT
50 return true; // NOLINT
51}
52bool registered = register_extensions();
53} // namespace cxs
The TLM transaction extensions recorder interface.
CXS TLM utilities.
Definition cxs_tlm.cpp:22