Ruby.py revision 7557
16892SBrad.Beckmann@amd.com# Copyright (c) 2006-2007 The Regents of The University of Michigan
26892SBrad.Beckmann@amd.com# Copyright (c) 2009 Advanced Micro Devices, Inc.
36892SBrad.Beckmann@amd.com# All rights reserved.
46892SBrad.Beckmann@amd.com#
56892SBrad.Beckmann@amd.com# Redistribution and use in source and binary forms, with or without
66892SBrad.Beckmann@amd.com# modification, are permitted provided that the following conditions are
76892SBrad.Beckmann@amd.com# met: redistributions of source code must retain the above copyright
86892SBrad.Beckmann@amd.com# notice, this list of conditions and the following disclaimer;
96892SBrad.Beckmann@amd.com# redistributions in binary form must reproduce the above copyright
106892SBrad.Beckmann@amd.com# notice, this list of conditions and the following disclaimer in the
116892SBrad.Beckmann@amd.com# documentation and/or other materials provided with the distribution;
126892SBrad.Beckmann@amd.com# neither the name of the copyright holders nor the names of its
136892SBrad.Beckmann@amd.com# contributors may be used to endorse or promote products derived from
146892SBrad.Beckmann@amd.com# this software without specific prior written permission.
156892SBrad.Beckmann@amd.com#
166892SBrad.Beckmann@amd.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176892SBrad.Beckmann@amd.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186892SBrad.Beckmann@amd.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196892SBrad.Beckmann@amd.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206892SBrad.Beckmann@amd.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216892SBrad.Beckmann@amd.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226892SBrad.Beckmann@amd.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236892SBrad.Beckmann@amd.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246892SBrad.Beckmann@amd.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256892SBrad.Beckmann@amd.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266892SBrad.Beckmann@amd.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276892SBrad.Beckmann@amd.com#
286892SBrad.Beckmann@amd.com# Authors: Brad Beckmann
296892SBrad.Beckmann@amd.com
306892SBrad.Beckmann@amd.comimport m5
316892SBrad.Beckmann@amd.comfrom m5.objects import *
326892SBrad.Beckmann@amd.comfrom m5.defines import buildEnv
336892SBrad.Beckmann@amd.com
347538SBrad.Beckmann@amd.comdef define_options(parser):
357538SBrad.Beckmann@amd.com    # ruby network options
367538SBrad.Beckmann@amd.com    parser.add_option("--topology", type="string", default="Crossbar",
377538SBrad.Beckmann@amd.com                 help="check src/mem/ruby/network/topologies for complete set")
387538SBrad.Beckmann@amd.com    parser.add_option("--mesh-rows", type="int", default=1,
397538SBrad.Beckmann@amd.com                      help="the number of rows in the mesh topology")
407538SBrad.Beckmann@amd.com    parser.add_option("--garnet-network", type="string", default=none,
417538SBrad.Beckmann@amd.com                      help="'fixed'|'flexible'")
427538SBrad.Beckmann@amd.com
437538SBrad.Beckmann@amd.com    # ruby mapping options
447538SBrad.Beckmann@amd.com    parser.add_option("--numa-high-bit", type="int", default=none,
457538SBrad.Beckmann@amd.com                      help="high order address bit to use for numa mapping")
467538SBrad.Beckmann@amd.com
477538SBrad.Beckmann@amd.com    # ruby sparse memory options
487538SBrad.Beckmann@amd.com    parser.add_option("--use-map", action="store_true", default=False)
497538SBrad.Beckmann@amd.com    parser.add_option("--map-levels", type="int", default=4)
507538SBrad.Beckmann@amd.com
517555SBrad.Beckmann@amd.com    # ruby debug cmd line options
527555SBrad.Beckmann@amd.com    parser.add_option("--ruby-debug", action="store_true", default=False)
537555SBrad.Beckmann@amd.com    parser.add_option("--ruby-debug-cycle", type="int", default=1)
547555SBrad.Beckmann@amd.com
557538SBrad.Beckmann@amd.com    protocol = buildEnv['PROTOCOL']
567538SBrad.Beckmann@amd.com    exec "import %s" % protocol
577538SBrad.Beckmann@amd.com    eval("%s.define_options(parser)" % protocol)
587538SBrad.Beckmann@amd.com
597541SBrad.Beckmann@amd.comdef create_system(options, system, piobus = None, dma_devices = []):
606892SBrad.Beckmann@amd.com
617032SBrad.Beckmann@amd.com    protocol = buildEnv['PROTOCOL']
627032SBrad.Beckmann@amd.com    exec "import %s" % protocol
636923SBrad.Beckmann@amd.com    try:
646893SBrad.Beckmann@amd.com        (cpu_sequencers, dir_cntrls, all_cntrls) = \
657557SBrad.Beckmann@amd.com             eval("%s.create_system(options, system, piobus, dma_devices)" \
667557SBrad.Beckmann@amd.com                  % protocol)
676923SBrad.Beckmann@amd.com    except:
686923SBrad.Beckmann@amd.com        print "Error: could not create sytem for ruby protocol %s" % protocol
697557SBrad.Beckmann@amd.com        raise
706923SBrad.Beckmann@amd.com
716892SBrad.Beckmann@amd.com    #
727032SBrad.Beckmann@amd.com    # Important: the topology must be created before the network and after the
737032SBrad.Beckmann@amd.com    # controllers.
746892SBrad.Beckmann@amd.com    #
757032SBrad.Beckmann@amd.com    exec "import %s" % options.topology
767032SBrad.Beckmann@amd.com    try:
777557SBrad.Beckmann@amd.com        net_topology = eval("%s.makeTopology(all_cntrls, options)" \
787557SBrad.Beckmann@amd.com                            % options.topology)
797032SBrad.Beckmann@amd.com    except:
807032SBrad.Beckmann@amd.com        print "Error: could not create topology %s" % options.topology
817557SBrad.Beckmann@amd.com        raise
827011SBrad.Beckmann@amd.com
836918SBrad.Beckmann@amd.com    if options.garnet_network == "fixed":
846918SBrad.Beckmann@amd.com        network = GarnetNetwork_d(topology = net_topology)
856918SBrad.Beckmann@amd.com    elif options.garnet_network == "flexible":
866918SBrad.Beckmann@amd.com        network = GarnetNetwork(topology = net_topology)
876918SBrad.Beckmann@amd.com    else:
886918SBrad.Beckmann@amd.com        network = SimpleNetwork(topology = net_topology)
896892SBrad.Beckmann@amd.com
906903SBrad.Beckmann@amd.com    #
917025SBrad.Beckmann@amd.com    # Determine the total memory size of the ruby system and verify it is equal
927025SBrad.Beckmann@amd.com    # to physmem.  However, if Ruby memory is using sparse memory in SE
937025SBrad.Beckmann@amd.com    # mode, then the system should not back-up the memory state with
947025SBrad.Beckmann@amd.com    # the Memory Vector and thus the memory size bytes should stay at 0.
956903SBrad.Beckmann@amd.com    #
966903SBrad.Beckmann@amd.com    total_mem_size = MemorySize('0B')
976903SBrad.Beckmann@amd.com    for dir_cntrl in dir_cntrls:
986903SBrad.Beckmann@amd.com        total_mem_size.value += dir_cntrl.directory.size.value
997541SBrad.Beckmann@amd.com    physmem_size = long(system.physmem.range.second) - \
1007541SBrad.Beckmann@amd.com                     long(system.physmem.range.first) + 1
1016905SBrad.Beckmann@amd.com    assert(total_mem_size.value == physmem_size)
1026892SBrad.Beckmann@amd.com
1036897SBrad.Beckmann@amd.com    ruby_profiler = RubyProfiler(num_of_sequencers = len(cpu_sequencers))
1046892SBrad.Beckmann@amd.com
1056893SBrad.Beckmann@amd.com    ruby = RubySystem(clock = options.clock,
1066892SBrad.Beckmann@amd.com                      network = network,
1076892SBrad.Beckmann@amd.com                      profiler = ruby_profiler,
1086892SBrad.Beckmann@amd.com                      tracer = RubyTracer(),
1096892SBrad.Beckmann@amd.com                      debug = RubyDebug(filter_string = 'none',
1106892SBrad.Beckmann@amd.com                                        verbosity_string = 'none',
1117555SBrad.Beckmann@amd.com                                        protocol_trace = options.ruby_debug,
1127555SBrad.Beckmann@amd.com                                        start_time = options.ruby_debug_cycle),
1136903SBrad.Beckmann@amd.com                      mem_size = total_mem_size)
1146892SBrad.Beckmann@amd.com
1156893SBrad.Beckmann@amd.com    ruby.cpu_ruby_ports = cpu_sequencers
1166892SBrad.Beckmann@amd.com
1176892SBrad.Beckmann@amd.com    return ruby
118