Deleted Added
sdiff udiff text old ( 13273:af60ddcf2a32 ) new ( 13290:1e720f971554 )
full compact
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

--- 87 unchanged lines hidden (view full) ---

96 virtual int vbind(sc_interface &) = 0;
97 virtual int vbind(sc_port_base &) = 0;
98
99 virtual void before_end_of_elaboration() = 0;
100 virtual void end_of_elaboration() = 0;
101 virtual void start_of_simulation() = 0;
102 virtual void end_of_simulation() = 0;
103
104 void report_error(const char *id, const char *add_msg) const;
105
106 private:
107 friend class ::sc_gem5::Port;
108 friend class ::sc_gem5::Kernel;
109
110 virtual sc_interface *_gem5Interface(int n) const = 0;
111 virtual void _gem5AddInterface(sc_interface *i) = 0;
112
113 ::sc_gem5::Port *_gem5Port;

--- 8 unchanged lines hidden (view full) ---

122 void operator () (sc_port_b<IF> &p) { bind(p); }
123
124 virtual void bind(IF &i) { sc_port_base::bind(i); }
125 virtual void bind(sc_port_b<IF> &p) { sc_port_base::bind(p); }
126
127 IF *
128 operator -> ()
129 {
130 if (_interfaces.empty()) {
131 report_error("(E112) get interface failed", "port is not bound");
132 sc_abort();
133 }
134 return _interfaces[0];
135 }
136 const IF *
137 operator -> () const
138 {
139 if (_interfaces.empty()) {
140 report_error("(E112) get interface failed", "port is not bound");
141 sc_abort();
142 }
143 return _interfaces[0];
144 }
145
146 IF *
147 operator [] (int n)
148 {
149 if (n < 0 || n >= size()) {
150 report_error("(E112) get interface failed", "index out of range");
151 return NULL;
152 }
153 return _interfaces[n];
154 }
155 const IF *
156 operator [] (int n) const
157 {
158 if (n < 0 || n >= size()) {
159 report_error("(E112) get interface failed", "index out of range");
160 return NULL;
161 }
162 return _interfaces[n];
163 }
164
165 sc_interface *
166 get_interface()
167 {
168 if (_interfaces.empty())
169 return NULL;
170 return _interfaces[0];
171 }
172 const sc_interface *
173 get_interface() const
174 {
175 if (_interfaces.empty())
176 return NULL;
177 return _interfaces[0];
178 }
179
180 protected:
181 void before_end_of_elaboration() {}
182 void end_of_elaboration() {}
183 void start_of_simulation() {}
184 void end_of_simulation() {}

--- 27 unchanged lines hidden (view full) ---

212 }
213
214 private:
215 std::vector<IF *> _interfaces;
216
217 sc_interface *
218 _gem5Interface(int n) const
219 {
220 if (n < 0 || n >= size()) {
221 report_error("(E112) get interface failed", "index out of range");
222 return NULL;
223 }
224 return _interfaces[n];
225 }
226 void
227 _gem5AddInterface(sc_interface *iface)
228 {
229 IF *interface = dynamic_cast<IF *>(iface);
230 sc_assert(interface);
231 for (int i = 0; i < _interfaces.size(); i++) {
232 if (interface == _interfaces[i]) {
233 report_error("(E107) bind interface to port failed",
234 "interface already bound to port");
235 }
236 }
237 _interfaces.push_back(interface);
238 }
239
240 const char *_ifTypeName() const { return typeid(IF).name(); }
241
242 // Disabled
243 sc_port_b() {}
244 sc_port_b(const sc_port_b<IF> &) {}

--- 62 unchanged lines hidden ---