scc 2025.09
SystemC components library
obi_tlm.h
1/*******************************************************************************
2 * Copyright 2021 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 _BUS_OBI_TLM_H_
18#define _BUS_OBI_TLM_H_
19
20#include <array>
21#include <cstdint>
22#include <tlm>
23
25namespace obi {
26
27struct obi_extension : public tlm::tlm_extension<obi_extension> {
28
29 uint32_t get_id() const;
30 void set_id(uint32_t);
31
32 uint32_t get_auser() const;
33 void set_auser(uint32_t);
34
35 uint32_t get_duser() const;
36 void set_duser(uint32_t);
37
38 obi_extension() = default;
39
40 obi_extension(const obi_extension& o) = default;
45 tlm::tlm_extension_base* clone() const override;
50 void copy_from(tlm::tlm_extension_base const& ext) override;
51
52private:
53 uint32_t id{0};
54 uint32_t auser{0};
55 uint32_t duser{0};
56};
57
58inline tlm::tlm_extension_base* obi_extension::clone() const { return new obi_extension(*this); }
59
60inline uint32_t obi_extension::get_id() const { return id; }
61
62inline void obi_extension::set_id(uint32_t unsignedInt) { id = unsignedInt; }
63
64inline uint32_t obi_extension::get_auser() const { return auser; }
65
66inline void obi_extension::set_auser(uint32_t unsignedInt) { auser = unsignedInt; }
67
68inline uint32_t obi_extension::get_duser() const { return duser; }
69
70inline void obi_extension::set_duser(uint32_t unsignedInt) { duser = unsignedInt; }
71
72inline void obi_extension::copy_from(const tlm::tlm_extension_base& ext) {
73 auto const* obi_ext = dynamic_cast<const obi_extension*>(&ext);
74 assert(obi_ext);
75 (*this) = *obi_ext;
76}
77
78inline unsigned get_obi_id(tlm::tlm_generic_payload& trans) {
79 auto* ext = trans.get_extension<obi::obi_extension>();
80 assert(ext && "No OBI extension found");
81 return ext->get_id();
82}
83} // namespace obi
84
85#endif /* _BUS_OBI_TLM_H_ */
TLM2.0 components modeling OBI.
Definition obi_tlm.h:25
void copy_from(tlm::tlm_extension_base const &ext) override
deep copy all values from ext
Definition obi_tlm.h:72
tlm::tlm_extension_base * clone() const override
the clone function to create deep copies of
Definition obi_tlm.h:58