gem5 v24.0.0.0
Loading...
Searching...
No Matches
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"
35
36namespace sc_gem5
37{
38
39void
41{
42 for (int i = 0; i < size(); i++)
44}
45
46void
48{
49 for (int i = 0; i < size(); i++)
50 finder->addEvent(&finder->find(getInterface(i)));
51}
52
53void
55{
56 assert(size() <= 1);
57 if (size()) {
58 auto iface =
60 assert(iface);
61 if (!reset->install(iface))
62 delete reset;
63 }
64}
65
66void
68{
69 if (finalized)
70 finalizePort(port);
71 else
72 sensitivities.push_back(new Sensitivity(port));
73}
74
75void
77{
78 if (finalized)
79 finalizeFinder(finder);
80 else
81 sensitivities.push_back(new Sensitivity(finder));
82}
83
84void
86{
87 if (finalized)
88 finalizeReset(reset);
89 else
90 resets.push_back(reset);
91}
92
93void
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
157void
159{
160 if (!regPortNeeded)
161 return;
162
163 for (int i = 0; i < size(); i++)
165}
166
168
169} // namespace sc_gem5
virtual void register_port(sc_port_base &, const char *)
virtual const sc_event & default_event() const
virtual const char * _ifTypeName() const =0
virtual sc_port_policy _portPolicy() const =0
void report_error(const char *id, const char *add_msg) const
Definition sc_port.cc:97
void addInterface(::sc_core::sc_interface *iface)
Definition port.hh:66
void finalize()
Definition port.cc:94
::sc_core::sc_port_base * portBase
Definition port.hh:53
std::vector< Reset * > resets
Definition port.hh:117
void finalizePort(StaticSensitivityPort *port)
Definition port.cc:40
int maxSize()
Definition port.hh:160
void finalizeFinder(StaticSensitivityFinder *finder)
Definition port.cc:47
void addReset(Reset *reset)
Definition port.cc:85
std::vector< Binding * > bindings
Definition port.hh:115
void addInterfaces(::sc_core::sc_port_base *pb)
Definition port.hh:73
std::vector< Sensitivity * > sensitivities
Definition port.hh:116
bool finalized
Definition port.hh:55
void sensitive(StaticSensitivityPort *port)
Definition port.cc:67
void finalizeReset(Reset *reset)
Definition port.cc:54
int size()
Definition port.hh:159
::sc_core::sc_interface * getInterface(int i)
Definition port.hh:82
bool regPortNeeded
Definition port.hh:59
void regPort()
Definition port.cc:158
void addEvent(const ::sc_core::sc_event *event)
const ::sc_core::sc_event & find(::sc_core::sc_interface *i)
STL list class.
Definition stl.hh:51
SwitchingFiber b
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
const char SC_ID_COMPLETE_BINDING_[]
Definition messages.cc:46
@ SC_ALL_BOUND
Definition sc_port.hh:71
@ SC_ZERO_OR_MORE_BOUND
Definition sc_port.hh:70
@ SC_ONE_OR_MORE_BOUND
Definition sc_port.hh:69
std::list< Port * > allPorts
Definition port.cc:167
std::stringstream ss
Definition trace.test.cc:45

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0