17032SN/A# Copyright (c) 2010 Advanced Micro Devices, Inc. 27032SN/A# All rights reserved. 37032SN/A# 47032SN/A# Redistribution and use in source and binary forms, with or without 57032SN/A# modification, are permitted provided that the following conditions are 67032SN/A# met: redistributions of source code must retain the above copyright 77032SN/A# notice, this list of conditions and the following disclaimer; 87032SN/A# redistributions in binary form must reproduce the above copyright 97032SN/A# notice, this list of conditions and the following disclaimer in the 107032SN/A# documentation and/or other materials provided with the distribution; 117032SN/A# neither the name of the copyright holders nor the names of its 127032SN/A# contributors may be used to endorse or promote products derived from 137032SN/A# this software without specific prior written permission. 147032SN/A# 157032SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 167032SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 177032SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 187032SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 197032SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 207032SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 217032SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 227032SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 237032SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 247032SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 257032SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 267032SN/A# 277032SN/A# Authors: Steve Reinhardt 287032SN/A 2913774Sandreas.sandberg@arm.comfrom __future__ import print_function 3013774Sandreas.sandberg@arm.comfrom __future__ import absolute_import 3113774Sandreas.sandberg@arm.com 327032SN/Afrom m5.params import * 337032SN/Afrom m5.objects import * 347032SN/A 3513774Sandreas.sandberg@arm.comfrom .BaseTopology import SimpleTopology 369100SBrad.Beckmann@amd.com 379148Spowerjg@cs.wisc.educlass Crossbar(SimpleTopology): 387540SN/A description='Crossbar' 397540SN/A 409862Snilay@cs.wisc.edu def makeTopology(self, options, network, IntLink, ExtLink, Router): 4111666Stushar@ece.gatech.edu 4211666Stushar@ece.gatech.edu # default values for link latency and router latency. 4311666Stushar@ece.gatech.edu # Can be over-ridden on a per link/router basis 4411666Stushar@ece.gatech.edu link_latency = options.link_latency # used by simple and garnet 4511666Stushar@ece.gatech.edu router_latency = options.router_latency # only used by garnet 4611666Stushar@ece.gatech.edu 479862Snilay@cs.wisc.edu # Create an individual router for each controller plus one more for 489862Snilay@cs.wisc.edu # the centralized crossbar. The large numbers of routers are needed 499862Snilay@cs.wisc.edu # because external links do not model outgoing bandwidth in the 509862Snilay@cs.wisc.edu # simple network, but internal links do. 5111663Stushar@ece.gatech.edu # For garnet, one router suffices, use CrossbarGarnet.py 527032SN/A 539100SBrad.Beckmann@amd.com routers = [Router(router_id=i) for i in range(len(self.nodes)+1)] 549862Snilay@cs.wisc.edu xbar = routers[len(self.nodes)] # the crossbar router is the last router created 559862Snilay@cs.wisc.edu network.routers = routers 569862Snilay@cs.wisc.edu 5711666Stushar@ece.gatech.edu ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i], 5811666Stushar@ece.gatech.edu latency = link_latency) 599100SBrad.Beckmann@amd.com for (i, n) in enumerate(self.nodes)] 609862Snilay@cs.wisc.edu network.ext_links = ext_links 619862Snilay@cs.wisc.edu 629100SBrad.Beckmann@amd.com link_count = len(self.nodes) 6311663Stushar@ece.gatech.edu 6411663Stushar@ece.gatech.edu int_links = [] 6511663Stushar@ece.gatech.edu for i in range(len(self.nodes)): 6611663Stushar@ece.gatech.edu int_links.append(IntLink(link_id=(link_count+i), 6711663Stushar@ece.gatech.edu src_node=routers[i], 6811666Stushar@ece.gatech.edu dst_node=xbar, 6911666Stushar@ece.gatech.edu latency = link_latency)) 7011663Stushar@ece.gatech.edu 7111663Stushar@ece.gatech.edu link_count += len(self.nodes) 7211663Stushar@ece.gatech.edu 7311663Stushar@ece.gatech.edu for i in range(len(self.nodes)): 7411663Stushar@ece.gatech.edu int_links.append(IntLink(link_id=(link_count+i), 7511663Stushar@ece.gatech.edu src_node=xbar, 7611666Stushar@ece.gatech.edu dst_node=routers[i], 7711666Stushar@ece.gatech.edu latency = link_latency)) 7811663Stushar@ece.gatech.edu 799862Snilay@cs.wisc.edu network.int_links = int_links 80