diff options
author | Nathan Binkert <binkertn@umich.edu> | 2005-03-24 12:24:17 -0500 |
---|---|---|
committer | Nathan Binkert <binkertn@umich.edu> | 2005-03-24 12:24:17 -0500 |
commit | eeff53841a6cb6c3819b69543fae861fa84cc541 (patch) | |
tree | 5106a052f1cdcd5b382874240bc830ef3c56722a /python/m5 | |
parent | 257be7434193c8a06e024f5fa9eca151025bda1e (diff) | |
download | gem5-eeff53841a6cb6c3819b69543fae861fa84cc541.tar.xz |
Add Frequency and Latency as new parameter types and use them
where we can
python/m5/config.py:
Add two new parameter types: Frequency and Latency. These will soon
be an integral part of the tick is picosecond thing. If the value
can be converted directly to an integer without any special tricks,
we assume that the number is the exact value desired. Otherwise,
we convert the number assuming that it is in Hz or s.
python/m5/objects/Bus.mpy:
Use the new Latency and Frequency types where we can
--HG--
extra : convert_revision : b3cff6020db83fb819507c348451c98697d1cf27
Diffstat (limited to 'python/m5')
-rw-r--r-- | python/m5/config.py | 40 | ||||
-rw-r--r-- | python/m5/objects/Bus.mpy | 2 |
2 files changed, 39 insertions, 3 deletions
diff --git a/python/m5/config.py b/python/m5/config.py index e097173f3..1af2c5e3e 100644 --- a/python/m5/config.py +++ b/python/m5/config.py @@ -27,7 +27,7 @@ from __future__ import generators import os, re, sys, types, inspect -from m5 import panic +from m5 import panic, env from convert import * from multidict import multidict @@ -1340,6 +1340,42 @@ class Enum(ParamType): # "Constants"... handy aliases for various values. # +class Frequency(int,ParamType): + _cpp_param_decl = 'Tick' + + def __new__(cls, value): + if isinstance(value, basestring): + val = int(env['FREQUENCY'] / toFrequency(value)) + else: + val = toFrequency(value) + return super(cls, Frequency).__new__(cls, val) + + def _convert(cls, value): + return cls(value) + _convert = classmethod(_convert) + + def _string(cls, value): + return '%d' % value + _string = classmethod(_string) + +class Latency(int,ParamType): + _cpp_param_decl = 'Tick' + def __new__(cls, value): + if isinstance(value, basestring): + val = int(env['FREQUENCY'] * toLatency(value)) + else: + val = toLatency(value) + return super(cls, Latency).__new__(cls, val) + + def _convert(cls, value): + return cls(value) + _convert = classmethod(_convert) + + def _string(cls, value): + return '%d' % value + _string = classmethod(_string) + + # Some memory range specifications use this as a default upper bound. MaxAddr = Addr.max MaxTick = Tick.max @@ -1383,6 +1419,6 @@ __all__ = ['ConfigNode', 'SimObject', 'ParamContext', 'Param', 'VectorParam', 'Int', 'Unsigned', 'Int8', 'UInt8', 'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', 'Counter', 'Addr', 'Tick', 'Percent', - 'MemorySize', + 'MemorySize', 'Frequency', 'Latency', 'Range', 'AddrRange', 'MaxAddr', 'MaxTick', 'AllMemory', 'NULL', 'NextEthernetAddr', 'instantiate'] diff --git a/python/m5/objects/Bus.mpy b/python/m5/objects/Bus.mpy index 025d69785..330a2c82b 100644 --- a/python/m5/objects/Bus.mpy +++ b/python/m5/objects/Bus.mpy @@ -2,5 +2,5 @@ from BaseHier import BaseHier simobj Bus(BaseHier): type = 'Bus' - clock_ratio = Param.Int("ratio of CPU to bus frequency") + clock_ratio = Param.Frequency("ratio of CPU to bus frequency") width = Param.Int("bus width in bytes") |