BaseTopology.py revision 9148
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
299148Spowerjg@cs.wisc.eduimport m5
309100SBrad.Beckmann@amd.com
319100SBrad.Beckmann@amd.comclass BaseTopology(object):
329100SBrad.Beckmann@amd.com    description = "BaseTopology"
339100SBrad.Beckmann@amd.com
349100SBrad.Beckmann@amd.com    def __init__(self):
359100SBrad.Beckmann@amd.com        """ When overriding place any objects created in
369100SBrad.Beckmann@amd.com            configs/ruby/<protocol>.py that are needed in
379100SBrad.Beckmann@amd.com            makeTopology (below) here. The minimum is usually
389100SBrad.Beckmann@amd.com            all of the controllers created in the above file.
399100SBrad.Beckmann@amd.com        """
409100SBrad.Beckmann@amd.com
419100SBrad.Beckmann@amd.com    def makeTopology(self, options, IntLink, ExtLink, Router):
429148Spowerjg@cs.wisc.edu        """ Called from configs/ruby/Ruby.py
439100SBrad.Beckmann@amd.com            The return value is ( list(Router), list(IntLink), list(ExtLink))
449100SBrad.Beckmann@amd.com            The API of this function cannot change when subclassing!!
459100SBrad.Beckmann@amd.com            Any additional information needed to create this topology should
469100SBrad.Beckmann@amd.com            be passed into the constructor when it's instantiated in
479100SBrad.Beckmann@amd.com            configs/ruby/<protocol>.py
489100SBrad.Beckmann@amd.com        """
499148Spowerjg@cs.wisc.edu        m5.util.fatal("BaseTopology should have been overridden!!")
509100SBrad.Beckmann@amd.com
519148Spowerjg@cs.wisc.educlass SimpleTopology(BaseTopology):
529148Spowerjg@cs.wisc.edu    """ Provides methods needed for the topologies included in Ruby before
539148Spowerjg@cs.wisc.edu        topology changes.
549148Spowerjg@cs.wisc.edu        These topologies are "simple" in the sense that they only use a flat
559148Spowerjg@cs.wisc.edu        list of controllers to construct the topology.
569148Spowerjg@cs.wisc.edu    """
579148Spowerjg@cs.wisc.edu    description = "SimpleTopology"
589148Spowerjg@cs.wisc.edu
599148Spowerjg@cs.wisc.edu    def __init__(self, controllers):
609148Spowerjg@cs.wisc.edu        self.nodes = controllers
619148Spowerjg@cs.wisc.edu
629148Spowerjg@cs.wisc.edu    def addController(self, controller):
639148Spowerjg@cs.wisc.edu        self.nodes.append(controller)
649148Spowerjg@cs.wisc.edu
659148Spowerjg@cs.wisc.edu    def __len__(self):
669148Spowerjg@cs.wisc.edu        return len(self.nodes)
67