SimpleNetwork.hh revision 9799
1955SN/A/* 2955SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 31762SN/A * All rights reserved. 4955SN/A * 5955SN/A * Redistribution and use in source and binary forms, with or without 6955SN/A * modification, are permitted provided that the following conditions are 7955SN/A * met: redistributions of source code must retain the above copyright 8955SN/A * notice, this list of conditions and the following disclaimer; 9955SN/A * redistributions in binary form must reproduce the above copyright 10955SN/A * notice, this list of conditions and the following disclaimer in the 11955SN/A * documentation and/or other materials provided with the distribution; 12955SN/A * neither the name of the copyright holders nor the names of its 13955SN/A * contributors may be used to endorse or promote products derived from 14955SN/A * this software without specific prior written permission. 15955SN/A * 16955SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17955SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18955SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19955SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20955SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21955SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22955SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23955SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24955SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25955SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26955SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27955SN/A */ 282665Ssaidi@eecs.umich.edu 294762Snate@binkert.org#ifndef __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ 30955SN/A#define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ 315522Snate@binkert.org 324762Snate@binkert.org#include <iostream> 335522Snate@binkert.org#include <vector> 34955SN/A 355522Snate@binkert.org#include "mem/ruby/common/Global.hh" 36955SN/A#include "mem/ruby/network/Network.hh" 375522Snate@binkert.org#include "params/SimpleNetwork.hh" 384202Sbinkertn@umich.edu#include "sim/sim_object.hh" 395742Snate@binkert.org 40955SN/Aclass NetDest; 414381Sbinkertn@umich.educlass MessageBuffer; 424381Sbinkertn@umich.educlass Throttle; 43955SN/Aclass Switch; 44955SN/Aclass Topology; 45955SN/A 464202Sbinkertn@umich.educlass SimpleNetwork : public Network 47955SN/A{ 484382Sbinkertn@umich.edu public: 494382Sbinkertn@umich.edu typedef SimpleNetworkParams Params; 504382Sbinkertn@umich.edu SimpleNetwork(const Params *p); 515517Snate@binkert.org ~SimpleNetwork(); 525517Snate@binkert.org 534762Snate@binkert.org void init(); 544762Snate@binkert.org 554762Snate@binkert.org int getBufferSize() { return m_buffer_size; } 564762Snate@binkert.org int getEndpointBandwidth() { return m_endpoint_bandwidth; } 574762Snate@binkert.org bool getAdaptiveRouting() {return m_adaptive_routing; } 584762Snate@binkert.org 594762Snate@binkert.org void printStats(std::ostream& out) const; 604762Snate@binkert.org void clearStats(); 614762Snate@binkert.org void reset(); 624762Snate@binkert.org 635522Snate@binkert.org // returns the queue requested for the given component 645604Snate@binkert.org MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num, std::string vnet_type); 655604Snate@binkert.org MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num, std::string vnet_type); 665604Snate@binkert.org virtual const std::vector<Throttle*>* getThrottles(NodeID id) const; 674762Snate@binkert.org 684762Snate@binkert.org bool isVNetOrdered(int vnet) { return m_ordered[vnet]; } 694762Snate@binkert.org bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; } 705522Snate@binkert.org 715522Snate@binkert.org int getNumNodes() {return m_nodes; } 725522Snate@binkert.org 735522Snate@binkert.org // Methods used by Topology to setup the network 745604Snate@binkert.org void makeOutLink(SwitchID src, NodeID dest, BasicLink* link, 755604Snate@binkert.org LinkDirection direction, 764762Snate@binkert.org const NetDest& routing_table_entry); 774762Snate@binkert.org void makeInLink(NodeID src, SwitchID dest, BasicLink* link, 784762Snate@binkert.org LinkDirection direction, 794762Snate@binkert.org const NetDest& routing_table_entry); 805522Snate@binkert.org void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link, 814762Snate@binkert.org LinkDirection direction, 824762Snate@binkert.org const NetDest& routing_table_entry); 835604Snate@binkert.org 845604Snate@binkert.org void print(std::ostream& out) const; 855604Snate@binkert.org 865604Snate@binkert.org bool functionalRead(Packet *pkt); 875604Snate@binkert.org uint32_t functionalWrite(Packet *pkt); 885604Snate@binkert.org 894762Snate@binkert.org private: 904762Snate@binkert.org void checkNetworkAllocation(NodeID id, bool ordered, int network_num); 914762Snate@binkert.org void addLink(SwitchID src, SwitchID dest, int link_latency); 924762Snate@binkert.org void makeLink(SwitchID src, SwitchID dest, 935604Snate@binkert.org const NetDest& routing_table_entry, int link_latency); 944762Snate@binkert.org SwitchID createSwitch(); 955522Snate@binkert.org void makeTopology(); 965522Snate@binkert.org void linkTopology(); 975522Snate@binkert.org 984762Snate@binkert.org // Private copy constructor and assignment operator 994382Sbinkertn@umich.edu SimpleNetwork(const SimpleNetwork& obj); 1004762Snate@binkert.org SimpleNetwork& operator=(const SimpleNetwork& obj); 1014382Sbinkertn@umich.edu 1025522Snate@binkert.org // vector of queues from the components 1034381Sbinkertn@umich.edu std::vector<std::vector<MessageBuffer*> > m_toNetQueues; 1045522Snate@binkert.org std::vector<std::vector<MessageBuffer*> > m_fromNetQueues; 1054762Snate@binkert.org 1064762Snate@binkert.org std::vector<bool> m_in_use; 1074762Snate@binkert.org std::vector<bool> m_ordered; 1085522Snate@binkert.org std::vector<Switch*> m_switch_ptr_vector; 1095522Snate@binkert.org std::vector<MessageBuffer*> m_buffers_to_free; 1105522Snate@binkert.org std::vector<Switch*> m_endpoint_switches; 1115522Snate@binkert.org 1125522Snate@binkert.org int m_buffer_size; 1135522Snate@binkert.org int m_endpoint_bandwidth; 1145522Snate@binkert.org bool m_adaptive_routing; 1155522Snate@binkert.org}; 1165522Snate@binkert.org 1174762Snate@binkert.orginline std::ostream& 1184762Snate@binkert.orgoperator<<(std::ostream& out, const SimpleNetwork& obj) 1194762Snate@binkert.org{ 1204762Snate@binkert.org obj.print(out); 1214762Snate@binkert.org out << std::flush; 1224762Snate@binkert.org return out; 1234762Snate@binkert.org} 1244762Snate@binkert.org 1254762Snate@binkert.org#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ 1264762Snate@binkert.org