BasicLink.hh revision 6876
1955SN/A/*
2955SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
35871Snate@binkert.org * All rights reserved.
41762SN/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 */
28955SN/A
292665Ssaidi@eecs.umich.edu/*
302665Ssaidi@eecs.umich.edu * Network.hh
315863Snate@binkert.org *
32955SN/A * Description: The Network class is the base class for classes that
33955SN/A * implement the interconnection network between components
34955SN/A * (processor/cache components and memory/directory components).  The
35955SN/A * interconnection network as described here is not a physical
36955SN/A * network, but a programming concept used to implement all
372632Sstever@eecs.umich.edu * communication between components.  Thus parts of this 'network'
382632Sstever@eecs.umich.edu * will model the on-chip connections between cache controllers and
392632Sstever@eecs.umich.edu * directory controllers as well as the links between chip and network
402632Sstever@eecs.umich.edu * switches.
41955SN/A *
422632Sstever@eecs.umich.edu * $Id$
432632Sstever@eecs.umich.edu * */
442761Sstever@eecs.umich.edu
452632Sstever@eecs.umich.edu#ifndef NETWORK_H
462632Sstever@eecs.umich.edu#define NETWORK_H
472632Sstever@eecs.umich.edu
482761Sstever@eecs.umich.edu#include "mem/ruby/common/Global.hh"
492761Sstever@eecs.umich.edu#include "mem/ruby/system/NodeID.hh"
502761Sstever@eecs.umich.edu#include "mem/protocol/MessageSizeType.hh"
512632Sstever@eecs.umich.edu#include "mem/ruby/system/System.hh"
522632Sstever@eecs.umich.edu#include "sim/sim_object.hh"
532761Sstever@eecs.umich.edu#include "params/RubyNetwork.hh"
542761Sstever@eecs.umich.edu
552761Sstever@eecs.umich.educlass NetDest;
562761Sstever@eecs.umich.educlass MessageBuffer;
572761Sstever@eecs.umich.educlass Throttle;
582632Sstever@eecs.umich.educlass Topology;
592632Sstever@eecs.umich.edu
602632Sstever@eecs.umich.educlass Network : public SimObject {
612632Sstever@eecs.umich.edupublic:
622632Sstever@eecs.umich.edu  // Constructors
632632Sstever@eecs.umich.edu    typedef RubyNetworkParams Params;
642632Sstever@eecs.umich.edu    Network(const Params *p);
65955SN/A  virtual void init();
66955SN/A
67955SN/A  // Destructor
685863Snate@binkert.org  virtual ~Network() {}
695863Snate@binkert.org
705863Snate@binkert.org  // Public Methods
715863Snate@binkert.org  int getBufferSize() { return m_buffer_size; }
725863Snate@binkert.org  int getNumberOfVirtualNetworks() { return m_virtual_networks; }
735863Snate@binkert.org  int getEndpointBandwidth() { return m_endpoint_bandwidth; }
745863Snate@binkert.org  bool getAdaptiveRouting() {return m_adaptive_routing; }
755863Snate@binkert.org  int getLinkLatency() { return m_link_latency; }
765863Snate@binkert.org  int MessageSizeType_to_int(MessageSizeType size_type);
775863Snate@binkert.org
785863Snate@binkert.org
795863Snate@binkert.org  // returns the queue requested for the given component
805863Snate@binkert.org  virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered, int netNumber) = 0;
815863Snate@binkert.org  virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int netNumber) = 0;
825863Snate@binkert.org  virtual const Vector<Throttle*>* getThrottles(NodeID id) const { return NULL; }
835863Snate@binkert.org
845863Snate@binkert.org  virtual int getNumNodes() {return 1;}
855863Snate@binkert.org
865863Snate@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;
875863Snate@binkert.org  virtual void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration) = 0;
885863Snate@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;
895863Snate@binkert.org
905863Snate@binkert.org  virtual void reset() = 0;
915863Snate@binkert.org
925863Snate@binkert.org  virtual void printStats(ostream& out) const = 0;
935863Snate@binkert.org  virtual void clearStats() = 0;
945863Snate@binkert.org  virtual void printConfig(ostream& out) const = 0;
955863Snate@binkert.org  virtual void print(ostream& out) const = 0;
965863Snate@binkert.org
975863Snate@binkert.orgprotected:
985863Snate@binkert.org
99955SN/A  // Private Methods
1005396Ssaidi@eecs.umich.edu  // Private copy constructor and assignment operator
1015863Snate@binkert.org  Network(const Network& obj);
1025863Snate@binkert.org  Network& operator=(const Network& obj);
1034202Sbinkertn@umich.edu
1045863Snate@binkert.org  // Data Members (m_ prefix)
1055863Snate@binkert.orgprotected:
1065863Snate@binkert.org  const string m_name;
1075863Snate@binkert.org  int m_nodes;
108955SN/A  int m_virtual_networks;
1095273Sstever@gmail.com  int m_buffer_size;
1105871Snate@binkert.org  int m_endpoint_bandwidth;
1115273Sstever@gmail.com  Topology* m_topology_ptr;
1125871Snate@binkert.org  bool m_adaptive_routing;
1135863Snate@binkert.org  int m_link_latency;
1145863Snate@binkert.org  int m_control_msg_size;
1155863Snate@binkert.org  int m_data_msg_size;
1165871Snate@binkert.org};
1175872Snate@binkert.org
1185872Snate@binkert.org// Output operator declaration
1195872Snate@binkert.orgostream& operator<<(ostream& out, const Network& obj);
1205871Snate@binkert.org
1215871Snate@binkert.org// ******************* Definitions *******************
1225871Snate@binkert.org
1235871Snate@binkert.org// Output operator definition
1245871Snate@binkert.orgextern inline
1255871Snate@binkert.orgostream& operator<<(ostream& out, const Network& obj)
1265871Snate@binkert.org{
1275871Snate@binkert.org  obj.print(out);
1285871Snate@binkert.org  out << flush;
1295871Snate@binkert.org  return out;
1305871Snate@binkert.org}
1315871Snate@binkert.org
1325871Snate@binkert.org#endif //NETWORK_H
1335871Snate@binkert.org