scc 2025.09
SystemC components library
tlm2_lwtr.cpp
1/*******************************************************************************
2 * Copyright 2016-2022 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#include "tlm2_lwtr.h"
18#include <tlm/scc/lwtr/lwtr4tlm2_extension_registry.h>
19#include <tlm/scc/tlm_id.h>
20
21namespace lwtr {
22template <class Archive> void record(Archive& ar, tlm::scc::tlm_id_extension const& e) { ar& field("uid", e.id); }
23} // namespace lwtr
24
25namespace tlm {
26namespace scc {
27namespace lwtr {
28namespace {
29const std::array<std::string, 3> cmd2char{{"READ", "WRITE", "IGNORE"}};
30const std::array<std::string, 7> resp2char{
31 {"OK", "INCOMPLETE", "GENERIC_ERROR", "ADDRESS_ERROR", "COMMAND_ERROR", "BURST_ERROR", "BYTE_ENABLE_ERROR"}};
32const std::array<std::string, 3> gp_option2char{{"MIN_PAYLOAD", "FULL_PAYLOAD", "FULL_PAYLOAD_ACCEPTED"}};
33const std::array<std::string, 5> phase2char{{"UNINITIALIZED_PHASE", "BEGIN_REQ", "END_REQ", "BEGIN_RESP", "END_RESP"}};
34const std::array<std::string, 4> dmi2char{{"DMI_ACCESS_NONE", "DMI_ACCESS_READ", "DMI_ACCESS_WRITE", "DMI_ACCESS_READ_WRITE"}};
35const std::array<std::string, 3> sync2char{{"ACCEPTED", "UPDATED", "COMPLETED"}};
36
37} // namespace
38
39class tlm_id_ext_recording : public tlm::scc::lwtr::lwtr4tlm2_extension_registry_if<tlm::tlm_base_protocol_types> {
40 void recordBeginTx(::lwtr::tx_handle& handle, tlm::tlm_base_protocol_types::tlm_payload_type& trans) override {
41 if(auto* ext = trans.get_extension<tlm::scc::tlm_id_extension>())
42 handle.record_attribute("trans", *ext);
43 }
44 void recordEndTx(::lwtr::tx_handle& handle, tlm::tlm_base_protocol_types::tlm_payload_type& trans) override {}
45};
46
47// using namespace tlm::scc::scv;
48#if defined(__GNUG__)
49__attribute__((constructor))
50#endif
51bool register_extensions() {
52 tlm::scc::tlm_id_extension ext(nullptr); // NOLINT
53 lwtr4tlm2_extension_registry<tlm::tlm_base_protocol_types>::inst().register_ext_rec(ext.ID, new tlm_id_ext_recording()); // NOLINT
54 return true; // NOLINT
55}
56bool registered = register_extensions();
57
58} // namespace lwtr
59} // namespace scc
60} // namespace tlm
The TLM transaction extensions recorder interface.
SCC SCV4TLM classes and functions.
SCC TLM utilities.
Definition axis_tlm.h:56
SystemC TLM.
Definition dmi_mgr.h:19