scc 2025.09
SystemC components library
tlm_extension_recording_registry.h
1/*******************************************************************************
2 * Copyright 2016, 2020 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 TLM_RECORDER_REGISTRY_H_
18#define TLM_RECORDER_REGISTRY_H_
19
20#ifdef HAS_SCV
21#include <scv.h>
22#ifndef SCVNS
23#define SCVNS
24#endif
25#else
26#include <scv-tr.h>
27#ifndef SCVNS
28#define SCVNS ::scv_tr::
29#endif
30#endif
31#include <tlm>
32
34namespace tlm {
36namespace scc {
38namespace scv {
45template <typename TYPES = tlm::tlm_base_protocol_types> class tlm_extensions_recording_if {
46public:
51 virtual void recordBeginTx(SCVNS scv_tr_handle& handle, typename TYPES::tlm_payload_type& trans) = 0;
52
57 virtual void recordEndTx(SCVNS scv_tr_handle& handle, typename TYPES::tlm_payload_type& trans) = 0;
58
59 virtual ~tlm_extensions_recording_if() = default;
60};
61
68template <typename TYPES = tlm::tlm_base_protocol_types> class tlm_extension_recording_registry {
69public:
70 static tlm_extension_recording_registry& inst() {
71 static tlm_extension_recording_registry reg;
72 return reg;
73 }
74
75 void register_ext_rec(size_t id, tlm_extensions_recording_if<TYPES>* ext) {
76 if(id == 0)
77 return;
78 if(id >= ext_rec.size())
79 ext_rec.resize(id + 1);
80 if(ext_rec[id])
81 delete ext_rec[id];
82 ext_rec[id] = ext;
83 }
84
85 bool is_ext_registered(size_t id) {
86 if(id == 0)
87 return true;
88 if(id >= ext_rec.size())
89 return false;
90 if(ext_rec[id])
91 return true;
92 return false;
93 }
94 const std::vector<tlm_extensions_recording_if<TYPES>*>& get() { return ext_rec; }
95
96 inline void recordBeginTx(size_t id, SCVNS scv_tr_handle& handle, typename TYPES::tlm_payload_type& trans) {
97 if(ext_rec.size() > id && ext_rec[id])
98 ext_rec[id]->recordBeginTx(handle, trans);
99 }
100
105 inline void recordEndTx(size_t id, SCVNS scv_tr_handle& handle, typename TYPES::tlm_payload_type& trans) {
106 if(ext_rec.size() > id && ext_rec[id])
107 ext_rec[id]->recordEndTx(handle, trans);
108 }
109
110private:
113 for(auto& ext : ext_rec)
114 delete(ext);
115 }
116 std::vector<tlm_extensions_recording_if<TYPES>*> ext_rec{};
117};
118
119} // namespace scv
120} // namespace scc
121} // namespace tlm
122#endif /* TLM_RECORDER_REGISTRY_H_ */
The TLM transaction extensions recorder registry.
void recordEndTx(size_t id, SCVNS scv_tr_handle &handle, typename TYPES::tlm_payload_type &trans)
recording attributes in extensions at the end, it is intended to be overload as it does nothing
The TLM transaction extensions recorder interface.
virtual void recordEndTx(SCVNS scv_tr_handle &handle, typename TYPES::tlm_payload_type &trans)=0
recording attributes in extensions at the end, it is intended to be overload as it does nothing
virtual void recordBeginTx(SCVNS scv_tr_handle &handle, typename TYPES::tlm_payload_type &trans)=0
recording attributes in extensions at the beginning, it is intended to be overload as it does nothing
SCC SCV4TLM classes and functions.
SCC TLM utilities.
Definition axis_tlm.h:56
SystemC TLM.
Definition dmi_mgr.h:19