configs: Enable Semihosting for baremetal.py
[gem5.git] / configs / example / ruby_mem_test.py
index 5b693f3f68ca6e717ab9664e83d896c390321021..070cb37e82bfe540ea0feab8fd867d6d665474c5 100644 (file)
 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# Authors: Ron Dreslinski
-#          Brad Beckmann
+
+from __future__ import print_function
+from __future__ import absolute_import
 
 import m5
 from m5.objects import *
 from m5.defines import buildEnv
 from m5.util import addToPath
 import os, optparse, sys
-addToPath('../common')
-addToPath('../ruby')
 
-import Ruby
+addToPath('../')
+
+from common import Options
+from ruby import Ruby
 
 # Get paths we might need.  It's expected this file is in m5/configs/example.
 config_path = os.path.dirname(os.path.abspath(__file__))
 config_root = os.path.dirname(config_path)
-m5_root = os.path.dirname(config_root)
 
 parser = optparse.OptionParser()
+Options.addNoISAOptions(parser)
 
-parser.add_option("-l", "--maxloads", metavar="N", default=0,
+parser.add_option("--maxloads", metavar="N", default=0,
                   help="Stop after N loads")
 parser.add_option("--progress", type="int", default=1000,
                   metavar="NLOADS",
@@ -62,7 +63,9 @@ parser.add_option("--suppress-func-warnings", action="store_true",
 #
 Ruby.define_options(parser)
 
-execfile(os.path.join(config_root, "common", "Options.py"))
+exec(compile( \
+    open(os.path.join(config_root, "common", "Options.py")).read(), \
+    os.path.join(config_root, "common", "Options.py"), 'exec'))
 
 (options, args) = parser.parse_args()
 
@@ -80,80 +83,74 @@ options.l2_assoc=2
 options.l3_assoc=2
 
 if args:
-     print "Error: script doesn't take any positional arguments"
+     print("Error: script doesn't take any positional arguments")
      sys.exit(1)
 
 block_size = 64
 
 if options.num_cpus > block_size:
-     print "Error: Number of testers %d limited to %d because of false sharing" \
-           % (options.num_cpus, block_size)
+     print("Error: Number of testers %d limited to %d because of false sharing"
+           % (options.num_cpus, block_size))
      sys.exit(1)
 
 #
 # Currently ruby does not support atomic or uncacheable accesses
 #
-cpus = [ MemTest(atomic = False,
-                 max_loads = options.maxloads,
-                 issue_dmas = False,
+cpus = [ MemTest(max_loads = options.maxloads,
                  percent_functional = options.functional,
                  percent_uncacheable = 0,
                  progress_interval = options.progress,
                  suppress_func_warnings = options.suppress_func_warnings) \
-         for i in xrange(options.num_cpus) ]
+         for i in range(options.num_cpus) ]
 
 system = System(cpu = cpus,
-                funcmem = PhysicalMemory(),
-                physmem = PhysicalMemory())
+                clk_domain = SrcClockDomain(clock = options.sys_clock),
+                mem_ranges = [AddrRange(options.mem_size)])
 
 if options.num_dmas > 0:
-    dmas = [ MemTest(atomic = False,
-                     max_loads = options.maxloads,
-                     issue_dmas = True,
+    dmas = [ MemTest(max_loads = options.maxloads,
                      percent_functional = 0,
                      percent_uncacheable = 0,
                      progress_interval = options.progress,
-                     warn_on_failure = options.warn_on_failure) \
-             for i in xrange(options.num_dmas) ]
+                     suppress_func_warnings =
+                                        not options.suppress_func_warnings) \
+             for i in range(options.num_dmas) ]
     system.dma_devices = dmas
 else:
     dmas = []
 
-Ruby.create_system(options, system, dma_devices = dmas)
+dma_ports = []
+for (i, dma) in enumerate(dmas):
+    dma_ports.append(dma.test)
+Ruby.create_system(options, False, system, dma_ports = dma_ports)
+
+# Create a top-level voltage domain and clock domain
+system.voltage_domain = VoltageDomain(voltage = options.sys_voltage)
+system.clk_domain = SrcClockDomain(clock = options.sys_clock,
+                                   voltage_domain = system.voltage_domain)
+# Create a seperate clock domain for Ruby
+system.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
+                                        voltage_domain = system.voltage_domain)
 
 #
 # The tester is most effective when randomization is turned on and
 # artifical delay is randomly inserted on messages
 #
 system.ruby.randomization = True
-assert(len(cpus) == len(system.ruby._cpu_ruby_ports))
+
+assert(len(cpus) == len(system.ruby._cpu_ports))
 
 for (i, cpu) in enumerate(cpus):
     #
     # Tie the cpu memtester ports to the correct system ports
     #
-    cpu.test = system.ruby._cpu_ruby_ports[i].port
-    cpu.functional = system.funcmem.port
+    cpu.port = system.ruby._cpu_ports[i].slave
 
     #
     # Since the memtester is incredibly bursty, increase the deadlock
     # threshold to 5 million cycles
     #
-    system.ruby._cpu_ruby_ports[i].deadlock_threshold = 5000000
-
-    #
-    # Ruby doesn't need the backing image of memory when running with
-    # the tester.
-    #
-    system.ruby._cpu_ruby_ports[i].access_phys_mem = False
-
-for (i, dma) in enumerate(dmas):
-    #
-    # Tie the dma memtester ports to the correct functional port
-    # Note that the test port has already been connected to the dma_sequencer
-    #
-    dma.functional = system.funcmem.port
+    system.ruby._cpu_ports[i].deadlock_threshold = 5000000
 
 # -----------------------
 # run simulation
@@ -169,6 +166,6 @@ m5.ticks.setGlobalFrequency('1ns')
 m5.instantiate()
 
 # simulate until program terminates
-exit_event = m5.simulate(options.maxtick)
+exit_event = m5.simulate(options.abs_max_tick)
 
-print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
+print('Exiting @ tick', m5.curTick(), 'because', exit_event.getCause())