gem5 v24.0.0.0
Loading...
Searching...
No Matches
cxx_manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met: redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer;
18 * redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution;
21 * neither the name of the copyright holders nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include "sim/cxx_manager.hh"
39
40#include <cstdlib>
41#include <sstream>
42
43#include "base/str.hh"
44#include "base/trace.hh"
45#include "debug/CxxConfig.hh"
46#include "sim/serialize.hh"
47#include "sim/sim_object.hh"
48
49namespace gem5
50{
51
53 configFile(configFile_), flags(configFile_.getFlags()),
54 simObjectResolver(*this)
55{
56}
57
59CxxConfigManager::findObjectType(const std::string &object_name,
60 std::string &object_type)
61{
62 if (!configFile.objectExists(object_name))
63 throw Exception(object_name, "Can't find sim object");
64
65 if (!configFile.getParam(object_name, "type", object_type))
66 throw Exception(object_name, "Sim object has no 'type' field");
67
68 if (cxxConfigDirectory().find(object_type) ==
69 cxxConfigDirectory().end())
70 {
71 throw Exception(object_name, csprintf(
72 "No sim object type %s is available", object_type));
73 }
74
75 const CxxConfigDirectoryEntry *entry = cxxConfigDirectory()[object_type];
76
77 return *entry;
78}
79
80std::string
81CxxConfigManager::rename(const std::string &from_name)
82{
83 for (auto i = renamings.begin(); i != renamings.end(); ++ i) {
84 const Renaming &renaming = *i;
85
86 if (from_name.find(renaming.fromPrefix) == 0) {
87 return renaming.toPrefix +
88 from_name.substr(renaming.fromPrefix.length());
89 }
90 }
91
92 return from_name;
93}
94
95std::string
96CxxConfigManager::unRename(const std::string &to_name)
97{
98 for (auto i = renamings.begin(); i != renamings.end(); ++ i) {
99 const Renaming &renaming = *i;
100
101 if (to_name.find(renaming.toPrefix) == 0) {
102 return renaming.fromPrefix +
103 to_name.substr(renaming.toPrefix.length());
104 }
105 }
106
107 return to_name;
108}
109
110static
111std::string formatParamList(const std::vector<std::string> &param_values)
112{
113 std::ostringstream params;
114
115 auto i = param_values.begin();
116 auto end_i = param_values.end();
117
118 params << '[';
119 while (i != end_i) {
120 params << (*i);
121 ++i;
122
123 if (i != end_i)
124 params << ", ";
125 }
126 params << ']';
127
128 return params.str();
129}
130
131SimObject *
132CxxConfigManager::findObject(const std::string &object_name,
133 bool visit_children)
134{
135 std::string instance_name = rename(object_name);
136
137 if (object_name == "Null")
138 return NULL;
139
140 /* Already constructed */
141 if (objectsByName.find(instance_name) != objectsByName.end())
142 return objectsByName[instance_name];
143
144 if (inVisit.find(instance_name) != inVisit.end())
145 throw Exception(instance_name, "Cycle in configuration");
146
147 std::string object_type;
148 const CxxConfigDirectoryEntry &entry =
149 findObjectType(object_name, object_type);
150
151 SimObject *object = NULL;
152
153 CxxConfigParams *object_params = findObjectParams(object_name);
154
155 try {
156 DPRINTF(CxxConfig, "Configuring sim object references for: %s"
157 " (%s from object %s)\n", instance_name, object_type,
158 object_name);
159
160 /* Remember the path back to the top of the recursion to detect
161 * cycles */
162 inVisit.insert(instance_name);
163
164 /* Resolve pointed-to SimObjects by recursing into them */
165 for (auto i = entry.parameters.begin();
166 i != entry.parameters.end(); ++i)
167 {
168 const CxxConfigDirectoryEntry::ParamDesc *param = (*i).second;
169
170 if (param->isSimObject) {
171 if (param->isVector) {
172 std::vector<std::string> sub_object_names;
173
174 if (!configFile.getParamVector(object_name, param->name,
175 sub_object_names))
176 {
177 throw Exception(object_name, csprintf(
178 "Element not found: %s", param->name));
179 }
180
181 std::vector<SimObject *> sub_objects;
182
183 for (auto n = sub_object_names.begin();
184 n != sub_object_names.end(); ++n)
185 {
186 SimObject *sub_object = findObject(*n,
187 visit_children);
188
189 if (sub_object)
190 sub_objects.push_back(sub_object);
191 }
192
193 if (!object_params->setSimObjectVector(param->name,
194 sub_objects))
195 {
196 throw Exception(object_name, csprintf(
197 "Can't assign sim object element %s from \"%s\"",
198 param->name, formatParamList(sub_object_names)));
199 }
200
201 DPRINTF(CxxConfig, "Setting sim object(s): %s.%s=%s\n",
202 object_name, param->name,
203 formatParamList(sub_object_names));
204 } else {
205 std::string sub_object_name;
206
207 if (!configFile.getParam(object_name, param->name,
208 sub_object_name))
209 {
210 throw Exception(object_name, csprintf(
211 "Element not found: %s", param->name));
212 }
213
214 SimObject *sub_object = findObject(sub_object_name,
215 visit_children);
216
217 if (sub_object) {
218 if (!object_params->setSimObject(param->name,
219 sub_object))
220 {
221 throw Exception(object_name, csprintf(
222 "Can't assign sim object element %s from"
223 " \"%s\"", param->name, sub_object_name));
224 }
225 }
226
227 DPRINTF(CxxConfig, "Setting sim object(s):"
228 " %s.%s=%s\n", object_name, param->name,
229 sub_object_name);
230 }
231 }
232 }
233
234 DPRINTF(CxxConfig, "Creating SimObject: %s\n", instance_name);
235 object = object_params->simObjectCreate();
236
237 if (!object) {
238 throw Exception(object_name, csprintf("Couldn't create object of"
239 " type: %s", object_type));
240 }
241
242 objectsByName[instance_name] = object;
243 objectParamsByName[instance_name] = object_params;
244
245 if (visit_children) {
247 configFile.getObjectChildren(object_name, children, true);
248
249 /* Visit all your children */
250 for (auto i = children.begin(); i != children.end(); ++i)
251 findObject(*i, visit_children);
252 }
253 } catch (Exception &) {
254 delete object_params;
255 throw;
256 }
257
258 /* Mark that we've exited object
259 * construction and so 'find'ing this object again won't be a
260 * configuration loop */
261 inVisit.erase(object_name);
262 return object;
263}
264
266CxxConfigManager::findObjectParams(const std::string &object_name)
267{
268 std::string instance_name = rename(object_name);
269
270 /* Already constructed */
271 if (objectParamsByName.find(instance_name) != objectParamsByName.end())
272 return objectParamsByName[instance_name];
273
274 std::string object_type;
275 const CxxConfigDirectoryEntry &entry =
276 findObjectType(object_name, object_type);
277
278 DPRINTF(CxxConfig, "Configuring parameters of object: %s (%s)\n",
279 instance_name, object_type);
280
281 CxxConfigParams *object_params = entry.makeParamsObject();
282
283 try {
284 /* Fill in the implicit parameters that don't necessarily
285 * appear in config files */
286 object_params->setName(instance_name);
287
288 /* Fill in parameters */
289 for (auto i = entry.parameters.begin();
290 i != entry.parameters.end(); ++i)
291 {
292 const CxxConfigDirectoryEntry::ParamDesc *param = (*i).second;
293
294 if (!param->isSimObject) {
295 /* Only handle non-SimObject parameters here (see below) */
296
297 if (param->isVector) {
298 std::vector<std::string> param_values;
299
300 if (!configFile.getParamVector(object_name, param->name,
301 param_values))
302 {
303 throw Exception(object_name, csprintf(
304 "Element not found for parameter: %s",
305 param->name));
306 }
307
308 if (!object_params->setParamVector(param->name,
309 param_values, flags))
310 {
311 throw Exception(instance_name, csprintf(
312 "Bad parameter value: .%s=X=\"%s\"",
313 param->name, formatParamList(param_values)));
314 }
315
316 DPRINTF(CxxConfig, "Setting parameter"
317 " %s.%s=%s\n", instance_name, param->name,
318 formatParamList(param_values));
319 } else {
320 std::string param_value;
321
322 if (!configFile.getParam(object_name, param->name,
323 param_value))
324 {
325 throw Exception(object_name, csprintf(
326 "Element not found for parameter: %s",
327 param->name));
328 }
329
330 if (!object_params->setParam(param->name, param_value,
331 flags))
332 {
333 throw Exception(instance_name, csprintf(
334 "Bad parameter value: .%s=X=\"%s\"",
335 param->name, param_value));
336 }
337
338 DPRINTF(CxxConfig, "Setting parameter %s.%s=%s\n",
339 instance_name, param->name, param_value);
340 }
341 }
342 }
343
344 /* Find the number of ports that will need binding and set the
345 * appropriate port_..._connection_count parameters */
346 for (auto i = entry.ports.begin(); i != entry.ports.end(); ++i) {
347 const CxxConfigDirectoryEntry::PortDesc *port = (*i).second;
349
350 if (!configFile.getPortPeers(object_name, port->name, peers)) {
351 DPRINTF(CxxConfig, "Port not found: %s.%s,"
352 " assuming there are no connections\n",
353 instance_name, port->name);
354 }
355
356 unsigned int peer_count = peers.size();
357
358 /* It would be more efficient to split the peer list and
359 * save the values for peer binding later but that would
360 * require another annoying intermediate structure to
361 * hold for little performance increase */
362
363 if (!object_params->setPortConnectionCount(port->name,
364 peer_count))
365 {
366 throw Exception(instance_name, csprintf(
367 "Unconnected port: %s", port->name));
368 }
369
370 DPRINTF(CxxConfig, "Setting port connection count"
371 " for: %s.%s to %d\n",
372 instance_name, port->name, peer_count);
373 }
374
375 /* Set pointed-to SimObjects to NULL */
376 for (auto i = entry.parameters.begin();
377 i != entry.parameters.end(); ++i)
378 {
379 const CxxConfigDirectoryEntry::ParamDesc *param = (*i).second;
380
381 if (param->isSimObject) {
382 bool ret;
383
384 DPRINTF(CxxConfig, "Nulling sim object reference: %s.%s\n",
385 instance_name, param->name);
386
387 if (param->isVector) {
388 /* Clear the reference list. */
390 ret = object_params->setSimObjectVector(param->name,
391 empty);
392 } else {
393 ret = object_params->setSimObject(param->name, NULL);
394 }
395
396 if (!ret) {
397 throw Exception(instance_name, csprintf(
398 "Error nulling sim object reference(s): %s",
399 param->name));
400 }
401 }
402 }
403 } catch (Exception &) {
404 delete object_params;
405 throw;
406 }
407
408 objectParamsByName[instance_name] = object_params;
409
410 return object_params;
411}
412
413void
415{
418
419 /* Set the traversal order for further iterators */
420 objectsInOrder.clear();
421 findTraversalOrder("root");
422}
423
424void
425CxxConfigManager::findTraversalOrder(const std::string &object_name)
426{
427 SimObject *object = findObject(object_name);
428
429 if (object) {
430 objectsInOrder.push_back(object);
431
433 configFile.getObjectChildren(object_name, children, true);
434
435 /* Visit all your children */
436 for (auto i = children.begin(); i != children.end(); ++i)
438 }
439}
440
441void
443{
444 for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++i)
446}
447
448void
450 SimObject *requestor_object, const std::string &request_port_name,
451 PortID request_port_index,
452 SimObject *responder_object, const std::string &response_port_name,
453 PortID response_port_index)
454{
455 /* FIXME, check response_port_index against connection_count
456 * defined for port, need getPortConnectionCount and a
457 * getCxxConfigDirectoryEntry for each object. */
458
459 /* It would be nice to be able to catch the errors from these calls. */
460 Port &request_port = requestor_object->getPort(
461 request_port_name, request_port_index);
462 Port &response_port = responder_object->getPort(
463 response_port_name, response_port_index);
464
465 if (request_port.isConnected()) {
466 throw Exception(requestor_object->name(), csprintf(
467 "Request port: %s[%d] is already connected\n", request_port_name,
468 request_port_index));
469 }
470
471 if (response_port.isConnected()) {
472 throw Exception(responder_object->name(), csprintf(
473 "Response port: %s[%d] is already connected\n", response_port_name,
474 response_port_index));
475 }
476
477 DPRINTF(CxxConfig, "Binding port %s.%s[%d]"
478 " to %s:%s[%d]\n",
479 requestor_object->name(), request_port_name, request_port_index,
480 responder_object->name(), response_port_name, response_port_index);
481
482 request_port.bind(response_port);
483}
484
485void
488 const std::vector<std::string> &peers)
489{
490 unsigned int request_port_index = 0;
491
492 for (auto peer_i = peers.begin(); peer_i != peers.end();
493 ++peer_i)
494 {
495 const std::string &peer = *peer_i;
496 std::string response_object_name;
497 std::string response_port_name;
498 unsigned int response_port_index;
499
500 parsePort(peer, response_object_name, response_port_name,
501 response_port_index);
502
503 std::string response_instance_name = rename(response_object_name);
504
505 if (objectsByName.find(response_instance_name)
506 == objectsByName.end()) {
507 throw Exception(object->name(), csprintf(
508 "Can't find response port object: %s",
509 response_instance_name));
510 }
511
512 SimObject *responder_object = objectsByName[response_instance_name];
513
514 bindPort(object, port.name, request_port_index,
515 responder_object, response_port_name, response_port_index);
516
517 request_port_index++;
518 }
519}
520
521void
523{
524 /* We may want to separate object->name() from the name in configuration
525 * later to allow (for example) repetition of fragments of configs */
526 const std::string &instance_name = object->name();
527
528 std::string object_name = unRename(instance_name);
529
530 std::string object_type;
531 const CxxConfigDirectoryEntry &entry =
532 findObjectType(object_name, object_type);
533
534 DPRINTF(CxxConfig, "Binding ports of object: %s (%s)\n",
535 instance_name, object_type);
536
537 for (auto i = entry.ports.begin(); i != entry.ports.end(); ++i) {
538 const CxxConfigDirectoryEntry::PortDesc *port = (*i).second;
539
540 DPRINTF(CxxConfig, "Binding port: %s.%s\n", instance_name,
541 port->name);
542
544 configFile.getPortPeers(object_name, port->name, peers);
545
546 /* Only handle master ports as binding only needs to happen once
547 * for each observed pair of ports */
548 if (port->isRequestor) {
549 if (!port->isVector && peers.size() > 1) {
550 throw Exception(instance_name, csprintf(
551 "Too many connections to non-vector port %s (%d)\n",
552 port->name, peers.size()));
553 }
554
555 bindRequestPort(object, *port, peers);
556 }
557 }
558}
559
560void
561CxxConfigManager::parsePort(const std::string &inp,
562 std::string &path, std::string &port, unsigned int &index)
563{
564 std::size_t dot_i = inp.rfind('.');
565 std::size_t open_square_i = inp.rfind('[');
566
567 if (dot_i == std::string::npos) {
568 DPRINTF(CxxConfig, "Bad port string: %s\n", inp);
569 path = "";
570 port = "";
571 index = 0;
572 } else {
573 path = std::string(inp, 0, dot_i);
574
575 if (open_square_i == std::string::npos) {
576 /* Singleton port */
577 port = std::string(inp, dot_i + 1, inp.length() - dot_i);
578 index = 0;
579 } else {
580 /* Vectored port elemnt */
581 port = std::string(inp, dot_i + 1, (open_square_i - 1) - dot_i);
582 index = std::atoi(inp.c_str() + open_square_i + 1);
583 }
584 }
585}
586
587void
589{
590 for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++i)
591 ((*i)->*mem_func)();
592}
593
594void
596{
597 if (build_all) {
599 bindAllPorts();
600 }
601
602 DPRINTF(CxxConfig, "Initialising all objects\n");
604
605 DPRINTF(CxxConfig, "Registering stats\n");
607
608 DPRINTF(CxxConfig, "Registering probe points\n");
610
611 DPRINTF(CxxConfig, "Connecting probe listeners\n");
613}
614
615void
617{
618 DPRINTF(CxxConfig, "Calling initState on all objects\n");
620}
621
622void
624{
625 DPRINTF(CxxConfig, "Starting up all objects\n");
627}
628
629unsigned int
631{
632 return DrainManager::instance().tryDrain() ? 0 : 1;
633}
634
635void
640
641void
643{
644 for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++ i) {
645 // (*i)->nameOut(os); FIXME, change access spec. for nameOut
646 os << '[' << (*i)->name() << "]\n";
647 (*i)->serialize(os);
648 }
649}
650
651void
653{
654 for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++ i)
655 (*i)->loadState(checkpoint);
656}
657
658void
660{
661 for (auto i = objectsInOrder.rbegin(); i != objectsInOrder.rend(); ++i) {
662 DPRINTF(CxxConfig, "Freeing sim object: %s\n", (*i)->name());
663 delete *i;
664 }
665
666 for (auto i = objectParamsByName.rbegin();
667 i != objectParamsByName.rend(); ++i)
668 {
669 CxxConfigParams *params = (*i).second;
670
671 DPRINTF(CxxConfig, "Freeing sim object params: %s\n",
672 params->getName());
673 delete params;
674 }
675
676 objectsInOrder.clear();
677 objectsByName.clear();
678}
679
680void
681CxxConfigManager::setParam(const std::string &object_name,
682 const std::string &param_name, const std::string &param_value)
683{
684 CxxConfigParams *params = findObjectParams(object_name);
685
686 if (!params->setParam(param_name, param_value, flags)) {
687 throw Exception(object_name, csprintf("Bad parameter value:"
688 " .%s=X=\"%s\"", param_name, param_value));
689 } else {
690 std::string instance_name = rename(object_name);
691
692 DPRINTF(CxxConfig, "Setting parameter %s.%s=%s\n",
693 instance_name, param_name, param_value);
694 }
695}
696
697void
698CxxConfigManager::setParamVector(const std::string &object_name,
699 const std::string &param_name,
700 const std::vector<std::string> &param_values)
701{
702 CxxConfigParams *params = findObjectParams(object_name);
703
704 if (!params->setParamVector(param_name, param_values, flags)) {
705 throw Exception(object_name, csprintf("Bad vector parameter value:"
706 " .%s=X=\"%s\"", param_name, formatParamList(param_values)));
707 } else {
708 std::string instance_name = rename(object_name);
709
710 DPRINTF(CxxConfig, "Setting parameter %s.%s=\"%s\"\n",
711 instance_name, param_name, formatParamList(param_values));
712 }
713}
714
716{
717 renamings.push_back(renaming);
718}
719
720} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:210
const bool isSimObject
Is this a SimObject, and so is to be set with setSimObject... or another from-string parameter set wi...
Definition cxx_config.hh:84
Similar to ParamDesc to describe ports.
Definition cxx_config.hh:94
const bool isRequestor
Is this a request or response port.
Config details entry for a SimObject.
Definition cxx_config.hh:70
std::map< std::string, ParamDesc * > parameters
All parameters (including SimObjects) in order.
virtual CxxConfigParams * makeParamsObject() const
Make a ...Param structure for the SimObject class of this entry.
std::map< std::string, PortDesc * > ports
Ports.
Config file wrapper providing a common interface to CxxConfigManager.
virtual void getAllObjectNames(std::vector< std::string > &list) const =0
Get all SimObjects in the config.
virtual bool getParamVector(const std::string &object_name, const std::string &param_name, std::vector< std::string > &values) const =0
Get a list/vector parameter.
virtual void getObjectChildren(const std::string &object_name, std::vector< std::string > &children, bool return_paths=false) const =0
Get the names or paths of all the children SimObjects of this SimObject.
virtual bool getPortPeers(const std::string &object_name, const std::string &port_name, std::vector< std::string > &peers) const =0
Get the peer (connected) ports of the named ports.
virtual bool getParam(const std::string &object_name, const std::string &param_name, std::string &value) const =0
Get a single parameter value as a string returned in value.
virtual bool objectExists(const std::string &object_name) const =0
Does an object with this path exist?
Exception for instantiate/post-instantiate errors.
std::set< std::string > inVisit
While configuring, inVisit contains names of SimObjects visited in this recursive configuration walk.
std::list< SimObject * > objectsInOrder
SimObjects in order.
void drainResume()
Resume from drain.
static void parsePort(const std::string &inp, std::string &path, std::string &port, unsigned int &index)
Parse a port string of the form 'path(.path)*.port[index]' into path, port and index.
void startup()
Call startup on all objects.
void deleteObjects()
Delete all objects and clear objectsByName and objectsByOrder.
CxxConfigManager(CxxConfigFileBase &configFile_)
void serialize(std::ostream &os)
Serialize (checkpoint) all objects to the given stream.
std::string rename(const std::string &from_name)
Apply the first matching renaming in renamings to the given name.
std::string unRename(const std::string &to_name)
Apply the first matching renaming in reverse (toPrefix -> fromPrefix for the given name.
CxxConfigParams::Flags flags
Flags to pass to affect param setting.
void setParamVector(const std::string &object_name, const std::string &param_name, const std::vector< std::string > &param_values)
CxxConfigFileBase & configFile
Configuration file being read.
void bindPort(SimObject *requestorObject, const std::string &requestPort, PortID requestPortIndex, SimObject *responderObject, const std::string &responsePort, PortID responsePortIndex)
Bind a single connection between two objects' ports.
void addRenaming(const Renaming &renaming)
Add a name prefix renaming to those currently applied.
unsigned int drain()
Drain all objects.
void initState()
Call initState on all objects.
std::list< Renaming > renamings
All the renamings applicable when instantiating objects.
void findTraversalOrder(const std::string &object_name)
Populate objectsInOrder with a preorder, depth first traversal from the given object name down throug...
std::map< std::string, SimObject * > objectsByName
SimObject indexed by name.
void setParam(const std::string &object_name, const std::string &param_name, const std::string &param_value)
Convenience functions for calling set... member functions on a CxxConfigParams for an object.
void forEachObject(void(SimObject::*mem_func)())
Perform mem_func on each SimObject.
void bindRequestPort(SimObject *object, const CxxConfigDirectoryEntry::PortDesc &port, const std::vector< std::string > &peers)
Bind a single (possibly vectored) request port to peers from the unparsed list peers with elements in...
CxxConfigParams * findObjectParams(const std::string &object_name)
Find the parameters for the named object.
void bindObjectPorts(SimObject *object)
Bind the ports of a single SimObject.
std::map< std::string, CxxConfigParams * > objectParamsByName
...Params objects created by this manager
void loadState(CheckpointIn &checkpoint)
Load all objects' state from the given Checkpoint.
void findAllObjects()
Find all objects by iterating over the object names in the config file with findObject.
SimObject * findObject(const std::string &object_name, bool visit_children=false)
Walk the configuration starting with object object_name and fill in all the elements of this object o...
void bindAllPorts()
Bind the ports of all the objects in objectInOrder order.
void instantiate(bool build_all=true)
Build all objects (if build_all is true, otherwise objects must have been individually findObject-ed ...
const CxxConfigDirectoryEntry & findObjectType(const std::string &object_name, std::string &object_type)
Find the type field for a named object and return both the name of the type to object_type and the ob...
Base for peer classes of SimObjectParams derived classes with parameter modifying member functions.
virtual bool setParam(const std::string &name, const std::string &value, const Flags flags)
Set a parameter with a value parsed from the given string.
virtual bool setPortConnectionCount(const std::string &name, unsigned int count)
Set the number of connections expected for the named port.
virtual const std::string & getName()
Get full path name string.
virtual bool setSimObjectVector(const std::string &name, const std::vector< SimObject * > &simObjects)
As setSimObjectVector but set a whole vector of references.
virtual SimObject * simObjectCreate()
Create the associated SimObject.
virtual void setName(const std::string &name_)
Example flag.
virtual bool setSimObject(const std::string &name, SimObject *simObject)
Set a SimObject valued parameter with a reference to the given SimObject.
virtual bool setParamVector(const std::string &name, const std::vector< std::string > &values, const Flags flags)
As setParamVector but for parameters given as vectors pre-separated into elements.
static DrainManager & instance()
Get the singleton DrainManager instance.
Definition drain.hh:91
virtual std::string name() const
Definition named.hh:47
Ports are used to interface objects to each other.
Definition port.hh:62
bool isConnected() const
Is this port currently connected to a peer?
Definition port.hh:133
virtual void bind(Port &peer)
Attach to a peer port.
Definition port.hh:118
Abstract superclass for simulation objects.
STL vector class.
Definition stl.hh:37
C++-only configuration and instantiation support.
void resume()
Resume normal simulation in a Drained system.
Definition drain.cc:96
bool tryDrain()
Try to drain the system.
Definition drain.cc:64
virtual void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
Definition sim_object.cc:91
virtual void regProbeListeners()
Register probe listeners for this object.
virtual void startup()
startup() is the final initialization call before simulation.
Definition sim_object.cc:96
virtual void regProbePoints()
Register probe points for this object.
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition sim_object.cc:73
virtual void regStats()
Callback to set stat parameters.
Definition group.cc:68
uint8_t flags
Definition helpers.cc:87
Bitfield< 31 > n
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 30, 0 > index
Bitfield< 17 > os
Definition misc.hh:838
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::map< std::string, CxxConfigDirectoryEntry * > & cxxConfigDirectory()
Directory of all SimObject classes config details.
Definition cxx_config.cc:47
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
static std::string formatParamList(const std::vector< std::string > &param_values)
std::string csprintf(const char *format, const Args &...args)
Definition cprintf.hh:161
Name substitution when instantiating any object whose name starts with fromPrefix.

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