gem5  v20.1.0.0
phase.hh
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 #ifndef __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_PHASE_HH__
21 #define __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_PHASE_HH__
22 
23 #include <iostream>
24 #include <typeinfo>
25 #include <vector>
26 
27 #define SC_CONCAT_HELPER_(a, b) SC_CONCAT_HELPER_DEFERRED_(a, b)
28 #define SC_CONCAT_HELPER_DEFERRED_(a, b) SC_CONCAT_HELPER_MORE_DEFERRED_(a, b)
29 #define SC_CONCAT_HELPER_MORE_DEFERRED_(a, b) a ## b
30 
31 #define SC_STRINGIFY_HELPER_(a) SC_STRINGIFY_HELPER_DEFERRED_(a)
32 #define SC_STRINGIFY_HELPER_DEFERRED_(a) SC_STRINGIFY_HELPER_MORE_DEFERRED_(a)
33 #define SC_STRINGIFY_HELPER_MORE_DEFERRED_(a) #a
34 
35 namespace tlm
36 {
37 
39 {
41  BEGIN_REQ = 1,
45 };
46 
47 class tlm_phase
48 {
49  public:
50  tlm_phase();
51  tlm_phase(unsigned int id);
52 
53  tlm_phase(tlm_phase_enum standard);
55 
56  operator unsigned int() const { return m_id; }
57  const char *get_name() const;
58 
59  protected:
60  // Register extended phase.
61  tlm_phase(const std::type_info &type, const char *name);
62 
63  private:
64  unsigned int m_id;
65 };
66 
68 
69 inline tlm_phase::tlm_phase(tlm_phase_enum standard) : m_id(standard) {}
70 
71 inline tlm_phase &
73 {
74  m_id = standard;
75  return *this;
76 }
77 
78 inline std::ostream &
79 operator << (std::ostream &s, const tlm_phase &p)
80 {
81  s << p.get_name();
82  return s;
83 }
84 
85 #define TLM_DECLARE_EXTENDED_PHASE(name_arg) \
86 static class SC_CONCAT_HELPER_(tlm_phase_, name_arg) : \
87  public ::tlm::tlm_phase \
88 { \
89  typedef SC_CONCAT_HELPER_(tlm_phase_, name_arg) this_type; \
90  public: \
91  SC_CONCAT_HELPER_(tlm_phase_, name_arg)() : \
92  /* register extended phase */ \
93  ::tlm::tlm_phase(typeid(*this), SC_STRINGIFY_HELPER_(name_arg)) \
94  {} \
95  \
96  static const this_type &get_phase() \
97  /* needed only for IEEE 1666-2011 */ \
98  { \
99  static this_type this_; \
100  return this_; \
101  } \
102 } const name_arg
103 
104 // for backwards-compatibility
105 #define DECLARE_EXTENDED_PHASE(NameArg) TLM_DECLARE_EXTENDED_PHASE(NameArg)
106 
107 } // namespace tlm
108 
109 #endif /* __SYSTEMC_EXT_TLM_CORE_2_GENERIC_PAYLOAD_PHASE_HH__ */
tlm::tlm_phase
Definition: phase.hh:47
tlm::UNINITIALIZED_PHASE
@ UNINITIALIZED_PHASE
Definition: phase.hh:40
type
uint8_t type
Definition: inet.hh:421
tlm::END_REQ
@ END_REQ
Definition: phase.hh:42
tlm::tlm_phase_enum
tlm_phase_enum
Definition: phase.hh:38
tlm::tlm_phase::tlm_phase
tlm_phase()
Definition: phase.hh:67
tlm::tlm_phase::m_id
unsigned int m_id
Definition: phase.hh:64
tlm::tlm_phase::operator=
tlm_phase & operator=(tlm_phase_enum standard)
Definition: phase.hh:72
tlm
Definition: analysis_fifo.hh:27
tlm::END_RESP
@ END_RESP
Definition: phase.hh:44
name
const std::string & name()
Definition: trace.cc:50
tlm::BEGIN_REQ
@ BEGIN_REQ
Definition: phase.hh:41
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
ArmISA::s
Bitfield< 4 > s
Definition: miscregs_types.hh:556
tlm::tlm_phase::get_name
const char * get_name() const
Definition: phase.cc:123
tlm::BEGIN_RESP
@ BEGIN_RESP
Definition: phase.hh:43
tlm::operator<<
std::ostream & operator<<(std::ostream &s, const tlm_phase &p)
Definition: phase.hh:79

Generated on Wed Sep 30 2020 14:02:16 for gem5 by doxygen 1.8.17