Network.hh revision 9302
17735SN/A/* 27735SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 37735SN/A * All rights reserved. 49988Snilay@cs.wisc.edu * 58835SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without 69988Snilay@cs.wisc.edu * modification, are permitted provided that the following conditions are 77935SN/A * met: redistributions of source code must retain the above copyright 87935SN/A * notice, this list of conditions and the following disclaimer; 97935SN/A * redistributions in binary form must reproduce the above copyright 107735SN/A * notice, this list of conditions and the following disclaimer in the 117735SN/A * documentation and/or other materials provided with the distribution; 127735SN/A * neither the name of the copyright holders nor the names of its 1310315Snilay@cs.wisc.edu * contributors may be used to endorse or promote products derived from 1410513SAli.Saidi@ARM.com * this software without specific prior written permission. 1511239Sandreas.sandberg@arm.com * 1610513SAli.Saidi@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179885Sstever@gmail.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189885Sstever@gmail.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1911239Sandreas.sandberg@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209055Ssaidi@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219449SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229988Snilay@cs.wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2310513SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2410513SAli.Saidi@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2510038SAli.Saidi@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2610038SAli.Saidi@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2710038SAli.Saidi@ARM.com */ 2810038SAli.Saidi@ARM.com 2910038SAli.Saidi@ARM.com/* 307735SN/A * The Network class is the base class for classes that implement the 3111239Sandreas.sandberg@arm.com * interconnection network between components (processor/cache 3210315Snilay@cs.wisc.edu * components and memory/directory components). The interconnection 337735SN/A * network as described here is not a physical network, but a 3410513SAli.Saidi@ARM.com * programming concept used to implement all communication between 3510513SAli.Saidi@ARM.com * components. Thus parts of this 'network' will model the on-chip 367735SN/A * connections between cache controllers and directory controllers as 3710513SAli.Saidi@ARM.com * well as the links between chip and network switches. 3810636Snilay@cs.wisc.edu */ 3910736Snilay@cs.wisc.edu 409079SAli.Saidi@ARM.com#ifndef __MEM_RUBY_NETWORK_NETWORK_HH__ 4111219Snilay@cs.wisc.edu#define __MEM_RUBY_NETWORK_NETWORK_HH__ 428721SN/A 439885Sstever@gmail.com#include <iostream> 449885Sstever@gmail.com#include <string> 4510038SAli.Saidi@ARM.com#include <vector> 4611239Sandreas.sandberg@arm.com 4710038SAli.Saidi@ARM.com#include "mem/packet.hh" 487735SN/A#include "mem/protocol/LinkDirection.hh" 497935SN/A#include "mem/protocol/MessageSizeType.hh" 507935SN/A#include "mem/ruby/common/TypeDefines.hh" 517935SN/A#include "params/RubyNetwork.hh" 527935SN/A#include "sim/sim_object.hh" 537935SN/A 547935SN/Aclass NetDest; 557935SN/Aclass MessageBuffer; 5610513SAli.Saidi@ARM.comclass Throttle; 577735SN/Aclass Topology; 587735SN/A 597735SN/Aclass Network : public SimObject 609885Sstever@gmail.com{ 617735SN/A public: 629988Snilay@cs.wisc.edu typedef RubyNetworkParams Params; 6310513SAli.Saidi@ARM.com Network(const Params *p); 648721SN/A virtual ~Network() {} 658721SN/A 668891SAli.Saidi@ARM.com virtual void init(); 678891SAli.Saidi@ARM.com 687735SN/A static int getNumberOfVirtualNetworks() { return m_virtual_networks; } 698528SN/A static uint32_t MessageSizeType_to_int(MessageSizeType size_type); 708528SN/A 718528SN/A // returns the queue requested for the given component 728528SN/A virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered, 738528SN/A int netNumber, std::string vnet_type) = 0; 749988Snilay@cs.wisc.edu virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, 758528SN/A int netNumber, std::string vnet_type) = 0; 768528SN/A virtual const std::vector<Throttle*>* getThrottles(NodeID id) const; 778528SN/A virtual int getNumNodes() {return 1;} 788528SN/A 798528SN/A virtual void makeOutLink(SwitchID src, NodeID dest, BasicLink* link, 808528SN/A LinkDirection direction, 819988Snilay@cs.wisc.edu const NetDest& routing_table_entry, 828528SN/A bool isReconfiguration) = 0; 838528SN/A virtual void makeInLink(NodeID src, SwitchID dest, BasicLink* link, 848528SN/A LinkDirection direction, 858528SN/A const NetDest& routing_table_entry, 868528SN/A bool isReconfiguration) = 0; 878528SN/A virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link, 889988Snilay@cs.wisc.edu LinkDirection direction, 8911239Sandreas.sandberg@arm.com const NetDest& routing_table_entry, 908528SN/A bool isReconfiguration) = 0; 918528SN/A 929885Sstever@gmail.com virtual void reset() = 0; 939885Sstever@gmail.com 949885Sstever@gmail.com virtual void printStats(std::ostream& out) const = 0; 9510315Snilay@cs.wisc.edu virtual void clearStats() = 0; 969988Snilay@cs.wisc.edu virtual void print(std::ostream& out) const = 0; 9710315Snilay@cs.wisc.edu 989885Sstever@gmail.com /* 999885Sstever@gmail.com * Virtual functions for functionally reading and writing packets in 1007735SN/A * the network. Each network needs to implement these for functional 1017735SN/A * accesses to work correctly. 10210038SAli.Saidi@ARM.com */ 10310315Snilay@cs.wisc.edu virtual bool functionalRead(Packet *pkt) 1047735SN/A { fatal("Functional read not implemented.\n"); } 1059885Sstever@gmail.com virtual uint32_t functionalWrite(Packet *pkt) 1067735SN/A { fatal("Functional write not implemented.\n"); } 1077735SN/A 1087735SN/A protected: 1097735SN/A // Private copy constructor and assignment operator 11010038SAli.Saidi@ARM.com Network(const Network& obj); 1117735SN/A Network& operator=(const Network& obj); 1129988Snilay@cs.wisc.edu 1137735SN/A protected: 1147735SN/A const std::string m_name; 1157735SN/A int m_nodes; 1169449SAli.Saidi@ARM.com static uint32_t m_virtual_networks; 11710038SAli.Saidi@ARM.com Topology* m_topology_ptr; 1187735SN/A static uint32_t m_control_msg_size; 1197735SN/A static uint32_t m_data_msg_size; 1207735SN/A}; 1217735SN/A 1227735SN/Ainline std::ostream& 1237735SN/Aoperator<<(std::ostream& out, const Network& obj) 1247735SN/A{ 1257735SN/A obj.print(out); 1269885Sstever@gmail.com out << std::flush; 12710315Snilay@cs.wisc.edu return out; 1289449SAli.Saidi@ARM.com} 1297735SN/A 1307735SN/A#endif // __MEM_RUBY_NETWORK_NETWORK_HH__ 1318835SAli.Saidi@ARM.com