111662Stushar@ece.gatech.edu# Copyright (c) 2016 Georgia Institute of Technology 211662Stushar@ece.gatech.edu# All rights reserved. 311662Stushar@ece.gatech.edu# 411662Stushar@ece.gatech.edu# Redistribution and use in source and binary forms, with or without 511662Stushar@ece.gatech.edu# modification, are permitted provided that the following conditions are 611662Stushar@ece.gatech.edu# met: redistributions of source code must retain the above copyright 711662Stushar@ece.gatech.edu# notice, this list of conditions and the following disclaimer; 811662Stushar@ece.gatech.edu# redistributions in binary form must reproduce the above copyright 911662Stushar@ece.gatech.edu# notice, this list of conditions and the following disclaimer in the 1011662Stushar@ece.gatech.edu# documentation and/or other materials provided with the distribution; 1111662Stushar@ece.gatech.edu# neither the name of the copyright holders nor the names of its 1211662Stushar@ece.gatech.edu# contributors may be used to endorse or promote products derived from 1311662Stushar@ece.gatech.edu# this software without specific prior written permission. 1411662Stushar@ece.gatech.edu# 1511662Stushar@ece.gatech.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1611662Stushar@ece.gatech.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1711662Stushar@ece.gatech.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1811662Stushar@ece.gatech.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1911662Stushar@ece.gatech.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2011662Stushar@ece.gatech.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2111662Stushar@ece.gatech.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2211662Stushar@ece.gatech.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2311662Stushar@ece.gatech.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2411662Stushar@ece.gatech.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2511662Stushar@ece.gatech.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2611662Stushar@ece.gatech.edu# 2711662Stushar@ece.gatech.edu# Authors: Tushar Krishna 2811662Stushar@ece.gatech.edu 2913774Sandreas.sandberg@arm.comfrom __future__ import print_function 3013774Sandreas.sandberg@arm.comfrom __future__ import absolute_import 3113774Sandreas.sandberg@arm.com 3211662Stushar@ece.gatech.eduimport math 3311662Stushar@ece.gatech.eduimport m5 3411662Stushar@ece.gatech.edufrom m5.objects import * 3511662Stushar@ece.gatech.edufrom m5.defines import buildEnv 3611662Stushar@ece.gatech.edufrom m5.util import addToPath, fatal 3711662Stushar@ece.gatech.edu 3811662Stushar@ece.gatech.edudef define_options(parser): 3911662Stushar@ece.gatech.edu # By default, ruby uses the simple timing cpu 4012014Sgabeblack@google.com parser.set_defaults(cpu_type="TimingSimpleCPU") 4111662Stushar@ece.gatech.edu 4211662Stushar@ece.gatech.edu parser.add_option("--topology", type="string", default="Crossbar", 4311662Stushar@ece.gatech.edu help="check configs/topologies for complete set") 4411666Stushar@ece.gatech.edu parser.add_option("--mesh-rows", type="int", default=0, 4511662Stushar@ece.gatech.edu help="the number of rows in the mesh topology") 4611666Stushar@ece.gatech.edu parser.add_option("--network", type="choice", default="simple", 4711666Stushar@ece.gatech.edu choices=['simple', 'garnet2.0'], 4811666Stushar@ece.gatech.edu help="'simple'|'garnet2.0'") 4911666Stushar@ece.gatech.edu parser.add_option("--router-latency", action="store", type="int", 5011666Stushar@ece.gatech.edu default=1, 5111666Stushar@ece.gatech.edu help="""number of pipeline stages in the garnet router. 5211666Stushar@ece.gatech.edu Has to be >= 1. 5311666Stushar@ece.gatech.edu Can be over-ridden on a per router basis 5411666Stushar@ece.gatech.edu in the topology file.""") 5511666Stushar@ece.gatech.edu parser.add_option("--link-latency", action="store", type="int", default=1, 5611666Stushar@ece.gatech.edu help="""latency of each link the simple/garnet networks. 5711666Stushar@ece.gatech.edu Has to be >= 1. 5811666Stushar@ece.gatech.edu Can be over-ridden on a per link basis 5911666Stushar@ece.gatech.edu in the topology file.""") 6011666Stushar@ece.gatech.edu parser.add_option("--link-width-bits", action="store", type="int", 6111666Stushar@ece.gatech.edu default=128, 6211666Stushar@ece.gatech.edu help="width in bits for all links inside garnet.") 6311666Stushar@ece.gatech.edu parser.add_option("--vcs-per-vnet", action="store", type="int", default=4, 6411666Stushar@ece.gatech.edu help="""number of virtual channels per virtual network 6511666Stushar@ece.gatech.edu inside garnet network.""") 6611666Stushar@ece.gatech.edu parser.add_option("--routing-algorithm", action="store", type="int", 6711666Stushar@ece.gatech.edu default=0, 6811666Stushar@ece.gatech.edu help="""routing algorithm in network. 6911666Stushar@ece.gatech.edu 0: weight-based table 7011666Stushar@ece.gatech.edu 1: XY (for Mesh. see garnet2.0/RoutingUnit.cc) 7111666Stushar@ece.gatech.edu 2: Custom (see garnet2.0/RoutingUnit.cc""") 7211666Stushar@ece.gatech.edu parser.add_option("--network-fault-model", action="store_true", 7311666Stushar@ece.gatech.edu default=False, 7411666Stushar@ece.gatech.edu help="""enable network fault model: 7511666Stushar@ece.gatech.edu see src/mem/ruby/network/fault_model/""") 7611762Sjieming.yin@amd.com parser.add_option("--garnet-deadlock-threshold", action="store", 7711762Sjieming.yin@amd.com type="int", default=50000, 7811762Sjieming.yin@amd.com help="network-level deadlock threshold.") 7911662Stushar@ece.gatech.edu 8011662Stushar@ece.gatech.edu 8111662Stushar@ece.gatech.edudef create_network(options, ruby): 8211662Stushar@ece.gatech.edu 8311662Stushar@ece.gatech.edu # Set the network classes based on the command line options 8411666Stushar@ece.gatech.edu if options.network == "garnet2.0": 8511662Stushar@ece.gatech.edu NetworkClass = GarnetNetwork 8611662Stushar@ece.gatech.edu IntLinkClass = GarnetIntLink 8711662Stushar@ece.gatech.edu ExtLinkClass = GarnetExtLink 8811662Stushar@ece.gatech.edu RouterClass = GarnetRouter 8911662Stushar@ece.gatech.edu InterfaceClass = GarnetNetworkInterface 9011662Stushar@ece.gatech.edu 9111662Stushar@ece.gatech.edu else: 9211662Stushar@ece.gatech.edu NetworkClass = SimpleNetwork 9311662Stushar@ece.gatech.edu IntLinkClass = SimpleIntLink 9411662Stushar@ece.gatech.edu ExtLinkClass = SimpleExtLink 9511662Stushar@ece.gatech.edu RouterClass = Switch 9611662Stushar@ece.gatech.edu InterfaceClass = None 9711662Stushar@ece.gatech.edu 9811662Stushar@ece.gatech.edu # Instantiate the network object 9911662Stushar@ece.gatech.edu # so that the controllers can connect to it. 10011662Stushar@ece.gatech.edu network = NetworkClass(ruby_system = ruby, topology = options.topology, 10111662Stushar@ece.gatech.edu routers = [], ext_links = [], int_links = [], netifs = []) 10211662Stushar@ece.gatech.edu 10311662Stushar@ece.gatech.edu return (network, IntLinkClass, ExtLinkClass, RouterClass, InterfaceClass) 10411662Stushar@ece.gatech.edu 10511662Stushar@ece.gatech.edudef init_network(options, network, InterfaceClass): 10611662Stushar@ece.gatech.edu 10711666Stushar@ece.gatech.edu if options.network == "garnet2.0": 10811666Stushar@ece.gatech.edu network.num_rows = options.mesh_rows 10911666Stushar@ece.gatech.edu network.vcs_per_vnet = options.vcs_per_vnet 11011666Stushar@ece.gatech.edu network.ni_flit_size = options.link_width_bits / 8 11111666Stushar@ece.gatech.edu network.routing_algorithm = options.routing_algorithm 11211762Sjieming.yin@amd.com network.garnet_deadlock_threshold = options.garnet_deadlock_threshold 11311666Stushar@ece.gatech.edu 11411666Stushar@ece.gatech.edu if options.network == "simple": 11511662Stushar@ece.gatech.edu network.setup_buffers() 11611662Stushar@ece.gatech.edu 11711662Stushar@ece.gatech.edu if InterfaceClass != None: 11811662Stushar@ece.gatech.edu netifs = [InterfaceClass(id=i) \ 11911662Stushar@ece.gatech.edu for (i,n) in enumerate(network.ext_links)] 12011662Stushar@ece.gatech.edu network.netifs = netifs 12111662Stushar@ece.gatech.edu 12211662Stushar@ece.gatech.edu if options.network_fault_model: 12311666Stushar@ece.gatech.edu assert(options.network == "garnet2.0") 12411662Stushar@ece.gatech.edu network.enable_fault_model = True 12511662Stushar@ece.gatech.edu network.fault_model = FaultModel() 126