Don't allow SimObject-valued class params to be set
after the class has been instantiated or subclassed. This is one of the main situations that leads to confusing results. configs/test/fs.py: Clean up to avoid modifying BaseCPU after it's been subclassed. --HG-- extra : convert_revision : 335cb87bc3b211ecc8969cfb99ffc28f62f1f877
This commit is contained in:
parent
39f85a1de4
commit
bb58e4b851
2 changed files with 17 additions and 8 deletions
|
@ -197,6 +197,8 @@ class LinuxAlphaSystem(LinuxAlphaSystem):
|
||||||
else:
|
else:
|
||||||
cpu = AtomicSimpleCPU()
|
cpu = AtomicSimpleCPU()
|
||||||
cpu.mem = Parent.magicbus2
|
cpu.mem = Parent.magicbus2
|
||||||
|
cpu.itb = AlphaITB()
|
||||||
|
cpu.dtb = AlphaDTB()
|
||||||
sim_console = SimConsole(listener=ConsoleListener(port=3456))
|
sim_console = SimConsole(listener=ConsoleListener(port=3456))
|
||||||
kernel = binary('vmlinux')
|
kernel = binary('vmlinux')
|
||||||
pal = binary('ts_osfpal')
|
pal = binary('ts_osfpal')
|
||||||
|
@ -205,18 +207,15 @@ class LinuxAlphaSystem(LinuxAlphaSystem):
|
||||||
# readfile = os.path.join(test_base, 'halt.sh')
|
# readfile = os.path.join(test_base, 'halt.sh')
|
||||||
|
|
||||||
|
|
||||||
BaseCPU.itb = AlphaITB()
|
|
||||||
BaseCPU.dtb = AlphaDTB()
|
|
||||||
BaseCPU.system = Parent.any
|
|
||||||
|
|
||||||
class TsunamiRoot(System):
|
class TsunamiRoot(System):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def DualRoot(ClientSystem, ServerSystem):
|
def DualRoot(clientSystem, serverSystem):
|
||||||
self = Root()
|
self = Root()
|
||||||
self.client = ClientSystem()
|
self.client = clientSystem
|
||||||
self.server = ServerSystem()
|
self.server = serverSystem
|
||||||
|
|
||||||
self.etherdump = EtherDump(file='ethertrace')
|
self.etherdump = EtherDump(file='ethertrace')
|
||||||
self.etherlink = EtherLink(int1 = Parent.client.tsunami.etherint[0],
|
self.etherlink = EtherLink(int1 = Parent.client.tsunami.etherint[0],
|
||||||
|
@ -225,8 +224,8 @@ def DualRoot(ClientSystem, ServerSystem):
|
||||||
self.clock = '5GHz'
|
self.clock = '5GHz'
|
||||||
return self
|
return self
|
||||||
|
|
||||||
root = DualRoot(ClientSystem = LinuxAlphaSystem(readfile=script('netperf-stream-nt-client.rcS')),
|
root = DualRoot(LinuxAlphaSystem(readfile=script('netperf-stream-nt-client.rcS')),
|
||||||
ServerSystem = LinuxAlphaSystem(readfile=script('netperf-server.rcS')))
|
LinuxAlphaSystem(readfile=script('netperf-server.rcS')))
|
||||||
|
|
||||||
m5.instantiate(root)
|
m5.instantiate(root)
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,7 @@ class MetaSimObject(type):
|
||||||
# initialize required attributes
|
# initialize required attributes
|
||||||
cls._params = multidict()
|
cls._params = multidict()
|
||||||
cls._values = multidict()
|
cls._values = multidict()
|
||||||
|
cls._instantiated = False # really instantiated or subclassed
|
||||||
cls._anon_subclass_counter = 0
|
cls._anon_subclass_counter = 0
|
||||||
|
|
||||||
# We don't support multiple inheritance. If you want to, you
|
# We don't support multiple inheritance. If you want to, you
|
||||||
|
@ -225,6 +226,7 @@ class MetaSimObject(type):
|
||||||
if isinstance(base, MetaSimObject):
|
if isinstance(base, MetaSimObject):
|
||||||
cls._params.parent = base._params
|
cls._params.parent = base._params
|
||||||
cls._values.parent = base._values
|
cls._values.parent = base._values
|
||||||
|
base._instantiated = True
|
||||||
|
|
||||||
# now process the _init_dict items
|
# now process the _init_dict items
|
||||||
for key,val in cls._init_dict.items():
|
for key,val in cls._init_dict.items():
|
||||||
|
@ -299,6 +301,12 @@ class MetaSimObject(type):
|
||||||
param = cls._params.get(attr, None)
|
param = cls._params.get(attr, None)
|
||||||
if param:
|
if param:
|
||||||
# It's ok: set attribute by delegating to 'object' class.
|
# It's ok: set attribute by delegating to 'object' class.
|
||||||
|
if (isSimObject(value) or isSimObjSequence(value)) \
|
||||||
|
and cls._instantiated:
|
||||||
|
raise AttributeError, \
|
||||||
|
"Cannot set SimObject parameter '%s' after\n" \
|
||||||
|
" class %s has been instantiated or subclassed" \
|
||||||
|
% (attr, cls.__name__)
|
||||||
try:
|
try:
|
||||||
cls._values[attr] = param.convert(value)
|
cls._values[attr] = param.convert(value)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
@ -386,6 +394,8 @@ class SimObject(object):
|
||||||
# instantiated objects.
|
# instantiated objects.
|
||||||
_memo = {}
|
_memo = {}
|
||||||
|
|
||||||
|
self.__class__._instantiated = True
|
||||||
|
|
||||||
self._children = {}
|
self._children = {}
|
||||||
# Inherit parameter values from class using multidict so
|
# Inherit parameter values from class using multidict so
|
||||||
# individual value settings can be overridden.
|
# individual value settings can be overridden.
|
||||||
|
|
Loading…
Reference in a new issue