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
3113774Sandreas.sandberg@arm.comfrom __future__ import print_function
3213774Sandreas.sandberg@arm.comfrom __future__ import absolute_import
3313774Sandreas.sandberg@arm.com
348292SN/Afrom m5.params import *
358292SN/Afrom m5.objects import *
368292SN/A
3713774Sandreas.sandberg@arm.comfrom .BaseTopology import SimpleTopology
389100SBrad.Beckmann@amd.com
399148Spowerjg@cs.wisc.educlass Pt2Pt(SimpleTopology):
408292SN/A    description='Pt2Pt'
418292SN/A
429100SBrad.Beckmann@amd.com    def __init__(self, controllers):
439100SBrad.Beckmann@amd.com        self.nodes = controllers
448292SN/A
459862Snilay@cs.wisc.edu    def makeTopology(self, options, network, IntLink, ExtLink, Router):
469100SBrad.Beckmann@amd.com        nodes = self.nodes
479862Snilay@cs.wisc.edu
4811666Stushar@ece.gatech.edu        # default values for link latency and router latency.
4911666Stushar@ece.gatech.edu        # Can be over-ridden on a per link/router basis
5011666Stushar@ece.gatech.edu        link_latency = options.link_latency # used by simple and garnet
5111666Stushar@ece.gatech.edu        router_latency = options.router_latency # only used by garnet
5211666Stushar@ece.gatech.edu
5311666Stushar@ece.gatech.edu        # Create an individual router for each controller,
5411666Stushar@ece.gatech.edu        # and connect all to all.
5511666Stushar@ece.gatech.edu        # Since this is a high-radix router, router_latency should
5611666Stushar@ece.gatech.edu        # accordingly be set to a higher value than the default
5711666Stushar@ece.gatech.edu        # (which is 1 for mesh routers)
5811666Stushar@ece.gatech.edu        routers = [Router(router_id=i, latency = router_latency) \
5911666Stushar@ece.gatech.edu            for i in range(len(nodes))]
609862Snilay@cs.wisc.edu        network.routers = routers
618292SN/A
6211666Stushar@ece.gatech.edu        ext_links = [ExtLink(link_id=i, ext_node=n, int_node=routers[i],
6311666Stushar@ece.gatech.edu                     latency = link_latency)
649100SBrad.Beckmann@amd.com                    for (i, n) in enumerate(nodes)]
659862Snilay@cs.wisc.edu        network.ext_links = ext_links
669862Snilay@cs.wisc.edu
679100SBrad.Beckmann@amd.com        link_count = len(nodes)
689100SBrad.Beckmann@amd.com        int_links = []
6913731Sandreas.sandberg@arm.com        for i in range(len(nodes)):
7013731Sandreas.sandberg@arm.com            for j in range(len(nodes)):
719100SBrad.Beckmann@amd.com                if (i != j):
729100SBrad.Beckmann@amd.com                    link_count += 1
739100SBrad.Beckmann@amd.com                    int_links.append(IntLink(link_id=link_count,
7411663Stushar@ece.gatech.edu                                             src_node=routers[i],
7511666Stushar@ece.gatech.edu                                             dst_node=routers[j],
7611666Stushar@ece.gatech.edu                                             latency = link_latency))
779100SBrad.Beckmann@amd.com
789862Snilay@cs.wisc.edu        network.int_links = int_links
79