Configs: SE script fix for Alpha and Ruby simulations
[gem5.git] / configs / example / memtest.py
index 5bb874e8543043e7ff0c772389750f687fea668f..b29a612e9c1f4be5befe1704602bf95d709b8b5f 100644 (file)
 #
 # Authors: Ron Dreslinski
 
+import optparse
+import sys
+
 import m5
 from m5.objects import *
-import os, optparse, sys
-m5.AddToPath('../common')
 
 parser = optparse.OptionParser()
 
@@ -109,12 +110,13 @@ if len(treespec) < 1:
 
 # define prototype L1 cache
 proto_l1 = BaseCache(size = '32kB', assoc = 4, block_size = block_size,
-                     latency = '1ns', tgts_per_mshr = 8)
+                     hit_latency = '1ns', response_latency = '1ns',
+                     tgts_per_mshr = 8)
 
 if options.blocking:
      proto_l1.mshrs = 1
 else:
-     proto_l1.mshrs = 8
+     proto_l1.mshrs = 4
 
 # build a list of prototypes, one for each level of treespec, starting
 # at the end (last entry is tester objects)
@@ -128,28 +130,35 @@ if len(treespec) > 1:
      prototypes.insert(0, proto_l1)
 
 # now add additional cache levels (if any) by scaling L1 params
-while len(prototypes) < len(treespec):
+for scale in treespec[:-2]:
      # clone previous level and update params
      prev = prototypes[0]
      next = prev()
-     next.size = prev.size * 4
+     next.size = prev.size * scale
      next.latency = prev.latency * 10
-     next.assoc = prev.assoc * 2
+     next.assoc = prev.assoc * scale
+     next.mshrs = prev.mshrs * scale
      prototypes.insert(0, next)
 
 # system simulated
-system = System(funcmem = PhysicalMemory(),
-                physmem = PhysicalMemory(latency = "100ns"))
+system = System(funcmem = SimpleMemory(in_addr_map = False),
+                funcbus = NoncoherentBus(),
+                physmem = SimpleMemory(latency = "100ns"))
 
 def make_level(spec, prototypes, attach_obj, attach_port):
      fanout = spec[0]
      parent = attach_obj # use attach obj as config parent too
      if len(spec) > 1 and (fanout > 1 or options.force_bus):
-          new_bus = Bus(clock="500MHz", width=16)
-          new_bus.port = getattr(attach_obj, attach_port)
+          port = getattr(attach_obj, attach_port)
+          new_bus = CoherentBus(clock="500MHz", width=16)
+          if (port.role == 'MASTER'):
+               new_bus.slave = port
+               attach_port = "master"
+          else:
+               new_bus.master = port
+               attach_port = "slave"
           parent.cpu_side_bus = new_bus
           attach_obj = new_bus
-          attach_port = "port"
      objs = [prototypes[0]() for i in xrange(fanout)]
      if len(spec) > 1:
           # we just built caches, more levels to go
@@ -162,25 +171,32 @@ def make_level(spec, prototypes, attach_obj, attach_port):
           parent.cpu = objs
           for t in objs:
                t.test = getattr(attach_obj, attach_port)
-               t.functional = system.funcmem.port
+               t.functional = system.funcbus.slave
 
 make_level(treespec, prototypes, system.physmem, "port")
 
+# connect reference memory to funcbus
+system.funcbus.master = system.funcmem.port
+
 # -----------------------
 # run simulation
 # -----------------------
 
-root = Root( system = system )
+root = Root( full_system = False, system = system )
 if options.atomic:
     root.system.mem_mode = 'atomic'
 else:
     root.system.mem_mode = 'timing'
 
+# The system port is never used in the tester so merely connect it
+# to avoid problems
+root.system.system_port = root.system.funcbus.slave
+
 # Not much point in this being higher than the L1 latency
 m5.ticks.setGlobalFrequency('1ns')
 
 # instantiate configuration
-m5.instantiate(root)
+m5.instantiate()
 
 # simulate until program terminates
 exit_event = m5.simulate(options.maxtick)