scc  2022.4.0
SystemC components library
tlm_recording_extension.h
1 /*******************************************************************************
2  * Copyright 2016, 2018 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 _SCV4TLM_TLM_RECORDING_EXTENSION_H_
18 #define _SCV4TLM_TLM_RECORDING_EXTENSION_H_
19 
20 #include <array>
21 #ifdef HAS_SCV
22 #include <scv.h>
23 #else
24 #include <scv-tr.h>
25 #endif
26 #include <tlm>
27 
29 namespace tlm {
31 namespace scc {
33 namespace scv {
34 #ifndef HAS_SCV
35 #ifndef SCVNS
36 #define SCVNS ::scv_tr::
37 #endif
38 #endif
39 
41 enum tx_rel {
44 };
46 static std::array<const char*, 2> tx_rel_str = {{"PARENT/CHILD", "PRED/SUCC"}};
51 inline const char* rel_str(tx_rel rel) { return (tx_rel_str[rel]); }
62 class tlm_recording_extension : public tlm::tlm_extension<tlm_recording_extension> {
63 public:
67  virtual tlm_extension_base* clone() const {
68  tlm_recording_extension* t = new tlm_recording_extension(this->txHandle, this->creator);
69  return t;
70  }
75  virtual void copy_from(tlm_extension_base const& from) {
76  txHandle = static_cast<tlm_recording_extension const&>(from).txHandle;
77  creator = static_cast<tlm_recording_extension const&>(from).creator;
78  }
86  tlm_recording_extension(SCVNS scv_tr_handle handle, void* creator_)
87  : txHandle(handle)
88  , creator(creator_) {}
92  void* get_creator() { return creator; }
96  SCVNS scv_tr_handle txHandle;
97 
98 private:
100  void* creator;
101 };
102 } // namespace scv
103 } // namespace scc
104 } // namespace tlm
105 
106 #endif /* TLM_RECORDING_EXTENSION_H_ */
generic payload extension class holding the handle of the last recorded SCV transaction
virtual tlm_extension_base * clone() const
clone the given extension and duplicate the SCV transaction handle.
SCVNS scv_tr_handle txHandle
accessor to the SCV transaction handle.
virtual void copy_from(tlm_extension_base const &from)
copy data between extensions.
tlm_recording_extension(SCVNS scv_tr_handle handle, void *creator_)
constructor storing the handle of the transaction and the owner of this extension
void * get_creator()
accessor to the owner, the property is read only.
SCC SystemC utilities.
const char * rel_str(tx_rel rel)
cast the tx_rel enum to a string
tx_rel
transaction relationships
SystemC TLM.