gem5 [DEVELOP-FOR-25.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#include <unordered_map>
43
44#include "base/str.hh"
45#include "base/trace.hh"
46#include "debug/CxxConfig.hh"
47#include "sim/serialize.hh"
48#include "sim/sim_object.hh"
49
50namespace gem5
51{
52
54 configFile(configFile_), flags(configFile_.getFlags()),
56{
57}
58
60CxxConfigManager::findObjectType(const std::string &object_name,
61 std::string &object_type)
62{
63 if (!configFile.objectExists(object_name))
64 throw Exception(object_name, "Can't find sim object");
65
66 if (!configFile.getParam(object_name, "type", object_type))
67 throw Exception(object_name, "Sim object has no 'type' field");
68
69 if (cxxConfigDirectory().find(object_type) ==
70 cxxConfigDirectory().end())
71 {
72 throw Exception(object_name, csprintf(
73 "No sim object type %s is available", object_type));
74 }
75
76 const CxxConfigDirectoryEntry *entry = cxxConfigDirectory()[object_type];
77
78 return *entry;
79}
80
81std::string
82CxxConfigManager::rename(const std::string &from_name)
83{
84 for (auto i = renamings.begin(); i != renamings.end(); ++ i) {
85 const Renaming &renaming = *i;
86
87 if (from_name.find(renaming.fromPrefix) == 0) {
88 return renaming.toPrefix +
89 from_name.substr(renaming.fromPrefix.length());
90 }
91 }
92
93 return from_name;
94}
95
96std::string
97CxxConfigManager::unRename(const std::string &to_name)
98{
99 for (auto i = renamings.begin(); i != renamings.end(); ++ i) {
100 const Renaming &renaming = *i;
101
102 if (to_name.find(renaming.toPrefix) == 0) {
103 return renaming.fromPrefix +
104 to_name.substr(renaming.toPrefix.length());
105 }
106 }
107
108 return to_name;
109}
110
111static std::string
113{
114 std::ostringstream params;
115
116 auto i = param_values.begin();
117 auto end_i = param_values.end();
118
119 params << '[';
120 while (i != end_i) {
121 params << (*i);
122 ++i;
123
124 if (i != end_i)
125 params << ", ";
126 }
127 params << ']';
128
129 return params.str();
130}
131
132// Formats the dictionary parameter to be printed as a string
133// in the python canonical format {key1: value, key2: value}
134static std::string
135formatParamList(const std::unordered_map<std::string, std::string> &param_values)
136{
137 std::ostringstream params;
138
139 auto i = param_values.begin();
140 auto end_i = param_values.end();
141
142 params << '{';
143 while (i != end_i) {
144 params << (i->first);
145 params << ": ";
146 params << (i->second);
147 ++i;
148
149 if (i != end_i)
150 params << ", ";
151 }
152 params << '}';
153
154 return params.str();
155}
156
157void
158CxxConfigManager::populateParams(const std::string &object_name,
159 const std::string &instance_name,
160 CxxConfigParams *object_params,
162{
163 if (param->isVector) {
164 std::vector<std::string> param_values;
165
166 if (!configFile.getParamVector(object_name, param->name,
167 param_values))
168 {
169 throw Exception(object_name, csprintf(
170 "Element not found for parameter: %s",
171 param->name));
172 }
173
174 if (!object_params->setParamVector(param->name,
175 param_values, flags))
176 {
177 throw Exception(instance_name, csprintf(
178 "Bad parameter value: .%s=X=\"%s\"",
179 param->name, formatParamList(param_values)));
180 }
181
182 DPRINTF(CxxConfig, "Setting parameter"
183 " %s.%s=%s\n", instance_name, param->name,
184 formatParamList(param_values));
185 } else if (param->isDict) {
186 std::unordered_map<std::string, std::string> param_values;
187
188 if (!configFile.getParamDict(object_name, param->name,
189 param_values))
190 {
191 throw Exception(object_name, csprintf(
192 "Element not found for parameter: %s",
193 param->name));
194 }
195
196 if (!object_params->setParamDict(param->name,
197 param_values, flags))
198 {
199 throw Exception(instance_name, csprintf(
200 "Bad parameter value: .%s=X=\"%s\"",
201 param->name, formatParamList(param_values)));
202 }
203
204 DPRINTF(CxxConfig, "Setting parameter"
205 " %s.%s=%s\n", instance_name, param->name,
206 formatParamList(param_values));
207 } else {
208 std::string param_value;
209
210 if (!configFile.getParam(object_name, param->name,
211 param_value))
212 {
213 throw Exception(object_name, csprintf(
214 "Element not found for parameter: %s",
215 param->name));
216 }
217
218 if (!object_params->setParam(param->name, param_value,
219 flags))
220 {
221 throw Exception(instance_name, csprintf(
222 "Bad parameter value: .%s=X=\"%s\"",
223 param->name, param_value));
224 }
225
226 DPRINTF(CxxConfig, "Setting parameter %s.%s=%s\n",
227 instance_name, param->name, param_value);
228 }
229}
230
231SimObject *
232CxxConfigManager::findObject(const std::string &object_name,
233 bool visit_children)
234{
235 std::string instance_name = rename(object_name);
236
237 if (object_name == "Null")
238 return NULL;
239
240 /* Already constructed */
241 if (objectsByName.find(instance_name) != objectsByName.end())
242 return objectsByName[instance_name];
243
244 if (inVisit.find(instance_name) != inVisit.end())
245 throw Exception(instance_name, "Cycle in configuration");
246
247 std::string object_type;
248 const CxxConfigDirectoryEntry &entry =
249 findObjectType(object_name, object_type);
250
251 SimObject *object = NULL;
252
253 CxxConfigParams *object_params = findObjectParams(object_name);
254
255 try {
256 DPRINTF(CxxConfig, "Configuring sim object references for: %s"
257 " (%s from object %s)\n", instance_name, object_type,
258 object_name);
259
260 /* Remember the path back to the top of the recursion to detect
261 * cycles */
262 inVisit.insert(instance_name);
263
264 /* Resolve pointed-to SimObjects by recursing into them */
265 for (auto i = entry.parameters.begin();
266 i != entry.parameters.end(); ++i)
267 {
268 const CxxConfigDirectoryEntry::ParamDesc *param = (*i).second;
269
270 if (param->isSimObject) {
271 if (param->isVector) {
272 std::vector<std::string> sub_object_names;
273
274 if (!configFile.getParamVector(object_name, param->name,
275 sub_object_names))
276 {
277 throw Exception(object_name, csprintf(
278 "Element not found: %s", param->name));
279 }
280
281 std::vector<SimObject *> sub_objects;
282
283 for (auto n = sub_object_names.begin();
284 n != sub_object_names.end(); ++n)
285 {
286 SimObject *sub_object = findObject(*n,
287 visit_children);
288
289 if (sub_object)
290 sub_objects.push_back(sub_object);
291 }
292
293 if (!object_params->setSimObjectVector(param->name,
294 sub_objects))
295 {
296 throw Exception(object_name, csprintf(
297 "Can't assign sim object element %s from \"%s\"",
298 param->name, formatParamList(sub_object_names)));
299 }
300
301 DPRINTF(CxxConfig, "Setting sim object(s): %s.%s=%s\n",
302 object_name, param->name,
303 formatParamList(sub_object_names));
304 } else {
305 std::string sub_object_name;
306
307 if (!configFile.getParam(object_name, param->name,
308 sub_object_name))
309 {
310 throw Exception(object_name, csprintf(
311 "Element not found: %s", param->name));
312 }
313
314 SimObject *sub_object = findObject(sub_object_name,
315 visit_children);
316
317 if (sub_object) {
318 if (!object_params->setSimObject(param->name,
319 sub_object))
320 {
321 throw Exception(object_name, csprintf(
322 "Can't assign sim object element %s from"
323 " \"%s\"", param->name, sub_object_name));
324 }
325 }
326
327 DPRINTF(CxxConfig, "Setting sim object(s):"
328 " %s.%s=%s\n", object_name, param->name,
329 sub_object_name);
330 }
331 }
332 }
333
334 DPRINTF(CxxConfig, "Creating SimObject: %s\n", instance_name);
335 object = object_params->simObjectCreate();
336
337 if (!object) {
338 throw Exception(object_name, csprintf("Couldn't create object of"
339 " type: %s", object_type));
340 }
341
342 objectsByName[instance_name] = object;
343 objectParamsByName[instance_name] = object_params;
344
345 if (visit_children) {
347 configFile.getObjectChildren(object_name, children, true);
348
349 /* Visit all your children */
350 for (auto i = children.begin(); i != children.end(); ++i)
351 findObject(*i, visit_children);
352 }
353 } catch (Exception &) {
354 delete object_params;
355 throw;
356 }
357
358 /* Mark that we've exited object
359 * construction and so 'find'ing this object again won't be a
360 * configuration loop */
361 inVisit.erase(object_name);
362 return object;
363}
364
366CxxConfigManager::findObjectParams(const std::string &object_name)
367{
368 std::string instance_name = rename(object_name);
369
370 /* Already constructed */
371 if (objectParamsByName.find(instance_name) != objectParamsByName.end())
372 return objectParamsByName[instance_name];
373
374 std::string object_type;
375 const CxxConfigDirectoryEntry &entry =
376 findObjectType(object_name, object_type);
377
378 DPRINTF(CxxConfig, "Configuring parameters of object: %s (%s)\n",
379 instance_name, object_type);
380
381 CxxConfigParams *object_params = entry.makeParamsObject();
382
383 try {
384 /* Fill in the implicit parameters that don't necessarily
385 * appear in config files */
386 object_params->setName(instance_name);
387
388 /* Fill in parameters */
389 for (auto i = entry.parameters.begin();
390 i != entry.parameters.end(); ++i)
391 {
392 const CxxConfigDirectoryEntry::ParamDesc *param = (*i).second;
393
394 /* Only handle non-SimObject parameters here (see below) */
395 if (!param->isSimObject) {
396 populateParams(object_name, instance_name,
397 object_params, param);
398 }
399 }
400
401 /* Find the number of ports that will need binding and set the
402 * appropriate port_..._connection_count parameters */
403 for (auto i = entry.ports.begin(); i != entry.ports.end(); ++i) {
404 const CxxConfigDirectoryEntry::PortDesc *port = (*i).second;
406
407 if (!configFile.getPortPeers(object_name, port->name, peers)) {
408 DPRINTF(CxxConfig, "Port not found: %s.%s,"
409 " assuming there are no connections\n",
410 instance_name, port->name);
411 }
412
413 unsigned int peer_count = peers.size();
414
415 /* It would be more efficient to split the peer list and
416 * save the values for peer binding later but that would
417 * require another annoying intermediate structure to
418 * hold for little performance increase */
419
420 if (!object_params->setPortConnectionCount(port->name,
421 peer_count))
422 {
423 throw Exception(instance_name, csprintf(
424 "Unconnected port: %s", port->name));
425 }
426
427 DPRINTF(CxxConfig, "Setting port connection count"
428 " for: %s.%s to %d\n",
429 instance_name, port->name, peer_count);
430 }
431
432 /* Set pointed-to SimObjects to NULL */
433 for (auto i = entry.parameters.begin();
434 i != entry.parameters.end(); ++i)
435 {
436 const CxxConfigDirectoryEntry::ParamDesc *param = (*i).second;
437
438 if (param->isSimObject) {
439 bool ret;
440
441 DPRINTF(CxxConfig, "Nulling sim object reference: %s.%s\n",
442 instance_name, param->name);
443
444 if (param->isVector) {
445 /* Clear the reference list. */
447 ret = object_params->setSimObjectVector(param->name,
448 empty);
449 } else {
450 ret = object_params->setSimObject(param->name, NULL);
451 }
452
453 if (!ret) {
454 throw Exception(instance_name, csprintf(
455 "Error nulling sim object reference(s): %s",
456 param->name));
457 }
458 }
459 }
460 } catch (Exception &) {
461 delete object_params;
462 throw;
463 }
464
465 objectParamsByName[instance_name] = object_params;
466
467 return object_params;
468}
469
470void
472{
474 configFile.getAllObjectNames(objects);
475
476 /* Set the traversal order for further iterators */
477 objectsInOrder.clear();
478 findTraversalOrder("root");
479}
480
481void
482CxxConfigManager::findTraversalOrder(const std::string &object_name)
483{
484 SimObject *object = findObject(object_name);
485
486 if (object) {
487 objectsInOrder.push_back(object);
488
490 configFile.getObjectChildren(object_name, children, true);
491
492 /* Visit all your children */
493 for (auto i = children.begin(); i != children.end(); ++i)
495 }
496}
497
498void
500{
501 for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++i)
503}
504
505void
507 SimObject *requestor_object, const std::string &request_port_name,
508 PortID request_port_index,
509 SimObject *responder_object, const std::string &response_port_name,
510 PortID response_port_index)
511{
512 /* FIXME, check response_port_index against connection_count
513 * defined for port, need getPortConnectionCount and a
514 * getCxxConfigDirectoryEntry for each object. */
515
516 /* It would be nice to be able to catch the errors from these calls. */
517 Port &request_port = requestor_object->getPort(
518 request_port_name, request_port_index);
519 Port &response_port = responder_object->getPort(
520 response_port_name, response_port_index);
521
522 if (request_port.isConnected()) {
523 throw Exception(requestor_object->name(), csprintf(
524 "Request port: %s[%d] is already connected\n", request_port_name,
525 request_port_index));
526 }
527
528 if (response_port.isConnected()) {
529 throw Exception(responder_object->name(), csprintf(
530 "Response port: %s[%d] is already connected\n", response_port_name,
531 response_port_index));
532 }
533
534 DPRINTF(CxxConfig, "Binding port %s.%s[%d]"
535 " to %s:%s[%d]\n",
536 requestor_object->name(), request_port_name, request_port_index,
537 responder_object->name(), response_port_name, response_port_index);
538
539 request_port.bind(response_port);
540}
541
542void
545 const std::vector<std::string> &peers)
546{
547 unsigned int request_port_index = 0;
548
549 for (auto peer_i = peers.begin(); peer_i != peers.end();
550 ++peer_i)
551 {
552 const std::string &peer = *peer_i;
553 std::string response_object_name;
554 std::string response_port_name;
555 unsigned int response_port_index;
556
557 parsePort(peer, response_object_name, response_port_name,
558 response_port_index);
559
560 std::string response_instance_name = rename(response_object_name);
561
562 if (objectsByName.find(response_instance_name)
563 == objectsByName.end()) {
564 throw Exception(object->name(), csprintf(
565 "Can't find response port object: %s",
566 response_instance_name));
567 }
568
569 SimObject *responder_object = objectsByName[response_instance_name];
570
571 bindPort(object, port.name, request_port_index,
572 responder_object, response_port_name, response_port_index);
573
574 request_port_index++;
575 }
576}
577
578void
580{
581 /* We may want to separate object->name() from the name in configuration
582 * later to allow (for example) repetition of fragments of configs */
583 const std::string &instance_name = object->name();
584
585 std::string object_name = unRename(instance_name);
586
587 std::string object_type;
588 const CxxConfigDirectoryEntry &entry =
589 findObjectType(object_name, object_type);
590
591 DPRINTF(CxxConfig, "Binding ports of object: %s (%s)\n",
592 instance_name, object_type);
593
594 for (auto i = entry.ports.begin(); i != entry.ports.end(); ++i) {
595 const CxxConfigDirectoryEntry::PortDesc *port = (*i).second;
596
597 DPRINTF(CxxConfig, "Binding port: %s.%s\n", instance_name,
598 port->name);
599
601 configFile.getPortPeers(object_name, port->name, peers);
602
603 /* Only handle master ports as binding only needs to happen once
604 * for each observed pair of ports */
605 if (port->isRequestor) {
606 if (!port->isVector && peers.size() > 1) {
607 throw Exception(instance_name, csprintf(
608 "Too many connections to non-vector port %s (%d)\n",
609 port->name, peers.size()));
610 }
611
612 bindRequestPort(object, *port, peers);
613 }
614 }
615}
616
617void
618CxxConfigManager::parsePort(const std::string &inp,
619 std::string &path, std::string &port, unsigned int &index)
620{
621 std::size_t dot_i = inp.rfind('.');
622 std::size_t open_square_i = inp.rfind('[');
623
624 if (dot_i == std::string::npos) {
625 DPRINTF(CxxConfig, "Bad port string: %s\n", inp);
626 path = "";
627 port = "";
628 index = 0;
629 } else {
630 path = std::string(inp, 0, dot_i);
631
632 if (open_square_i == std::string::npos) {
633 /* Singleton port */
634 port = std::string(inp, dot_i + 1, inp.length() - dot_i);
635 index = 0;
636 } else {
637 /* Vectored port elemnt */
638 port = std::string(inp, dot_i + 1, (open_square_i - 1) - dot_i);
639 index = std::atoi(inp.c_str() + open_square_i + 1);
640 }
641 }
642}
643
644void
646{
647 for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++i)
648 ((*i)->*mem_func)();
649}
650
651void
653{
654 if (build_all) {
656 bindAllPorts();
657 }
658
659 DPRINTF(CxxConfig, "Initialising all objects\n");
661
662 DPRINTF(CxxConfig, "Registering stats\n");
664
665 DPRINTF(CxxConfig, "Registering probe points\n");
667
668 DPRINTF(CxxConfig, "Connecting probe listeners\n");
670}
671
672void
674{
675 DPRINTF(CxxConfig, "Calling initState on all objects\n");
677}
678
679void
681{
682 DPRINTF(CxxConfig, "Starting up all objects\n");
684}
685
686unsigned int
688{
689 return DrainManager::instance().tryDrain() ? 0 : 1;
690}
691
692void
697
698void
700{
701 for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++ i) {
702 // (*i)->nameOut(os); FIXME, change access spec. for nameOut
703 os << '[' << (*i)->name() << "]\n";
704 (*i)->serialize(os);
705 }
706}
707
708void
710{
711 for (auto i = objectsInOrder.begin(); i != objectsInOrder.end(); ++ i)
712 (*i)->loadState(checkpoint);
713}
714
715void
717{
718 for (auto i = objectsInOrder.rbegin(); i != objectsInOrder.rend(); ++i) {
719 DPRINTF(CxxConfig, "Freeing sim object: %s\n", (*i)->name());
720 delete *i;
721 }
722
723 for (auto i = objectParamsByName.rbegin();
724 i != objectParamsByName.rend(); ++i)
725 {
726 CxxConfigParams *params = (*i).second;
727
728 DPRINTF(CxxConfig, "Freeing sim object params: %s\n",
729 params->getName());
730 delete params;
731 }
732
733 objectsInOrder.clear();
734 objectsByName.clear();
735}
736
737void
738CxxConfigManager::setParam(const std::string &object_name,
739 const std::string &param_name, const std::string &param_value)
740{
741 CxxConfigParams *params = findObjectParams(object_name);
742
743 if (!params->setParam(param_name, param_value, flags)) {
744 throw Exception(object_name, csprintf("Bad parameter value:"
745 " .%s=X=\"%s\"", param_name, param_value));
746 } else {
747 std::string instance_name = rename(object_name);
748
749 DPRINTF(CxxConfig, "Setting parameter %s.%s=%s\n",
750 instance_name, param_name, param_value);
751 }
752}
753
754void
755CxxConfigManager::setParamVector(const std::string &object_name,
756 const std::string &param_name,
757 const std::vector<std::string> &param_values)
758{
759 CxxConfigParams *params = findObjectParams(object_name);
760
761 if (!params->setParamVector(param_name, param_values, flags)) {
762 throw Exception(object_name, csprintf("Bad vector parameter value:"
763 " .%s=X=\"%s\"", param_name, formatParamList(param_values)));
764 } else {
765 std::string instance_name = rename(object_name);
766
767 DPRINTF(CxxConfig, "Setting parameter %s.%s=\"%s\"\n",
768 instance_name, param_name, formatParamList(param_values));
769 }
770}
771
773{
774 renamings.push_back(renaming);
775}
776
777} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:209
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:87
Similar to ParamDesc to describe ports.
Definition cxx_config.hh:98
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.
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...
void populateParams(const std::string &object_name, const std::string &instance_name, CxxConfigParams *object_params, const CxxConfigDirectoryEntry::ParamDesc *param)
Assign a parameter to the named object.
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...
SimObjectResolver simObjectResolver
Singleton instance of SimObjectResolver.
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 setParamDict(const std::string &name, const std::unordered_map< std::string, std::string > &values, const Flags flags)
As setParamVector but for parameters given as dictionaries pre-separated into elements.
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 setParam 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:60
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
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 Arm Limited 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 Mon May 26 2025 09:19:13 for gem5 by doxygen 1.13.2