Network.hh revision 6285
16145Snate@binkert.org 26145Snate@binkert.org/* 36145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 46145Snate@binkert.org * All rights reserved. 56145Snate@binkert.org * 66145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 76145Snate@binkert.org * modification, are permitted provided that the following conditions are 86145Snate@binkert.org * met: redistributions of source code must retain the above copyright 96145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 106145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 116145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 126145Snate@binkert.org * documentation and/or other materials provided with the distribution; 136145Snate@binkert.org * neither the name of the copyright holders nor the names of its 146145Snate@binkert.org * contributors may be used to endorse or promote products derived from 156145Snate@binkert.org * this software without specific prior written permission. 166145Snate@binkert.org * 176145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286145Snate@binkert.org */ 296145Snate@binkert.org 306145Snate@binkert.org/* 316284Snate@binkert.org * Network.hh 326145Snate@binkert.org * 336145Snate@binkert.org * Description: The Network class is the base class for classes that 346145Snate@binkert.org * implement the interconnection network between components 356145Snate@binkert.org * (processor/cache components and memory/directory components). The 366145Snate@binkert.org * interconnection network as described here is not a physical 376145Snate@binkert.org * network, but a programming concept used to implement all 386145Snate@binkert.org * communication between components. Thus parts of this 'network' 396145Snate@binkert.org * will model the on-chip connections between cache controllers and 406145Snate@binkert.org * directory controllers as well as the links between chip and network 416145Snate@binkert.org * switches. 426145Snate@binkert.org * 436145Snate@binkert.org * $Id$ 446145Snate@binkert.org * */ 456145Snate@binkert.org 466145Snate@binkert.org#ifndef NETWORK_H 476145Snate@binkert.org#define NETWORK_H 486145Snate@binkert.org 496154Snate@binkert.org#include "mem/ruby/common/Global.hh" 506154Snate@binkert.org#include "mem/ruby/system/NodeID.hh" 516154Snate@binkert.org#include "mem/protocol/MessageSizeType.hh" 526285Snate@binkert.org#include "mem/ruby/system/System.hh" 536285Snate@binkert.org#include "mem/ruby/config/RubyConfig.hh" 546145Snate@binkert.org 556145Snate@binkert.orgclass NetDest; 566145Snate@binkert.orgclass MessageBuffer; 576145Snate@binkert.orgclass Throttle; 586285Snate@binkert.orgclass Topology; 596145Snate@binkert.org 606145Snate@binkert.orgclass Network { 616145Snate@binkert.orgpublic: 626145Snate@binkert.org // Constructors 636285Snate@binkert.org Network(const string & name); 646285Snate@binkert.org virtual void init(const vector<string> & argv); 656145Snate@binkert.org 666145Snate@binkert.org // Destructor 676145Snate@binkert.org virtual ~Network() {} 686145Snate@binkert.org 696145Snate@binkert.org // Public Methods 706285Snate@binkert.org int getBufferSize() { return m_buffer_size; } 716285Snate@binkert.org int getNumberOfVirtualNetworks() { return m_virtual_networks; } 726285Snate@binkert.org int getEndpointBandwidth() { return m_endpoint_bandwidth; } 736285Snate@binkert.org bool getAdaptiveRouting() {return m_adaptive_routing; } 746285Snate@binkert.org int getLinkLatency() { return m_link_latency; } 756145Snate@binkert.org 766145Snate@binkert.org // returns the queue requested for the given component 776145Snate@binkert.org virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered, int netNumber) = 0; 786145Snate@binkert.org virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int netNumber) = 0; 796145Snate@binkert.org virtual const Vector<Throttle*>* getThrottles(NodeID id) const { return NULL; } 806145Snate@binkert.org 816145Snate@binkert.org virtual int getNumNodes() {return 1;} 826145Snate@binkert.org 836145Snate@binkert.org virtual void makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0; 846145Snate@binkert.org virtual void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration) = 0; 856145Snate@binkert.org virtual void makeInternalLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0; 866145Snate@binkert.org 876145Snate@binkert.org virtual void reset() = 0; 886145Snate@binkert.org 896145Snate@binkert.org virtual void printStats(ostream& out) const = 0; 906145Snate@binkert.org virtual void clearStats() = 0; 916145Snate@binkert.org virtual void printConfig(ostream& out) const = 0; 926145Snate@binkert.org virtual void print(ostream& out) const = 0; 936145Snate@binkert.org 946285Snate@binkert.orgprotected: 956145Snate@binkert.org 966145Snate@binkert.org // Private Methods 976145Snate@binkert.org // Private copy constructor and assignment operator 986145Snate@binkert.org Network(const Network& obj); 996145Snate@binkert.org Network& operator=(const Network& obj); 1006145Snate@binkert.org 1016145Snate@binkert.org // Data Members (m_ prefix) 1026285Snate@binkert.orgprotected: 1036285Snate@binkert.org const string m_name; 1046285Snate@binkert.org int m_nodes; 1056285Snate@binkert.org int m_virtual_networks; 1066285Snate@binkert.org int m_buffer_size; 1076285Snate@binkert.org int m_endpoint_bandwidth; 1086285Snate@binkert.org Topology* m_topology_ptr; 1096285Snate@binkert.org bool m_adaptive_routing; 1106285Snate@binkert.org int m_link_latency; 1116145Snate@binkert.org}; 1126145Snate@binkert.org 1136145Snate@binkert.org// Output operator declaration 1146145Snate@binkert.orgostream& operator<<(ostream& out, const Network& obj); 1156145Snate@binkert.org 1166145Snate@binkert.org// ******************* Definitions ******************* 1176145Snate@binkert.org 1186145Snate@binkert.org// Output operator definition 1196145Snate@binkert.orgextern inline 1206145Snate@binkert.orgostream& operator<<(ostream& out, const Network& obj) 1216145Snate@binkert.org{ 1226145Snate@binkert.org obj.print(out); 1236145Snate@binkert.org out << flush; 1246145Snate@binkert.org return out; 1256145Snate@binkert.org} 1266145Snate@binkert.org 1276145Snate@binkert.org// Code to map network message size types to an integer number of bytes 1286145Snate@binkert.orgconst int CONTROL_MESSAGE_SIZE = 8; 1296285Snate@binkert.orgconst int DATA_MESSAGE_SIZE = (RubySystem::getBlockSizeBytes()+8); 1306145Snate@binkert.org 1316145Snate@binkert.orgextern inline 1326145Snate@binkert.orgint MessageSizeType_to_int(MessageSizeType size_type) 1336145Snate@binkert.org{ 1346145Snate@binkert.org switch(size_type) { 1356145Snate@binkert.org case MessageSizeType_Undefined: 1366145Snate@binkert.org ERROR_MSG("Can't convert Undefined MessageSizeType to integer"); 1376145Snate@binkert.org break; 1386145Snate@binkert.org case MessageSizeType_Control: 1396145Snate@binkert.org case MessageSizeType_Request_Control: 1406145Snate@binkert.org case MessageSizeType_Reissue_Control: 1416145Snate@binkert.org case MessageSizeType_Response_Control: 1426145Snate@binkert.org case MessageSizeType_Writeback_Control: 1436145Snate@binkert.org case MessageSizeType_Forwarded_Control: 1446145Snate@binkert.org case MessageSizeType_Invalidate_Control: 1456145Snate@binkert.org case MessageSizeType_Unblock_Control: 1466145Snate@binkert.org case MessageSizeType_Persistent_Control: 1476145Snate@binkert.org case MessageSizeType_Completion_Control: 1486145Snate@binkert.org return CONTROL_MESSAGE_SIZE; 1496145Snate@binkert.org break; 1506145Snate@binkert.org case MessageSizeType_Data: 1516145Snate@binkert.org case MessageSizeType_Response_Data: 1526145Snate@binkert.org case MessageSizeType_ResponseLocal_Data: 1536145Snate@binkert.org case MessageSizeType_ResponseL2hit_Data: 1546145Snate@binkert.org case MessageSizeType_Writeback_Data: 1556145Snate@binkert.org return DATA_MESSAGE_SIZE; 1566145Snate@binkert.org break; 1576145Snate@binkert.org default: 1586145Snate@binkert.org ERROR_MSG("Invalid range for type MessageSizeType"); 1596145Snate@binkert.org break; 1606145Snate@binkert.org } 1616145Snate@binkert.org return 0; 1626145Snate@binkert.org} 1636145Snate@binkert.org 1646145Snate@binkert.org#endif //NETWORK_H 165