Network.py revision 11662:004d34b65092
1# Copyright (c) 2016 Georgia Institute of Technology 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright 9# notice, this list of conditions and the following disclaimer in the 10# documentation and/or other materials provided with the distribution; 11# neither the name of the copyright holders nor the names of its 12# contributors may be used to endorse or promote products derived from 13# this software without specific prior written permission. 14# 15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26# 27# Authors: Tushar Krishna 28 29import math 30import m5 31from m5.objects import * 32from m5.defines import buildEnv 33from m5.util import addToPath, fatal 34 35def define_options(parser): 36 # By default, ruby uses the simple timing cpu 37 parser.set_defaults(cpu_type="timing") 38 39 parser.add_option("--topology", type="string", default="Crossbar", 40 help="check configs/topologies for complete set") 41 parser.add_option("--mesh-rows", type="int", default=1, 42 help="the number of rows in the mesh topology") 43 parser.add_option("--garnet-network", type="choice", 44 choices=['fixed', 'flexible'], help="'fixed'|'flexible'") 45 parser.add_option("--network-fault-model", action="store_true", default=False, 46 help="enable network fault model: see src/mem/ruby/network/fault_model/") 47 48 49def create_network(options, ruby): 50 51 # Set the network classes based on the command line options 52 if options.garnet_network == "fixed": 53 NetworkClass = GarnetNetwork_d 54 IntLinkClass = GarnetIntLink_d 55 ExtLinkClass = GarnetExtLink_d 56 RouterClass = GarnetRouter_d 57 InterfaceClass = GarnetNetworkInterface_d 58 59 elif options.garnet_network == "flexible": 60 NetworkClass = GarnetNetwork 61 IntLinkClass = GarnetIntLink 62 ExtLinkClass = GarnetExtLink 63 RouterClass = GarnetRouter 64 InterfaceClass = GarnetNetworkInterface 65 66 else: 67 NetworkClass = SimpleNetwork 68 IntLinkClass = SimpleIntLink 69 ExtLinkClass = SimpleExtLink 70 RouterClass = Switch 71 InterfaceClass = None 72 73 # Instantiate the network object 74 # so that the controllers can connect to it. 75 network = NetworkClass(ruby_system = ruby, topology = options.topology, 76 routers = [], ext_links = [], int_links = [], netifs = []) 77 78 return (network, IntLinkClass, ExtLinkClass, RouterClass, InterfaceClass) 79 80def init_network(options, network, InterfaceClass): 81 82 if options.garnet_network is None: 83 network.setup_buffers() 84 85 if InterfaceClass != None: 86 netifs = [InterfaceClass(id=i) \ 87 for (i,n) in enumerate(network.ext_links)] 88 network.netifs = netifs 89 90 if options.network_fault_model: 91 assert(options.garnet_network == "fixed") 92 network.enable_fault_model = True 93 network.fault_model = FaultModel() 94