1 # Copyright (c) 2016 Georgia Institute of Technology
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.
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.
27 from __future__
import print_function
28 from __future__
import absolute_import
32 from m5
.objects
import *
33 from m5
.defines
import buildEnv
34 from m5
.util
import addToPath
, fatal
36 def define_options(parser
):
37 # By default, ruby uses the simple timing cpu
38 parser
.set_defaults(cpu_type
="TimingSimpleCPU")
40 parser
.add_option("--topology", type="string", default
="Crossbar",
41 help="check configs/topologies for complete set")
42 parser
.add_option("--mesh-rows", type="int", default
=0,
43 help="the number of rows in the mesh topology")
44 parser
.add_option("--network", type="choice", default
="simple",
45 choices
=['simple', 'garnet2.0'],
46 help="'simple'|'garnet2.0'")
47 parser
.add_option("--router-latency", action
="store", type="int",
49 help="""number of pipeline stages in the garnet router.
51 Can be over-ridden on a per router basis
52 in the topology file.""")
53 parser
.add_option("--link-latency", action
="store", type="int", default
=1,
54 help="""latency of each link the simple/garnet networks.
56 Can be over-ridden on a per link basis
57 in the topology file.""")
58 parser
.add_option("--link-width-bits", action
="store", type="int",
60 help="width in bits for all links inside garnet.")
61 parser
.add_option("--vcs-per-vnet", action
="store", type="int", default
=4,
62 help="""number of virtual channels per virtual network
63 inside garnet network.""")
64 parser
.add_option("--routing-algorithm", action
="store", type="int",
66 help="""routing algorithm in network.
68 1: XY (for Mesh. see garnet2.0/RoutingUnit.cc)
69 2: Custom (see garnet2.0/RoutingUnit.cc""")
70 parser
.add_option("--network-fault-model", action
="store_true",
72 help="""enable network fault model:
73 see src/mem/ruby/network/fault_model/""")
74 parser
.add_option("--garnet-deadlock-threshold", action
="store",
75 type="int", default
=50000,
76 help="network-level deadlock threshold.")
79 def create_network(options
, ruby
):
81 # Set the network classes based on the command line options
82 if options
.network
== "garnet2.0":
83 NetworkClass
= GarnetNetwork
84 IntLinkClass
= GarnetIntLink
85 ExtLinkClass
= GarnetExtLink
86 RouterClass
= GarnetRouter
87 InterfaceClass
= GarnetNetworkInterface
90 NetworkClass
= SimpleNetwork
91 IntLinkClass
= SimpleIntLink
92 ExtLinkClass
= SimpleExtLink
96 # Instantiate the network object
97 # so that the controllers can connect to it.
98 network
= NetworkClass(ruby_system
= ruby
, topology
= options
.topology
,
99 routers
= [], ext_links
= [], int_links
= [], netifs
= [])
101 return (network
, IntLinkClass
, ExtLinkClass
, RouterClass
, InterfaceClass
)
103 def init_network(options
, network
, InterfaceClass
):
105 if options
.network
== "garnet2.0":
106 network
.num_rows
= options
.mesh_rows
107 network
.vcs_per_vnet
= options
.vcs_per_vnet
108 network
.ni_flit_size
= options
.link_width_bits
/ 8
109 network
.routing_algorithm
= options
.routing_algorithm
110 network
.garnet_deadlock_threshold
= options
.garnet_deadlock_threshold
112 if options
.network
== "simple":
113 network
.setup_buffers()
115 if InterfaceClass
!= None:
116 netifs
= [InterfaceClass(id=i
) \
117 for (i
,n
) in enumerate(network
.ext_links
)]
118 network
.netifs
= netifs
120 if options
.network_fault_model
:
121 assert(options
.network
== "garnet2.0")
122 network
.enable_fault_model
= True
123 network
.fault_model
= FaultModel()