Network.hh revision 11663:cf870cd20cfc
16899SN/A/* 28851Sandreas.hansson@arm.com * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 38851Sandreas.hansson@arm.com * All rights reserved. 48851Sandreas.hansson@arm.com * 58851Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without 68851Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are 78851Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright 88851Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer; 98851Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright 108851Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the 118851Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution; 128851Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its 138851Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from 146899SN/A * this software without specific prior written permission. 157553SN/A * 166899SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176899SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186899SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196899SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206899SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216899SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226899SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236899SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246899SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256899SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266899SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276899SN/A */ 286899SN/A 296899SN/A/* 306899SN/A * The Network class is the base class for classes that implement the 316899SN/A * interconnection network between components (processor/cache 326899SN/A * components and memory/directory components). The interconnection 336899SN/A * network as described here is not a physical network, but a 346899SN/A * programming concept used to implement all communication between 356899SN/A * components. Thus parts of this 'network' will model the on-chip 366899SN/A * connections between cache controllers and directory controllers as 376899SN/A * well as the links between chip and network switches. 386899SN/A */ 396899SN/A 406899SN/A#ifndef __MEM_RUBY_NETWORK_NETWORK_HH__ 416899SN/A#define __MEM_RUBY_NETWORK_NETWORK_HH__ 4211793Sbrandon.potter@amd.com 4311793Sbrandon.potter@amd.com#include <iostream> 4411800Sbrandon.potter@amd.com#include <string> 457632SBrad.Beckmann@amd.com#include <vector> 468232Snate@binkert.org 476899SN/A#include "mem/protocol/LinkDirection.hh" 486899SN/A#include "mem/protocol/MessageSizeType.hh" 497553SN/A#include "mem/ruby/common/TypeDefines.hh" 5012129Sspwilson2@wisc.edu#include "mem/ruby/network/Topology.hh" 5112129Sspwilson2@wisc.edu#include "mem/packet.hh" 5212129Sspwilson2@wisc.edu#include "params/RubyNetwork.hh" 537553SN/A#include "sim/clocked_object.hh" 547553SN/A 556899SN/Aclass NetDest; 567553SN/Aclass MessageBuffer; 576899SN/A 588851Sandreas.hansson@arm.comclass Network : public ClockedObject 598851Sandreas.hansson@arm.com{ 608851Sandreas.hansson@arm.com public: 618851Sandreas.hansson@arm.com typedef RubyNetworkParams Params; 628851Sandreas.hansson@arm.com Network(const Params *p); 638851Sandreas.hansson@arm.com const Params * params() const 647053SN/A { return dynamic_cast<const Params *>(_params); } 657553SN/A 666899SN/A virtual ~Network(); 676899SN/A virtual void init(); 687553SN/A 696899SN/A static uint32_t getNumberOfVirtualNetworks() { return m_virtual_networks; } 707053SN/A int getNumNodes() const { return m_nodes; } 717053SN/A 726899SN/A static uint32_t MessageSizeType_to_int(MessageSizeType size_type); 736899SN/A 747053SN/A // returns the queue requested for the given component 757553SN/A void setToNetQueue(NodeID id, bool ordered, int netNumber, 766899SN/A std::string vnet_type, MessageBuffer *b); 777053SN/A virtual void setFromNetQueue(NodeID id, bool ordered, int netNumber, 787553SN/A std::string vnet_type, MessageBuffer *b); 796899SN/A 806899SN/A virtual void checkNetworkAllocation(NodeID id, bool ordered, 8113784Sgabeblack@google.com int network_num, std::string vnet_type); 8213784Sgabeblack@google.com 836899SN/A virtual void makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link, 846899SN/A const NetDest& routing_table_entry) = 0; 858922Swilliam.wang@arm.com virtual void makeExtInLink(NodeID src, SwitchID dest, BasicLink* link, 8613784Sgabeblack@google.com const NetDest& routing_table_entry) = 0; 878922Swilliam.wang@arm.com virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link, 888922Swilliam.wang@arm.com const NetDest& routing_table_entry) = 0; 8913784Sgabeblack@google.com 908922Swilliam.wang@arm.com virtual void collateStats() = 0; 918922Swilliam.wang@arm.com virtual void print(std::ostream& out) const = 0; 928922Swilliam.wang@arm.com 936899SN/A /* 946899SN/A * Virtual functions for functionally reading and writing packets in 956899SN/A * the network. Each network needs to implement these for functional 966899SN/A * accesses to work correctly. 978975Sandreas.hansson@arm.com */ 986899SN/A virtual bool functionalRead(Packet *pkt) 998965Sandreas.hansson@arm.com { fatal("Functional read not implemented.\n"); } 10011320Ssteve.reinhardt@amd.com virtual uint32_t functionalWrite(Packet *pkt) 1017553SN/A { fatal("Functional write not implemented.\n"); } 1027553SN/A 1037553SN/A protected: 1047053SN/A // Private copy constructor and assignment operator 1057053SN/A Network(const Network& obj); 1066899SN/A Network& operator=(const Network& obj); 1076899SN/A 1088922Swilliam.wang@arm.com uint32_t m_nodes; 1097553SN/A static uint32_t m_virtual_networks; 1106899SN/A std::vector<std::string> m_vnet_type_names; 1117053SN/A Topology* m_topology_ptr; 1126899SN/A static uint32_t m_control_msg_size; 1137053SN/A static uint32_t m_data_msg_size; 1146899SN/A 1156899SN/A // vector of queues from the components 1167053SN/A std::vector<std::vector<MessageBuffer*> > m_toNetQueues; 1177553SN/A std::vector<std::vector<MessageBuffer*> > m_fromNetQueues; 1186899SN/A std::vector<bool> m_ordered; 1197553SN/A 1207553SN/A private: 1217553SN/A //! Callback class used for collating statistics from all the 1227553SN/A //! controller of this type. 1236899SN/A class StatsCallback : public Callback 12411320Ssteve.reinhardt@amd.com { 1257823Ssteve.reinhardt@amd.com private: 1266899SN/A Network *ctr; 1276899SN/A 1287053SN/A public: 1297553SN/A virtual ~StatsCallback() {} 1307053SN/A 1317553SN/A StatsCallback(Network *_ctr) 1327553SN/A : ctr(_ctr) 1337823Ssteve.reinhardt@amd.com { 1347553SN/A } 1357053SN/A 1367553SN/A void process() {ctr->collateStats();} 1377053SN/A }; 1386899SN/A}; 1396899SN/A 1407553SN/Ainline std::ostream& 1417553SN/Aoperator<<(std::ostream& out, const Network& obj) 1426899SN/A{ 1437553SN/A obj.print(out); 1446899SN/A out << std::flush; 145 return out; 146} 147 148#endif // __MEM_RUBY_NETWORK_NETWORK_HH__ 149