BaseTopology.py revision 13774
19100SBrad.Beckmann@amd.com# Copyright (c) 2012 Advanced Micro Devices, Inc.
29100SBrad.Beckmann@amd.com# All rights reserved.
39100SBrad.Beckmann@amd.com#
49100SBrad.Beckmann@amd.com# Redistribution and use in source and binary forms, with or without
59100SBrad.Beckmann@amd.com# modification, are permitted provided that the following conditions are
69100SBrad.Beckmann@amd.com# met: redistributions of source code must retain the above copyright
79100SBrad.Beckmann@amd.com# notice, this list of conditions and the following disclaimer;
89100SBrad.Beckmann@amd.com# redistributions in binary form must reproduce the above copyright
99100SBrad.Beckmann@amd.com# notice, this list of conditions and the following disclaimer in the
109100SBrad.Beckmann@amd.com# documentation and/or other materials provided with the distribution;
119100SBrad.Beckmann@amd.com# neither the name of the copyright holders nor the names of its
129100SBrad.Beckmann@amd.com# contributors may be used to endorse or promote products derived from
139100SBrad.Beckmann@amd.com# this software without specific prior written permission.
149100SBrad.Beckmann@amd.com#
159100SBrad.Beckmann@amd.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
169100SBrad.Beckmann@amd.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
179100SBrad.Beckmann@amd.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
189100SBrad.Beckmann@amd.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
199100SBrad.Beckmann@amd.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
209100SBrad.Beckmann@amd.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
219100SBrad.Beckmann@amd.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
229100SBrad.Beckmann@amd.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
239100SBrad.Beckmann@amd.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
249100SBrad.Beckmann@amd.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
259100SBrad.Beckmann@amd.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
269100SBrad.Beckmann@amd.com#
279100SBrad.Beckmann@amd.com# Authors: Jason Power
289100SBrad.Beckmann@amd.com
2913774Sandreas.sandberg@arm.comfrom __future__ import print_function
3013774Sandreas.sandberg@arm.comfrom __future__ import absolute_import
3113774Sandreas.sandberg@arm.com
329148Spowerjg@cs.wisc.eduimport m5
339100SBrad.Beckmann@amd.com
349100SBrad.Beckmann@amd.comclass BaseTopology(object):
359100SBrad.Beckmann@amd.com    description = "BaseTopology"
369100SBrad.Beckmann@amd.com
379100SBrad.Beckmann@amd.com    def __init__(self):
389100SBrad.Beckmann@amd.com        """ When overriding place any objects created in
399100SBrad.Beckmann@amd.com            configs/ruby/<protocol>.py that are needed in
409100SBrad.Beckmann@amd.com            makeTopology (below) here. The minimum is usually
419100SBrad.Beckmann@amd.com            all of the controllers created in the above file.
429100SBrad.Beckmann@amd.com        """
439100SBrad.Beckmann@amd.com
449862Snilay@cs.wisc.edu    def makeTopology(self, options, network, IntLink, ExtLink, Router):
459148Spowerjg@cs.wisc.edu        """ Called from configs/ruby/Ruby.py
469100SBrad.Beckmann@amd.com            The return value is ( list(Router), list(IntLink), list(ExtLink))
479100SBrad.Beckmann@amd.com            The API of this function cannot change when subclassing!!
489100SBrad.Beckmann@amd.com            Any additional information needed to create this topology should
499100SBrad.Beckmann@amd.com            be passed into the constructor when it's instantiated in
509100SBrad.Beckmann@amd.com            configs/ruby/<protocol>.py
519100SBrad.Beckmann@amd.com        """
529148Spowerjg@cs.wisc.edu        m5.util.fatal("BaseTopology should have been overridden!!")
539100SBrad.Beckmann@amd.com
549148Spowerjg@cs.wisc.educlass SimpleTopology(BaseTopology):
559148Spowerjg@cs.wisc.edu    """ Provides methods needed for the topologies included in Ruby before
569148Spowerjg@cs.wisc.edu        topology changes.
579148Spowerjg@cs.wisc.edu        These topologies are "simple" in the sense that they only use a flat
589148Spowerjg@cs.wisc.edu        list of controllers to construct the topology.
599148Spowerjg@cs.wisc.edu    """
609148Spowerjg@cs.wisc.edu    description = "SimpleTopology"
619148Spowerjg@cs.wisc.edu
629148Spowerjg@cs.wisc.edu    def __init__(self, controllers):
639148Spowerjg@cs.wisc.edu        self.nodes = controllers
649148Spowerjg@cs.wisc.edu
659148Spowerjg@cs.wisc.edu    def addController(self, controller):
669148Spowerjg@cs.wisc.edu        self.nodes.append(controller)
679148Spowerjg@cs.wisc.edu
689148Spowerjg@cs.wisc.edu    def __len__(self):
699148Spowerjg@cs.wisc.edu        return len(self.nodes)
70