Network.cc revision 7904
1451SN/A/* 25795Ssaidi@eecs.umich.edu * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3451SN/A * All rights reserved. 4451SN/A * 5451SN/A * Redistribution and use in source and binary forms, with or without 6451SN/A * modification, are permitted provided that the following conditions are 7451SN/A * met: redistributions of source code must retain the above copyright 8451SN/A * notice, this list of conditions and the following disclaimer; 9451SN/A * redistributions in binary form must reproduce the above copyright 10451SN/A * notice, this list of conditions and the following disclaimer in the 11451SN/A * documentation and/or other materials provided with the distribution; 12451SN/A * neither the name of the copyright holders nor the names of its 13451SN/A * contributors may be used to endorse or promote products derived from 14451SN/A * this software without specific prior written permission. 15451SN/A * 16451SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17451SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18451SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19451SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20451SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21451SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22451SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23451SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24451SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25451SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26451SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu */ 282665Ssaidi@eecs.umich.edu 29451SN/A#include "base/misc.hh" 30451SN/A#include "mem/protocol/MachineType.hh" 31451SN/A#include "mem/ruby/network/Network.hh" 32451SN/A#include "mem/ruby/network/simple/Topology.hh" 336215Snate@binkert.org 346215Snate@binkert.orgNetwork::Network(const Params *p) 352093SN/A : SimObject(p) 362093SN/A{ 372093SN/A m_virtual_networks = p->number_of_virtual_networks; 38451SN/A m_topology_ptr = p->topology; 39451SN/A m_buffer_size = p->buffer_size; 40451SN/A m_endpoint_bandwidth = p->endpoint_bandwidth; 412093SN/A m_adaptive_routing = p->adaptive_routing; 422093SN/A m_link_latency = p->link_latency; 435795Ssaidi@eecs.umich.edu m_control_msg_size = p->control_msg_size; 442093SN/A 453113Sgblack@eecs.umich.edu // Total nodes/controllers in network 462423SN/A // Must make sure this is called after the State Machine constructors 475795Ssaidi@eecs.umich.edu m_nodes = MachineType_base_number(MachineType_NUM); 485795Ssaidi@eecs.umich.edu assert(m_nodes != 0); 495795Ssaidi@eecs.umich.edu 502093SN/A assert(m_virtual_networks != 0); 512093SN/A assert(m_topology_ptr != NULL); 522093SN/A 532093SN/A // Initialize the controller's network pointers 542093SN/A m_topology_ptr->initNetworkPtr(this); 553113Sgblack@eecs.umich.edu} 563113Sgblack@eecs.umich.edu 572093SN/Avoid 582093SN/ANetwork::init() 592093SN/A{ 602093SN/A m_data_msg_size = RubySystem::getBlockSizeBytes() + m_control_msg_size; 612093SN/A} 623122Sgblack@eecs.umich.edu 632093SN/Aint 642093SN/ANetwork::MessageSizeType_to_int(MessageSizeType size_type) 652093SN/A{ 663122Sgblack@eecs.umich.edu switch(size_type) { 672093SN/A case MessageSizeType_Undefined: 682093SN/A panic("Can't convert Undefined MessageSizeType to integer"); 692093SN/A break; 703113Sgblack@eecs.umich.edu case MessageSizeType_Control: 713113Sgblack@eecs.umich.edu case MessageSizeType_Request_Control: 723113Sgblack@eecs.umich.edu case MessageSizeType_Reissue_Control: 735543Ssaidi@eecs.umich.edu case MessageSizeType_Response_Control: 745543Ssaidi@eecs.umich.edu case MessageSizeType_Writeback_Control: 755543Ssaidi@eecs.umich.edu case MessageSizeType_Broadcast_Control: 765543Ssaidi@eecs.umich.edu case MessageSizeType_Multicast_Control: 775543Ssaidi@eecs.umich.edu case MessageSizeType_Forwarded_Control: 785543Ssaidi@eecs.umich.edu case MessageSizeType_Invalidate_Control: 795543Ssaidi@eecs.umich.edu case MessageSizeType_Unblock_Control: 805543Ssaidi@eecs.umich.edu case MessageSizeType_Persistent_Control: 815543Ssaidi@eecs.umich.edu case MessageSizeType_Completion_Control: 825543Ssaidi@eecs.umich.edu return m_control_msg_size; 835543Ssaidi@eecs.umich.edu case MessageSizeType_Data: 845543Ssaidi@eecs.umich.edu case MessageSizeType_Response_Data: 855543Ssaidi@eecs.umich.edu case MessageSizeType_ResponseLocal_Data: 865543Ssaidi@eecs.umich.edu case MessageSizeType_ResponseL2hit_Data: 875543Ssaidi@eecs.umich.edu case MessageSizeType_Writeback_Data: 885543Ssaidi@eecs.umich.edu return m_data_msg_size; 893113Sgblack@eecs.umich.edu default: 902093SN/A panic("Invalid range for type MessageSizeType"); 912093SN/A break; 923113Sgblack@eecs.umich.edu } 935543Ssaidi@eecs.umich.edu} 945543Ssaidi@eecs.umich.edu 955543Ssaidi@eecs.umich.educonst std::vector<Throttle*>* 965543Ssaidi@eecs.umich.eduNetwork::getThrottles(NodeID id) const 975543Ssaidi@eecs.umich.edu{ 982093SN/A return NULL; 995543Ssaidi@eecs.umich.edu} 1005543Ssaidi@eecs.umich.edu