Network.hh revision 6154
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/*
316145Snate@binkert.org * Network.h
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"
526145Snate@binkert.org
536145Snate@binkert.orgclass NetDest;
546145Snate@binkert.orgclass MessageBuffer;
556145Snate@binkert.orgclass Throttle;
566145Snate@binkert.org
576145Snate@binkert.orgclass Network {
586145Snate@binkert.orgpublic:
596145Snate@binkert.org  // Constructors
606145Snate@binkert.org  Network() {}
616145Snate@binkert.org
626145Snate@binkert.org  // Destructor
636145Snate@binkert.org  virtual ~Network() {}
646145Snate@binkert.org
656145Snate@binkert.org  // Public Methods
666145Snate@binkert.org
676145Snate@binkert.org  static Network* createNetwork(int nodes);
686145Snate@binkert.org
696145Snate@binkert.org  // returns the queue requested for the given component
706145Snate@binkert.org  virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered, int netNumber) = 0;
716145Snate@binkert.org  virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int netNumber) = 0;
726145Snate@binkert.org  virtual const Vector<Throttle*>* getThrottles(NodeID id) const { return NULL; }
736145Snate@binkert.org
746145Snate@binkert.org  virtual int getNumNodes() {return 1;}
756145Snate@binkert.org
766145Snate@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;
776145Snate@binkert.org  virtual void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration) = 0;
786145Snate@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;
796145Snate@binkert.org
806145Snate@binkert.org  virtual void reset() = 0;
816145Snate@binkert.org
826145Snate@binkert.org  virtual void printStats(ostream& out) const = 0;
836145Snate@binkert.org  virtual void clearStats() = 0;
846145Snate@binkert.org  virtual void printConfig(ostream& out) const = 0;
856145Snate@binkert.org  virtual void print(ostream& out) const = 0;
866145Snate@binkert.org
876145Snate@binkert.orgprivate:
886145Snate@binkert.org
896145Snate@binkert.org  // Private Methods
906145Snate@binkert.org  // Private copy constructor and assignment operator
916145Snate@binkert.org  Network(const Network& obj);
926145Snate@binkert.org  Network& operator=(const Network& obj);
936145Snate@binkert.org
946145Snate@binkert.org  // Data Members (m_ prefix)
956145Snate@binkert.org};
966145Snate@binkert.org
976145Snate@binkert.org// Output operator declaration
986145Snate@binkert.orgostream& operator<<(ostream& out, const Network& obj);
996145Snate@binkert.org
1006145Snate@binkert.org// ******************* Definitions *******************
1016145Snate@binkert.org
1026145Snate@binkert.org// Output operator definition
1036145Snate@binkert.orgextern inline
1046145Snate@binkert.orgostream& operator<<(ostream& out, const Network& obj)
1056145Snate@binkert.org{
1066145Snate@binkert.org  obj.print(out);
1076145Snate@binkert.org  out << flush;
1086145Snate@binkert.org  return out;
1096145Snate@binkert.org}
1106145Snate@binkert.org
1116145Snate@binkert.org// Code to map network message size types to an integer number of bytes
1126145Snate@binkert.orgconst int CONTROL_MESSAGE_SIZE = 8;
1136145Snate@binkert.orgconst int DATA_MESSAGE_SIZE = (64+8);
1146145Snate@binkert.org
1156145Snate@binkert.orgextern inline
1166145Snate@binkert.orgint MessageSizeType_to_int(MessageSizeType size_type)
1176145Snate@binkert.org{
1186145Snate@binkert.org  switch(size_type) {
1196145Snate@binkert.org  case MessageSizeType_Undefined:
1206145Snate@binkert.org    ERROR_MSG("Can't convert Undefined MessageSizeType to integer");
1216145Snate@binkert.org    break;
1226145Snate@binkert.org  case MessageSizeType_Control:
1236145Snate@binkert.org  case MessageSizeType_Request_Control:
1246145Snate@binkert.org  case MessageSizeType_Reissue_Control:
1256145Snate@binkert.org  case MessageSizeType_Response_Control:
1266145Snate@binkert.org  case MessageSizeType_Writeback_Control:
1276145Snate@binkert.org  case MessageSizeType_Forwarded_Control:
1286145Snate@binkert.org  case MessageSizeType_Invalidate_Control:
1296145Snate@binkert.org  case MessageSizeType_Unblock_Control:
1306145Snate@binkert.org  case MessageSizeType_Persistent_Control:
1316145Snate@binkert.org  case MessageSizeType_Completion_Control:
1326145Snate@binkert.org    return CONTROL_MESSAGE_SIZE;
1336145Snate@binkert.org    break;
1346145Snate@binkert.org  case MessageSizeType_Data:
1356145Snate@binkert.org  case MessageSizeType_Response_Data:
1366145Snate@binkert.org  case MessageSizeType_ResponseLocal_Data:
1376145Snate@binkert.org  case MessageSizeType_ResponseL2hit_Data:
1386145Snate@binkert.org  case MessageSizeType_Writeback_Data:
1396145Snate@binkert.org    return DATA_MESSAGE_SIZE;
1406145Snate@binkert.org    break;
1416145Snate@binkert.org  default:
1426145Snate@binkert.org    ERROR_MSG("Invalid range for type MessageSizeType");
1436145Snate@binkert.org    break;
1446145Snate@binkert.org  }
1456145Snate@binkert.org  return 0;
1466145Snate@binkert.org}
1476145Snate@binkert.org
1486145Snate@binkert.org#endif //NETWORK_H
149