sw.py revision 11444
14298Sgblack@eecs.umich.edu# Copyright (c) 2015 The University of Illinois Urbana Champaign
24298Sgblack@eecs.umich.edu# All rights reserved
34298Sgblack@eecs.umich.edu#
44298Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
54298Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
64298Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
74298Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
84298Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
94298Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
104298Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
114298Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
124298Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
134298Sgblack@eecs.umich.edu# this software without specific prior written permission.
144298Sgblack@eecs.umich.edu#
154298Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
164298Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
174298Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
184298Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
194298Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
204298Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
214298Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
224298Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
234298Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
244298Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
254298Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
264298Sgblack@eecs.umich.edu#
274298Sgblack@eecs.umich.edu# Authors: Mohammad Alian
284298Sgblack@eecs.umich.edu
294298Sgblack@eecs.umich.edu# This is an example of an n port network switch to work in dist-gem5.
304298Sgblack@eecs.umich.edu# Users can extend this to have different different topologies
314298Sgblack@eecs.umich.edu
324298Sgblack@eecs.umich.eduimport optparse
334298Sgblack@eecs.umich.eduimport sys
344298Sgblack@eecs.umich.edu
354298Sgblack@eecs.umich.eduimport m5
364298Sgblack@eecs.umich.edufrom m5.defines import buildEnv
374298Sgblack@eecs.umich.edufrom m5.objects import *
384298Sgblack@eecs.umich.edufrom m5.util import addToPath, fatal
394298Sgblack@eecs.umich.edu
404298Sgblack@eecs.umich.eduaddToPath('../common')
414298Sgblack@eecs.umich.edu
424298Sgblack@eecs.umich.eduimport Simulation
434298Sgblack@eecs.umich.eduimport Options
444298Sgblack@eecs.umich.edu
454298Sgblack@eecs.umich.edudef build_switch(options):
464298Sgblack@eecs.umich.edu    # instantiate an EtherSwitch
474298Sgblack@eecs.umich.edu    switch = EtherSwitch()
484298Sgblack@eecs.umich.edu    # instantiate distEtherLinks to connect switch ports
494298Sgblack@eecs.umich.edu    # to other gem5 instances
504298Sgblack@eecs.umich.edu    switch.portlink = [DistEtherLink(speed = options.ethernet_linkspeed,
514298Sgblack@eecs.umich.edu                                      delay = options.ethernet_linkdelay,
524298Sgblack@eecs.umich.edu                                      dist_rank = options.dist_rank,
534298Sgblack@eecs.umich.edu                                      dist_size = options.dist_size,
544298Sgblack@eecs.umich.edu                                      server_name = options.dist_server_name,
554298Sgblack@eecs.umich.edu                                      server_port = options.dist_server_port,
564338Sgblack@eecs.umich.edu                                      sync_start = options.dist_sync_start,
574338Sgblack@eecs.umich.edu                                      sync_repeat = options.dist_sync_repeat,
584338Sgblack@eecs.umich.edu                                      is_switch = True,
594519Sgblack@eecs.umich.edu                                      num_nodes = options.dist_size)
604519Sgblack@eecs.umich.edu                       for i in xrange(options.dist_size)]
614372Sgblack@eecs.umich.edu
624519Sgblack@eecs.umich.edu    for (i, link) in enumerate(switch.portlink):
634519Sgblack@eecs.umich.edu        link.int0 = switch.interface[i]
64
65    return switch
66# Add options
67parser = optparse.OptionParser()
68Options.addCommonOptions(parser)
69Options.addFSOptions(parser)
70(options, args) = parser.parse_args()
71
72system = build_switch(options)
73root = Root(full_system = True, system = system)
74Simulation.run(options, root, None, None)
75
76