Network.cc revision 6881:5a61a8a9009a
12623SN/A/* 28926Sandreas.hansson@arm.com * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 38926Sandreas.hansson@arm.com * All rights reserved. 48926Sandreas.hansson@arm.com * 58926Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without 68926Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are 78926Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright 88926Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer; 98926Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright 108926Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the 118926Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution; 128926Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its 138926Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from 142623SN/A * this software without specific prior written permission. 152623SN/A * 162623SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172623SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182623SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192623SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202623SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212623SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222623SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232623SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242623SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252623SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262623SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272623SN/A */ 282623SN/A 292623SN/A#include "mem/protocol/MachineType.hh" 302623SN/A#include "mem/ruby/network/Network.hh" 312623SN/A#include "mem/ruby/network/simple/Topology.hh" 322623SN/A 332623SN/ANetwork::Network(const Params *p) 342623SN/A : SimObject(p) 352623SN/A{ 362623SN/A m_virtual_networks = p->number_of_virtual_networks; 372623SN/A m_topology_ptr = p->topology; 382623SN/A m_buffer_size = p->buffer_size; 392665Ssaidi@eecs.umich.edu m_endpoint_bandwidth = p->endpoint_bandwidth; 402665Ssaidi@eecs.umich.edu m_adaptive_routing = p->adaptive_routing; 412623SN/A m_link_latency = p->link_latency; 422623SN/A m_control_msg_size = p->control_msg_size; 433170Sstever@eecs.umich.edu 448105Sgblack@eecs.umich.edu // 452623SN/A // Total nodes/controllers in network 464040Ssaidi@eecs.umich.edu // Must make sure this is called after the State Machine constructors 479647Sdam.sunwoo@arm.com // 486658Snate@binkert.org m_nodes = MachineType_base_number(MachineType_NUM); 498229Snate@binkert.org assert(m_nodes != 0); 502623SN/A 519443SAndreas.Sandberg@ARM.com assert(m_virtual_networks != 0); 528232Snate@binkert.org assert(m_topology_ptr != NULL); 538232Snate@binkert.org 543348Sbinkertn@umich.edu // 553348Sbinkertn@umich.edu // Initialize the controller's network pointers 568926Sandreas.hansson@arm.com // 574762Snate@binkert.org m_topology_ptr->initNetworkPtr(this); 587678Sgblack@eecs.umich.edu} 592901Ssaidi@eecs.umich.edu 608779Sgblack@eecs.umich.eduvoid Network::init() 612623SN/A{ 622623SN/A m_data_msg_size = RubySystem::getBlockSizeBytes() + m_control_msg_size; 632623SN/A} 642623SN/A 652623SN/Aint Network::MessageSizeType_to_int(MessageSizeType size_type) 665606Snate@binkert.org{ 672623SN/A switch(size_type) { 682623SN/A case MessageSizeType_Undefined: 692623SN/A ERROR_MSG("Can't convert Undefined MessageSizeType to integer"); 702623SN/A break; 712623SN/A case MessageSizeType_Control: 722623SN/A case MessageSizeType_Request_Control: 732623SN/A case MessageSizeType_Reissue_Control: 742623SN/A case MessageSizeType_Response_Control: 752623SN/A case MessageSizeType_Writeback_Control: 762623SN/A case MessageSizeType_Forwarded_Control: 772623SN/A case MessageSizeType_Invalidate_Control: 785336Shines@cs.fsu.edu case MessageSizeType_Unblock_Control: 792623SN/A case MessageSizeType_Persistent_Control: 804873Sstever@eecs.umich.edu case MessageSizeType_Completion_Control: 812623SN/A return m_control_msg_size; 822623SN/A break; 832623SN/A case MessageSizeType_Data: 842623SN/A case MessageSizeType_Response_Data: 852623SN/A case MessageSizeType_ResponseLocal_Data: 862623SN/A case MessageSizeType_ResponseL2hit_Data: 878921Sandreas.hansson@arm.com case MessageSizeType_Writeback_Data: 888921Sandreas.hansson@arm.com return m_data_msg_size; 898921Sandreas.hansson@arm.com break; 908921Sandreas.hansson@arm.com default: 919433SAndreas.Sandberg@ARM.com ERROR_MSG("Invalid range for type MessageSizeType"); 928779Sgblack@eecs.umich.edu break; 938779Sgblack@eecs.umich.edu } 948779Sgblack@eecs.umich.edu return 0; 958779Sgblack@eecs.umich.edu} 968779Sgblack@eecs.umich.edu