scc  2024.06
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 
21 namespace lwtr {
22 template <class Archive> void record(Archive& ar, tlm::scc::tlm_id_extension const& e) { ar& field("uid", e.id); }
23 } // namespace lwtr
24 
25 namespace tlm {
26 namespace scc {
27 namespace lwtr {
28 namespace {
29 const std::array<std::string, 3> cmd2char{{"READ", "WRITE", "IGNORE"}};
30 const std::array<std::string, 7> resp2char{
31  {"OK", "INCOMPLETE", "GENERIC_ERROR", "ADDRESS_ERROR", "COMMAND_ERROR", "BURST_ERROR", "BYTE_ENABLE_ERROR"}};
32 const std::array<std::string, 3> gp_option2char{{"MIN_PAYLOAD", "FULL_PAYLOAD", "FULL_PAYLOAD_ACCEPTED"}};
33 const std::array<std::string, 5> phase2char{{"UNINITIALIZED_PHASE", "BEGIN_REQ", "END_REQ", "BEGIN_RESP", "END_RESP"}};
34 const std::array<std::string, 4> dmi2char{{"DMI_ACCESS_NONE", "DMI_ACCESS_READ", "DMI_ACCESS_WRITE", "DMI_ACCESS_READ_WRITE"}};
35 const std::array<std::string, 3> sync2char{{"ACCEPTED", "UPDATED", "COMPLETED"}};
36 
37 } // namespace
38 
39 class 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
51 bool register_extensions() {
52  tlm::scc::tlm_id_extension ext(nullptr); // NOLINT
54  return true; // NOLINT
55 }
56 bool registered = register_extensions();
57 
58 } // namespace lwtr
59 } // namespace scc
60 } // namespace tlm
The TLM transaction extensions recorder interface.
The TLM transaction extensions recorder registry.
SCC TLM utilities.
SystemC TLM.
Definition: cxs_tlm.h:69