Network.cc revision 9465
16700Snate@binkert.org/*
26700Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
36700Snate@binkert.org * All rights reserved.
46700Snate@binkert.org *
56700Snate@binkert.org * Redistribution and use in source and binary forms, with or without
66700Snate@binkert.org * modification, are permitted provided that the following conditions are
76700Snate@binkert.org * met: redistributions of source code must retain the above copyright
86700Snate@binkert.org * notice, this list of conditions and the following disclaimer;
96700Snate@binkert.org * redistributions in binary form must reproduce the above copyright
106700Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
116700Snate@binkert.org * documentation and/or other materials provided with the distribution;
126700Snate@binkert.org * neither the name of the copyright holders nor the names of its
136700Snate@binkert.org * contributors may be used to endorse or promote products derived from
146700Snate@binkert.org * this software without specific prior written permission.
156700Snate@binkert.org *
166700Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176700Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186700Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196700Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206700Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216700Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226700Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236700Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246700Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256700Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266700Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276700Snate@binkert.org */
286285Snate@binkert.org
297805Snilay@cs.wisc.edu#include "base/misc.hh"
306285Snate@binkert.org#include "mem/protocol/MachineType.hh"
316285Snate@binkert.org#include "mem/ruby/network/Network.hh"
328255SBrad.Beckmann@amd.com#include "mem/ruby/network/Topology.hh"
338645Snilay@cs.wisc.edu#include "mem/ruby/system/System.hh"
346285Snate@binkert.org
359275Snilay@cs.wisc.eduuint32_t Network::m_virtual_networks;
369275Snilay@cs.wisc.eduuint32_t Network::m_control_msg_size;
379275Snilay@cs.wisc.eduuint32_t Network::m_data_msg_size;
389275Snilay@cs.wisc.edu
396876Ssteve.reinhardt@amd.comNetwork::Network(const Params *p)
409465Snilay@cs.wisc.edu    : ClockedObject(p)
416285Snate@binkert.org{
426876Ssteve.reinhardt@amd.com    m_virtual_networks = p->number_of_virtual_networks;
436876Ssteve.reinhardt@amd.com    m_topology_ptr = p->topology;
446876Ssteve.reinhardt@amd.com    m_control_msg_size = p->control_msg_size;
456876Ssteve.reinhardt@amd.com
466881SBrad.Beckmann@amd.com    // Total nodes/controllers in network
476881SBrad.Beckmann@amd.com    // Must make sure this is called after the State Machine constructors
487054Snate@binkert.org    m_nodes = MachineType_base_number(MachineType_NUM);
496881SBrad.Beckmann@amd.com    assert(m_nodes != 0);
506881SBrad.Beckmann@amd.com
516876Ssteve.reinhardt@amd.com    assert(m_virtual_networks != 0);
526876Ssteve.reinhardt@amd.com    assert(m_topology_ptr != NULL);
536881SBrad.Beckmann@amd.com
546881SBrad.Beckmann@amd.com    // Initialize the controller's network pointers
556881SBrad.Beckmann@amd.com    m_topology_ptr->initNetworkPtr(this);
568436SBrad.Beckmann@amd.com    p->ruby_system->registerNetwork(this);
576285Snate@binkert.org}
586285Snate@binkert.org
597054Snate@binkert.orgvoid
607054Snate@binkert.orgNetwork::init()
616285Snate@binkert.org{
627054Snate@binkert.org    m_data_msg_size = RubySystem::getBlockSizeBytes() + m_control_msg_size;
636285Snate@binkert.org}
646493STushar.Krishna@amd.com
659275Snilay@cs.wisc.eduuint32_t
667054Snate@binkert.orgNetwork::MessageSizeType_to_int(MessageSizeType size_type)
676493STushar.Krishna@amd.com{
687054Snate@binkert.org    switch(size_type) {
697054Snate@binkert.org      case MessageSizeType_Undefined:
707805Snilay@cs.wisc.edu        panic("Can't convert Undefined MessageSizeType to integer");
717054Snate@binkert.org        break;
727054Snate@binkert.org      case MessageSizeType_Control:
737054Snate@binkert.org      case MessageSizeType_Request_Control:
747054Snate@binkert.org      case MessageSizeType_Reissue_Control:
757054Snate@binkert.org      case MessageSizeType_Response_Control:
767054Snate@binkert.org      case MessageSizeType_Writeback_Control:
777548SBrad.Beckmann@amd.com      case MessageSizeType_Broadcast_Control:
787904SBrad.Beckmann@amd.com      case MessageSizeType_Multicast_Control:
797054Snate@binkert.org      case MessageSizeType_Forwarded_Control:
807054Snate@binkert.org      case MessageSizeType_Invalidate_Control:
817054Snate@binkert.org      case MessageSizeType_Unblock_Control:
827054Snate@binkert.org      case MessageSizeType_Persistent_Control:
837054Snate@binkert.org      case MessageSizeType_Completion_Control:
847054Snate@binkert.org        return m_control_msg_size;
857054Snate@binkert.org      case MessageSizeType_Data:
867054Snate@binkert.org      case MessageSizeType_Response_Data:
877054Snate@binkert.org      case MessageSizeType_ResponseLocal_Data:
887054Snate@binkert.org      case MessageSizeType_ResponseL2hit_Data:
897054Snate@binkert.org      case MessageSizeType_Writeback_Data:
907054Snate@binkert.org        return m_data_msg_size;
917054Snate@binkert.org      default:
927805Snilay@cs.wisc.edu        panic("Invalid range for type MessageSizeType");
937054Snate@binkert.org        break;
947054Snate@binkert.org    }
956493STushar.Krishna@amd.com}
967054Snate@binkert.org
977454Snate@binkert.orgconst std::vector<Throttle*>*
987054Snate@binkert.orgNetwork::getThrottles(NodeID id) const
997054Snate@binkert.org{
1007054Snate@binkert.org    return NULL;
1017054Snate@binkert.org}
102