Network.hh revision 6284:a63d1dc4c820
16915SN/A
26915SN/A/*
36915SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
46915SN/A * All rights reserved.
56915SN/A *
66915SN/A * Redistribution and use in source and binary forms, with or without
76915SN/A * modification, are permitted provided that the following conditions are
86915SN/A * met: redistributions of source code must retain the above copyright
96915SN/A * notice, this list of conditions and the following disclaimer;
106915SN/A * redistributions in binary form must reproduce the above copyright
116915SN/A * notice, this list of conditions and the following disclaimer in the
126915SN/A * documentation and/or other materials provided with the distribution;
136915SN/A * neither the name of the copyright holders nor the names of its
146915SN/A * contributors may be used to endorse or promote products derived from
156915SN/A * this software without specific prior written permission.
166915SN/A *
176915SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186915SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196915SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206915SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216915SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226915SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236915SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246915SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256915SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266915SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276915SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286915SN/A */
296915SN/A
306915SN/A/*
316915SN/A * Network.hh
326915SN/A *
336915SN/A * Description: The Network class is the base class for classes that
349100SN/A * implement the interconnection network between components
3510529Smorr@cs.wisc.edu * (processor/cache components and memory/directory components).  The
366915SN/A * interconnection network as described here is not a physical
376915SN/A * network, but a programming concept used to implement all
386915SN/A * communication between components.  Thus parts of this 'network'
396915SN/A * will model the on-chip connections between cache controllers and
406915SN/A * directory controllers as well as the links between chip and network
416915SN/A * switches.
426915SN/A *
436915SN/A * $Id$
446915SN/A * */
456915SN/A
466915SN/A#ifndef NETWORK_H
476915SN/A#define NETWORK_H
486915SN/A
497538SN/A#include "mem/ruby/common/Global.hh"
507538SN/A#include "mem/ruby/system/NodeID.hh"
517538SN/A#include "mem/protocol/MessageSizeType.hh"
5210519Snilay@cs.wisc.edu
5310007Snilay@cs.wisc.educlass NetDest;
5410007Snilay@cs.wisc.educlass MessageBuffer;
5510007Snilay@cs.wisc.educlass Throttle;
566915SN/A
576915SN/Aclass Network {
5810007Snilay@cs.wisc.edupublic:
596915SN/A  // Constructors
606915SN/A  Network() {}
616915SN/A
626915SN/A  // Destructor
636915SN/A  virtual ~Network() {}
646915SN/A
656915SN/A  // Public Methods
666915SN/A
676915SN/A  static Network* createNetwork(int nodes);
686915SN/A
696915SN/A  // returns the queue requested for the given component
706915SN/A  virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered, int netNumber) = 0;
716915SN/A  virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int netNumber) = 0;
726915SN/A  virtual const Vector<Throttle*>* getThrottles(NodeID id) const { return NULL; }
738180SN/A
748180SN/A  virtual int getNumNodes() {return 1;}
7510007Snilay@cs.wisc.edu
766915SN/A  virtual void makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0;
776915SN/A  virtual void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration) = 0;
786915SN/A  virtual void makeInternalLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0;
796915SN/A
806915SN/A  virtual void reset() = 0;
818180SN/A
829319SN/A  virtual void printStats(ostream& out) const = 0;
839319SN/A  virtual void clearStats() = 0;
846915SN/A  virtual void printConfig(ostream& out) const = 0;
858180SN/A  virtual void print(ostream& out) const = 0;
869319SN/A
879319SN/Aprivate:
886915SN/A
899366SN/A  // Private Methods
909366SN/A  // Private copy constructor and assignment operator
918322SN/A  Network(const Network& obj);
929696SN/A  Network& operator=(const Network& obj);
939696SN/A
948436SN/A  // Data Members (m_ prefix)
9510529Smorr@cs.wisc.edu};
969366SN/A
979366SN/A// Output operator declaration
9810300Scastilloe@unican.esostream& operator<<(ostream& out, const Network& obj);
999841SN/A
1009366SN/A// ******************* Definitions *******************
1018322SN/A
1027015SN/A// Output operator definition
1037015SN/Aextern inline
1046915SN/Aostream& operator<<(ostream& out, const Network& obj)
10510300Scastilloe@unican.es{
1068436SN/A  obj.print(out);
1076915SN/A  out << flush;
1088322SN/A  return out;
1099468SN/A}
11010007Snilay@cs.wisc.edu
1116915SN/A// Code to map network message size types to an integer number of bytes
1126915SN/Aconst int CONTROL_MESSAGE_SIZE = 8;
1136915SN/Aconst int DATA_MESSAGE_SIZE = (64+8);
11410007Snilay@cs.wisc.edu
11510311Snilay@cs.wisc.eduextern inline
11610311Snilay@cs.wisc.eduint MessageSizeType_to_int(MessageSizeType size_type)
11710311Snilay@cs.wisc.edu{
11810311Snilay@cs.wisc.edu  switch(size_type) {
11910311Snilay@cs.wisc.edu  case MessageSizeType_Undefined:
12010311Snilay@cs.wisc.edu    ERROR_MSG("Can't convert Undefined MessageSizeType to integer");
12110311Snilay@cs.wisc.edu    break;
12210311Snilay@cs.wisc.edu  case MessageSizeType_Control:
12310311Snilay@cs.wisc.edu  case MessageSizeType_Request_Control:
1248180SN/A  case MessageSizeType_Reissue_Control:
1258180SN/A  case MessageSizeType_Response_Control:
1266915SN/A  case MessageSizeType_Writeback_Control:
1276915SN/A  case MessageSizeType_Forwarded_Control:
1286915SN/A  case MessageSizeType_Invalidate_Control:
1296915SN/A  case MessageSizeType_Unblock_Control:
1306915SN/A  case MessageSizeType_Persistent_Control:
1318180SN/A  case MessageSizeType_Completion_Control:
1328180SN/A    return CONTROL_MESSAGE_SIZE;
1336915SN/A    break;
1346915SN/A  case MessageSizeType_Data:
1359696SN/A  case MessageSizeType_Response_Data:
1369841SN/A  case MessageSizeType_ResponseLocal_Data:
1378436SN/A  case MessageSizeType_ResponseL2hit_Data:
13810007Snilay@cs.wisc.edu  case MessageSizeType_Writeback_Data:
1399468SN/A    return DATA_MESSAGE_SIZE;
1406915SN/A    break;
14110007Snilay@cs.wisc.edu  default:
14210311Snilay@cs.wisc.edu    ERROR_MSG("Invalid range for type MessageSizeType");
14310311Snilay@cs.wisc.edu    break;
14410311Snilay@cs.wisc.edu  }
14510311Snilay@cs.wisc.edu  return 0;
14610311Snilay@cs.wisc.edu}
14710311Snilay@cs.wisc.edu
14810311Snilay@cs.wisc.edu#endif //NETWORK_H
14910311Snilay@cs.wisc.edu