gem5  v20.1.0.0
port.cc
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 #include "systemc/core/port.hh"
29 
30 #include "base/logging.hh"
31 #include "systemc/core/process.hh"
35 
36 namespace sc_gem5
37 {
38 
39 void
41 {
42  for (int i = 0; i < size(); i++)
44 }
45 
46 void
48 {
49  for (int i = 0; i < size(); i++)
50  finder->addEvent(&finder->find(getInterface(i)));
51 }
52 
53 void
55 {
56  assert(size() <= 1);
57  if (size()) {
58  auto iface =
59  dynamic_cast<sc_core::sc_signal_in_if<bool> *>(getInterface(0));
60  assert(iface);
61  if (!reset->install(iface))
62  delete reset;
63  }
64 }
65 
66 void
68 {
69  if (finalized)
70  finalizePort(port);
71  else
72  sensitivities.push_back(new Sensitivity(port));
73 }
74 
75 void
77 {
78  if (finalized)
79  finalizeFinder(finder);
80  else
81  sensitivities.push_back(new Sensitivity(finder));
82 }
83 
84 void
86 {
87  if (finalized)
89  else
90  resets.push_back(reset);
91 }
92 
93 void
95 {
96  if (finalized)
97  return;
98  finalized = true;
99 
100  for (auto &b: bindings) {
101  if (b->interface) {
102  addInterface(b->interface);
103  } else {
104  b->port->_gem5Port->finalize();
105  addInterfaces(b->port);
106  }
107  delete b;
108  }
109 
110  bindings.clear();
111 
112  for (auto &s: sensitivities) {
113  if (s->port)
114  finalizePort(s->port);
115  else
116  finalizeFinder(s->finder);
117  delete s;
118  }
119 
120  sensitivities.clear();
121 
122  for (auto &r: resets)
123  finalizeReset(r);
124 
125  resets.clear();
126 
127  if (size() > maxSize()) {
128  std::ostringstream ss;
129  ss << size() << " binds exceeds maximum of " << maxSize() <<
130  " allowed";
132  ss.str().c_str());
133  }
134 
135  switch (portBase->_portPolicy()) {
137  if (size() == 0)
139  "port not bound");
140  break;
142  if (size() < maxSize() || size() < 1) {
143  std::stringstream ss;
144  ss << size() << " actual binds is less than required " <<
145  maxSize();
147  ss.str().c_str());
148  }
149  break;
151  break;
152  default:
153  panic("Unrecognized port policy %d.", portBase->_portPolicy());
154  }
155 }
156 
157 void
159 {
160  if (!regPortNeeded)
161  return;
162 
163  for (int i = 0; i < size(); i++)
165 }
166 
168 
169 } // namespace sc_gem5
port.hh
sc_core::SC_ALL_BOUND
@ SC_ALL_BOUND
Definition: sc_port.hh:71
sc_core::SC_ONE_OR_MORE_BOUND
@ SC_ONE_OR_MORE_BOUND
Definition: sc_port.hh:69
sc_core::sc_signal_in_if< bool >
Definition: sc_signal_in_if.hh:74
sc_core::sc_interface::register_port
virtual void register_port(sc_port_base &, const char *)
Definition: sc_interface.cc:36
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
sc_gem5::StaticSensitivityFinder
Definition: sensitivity.hh:228
sc_gem5::Port::regPortNeeded
bool regPortNeeded
Definition: port.hh:59
sc_core::sc_port_base::report_error
void report_error(const char *id, const char *add_msg) const
Definition: sc_port.cc:97
sc_gem5::Port::sensitivities
std::vector< Sensitivity * > sensitivities
Definition: port.hh:116
sc_gem5::Port::size
int size()
Definition: port.hh:159
sensitivity.hh
messages.hh
sc_gem5::Reset
Definition: process.hh:206
Stats::reset
void reset()
Definition: statistics.cc:569
sc_gem5::Port::finalized
bool finalized
Definition: port.hh:55
sc_core::sc_port_base::_ifTypeName
virtual const char * _ifTypeName() const =0
sc_gem5::SensitivityEvents::addEvent
void addEvent(const ::sc_core::sc_event *event)
Definition: sensitivity.hh:163
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
sc_core::SC_ZERO_OR_MORE_BOUND
@ SC_ZERO_OR_MORE_BOUND
Definition: sc_port.hh:70
sc_gem5::StaticSensitivityFinder::find
const ::sc_core::sc_event & find(::sc_core::sc_interface *i)
Definition: sensitivity.cc:177
MipsISA::r
r
Definition: pra_constants.hh:95
sc_signal_in_if.hh
sc_gem5::Port::maxSize
int maxSize()
Definition: port.hh:160
sc_gem5::StaticSensitivityPort
Definition: sensitivity.hh:205
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_interface::default_event
virtual const sc_event & default_event() const
Definition: sc_interface.cc:39
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
process.hh
sc_gem5::Port::finalize
void finalize()
Definition: port.cc:94
sc_gem5::Port::portBase
::sc_core::sc_port_base * portBase
Definition: port.hh:53
ArmISA::b
Bitfield< 7 > b
Definition: miscregs_types.hh:376
sc_gem5::Port::resets
std::vector< Reset * > resets
Definition: port.hh:117
sc_core::sc_port_base::_portPolicy
virtual sc_port_policy _portPolicy() const =0
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::finalizeFinder
void finalizeFinder(StaticSensitivityFinder *finder)
Definition: port.cc:47
logging.hh
sc_gem5::Port::Sensitivity
Definition: port.hh:101
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
ArmISA::s
Bitfield< 4 > s
Definition: miscregs_types.hh:556
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_gem5::Port::getInterface
::sc_core::sc_interface * getInterface(int i)
Definition: port.hh:82
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
sc_core::SC_ID_COMPLETE_BINDING_
const char SC_ID_COMPLETE_BINDING_[]
Definition: messages.cc:46

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