SimObject.py (11991:d3f19484145f) SimObject.py (12023:272819f230c0)
1# Copyright (c) 2017 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

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

472 # We don't support multiple inheritance of sim objects. If you want
473 # to, you must fix multidict to deal with it properly. Non sim-objects
474 # are ok, though
475 bTotal = 0
476 for c in bases:
477 if isinstance(c, MetaSimObject):
478 bTotal += 1
479 if bTotal > 1:
1# Copyright (c) 2017 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

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

472 # We don't support multiple inheritance of sim objects. If you want
473 # to, you must fix multidict to deal with it properly. Non sim-objects
474 # are ok, though
475 bTotal = 0
476 for c in bases:
477 if isinstance(c, MetaSimObject):
478 bTotal += 1
479 if bTotal > 1:
480 raise TypeError, "SimObjects do not support multiple inheritance"
480 raise TypeError, \
481 "SimObjects do not support multiple inheritance"
481
482 base = bases[0]
483
484 # Set up general inheritance via multidicts. A subclass will
485 # inherit all its settings from the base class. The only time
486 # the following is not true is when we define the SimObject
487 # class itself (in which case the multidicts have no parent).
488 if isinstance(base, MetaSimObject):

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

674 # will also be inherited from the base class's param struct
675 # here). Sort the params based on their key
676 params = map(lambda (k, v): v, sorted(cls._params.local.items()))
677 ports = cls._ports.local
678
679 code('''#include "pybind11/pybind11.h"
680#include "pybind11/stl.h"
681
482
483 base = bases[0]
484
485 # Set up general inheritance via multidicts. A subclass will
486 # inherit all its settings from the base class. The only time
487 # the following is not true is when we define the SimObject
488 # class itself (in which case the multidicts have no parent).
489 if isinstance(base, MetaSimObject):

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

675 # will also be inherited from the base class's param struct
676 # here). Sort the params based on their key
677 params = map(lambda (k, v): v, sorted(cls._params.local.items()))
678 ports = cls._ports.local
679
680 code('''#include "pybind11/pybind11.h"
681#include "pybind11/stl.h"
682
682#include "sim/sim_object.hh"
683#include "params/$cls.hh"
684#include "sim/init.hh"
683#include "params/$cls.hh"
684#include "sim/init.hh"
685#include "sim/sim_object.hh"
686
685#include "${{cls.cxx_header}}"
686
687''')
688
689 for param in params:
690 param.pybind_predecls(code)
691
692 code('''namespace py = pybind11;

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

977 type_str = 'Vector_%s' % values.ptype_str
978 ptype = values
979 else:
980 type_str = '%s' % values.ptype_str
981 ptype = values.ptype
982
983 if keys in self._hr_values\
984 and keys in self._values\
687#include "${{cls.cxx_header}}"
688
689''')
690
691 for param in params:
692 param.pybind_predecls(code)
693
694 code('''namespace py = pybind11;

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

979 type_str = 'Vector_%s' % values.ptype_str
980 ptype = values
981 else:
982 type_str = '%s' % values.ptype_str
983 ptype = values.ptype
984
985 if keys in self._hr_values\
986 and keys in self._values\
985 and not isinstance(self._values[keys], m5.proxy.BaseProxy):
987 and not isinstance(self._values[keys],
988 m5.proxy.BaseProxy):
986 cmd_str = cmd_line_str + keys
987 acc_str = access_str + keys
988 flags_dict[cmd_str] = ParamInfo(ptype,
989 self._params[keys].desc, type_str, ex_str,
990 values.pretty_print(self._hr_values[keys]),
991 acc_str)
992 elif not keys in self._hr_values\
993 and not keys in self._values:

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

1177 assert self._parent is old_parent
1178 self._parent = None
1179
1180 # Also implemented by SimObjectVector
1181 def set_parent(self, parent, name):
1182 self._parent = parent
1183 self._name = name
1184
989 cmd_str = cmd_line_str + keys
990 acc_str = access_str + keys
991 flags_dict[cmd_str] = ParamInfo(ptype,
992 self._params[keys].desc, type_str, ex_str,
993 values.pretty_print(self._hr_values[keys]),
994 acc_str)
995 elif not keys in self._hr_values\
996 and not keys in self._values:

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

1180 assert self._parent is old_parent
1181 self._parent = None
1182
1183 # Also implemented by SimObjectVector
1184 def set_parent(self, parent, name):
1185 self._parent = parent
1186 self._name = name
1187
1185 # Return parent object of this SimObject, not implemented by SimObjectVector
1186 # because the elements in a SimObjectVector may not share the same parent
1188 # Return parent object of this SimObject, not implemented by
1189 # SimObjectVector because the elements in a SimObjectVector may not share
1190 # the same parent
1187 def get_parent(self):
1188 return self._parent
1189
1190 # Also implemented by SimObjectVector
1191 def get_name(self):
1192 return self._name
1193
1194 # Also implemented by SimObjectVector

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

1270 (found_obj.path, child.path)
1271 found_obj = child
1272 # search param space
1273 for pname,pdesc in self._params.iteritems():
1274 if issubclass(pdesc.ptype, ptype):
1275 match_obj = self._values[pname]
1276 if found_obj != None and found_obj != match_obj:
1277 raise AttributeError, \
1191 def get_parent(self):
1192 return self._parent
1193
1194 # Also implemented by SimObjectVector
1195 def get_name(self):
1196 return self._name
1197
1198 # Also implemented by SimObjectVector

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

1274 (found_obj.path, child.path)
1275 found_obj = child
1276 # search param space
1277 for pname,pdesc in self._params.iteritems():
1278 if issubclass(pdesc.ptype, ptype):
1279 match_obj = self._values[pname]
1280 if found_obj != None and found_obj != match_obj:
1281 raise AttributeError, \
1278 'parent.any matched more than one: %s and %s' % (found_obj.path, match_obj.path)
1282 'parent.any matched more than one: %s and %s' % \
1283 (found_obj.path, match_obj.path)
1279 found_obj = match_obj
1280 return found_obj, found_obj != None
1281
1282 def find_all(self, ptype):
1283 all = {}
1284 # search children
1285 for child in self._children.itervalues():
1286 # a child could be a list, so ensure we visit each item

--- 256 unchanged lines hidden ---
1284 found_obj = match_obj
1285 return found_obj, found_obj != None
1286
1287 def find_all(self, ptype):
1288 all = {}
1289 # search children
1290 for child in self._children.itervalues():
1291 # a child could be a list, so ensure we visit each item

--- 256 unchanged lines hidden ---