111660Stushar@ece.gatech.edu# Copyright (c) 2009 Advanced Micro Devices, Inc.
211660Stushar@ece.gatech.edu# Copyright (c) 2016 Georgia Institute of Technology
311660Stushar@ece.gatech.edu# All rights reserved.
411660Stushar@ece.gatech.edu#
511660Stushar@ece.gatech.edu# Redistribution and use in source and binary forms, with or without
611660Stushar@ece.gatech.edu# modification, are permitted provided that the following conditions are
711660Stushar@ece.gatech.edu# met: redistributions of source code must retain the above copyright
811660Stushar@ece.gatech.edu# notice, this list of conditions and the following disclaimer;
911660Stushar@ece.gatech.edu# redistributions in binary form must reproduce the above copyright
1011660Stushar@ece.gatech.edu# notice, this list of conditions and the following disclaimer in the
1111660Stushar@ece.gatech.edu# documentation and/or other materials provided with the distribution;
1211660Stushar@ece.gatech.edu# neither the name of the copyright holders nor the names of its
1311660Stushar@ece.gatech.edu# contributors may be used to endorse or promote products derived from
1411660Stushar@ece.gatech.edu# this software without specific prior written permission.
1511660Stushar@ece.gatech.edu#
1611660Stushar@ece.gatech.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1711660Stushar@ece.gatech.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1811660Stushar@ece.gatech.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1911660Stushar@ece.gatech.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2011660Stushar@ece.gatech.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2111660Stushar@ece.gatech.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2211660Stushar@ece.gatech.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2311660Stushar@ece.gatech.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2411660Stushar@ece.gatech.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2511660Stushar@ece.gatech.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2611660Stushar@ece.gatech.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2711660Stushar@ece.gatech.edu#
2811660Stushar@ece.gatech.edu# Authors: Brad Beckmann
2911660Stushar@ece.gatech.edu#          Tushar Krishna
3011660Stushar@ece.gatech.edu
3111660Stushar@ece.gatech.eduimport m5
3211660Stushar@ece.gatech.edufrom m5.objects import *
3311660Stushar@ece.gatech.edufrom m5.defines import buildEnv
3411660Stushar@ece.gatech.edufrom m5.util import addToPath
3512065Snikos.nikoleris@arm.comfrom Ruby import create_topology, create_directories
3611660Stushar@ece.gatech.edu
3711660Stushar@ece.gatech.edu#
3811660Stushar@ece.gatech.edu# Declare caches used by the protocol
3911660Stushar@ece.gatech.edu#
4011660Stushar@ece.gatech.educlass L1Cache(RubyCache): pass
4111660Stushar@ece.gatech.edu
4211660Stushar@ece.gatech.edudef define_options(parser):
4311660Stushar@ece.gatech.edu    return
4411660Stushar@ece.gatech.edu
4512598Snikos.nikoleris@arm.comdef create_system(options, full_system, system, dma_ports, bootmem,
4612598Snikos.nikoleris@arm.com                  ruby_system):
4711660Stushar@ece.gatech.edu    if buildEnv['PROTOCOL'] != 'Garnet_standalone':
4811660Stushar@ece.gatech.edu        panic("This script requires Garnet_standalone protocol to be built.")
4911660Stushar@ece.gatech.edu
5011660Stushar@ece.gatech.edu    cpu_sequencers = []
5111660Stushar@ece.gatech.edu
5211660Stushar@ece.gatech.edu    #
5311660Stushar@ece.gatech.edu    # The Garnet_standalone protocol does not support fs nor dma
5411660Stushar@ece.gatech.edu    #
5511660Stushar@ece.gatech.edu    assert(dma_ports == [])
5611660Stushar@ece.gatech.edu
5711660Stushar@ece.gatech.edu    #
5811660Stushar@ece.gatech.edu    # The ruby network creation expects the list of nodes in the system to be
5911660Stushar@ece.gatech.edu    # consistent with the NetDest list.
6011660Stushar@ece.gatech.edu    # Therefore the l1 controller nodes must be listed before
6111660Stushar@ece.gatech.edu    # the directory nodes and directory nodes before dma nodes, etc.
6211660Stushar@ece.gatech.edu    l1_cntrl_nodes = []
6311660Stushar@ece.gatech.edu
6411660Stushar@ece.gatech.edu    #
6511660Stushar@ece.gatech.edu    # Must create the individual controllers before the network to ensure the
6611660Stushar@ece.gatech.edu    # controller constructors are called before the network constructor
6711660Stushar@ece.gatech.edu    #
6811660Stushar@ece.gatech.edu
6913731Sandreas.sandberg@arm.com    for i in range(options.num_cpus):
7011660Stushar@ece.gatech.edu        #
7111660Stushar@ece.gatech.edu        # First create the Ruby objects associated with this cpu
7211660Stushar@ece.gatech.edu        # Only one cache exists for this protocol, so by default use the L1D
7311660Stushar@ece.gatech.edu        # config parameters.
7411660Stushar@ece.gatech.edu        #
7511660Stushar@ece.gatech.edu        cache = L1Cache(size = options.l1d_size,
7611660Stushar@ece.gatech.edu                        assoc = options.l1d_assoc)
7711660Stushar@ece.gatech.edu
7811660Stushar@ece.gatech.edu        #
7911660Stushar@ece.gatech.edu        # Only one unified L1 cache exists.  Can cache instructions and data.
8011660Stushar@ece.gatech.edu        #
8111660Stushar@ece.gatech.edu        l1_cntrl = L1Cache_Controller(version = i,
8211660Stushar@ece.gatech.edu                                      cacheMemory = cache,
8311660Stushar@ece.gatech.edu                                      ruby_system = ruby_system)
8411660Stushar@ece.gatech.edu
8511660Stushar@ece.gatech.edu        cpu_seq = RubySequencer(icache = cache,
8611660Stushar@ece.gatech.edu                                dcache = cache,
8711660Stushar@ece.gatech.edu                                garnet_standalone = True,
8811660Stushar@ece.gatech.edu                                ruby_system = ruby_system)
8911660Stushar@ece.gatech.edu
9011660Stushar@ece.gatech.edu        l1_cntrl.sequencer = cpu_seq
9111660Stushar@ece.gatech.edu        exec("ruby_system.l1_cntrl%d = l1_cntrl" % i)
9211660Stushar@ece.gatech.edu
9311660Stushar@ece.gatech.edu        # Add controllers and sequencers to the appropriate lists
9411660Stushar@ece.gatech.edu        cpu_sequencers.append(cpu_seq)
9511660Stushar@ece.gatech.edu        l1_cntrl_nodes.append(l1_cntrl)
9611660Stushar@ece.gatech.edu
9711660Stushar@ece.gatech.edu        # Connect the L1 controllers and the network
9811660Stushar@ece.gatech.edu        l1_cntrl.mandatoryQueue = MessageBuffer()
9911660Stushar@ece.gatech.edu        l1_cntrl.requestFromCache = MessageBuffer()
10011660Stushar@ece.gatech.edu        l1_cntrl.responseFromCache = MessageBuffer()
10111660Stushar@ece.gatech.edu        l1_cntrl.forwardFromCache = MessageBuffer()
10211660Stushar@ece.gatech.edu
10312598Snikos.nikoleris@arm.com    mem_dir_cntrl_nodes, rom_dir_cntrl_node = create_directories(
10412976Snikos.nikoleris@arm.com        options, bootmem, ruby_system, system)
10512598Snikos.nikoleris@arm.com    dir_cntrl_nodes = mem_dir_cntrl_nodes[:]
10612598Snikos.nikoleris@arm.com    if rom_dir_cntrl_node is not None:
10712598Snikos.nikoleris@arm.com        dir_cntrl_nodes.append(rom_dir_cntrl_node)
10812065Snikos.nikoleris@arm.com    for dir_cntrl in dir_cntrl_nodes:
10911660Stushar@ece.gatech.edu        # Connect the directory controllers and the network
11011660Stushar@ece.gatech.edu        dir_cntrl.requestToDir = MessageBuffer()
11111660Stushar@ece.gatech.edu        dir_cntrl.forwardToDir = MessageBuffer()
11211660Stushar@ece.gatech.edu        dir_cntrl.responseToDir = MessageBuffer()
11311660Stushar@ece.gatech.edu
11411660Stushar@ece.gatech.edu
11511660Stushar@ece.gatech.edu    all_cntrls = l1_cntrl_nodes + dir_cntrl_nodes
11611660Stushar@ece.gatech.edu    ruby_system.network.number_of_virtual_networks = 3
11711660Stushar@ece.gatech.edu    topology = create_topology(all_cntrls, options)
11812598Snikos.nikoleris@arm.com    return (cpu_sequencers, mem_dir_cntrl_nodes, topology)
119