Network.hh revision 8257:7226aebb77b4
16657Snate@binkert.org/*
26657Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
36657Snate@binkert.org * All rights reserved.
46657Snate@binkert.org *
56657Snate@binkert.org * Redistribution and use in source and binary forms, with or without
66657Snate@binkert.org * modification, are permitted provided that the following conditions are
76657Snate@binkert.org * met: redistributions of source code must retain the above copyright
86657Snate@binkert.org * notice, this list of conditions and the following disclaimer;
96657Snate@binkert.org * redistributions in binary form must reproduce the above copyright
106657Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
116657Snate@binkert.org * documentation and/or other materials provided with the distribution;
126657Snate@binkert.org * neither the name of the copyright holders nor the names of its
136657Snate@binkert.org * contributors may be used to endorse or promote products derived from
146657Snate@binkert.org * this software without specific prior written permission.
156657Snate@binkert.org *
166657Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176657Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186657Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196657Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206657Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216657Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226657Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236657Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246657Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256657Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266657Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276657Snate@binkert.org */
286657Snate@binkert.org
296657Snate@binkert.org/*
306657Snate@binkert.org * The Network class is the base class for classes that implement the
316657Snate@binkert.org * interconnection network between components (processor/cache
326863Sdrh5@cs.wisc.edu * components and memory/directory components).  The interconnection
336863Sdrh5@cs.wisc.edu * network as described here is not a physical network, but a
346657Snate@binkert.org * programming concept used to implement all communication between
356657Snate@binkert.org * components.  Thus parts of this 'network' will model the on-chip
366657Snate@binkert.org * connections between cache controllers and directory controllers as
376657Snate@binkert.org * well as the links between chip and network switches.
386657Snate@binkert.org */
396657Snate@binkert.org
406657Snate@binkert.org#ifndef __MEM_RUBY_NETWORK_NETWORK_HH__
416657Snate@binkert.org#define __MEM_RUBY_NETWORK_NETWORK_HH__
426657Snate@binkert.org
436657Snate@binkert.org#include <iostream>
446657Snate@binkert.org#include <string>
456657Snate@binkert.org#include <vector>
466657Snate@binkert.org
476657Snate@binkert.org#include "mem/protocol/LinkDirection.hh"
486657Snate@binkert.org#include "mem/protocol/MessageSizeType.hh"
496657Snate@binkert.org#include "mem/ruby/common/Global.hh"
506657Snate@binkert.org#include "mem/ruby/system/NodeID.hh"
516657Snate@binkert.org#include "mem/ruby/system/System.hh"
526657Snate@binkert.org#include "params/RubyNetwork.hh"
536657Snate@binkert.org#include "sim/sim_object.hh"
546657Snate@binkert.org
556657Snate@binkert.orgclass NetDest;
566657Snate@binkert.orgclass MessageBuffer;
576657Snate@binkert.orgclass Throttle;
586657Snate@binkert.orgclass Topology;
596657Snate@binkert.org
606657Snate@binkert.orgclass Network : public SimObject
616657Snate@binkert.org{
627007Snate@binkert.org  public:
636657Snate@binkert.org    typedef RubyNetworkParams Params;
646657Snate@binkert.org    Network(const Params *p);
657007Snate@binkert.org    virtual ~Network() {}
666657Snate@binkert.org
677007Snate@binkert.org    virtual void init();
686863Sdrh5@cs.wisc.edu
696863Sdrh5@cs.wisc.edu    int getBufferSize() { return m_buffer_size; }
706863Sdrh5@cs.wisc.edu    int getNumberOfVirtualNetworks() { return m_virtual_networks; }
716863Sdrh5@cs.wisc.edu    int getEndpointBandwidth() { return m_endpoint_bandwidth; }
726863Sdrh5@cs.wisc.edu    bool getAdaptiveRouting() {return m_adaptive_routing; }
736863Sdrh5@cs.wisc.edu    int getLinkLatency() { return m_link_latency; }
746863Sdrh5@cs.wisc.edu    int MessageSizeType_to_int(MessageSizeType size_type);
756863Sdrh5@cs.wisc.edu
766863Sdrh5@cs.wisc.edu    // returns the queue requested for the given component
776863Sdrh5@cs.wisc.edu    virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered,
786863Sdrh5@cs.wisc.edu        int netNumber) = 0;
796657Snate@binkert.org    virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered,
806657Snate@binkert.org        int netNumber) = 0;
816657Snate@binkert.org    virtual const std::vector<Throttle*>* getThrottles(NodeID id) const;
826657Snate@binkert.org    virtual int getNumNodes() {return 1;}
836657Snate@binkert.org
846657Snate@binkert.org    virtual void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
856657Snate@binkert.org                             LinkDirection direction,
866657Snate@binkert.org                             const NetDest& routing_table_entry,
87                             bool isReconfiguration) = 0;
88    virtual void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
89                            LinkDirection direction,
90                            const NetDest& routing_table_entry,
91                            bool isReconfiguration) = 0;
92    virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
93                                  LinkDirection direction,
94                                  const NetDest& routing_table_entry,
95                                  bool isReconfiguration) = 0;
96
97    virtual void reset() = 0;
98
99    virtual void printStats(std::ostream& out) const = 0;
100    virtual void clearStats() = 0;
101    virtual void printConfig(std::ostream& out) const = 0;
102    virtual void print(std::ostream& out) const = 0;
103
104  protected:
105    // Private copy constructor and assignment operator
106    Network(const Network& obj);
107    Network& operator=(const Network& obj);
108
109  protected:
110    const std::string m_name;
111    int m_nodes;
112    int m_virtual_networks;
113    int m_buffer_size;
114    int m_endpoint_bandwidth;
115    Topology* m_topology_ptr;
116    bool m_adaptive_routing;
117    int m_link_latency;
118    int m_control_msg_size;
119    int m_data_msg_size;
120};
121
122inline std::ostream&
123operator<<(std::ostream& out, const Network& obj)
124{
125    obj.print(out);
126    out << std::flush;
127    return out;
128}
129
130#endif // __MEM_RUBY_NETWORK_NETWORK_HH__
131