summaryrefslogtreecommitdiff
path: root/configs
diff options
context:
space:
mode:
authorBrad Beckmann <Brad.Beckmann@amd.com>2010-01-29 20:29:33 -0800
committerBrad Beckmann <Brad.Beckmann@amd.com>2010-01-29 20:29:33 -0800
commitc441590b15ea724b07c5cf28afc75017d68a2eb3 (patch)
tree49449f548f1043e0d9d0a36ceaea0973e7ffa3a2 /configs
parent1feae85017d8db5d3bf39065fd95724f89b3fd18 (diff)
downloadgem5-c441590b15ea724b07c5cf28afc75017d68a2eb3.tar.xz
ruby: Removed if else statement in create_system
Based on Steve's suggestion, the ugly if-elif statement and multiple protocol module import calls are removed and replaced with exec statements using the protocol string.
Diffstat (limited to 'configs')
-rw-r--r--configs/ruby/Ruby.py50
1 files changed, 10 insertions, 40 deletions
diff --git a/configs/ruby/Ruby.py b/configs/ruby/Ruby.py
index 65adc152e..d6889ef1a 100644
--- a/configs/ruby/Ruby.py
+++ b/configs/ruby/Ruby.py
@@ -32,50 +32,20 @@ from m5.objects import *
from m5.defines import buildEnv
from m5.util import addToPath
-import MOESI_hammer
-import MESI_CMP_directory
-import MOESI_CMP_directory
-import MI_example
-import MOESI_CMP_token
+protocol = buildEnv['PROTOCOL']
-def create_system(options, physmem, piobus = None, dma_devices = []):
+exec "import %s" % protocol
- protocol = buildEnv['PROTOCOL']
+def create_system(options, physmem, piobus = None, dma_devices = []):
- if protocol == "MOESI_hammer":
- (cpu_sequencers, dir_cntrls, all_cntrls) = \
- MOESI_hammer.create_system(options, \
- physmem, \
- piobus, \
- dma_devices)
- elif protocol == "MESI_CMP_directory":
- (cpu_sequencers, dir_cntrls, all_cntrls) = \
- MESI_CMP_directory.create_system(options, \
- physmem, \
- piobus, \
- dma_devices)
- elif protocol == "MOESI_CMP_directory":
+ try:
(cpu_sequencers, dir_cntrls, all_cntrls) = \
- MOESI_CMP_directory.create_system(options, \
- physmem, \
- piobus, \
- dma_devices)
- elif protocol == "MI_example":
- (cpu_sequencers, dir_cntrls, all_cntrls) = \
- MI_example.create_system(options, \
- physmem, \
- piobus, \
- dma_devices)
- elif protocol == "MOESI_CMP_token":
- (cpu_sequencers, dir_cntrls, all_cntrls) = \
- MOESI_CMP_token.create_system(options, \
- physmem, \
- piobus, \
- dma_devices)
- else:
- print "Error: unsupported ruby protocol"
- sys.exit(1)
-
+ eval("%s.create_system(options, physmem, piobus, dma_devices)" \
+ % protocol)
+ except:
+ print "Error: could not create sytem for ruby protocol %s" % protocol
+ sys.exit(1)
+
#
# Important: the topology constructor must be called before the network
# constructor.