Ruby.py revision 7535:7f8213cb2337
111828Sjason@lowepower.com# Copyright (c) 2006-2007 The Regents of The University of Michigan
211482Sandreas.sandberg@arm.com# Copyright (c) 2009 Advanced Micro Devices, Inc.
311482Sandreas.sandberg@arm.com# All rights reserved.
411482Sandreas.sandberg@arm.com#
511482Sandreas.sandberg@arm.com# Redistribution and use in source and binary forms, with or without
611482Sandreas.sandberg@arm.com# modification, are permitted provided that the following conditions are
711482Sandreas.sandberg@arm.com# met: redistributions of source code must retain the above copyright
811482Sandreas.sandberg@arm.com# notice, this list of conditions and the following disclaimer;
911482Sandreas.sandberg@arm.com# redistributions in binary form must reproduce the above copyright
1011482Sandreas.sandberg@arm.com# notice, this list of conditions and the following disclaimer in the
1111482Sandreas.sandberg@arm.com# documentation and/or other materials provided with the distribution;
1211482Sandreas.sandberg@arm.com# neither the name of the copyright holders nor the names of its
1311482Sandreas.sandberg@arm.com# contributors may be used to endorse or promote products derived from
1411482Sandreas.sandberg@arm.com# this software without specific prior written permission.
1511482Sandreas.sandberg@arm.com#
1611482Sandreas.sandberg@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1711482Sandreas.sandberg@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1811482Sandreas.sandberg@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1911482Sandreas.sandberg@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2011482Sandreas.sandberg@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2111482Sandreas.sandberg@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2211482Sandreas.sandberg@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2311482Sandreas.sandberg@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2411482Sandreas.sandberg@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2511482Sandreas.sandberg@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2611482Sandreas.sandberg@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2711482Sandreas.sandberg@arm.com#
2811482Sandreas.sandberg@arm.com# Authors: Brad Beckmann
2911482Sandreas.sandberg@arm.com
3011482Sandreas.sandberg@arm.comimport m5
3111482Sandreas.sandberg@arm.comfrom m5.objects import *
3211482Sandreas.sandberg@arm.comfrom m5.defines import buildEnv
3311482Sandreas.sandberg@arm.com
3411482Sandreas.sandberg@arm.comdef create_system(options, physmem, piobus = None, dma_devices = []):
3511482Sandreas.sandberg@arm.com
3611482Sandreas.sandberg@arm.com    protocol = buildEnv['PROTOCOL']
3711482Sandreas.sandberg@arm.com    exec "import %s" % protocol
3811482Sandreas.sandberg@arm.com    try:
3911482Sandreas.sandberg@arm.com        (cpu_sequencers, dir_cntrls, all_cntrls) = \
4012581Sgiacomo.travaglini@arm.com          eval("%s.create_system(options, physmem, piobus, dma_devices)" \
4112581Sgiacomo.travaglini@arm.com               % protocol)
4211482Sandreas.sandberg@arm.com    except:
4311482Sandreas.sandberg@arm.com        print "Error: could not create sytem for ruby protocol %s" % protocol
4411482Sandreas.sandberg@arm.com        sys.exit(1)
4511482Sandreas.sandberg@arm.com
4611482Sandreas.sandberg@arm.com    #
4711482Sandreas.sandberg@arm.com    # Important: the topology must be created before the network and after the
4811482Sandreas.sandberg@arm.com    # controllers.
4911482Sandreas.sandberg@arm.com    #
5011482Sandreas.sandberg@arm.com    exec "import %s" % options.topology
5111482Sandreas.sandberg@arm.com    try:
5211482Sandreas.sandberg@arm.com        net_topology = eval("%s.makeTopology(all_cntrls, options)" % options.topology)
5311482Sandreas.sandberg@arm.com    except:
5411482Sandreas.sandberg@arm.com        print "Error: could not create topology %s" % options.topology
5511482Sandreas.sandberg@arm.com        sys.exit(1)
5611482Sandreas.sandberg@arm.com
5711482Sandreas.sandberg@arm.com    if options.garnet_network == "fixed":
5811482Sandreas.sandberg@arm.com        network = GarnetNetwork_d(topology = net_topology)
5911482Sandreas.sandberg@arm.com    elif options.garnet_network == "flexible":
6011482Sandreas.sandberg@arm.com        network = GarnetNetwork(topology = net_topology)
6111482Sandreas.sandberg@arm.com    else:
6211482Sandreas.sandberg@arm.com        network = SimpleNetwork(topology = net_topology)
6311482Sandreas.sandberg@arm.com
6411482Sandreas.sandberg@arm.com    #
6511482Sandreas.sandberg@arm.com    # Determine the total memory size of the ruby system and verify it is equal
6611482Sandreas.sandberg@arm.com    # to physmem.  However, if Ruby memory is using sparse memory in SE
6711482Sandreas.sandberg@arm.com    # mode, then the system should not back-up the memory state with
6811482Sandreas.sandberg@arm.com    # the Memory Vector and thus the memory size bytes should stay at 0.
6911482Sandreas.sandberg@arm.com    #
7011482Sandreas.sandberg@arm.com    total_mem_size = MemorySize('0B')
7111482Sandreas.sandberg@arm.com    for dir_cntrl in dir_cntrls:
7211482Sandreas.sandberg@arm.com        total_mem_size.value += dir_cntrl.directory.size.value
7311482Sandreas.sandberg@arm.com    physmem_size = long(physmem.range.second) - long(physmem.range.first) + 1
7411482Sandreas.sandberg@arm.com    assert(total_mem_size.value == physmem_size)
7511482Sandreas.sandberg@arm.com
7611482Sandreas.sandberg@arm.com    ruby_profiler = RubyProfiler(num_of_sequencers = len(cpu_sequencers))
7711482Sandreas.sandberg@arm.com
7811482Sandreas.sandberg@arm.com    ruby = RubySystem(clock = options.clock,
7911482Sandreas.sandberg@arm.com                      network = network,
8011482Sandreas.sandberg@arm.com                      profiler = ruby_profiler,
8111482Sandreas.sandberg@arm.com                      tracer = RubyTracer(),
8211482Sandreas.sandberg@arm.com                      debug = RubyDebug(filter_string = 'none',
8311482Sandreas.sandberg@arm.com                                        verbosity_string = 'none',
8411482Sandreas.sandberg@arm.com                                        protocol_trace = False),
8511482Sandreas.sandberg@arm.com                      mem_size = total_mem_size)
8611482Sandreas.sandberg@arm.com
8711482Sandreas.sandberg@arm.com    ruby.cpu_ruby_ports = cpu_sequencers
8811482Sandreas.sandberg@arm.com
8911482Sandreas.sandberg@arm.com    return ruby
9011482Sandreas.sandberg@arm.com