Pt2Pt.py revision 9100
18292SN/A# Copyright (c) 2011 Advanced Micro Devices, Inc. 28292SN/A# 2011 Massachusetts Institute of Technology 38292SN/A# All rights reserved. 48292SN/A# 58292SN/A# Redistribution and use in source and binary forms, with or without 68292SN/A# modification, are permitted provided that the following conditions are 78292SN/A# met: redistributions of source code must retain the above copyright 88292SN/A# notice, this list of conditions and the following disclaimer; 98292SN/A# redistributions in binary form must reproduce the above copyright 108292SN/A# notice, this list of conditions and the following disclaimer in the 118292SN/A# documentation and/or other materials provided with the distribution; 128292SN/A# neither the name of the copyright holders nor the names of its 138292SN/A# contributors may be used to endorse or promote products derived from 148292SN/A# this software without specific prior written permission. 158292SN/A# 168292SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 178292SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 188292SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 198292SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 208292SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 218292SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 228292SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 238292SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 248292SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 258292SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 268292SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 278292SN/A# 288292SN/A# Authors: Brad Beckmann 298292SN/A# Tushar Krishna 308292SN/A 318292SN/Afrom m5.params import * 328292SN/Afrom m5.objects import * 338292SN/A 349100SBrad.Beckmann@amd.comfrom BaseTopology import BaseTopology 359100SBrad.Beckmann@amd.com 369100SBrad.Beckmann@amd.comclass Pt2Pt(BaseTopology): 378292SN/A description='Pt2Pt' 388292SN/A 399100SBrad.Beckmann@amd.com def __init__(self, controllers): 409100SBrad.Beckmann@amd.com self.nodes = controllers 418292SN/A 429100SBrad.Beckmann@amd.com def makeTopology(self, options, IntLink, ExtLink, Router): 439100SBrad.Beckmann@amd.com nodes = self.nodes 449100SBrad.Beckmann@amd.com # Create an individual router for each controller, and connect all to all. 458292SN/A 469100SBrad.Beckmann@amd.com routers = [Router(router_id=i) for i in range(len(nodes))] 479100SBrad.Beckmann@amd.com ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i]) 489100SBrad.Beckmann@amd.com for (i, n) in enumerate(nodes)] 499100SBrad.Beckmann@amd.com link_count = len(nodes) 508322SN/A 519100SBrad.Beckmann@amd.com int_links = [] 529100SBrad.Beckmann@amd.com for i in xrange(len(nodes)): 539100SBrad.Beckmann@amd.com for j in xrange(len(nodes)): 549100SBrad.Beckmann@amd.com if (i != j): 559100SBrad.Beckmann@amd.com link_count += 1 569100SBrad.Beckmann@amd.com int_links.append(IntLink(link_id=link_count, 579100SBrad.Beckmann@amd.com node_a=routers[i], 589100SBrad.Beckmann@amd.com node_b=routers[j])) 599100SBrad.Beckmann@amd.com 609100SBrad.Beckmann@amd.com return routers, int_links, ext_links 61