Deleted Added
sdiff udiff text old ( 11666:10d59d546ea2 ) new ( 11762:29d401db3746 )
full compact
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=0,
42 help="the number of rows in the mesh topology")
43 parser.add_option("--network", type="choice", default="simple",
44 choices=['simple', 'garnet2.0'],
45 help="'simple'|'garnet2.0'")
46 parser.add_option("--router-latency", action="store", type="int",
47 default=1,
48 help="""number of pipeline stages in the garnet router.
49 Has to be >= 1.
50 Can be over-ridden on a per router basis
51 in the topology file.""")
52 parser.add_option("--link-latency", action="store", type="int", default=1,
53 help="""latency of each link the simple/garnet networks.
54 Has to be >= 1.
55 Can be over-ridden on a per link basis
56 in the topology file.""")
57 parser.add_option("--link-width-bits", action="store", type="int",
58 default=128,
59 help="width in bits for all links inside garnet.")
60 parser.add_option("--vcs-per-vnet", action="store", type="int", default=4,
61 help="""number of virtual channels per virtual network
62 inside garnet network.""")
63 parser.add_option("--routing-algorithm", action="store", type="int",
64 default=0,
65 help="""routing algorithm in network.
66 0: weight-based table
67 1: XY (for Mesh. see garnet2.0/RoutingUnit.cc)
68 2: Custom (see garnet2.0/RoutingUnit.cc""")
69 parser.add_option("--network-fault-model", action="store_true",
70 default=False,
71 help="""enable network fault model:
72 see src/mem/ruby/network/fault_model/""")
73
74
75def create_network(options, ruby):
76
77 # Set the network classes based on the command line options
78 if options.network == "garnet2.0":
79 NetworkClass = GarnetNetwork
80 IntLinkClass = GarnetIntLink
81 ExtLinkClass = GarnetExtLink
82 RouterClass = GarnetRouter
83 InterfaceClass = GarnetNetworkInterface
84
85 else:
86 NetworkClass = SimpleNetwork
87 IntLinkClass = SimpleIntLink
88 ExtLinkClass = SimpleExtLink
89 RouterClass = Switch
90 InterfaceClass = None
91
92 # Instantiate the network object
93 # so that the controllers can connect to it.
94 network = NetworkClass(ruby_system = ruby, topology = options.topology,
95 routers = [], ext_links = [], int_links = [], netifs = [])
96
97 return (network, IntLinkClass, ExtLinkClass, RouterClass, InterfaceClass)
98
99def init_network(options, network, InterfaceClass):
100
101 if options.network == "garnet2.0":
102 network.num_rows = options.mesh_rows
103 network.vcs_per_vnet = options.vcs_per_vnet
104 network.ni_flit_size = options.link_width_bits / 8
105 network.routing_algorithm = options.routing_algorithm
106
107 if options.network == "simple":
108 network.setup_buffers()
109
110 if InterfaceClass != None:
111 netifs = [InterfaceClass(id=i) \
112 for (i,n) in enumerate(network.ext_links)]
113 network.netifs = netifs
114
115 if options.network_fault_model:
116 assert(options.network == "garnet2.0")
117 network.enable_fault_model = True
118 network.fault_model = FaultModel()