gem5  v20.1.0.0
port.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef __SYSTEMC_CORE_PORT_HH__
29 #define __SYSTEMC_CORE_PORT_HH__
30 
31 #include <list>
32 #include <typeinfo>
33 #include <vector>
34 
35 #include "base/cprintf.hh"
38 
39 namespace sc_gem5
40 {
41 
42 class StaticSensitivityPort;
43 class StaticSensitivityFinder;
44 class Reset;
45 
46 class Port;
47 
49 
50 class Port
51 {
52  private:
54 
55  bool finalized;
56  int _maxSize;
57  int _size;
58 
60 
63  void finalizeReset(Reset *reset);
64 
65  void
67  {
69  _size++;
70  }
71 
72  void
74  {
75  // Only the ports farthest from the interfaces call register_port.
76  pb->_gem5Port->regPortNeeded = false;
77  for (int i = 0; i < pb->size(); i++)
79  }
80 
83  {
84  return portBase->_gem5Interface(i);
85  }
86 
87  struct Binding
88  {
90  interface(interface), port(nullptr)
91  {}
92 
94  interface(nullptr), port(port)
95  {}
96 
99  };
100 
101  struct Sensitivity
102  {
104  port(port), finder(nullptr)
105  {}
106 
108  port(nullptr), finder(finder)
109  {}
110 
113  };
114 
118 
119  public:
120  static Port *
121  fromPort(const ::sc_core::sc_port_base *pb)
122  {
123  return pb->_gem5Port;
124  }
125 
127 
128  Port(::sc_core::sc_port_base *port_base, int max) :
129  portBase(port_base), finalized(false), _maxSize(max), _size(0),
130  regPortNeeded(true)
131  {
132  allPorts.push_front(this);
133  }
134 
135  ~Port() { allPorts.remove(this); }
136 
137  void
139  {
140  if (bindings.empty())
141  addInterface(interface);
142  else
143  bindings.push_back(new Binding(interface));
144  }
145 
146  void
148  {
149  bindings.push_back(new Binding(port));
150  }
151 
152  void sensitive(StaticSensitivityPort *port);
153  void sensitive(StaticSensitivityFinder *finder);
154  void addReset(Reset *reset);
155 
156  void finalize();
157  void regPort();
158 
159  int size() { return _size; }
160  int maxSize() { return _maxSize ? _maxSize : _size; }
161 };
162 
163 } // namespace sc_gem5
164 
165 #endif // __SYSTEMC_CORE_PORT_HH__
sc_core::sc_port_base
Definition: sc_port.hh:74
sc_core::sc_port_base::_gem5Interface
virtual sc_interface * _gem5Interface(int n) const =0
sc_gem5::Port::Sensitivity::Sensitivity
Sensitivity(StaticSensitivityFinder *finder)
Definition: port.hh:107
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
sc_gem5::StaticSensitivityFinder
Definition: sensitivity.hh:228
sc_gem5::Port::Binding::interface
::sc_core::sc_interface * interface
Definition: port.hh:97
sc_gem5::Port::sc_port_base
::sc_core::sc_port_base * sc_port_base()
Definition: port.hh:126
sc_gem5::Port::regPortNeeded
bool regPortNeeded
Definition: port.hh:59
sc_core::sc_interface
Definition: sc_interface.hh:37
sc_gem5::Port::sensitivities
std::vector< Sensitivity * > sensitivities
Definition: port.hh:116
sc_port.hh
sc_gem5::Port::Sensitivity::Sensitivity
Sensitivity(StaticSensitivityPort *port)
Definition: port.hh:103
sc_gem5::Port::~Port
~Port()
Definition: port.hh:135
sc_gem5::Port::size
int size()
Definition: port.hh:159
std::vector
STL vector class.
Definition: stl.hh:37
sc_gem5::Port::bind
void bind(::sc_core::sc_interface *interface)
Definition: port.hh:138
sc_gem5::Reset
Definition: process.hh:206
sc_core::sc_port_base::_gem5AddInterface
virtual void _gem5AddInterface(sc_interface *i)=0
Stats::reset
void reset()
Definition: statistics.cc:569
sc_gem5::Port::finalized
bool finalized
Definition: port.hh:55
sc_gem5::Port::fromPort
static Port * fromPort(const ::sc_core::sc_port_base *pb)
Definition: port.hh:121
sc_gem5::Port::Binding::port
::sc_core::sc_port_base * port
Definition: port.hh:98
sc_gem5::Port::Binding::Binding
Binding(::sc_core::sc_port_base *port)
Definition: port.hh:93
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
sc_gem5::Port::maxSize
int maxSize()
Definition: port.hh:160
sc_gem5::StaticSensitivityPort
Definition: sensitivity.hh:205
sc_gem5::Port::_size
int _size
Definition: port.hh:57
sc_gem5::Port::_maxSize
int _maxSize
Definition: port.hh:56
cprintf.hh
sc_interface.hh
sc_gem5::Port::bindings
std::vector< Binding * > bindings
Definition: port.hh:115
sc_gem5::Port::finalizeReset
void finalizeReset(Reset *reset)
Definition: port.cc:54
sc_core::sc_port_base::_gem5Port
::sc_gem5::Port * _gem5Port
Definition: sc_port.hh:112
sc_gem5::Port::addInterface
void addInterface(::sc_core::sc_interface *iface)
Definition: port.hh:66
sc_gem5::Port::regPort
void regPort()
Definition: port.cc:158
sc_gem5::Port::bind
void bind(::sc_core::sc_port_base *port)
Definition: port.hh:147
sc_gem5::Port::finalize
void finalize()
Definition: port.cc:94
sc_gem5::Port::portBase
::sc_core::sc_port_base * portBase
Definition: port.hh:53
sc_gem5::Port::resets
std::vector< Reset * > resets
Definition: port.hh:117
sc_gem5::Port::Sensitivity::finder
StaticSensitivityFinder * finder
Definition: port.hh:112
sc_gem5::Port::addReset
void addReset(Reset *reset)
Definition: port.cc:85
sc_gem5::allPorts
std::list< Port * > allPorts
Definition: port.cc:167
sc_gem5::Port::Binding::Binding
Binding(::sc_core::sc_interface *interface)
Definition: port.hh:89
sc_gem5::Port::Sensitivity::port
StaticSensitivityPort * port
Definition: port.hh:111
sc_gem5::Port::finalizeFinder
void finalizeFinder(StaticSensitivityFinder *finder)
Definition: port.cc:47
sc_gem5::Port::Sensitivity
Definition: port.hh:101
sc_gem5::Port
Definition: port.hh:50
sc_gem5::Port::Port
Port(::sc_core::sc_port_base *port_base, int max)
Definition: port.hh:128
sc_gem5::Port::Binding
Definition: port.hh:87
sc_gem5
Definition: sc_clock.cc:42
std::list
STL list class.
Definition: stl.hh:51
sc_gem5::Port::finalizePort
void finalizePort(StaticSensitivityPort *port)
Definition: port.cc:40
sc_gem5::Port::sensitive
void sensitive(StaticSensitivityPort *port)
Definition: port.cc:67
sc_gem5::Port::addInterfaces
void addInterfaces(::sc_core::sc_port_base *pb)
Definition: port.hh:73
sc_core::sc_port_base::size
int size() const
Definition: sc_port.cc:107
Ps2::Reset
@ Reset
Definition: types.hh:63
sc_gem5::Port::getInterface
::sc_core::sc_interface * getInterface(int i)
Definition: port.hh:82

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