Network.hh revision 6493
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"
536145Snate@binkert.org
546145Snate@binkert.orgclass NetDest;
556145Snate@binkert.orgclass MessageBuffer;
566145Snate@binkert.orgclass Throttle;
576285Snate@binkert.orgclass Topology;
586145Snate@binkert.org
596145Snate@binkert.orgclass Network {
606145Snate@binkert.orgpublic:
616145Snate@binkert.org  // Constructors
626285Snate@binkert.org  Network(const string & name);
636285Snate@binkert.org  virtual void init(const vector<string> & argv);
646145Snate@binkert.org
656145Snate@binkert.org  // Destructor
666145Snate@binkert.org  virtual ~Network() {}
676145Snate@binkert.org
686145Snate@binkert.org  // Public Methods
696285Snate@binkert.org  int getBufferSize() { return m_buffer_size; }
706285Snate@binkert.org  int getNumberOfVirtualNetworks() { return m_virtual_networks; }
716285Snate@binkert.org  int getEndpointBandwidth() { return m_endpoint_bandwidth; }
726285Snate@binkert.org  bool getAdaptiveRouting() {return m_adaptive_routing; }
736285Snate@binkert.org  int getLinkLatency() { return m_link_latency; }
746493STushar.Krishna@amd.com  int MessageSizeType_to_int(MessageSizeType size_type);
756493STushar.Krishna@amd.com
766145Snate@binkert.org
776145Snate@binkert.org  // returns the queue requested for the given component
786145Snate@binkert.org  virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered, int netNumber) = 0;
796145Snate@binkert.org  virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int netNumber) = 0;
806145Snate@binkert.org  virtual const Vector<Throttle*>* getThrottles(NodeID id) const { return NULL; }
816145Snate@binkert.org
826145Snate@binkert.org  virtual int getNumNodes() {return 1;}
836145Snate@binkert.org
846145Snate@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;
856145Snate@binkert.org  virtual void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration) = 0;
866145Snate@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;
876145Snate@binkert.org
886145Snate@binkert.org  virtual void reset() = 0;
896145Snate@binkert.org
906145Snate@binkert.org  virtual void printStats(ostream& out) const = 0;
916145Snate@binkert.org  virtual void clearStats() = 0;
926145Snate@binkert.org  virtual void printConfig(ostream& out) const = 0;
936145Snate@binkert.org  virtual void print(ostream& out) const = 0;
946145Snate@binkert.org
956285Snate@binkert.orgprotected:
966145Snate@binkert.org
976145Snate@binkert.org  // Private Methods
986145Snate@binkert.org  // Private copy constructor and assignment operator
996145Snate@binkert.org  Network(const Network& obj);
1006145Snate@binkert.org  Network& operator=(const Network& obj);
1016145Snate@binkert.org
1026145Snate@binkert.org  // Data Members (m_ prefix)
1036285Snate@binkert.orgprotected:
1046285Snate@binkert.org  const string m_name;
1056285Snate@binkert.org  int m_nodes;
1066285Snate@binkert.org  int m_virtual_networks;
1076285Snate@binkert.org  int m_buffer_size;
1086285Snate@binkert.org  int m_endpoint_bandwidth;
1096285Snate@binkert.org  Topology* m_topology_ptr;
1106285Snate@binkert.org  bool m_adaptive_routing;
1116285Snate@binkert.org  int m_link_latency;
1126493STushar.Krishna@amd.com  int m_control_msg_size;
1136493STushar.Krishna@amd.com  int m_data_msg_size;
1146145Snate@binkert.org};
1156145Snate@binkert.org
1166145Snate@binkert.org// Output operator declaration
1176145Snate@binkert.orgostream& operator<<(ostream& out, const Network& obj);
1186145Snate@binkert.org
1196145Snate@binkert.org// ******************* Definitions *******************
1206145Snate@binkert.org
1216145Snate@binkert.org// Output operator definition
1226145Snate@binkert.orgextern inline
1236145Snate@binkert.orgostream& operator<<(ostream& out, const Network& obj)
1246145Snate@binkert.org{
1256145Snate@binkert.org  obj.print(out);
1266145Snate@binkert.org  out << flush;
1276145Snate@binkert.org  return out;
1286145Snate@binkert.org}
1296145Snate@binkert.org
1306145Snate@binkert.org#endif //NETWORK_H
131