scc  2022.4.0
SystemC components library
initiator_id.h
1 /*****************************************************************************
2  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
3  more contributor license agreements. See the NOTICE file distributed
4  with this work for additional information regarding copyright ownership.
5  Accellera licenses this file to you under the Apache License, Version 2.0
6  (the "License"); you may not use this file except in compliance with the
7  License. You may obtain a copy of the License at
8  http://www.apache.org/licenses/LICENSE-2.0
9  Unless required by applicable law or agreed to in writing, software
10  distributed under the License is distributed on an "AS IS" BASIS,
11  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  implied. See the License for the specific language governing
13  permissions and limitations under the License.
14  ****************************************************************************/
15 
16 #ifndef _SCP_INITIATOR_ID_EXTENSION_H
17 #define _SCP_INITIATOR_ID_EXTENSION_H
18 
19 #include <systemc>
20 #include <tlm>
21 
22 namespace scp {
23 namespace tlm_extensions {
33 class initiator_id : public tlm::tlm_extension<initiator_id> {
34  uint64_t m_id;
35 
36 public:
37  initiator_id(uint64_t id) { m_id = id; }
38  initiator_id(const initiator_id&) = default;
39 
40  virtual tlm_extension_base* clone() const override { return new initiator_id(*this); }
41 
42  virtual void copy_from(const tlm_extension_base& ext) override {
43  const initiator_id& other = static_cast<const initiator_id&>(ext);
44  *this = other;
45  }
46 
47  operator uint64_t() { return m_id; };
48 
49 #define overload(_OP) \
50  initiator_id& operator _OP(const uint64_t id) { \
51  this->m_id _OP id; \
52  return *this; \
53  }
54  overload(+=);
55  overload(-=);
56  overload(*=);
57  overload(/=);
58  overload(%=);
59  overload(&=);
60  overload(|=);
61  overload(^=);
62  overload(<<=);
63  overload(>>=);
64 
65  initiator_id& operator=(const uint64_t id) {
66  m_id = id;
67  return *this;
68  }
69 };
70 } // namespace tlm_extensions
71 } // namespace scp
72 #endif