Network.hh revision 8257:7226aebb77b4
16019Shines@cs.fsu.edu/*
26019Shines@cs.fsu.edu * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
37152Sgblack@eecs.umich.edu * All rights reserved.
47152Sgblack@eecs.umich.edu *
57152Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
67152Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
77152Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
87152Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
97152Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
107152Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
117152Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
127152Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
137152Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
147152Sgblack@eecs.umich.edu * this software without specific prior written permission.
156019Shines@cs.fsu.edu *
166019Shines@cs.fsu.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176019Shines@cs.fsu.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186019Shines@cs.fsu.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196019Shines@cs.fsu.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206019Shines@cs.fsu.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216019Shines@cs.fsu.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226019Shines@cs.fsu.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236019Shines@cs.fsu.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246019Shines@cs.fsu.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256019Shines@cs.fsu.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266019Shines@cs.fsu.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276019Shines@cs.fsu.edu */
286019Shines@cs.fsu.edu
296019Shines@cs.fsu.edu/*
306019Shines@cs.fsu.edu * The Network class is the base class for classes that implement the
316019Shines@cs.fsu.edu * interconnection network between components (processor/cache
326019Shines@cs.fsu.edu * components and memory/directory components).  The interconnection
336019Shines@cs.fsu.edu * network as described here is not a physical network, but a
346019Shines@cs.fsu.edu * programming concept used to implement all communication between
356019Shines@cs.fsu.edu * components.  Thus parts of this 'network' will model the on-chip
366019Shines@cs.fsu.edu * connections between cache controllers and directory controllers as
376019Shines@cs.fsu.edu * well as the links between chip and network switches.
386019Shines@cs.fsu.edu */
396019Shines@cs.fsu.edu
406019Shines@cs.fsu.edu#ifndef __MEM_RUBY_NETWORK_NETWORK_HH__
416019Shines@cs.fsu.edu#define __MEM_RUBY_NETWORK_NETWORK_HH__
426019Shines@cs.fsu.edu
436019Shines@cs.fsu.edu#include <iostream>
446019Shines@cs.fsu.edu#include <string>
456019Shines@cs.fsu.edu#include <vector>
466019Shines@cs.fsu.edu
476019Shines@cs.fsu.edu#include "mem/protocol/LinkDirection.hh"
487152Sgblack@eecs.umich.edu#include "mem/protocol/MessageSizeType.hh"
497152Sgblack@eecs.umich.edu#include "mem/ruby/common/Global.hh"
507152Sgblack@eecs.umich.edu#include "mem/ruby/system/NodeID.hh"
517152Sgblack@eecs.umich.edu#include "mem/ruby/system/System.hh"
527152Sgblack@eecs.umich.edu#include "params/RubyNetwork.hh"
537602SGene.Wu@arm.com#include "sim/sim_object.hh"
547152Sgblack@eecs.umich.edu
557152Sgblack@eecs.umich.educlass NetDest;
567152Sgblack@eecs.umich.educlass MessageBuffer;
577152Sgblack@eecs.umich.educlass Throttle;
587152Sgblack@eecs.umich.educlass Topology;
597152Sgblack@eecs.umich.edu
607152Sgblack@eecs.umich.educlass Network : public SimObject
617152Sgblack@eecs.umich.edu{
627152Sgblack@eecs.umich.edu  public:
637152Sgblack@eecs.umich.edu    typedef RubyNetworkParams Params;
647152Sgblack@eecs.umich.edu    Network(const Params *p);
657152Sgblack@eecs.umich.edu    virtual ~Network() {}
667602SGene.Wu@arm.com
677152Sgblack@eecs.umich.edu    virtual void init();
687152Sgblack@eecs.umich.edu
697152Sgblack@eecs.umich.edu    int getBufferSize() { return m_buffer_size; }
707152Sgblack@eecs.umich.edu    int getNumberOfVirtualNetworks() { return m_virtual_networks; }
717152Sgblack@eecs.umich.edu    int getEndpointBandwidth() { return m_endpoint_bandwidth; }
727152Sgblack@eecs.umich.edu    bool getAdaptiveRouting() {return m_adaptive_routing; }
737152Sgblack@eecs.umich.edu    int getLinkLatency() { return m_link_latency; }
747252Sgblack@eecs.umich.edu    int MessageSizeType_to_int(MessageSizeType size_type);
757152Sgblack@eecs.umich.edu
767252Sgblack@eecs.umich.edu    // returns the queue requested for the given component
777252Sgblack@eecs.umich.edu    virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered,
787252Sgblack@eecs.umich.edu        int netNumber) = 0;
797252Sgblack@eecs.umich.edu    virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered,
807252Sgblack@eecs.umich.edu        int netNumber) = 0;
817252Sgblack@eecs.umich.edu    virtual const std::vector<Throttle*>* getThrottles(NodeID id) const;
827252Sgblack@eecs.umich.edu    virtual int getNumNodes() {return 1;}
837252Sgblack@eecs.umich.edu
847252Sgblack@eecs.umich.edu    virtual void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
857252Sgblack@eecs.umich.edu                             LinkDirection direction,
867252Sgblack@eecs.umich.edu                             const NetDest& routing_table_entry,
877252Sgblack@eecs.umich.edu                             bool isReconfiguration) = 0;
887152Sgblack@eecs.umich.edu    virtual void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
897152Sgblack@eecs.umich.edu                            LinkDirection direction,
907152Sgblack@eecs.umich.edu                            const NetDest& routing_table_entry,
917152Sgblack@eecs.umich.edu                            bool isReconfiguration) = 0;
927152Sgblack@eecs.umich.edu    virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
937152Sgblack@eecs.umich.edu                                  LinkDirection direction,
947152Sgblack@eecs.umich.edu                                  const NetDest& routing_table_entry,
957152Sgblack@eecs.umich.edu                                  bool isReconfiguration) = 0;
967152Sgblack@eecs.umich.edu
977154Sgblack@eecs.umich.edu    virtual void reset() = 0;
987154Sgblack@eecs.umich.edu
997154Sgblack@eecs.umich.edu    virtual void printStats(std::ostream& out) const = 0;
1007154Sgblack@eecs.umich.edu    virtual void clearStats() = 0;
1017154Sgblack@eecs.umich.edu    virtual void printConfig(std::ostream& out) const = 0;
1027154Sgblack@eecs.umich.edu    virtual void print(std::ostream& out) const = 0;
1037154Sgblack@eecs.umich.edu
1047200Sgblack@eecs.umich.edu  protected:
1057154Sgblack@eecs.umich.edu    // Private copy constructor and assignment operator
1067154Sgblack@eecs.umich.edu    Network(const Network& obj);
1077281Sgblack@eecs.umich.edu    Network& operator=(const Network& obj);
1087154Sgblack@eecs.umich.edu
1097154Sgblack@eecs.umich.edu  protected:
1107154Sgblack@eecs.umich.edu    const std::string m_name;
1117154Sgblack@eecs.umich.edu    int m_nodes;
1127154Sgblack@eecs.umich.edu    int m_virtual_networks;
1137154Sgblack@eecs.umich.edu    int m_buffer_size;
1147154Sgblack@eecs.umich.edu    int m_endpoint_bandwidth;
1157154Sgblack@eecs.umich.edu    Topology* m_topology_ptr;
1167154Sgblack@eecs.umich.edu    bool m_adaptive_routing;
1177154Sgblack@eecs.umich.edu    int m_link_latency;
1187155Sgblack@eecs.umich.edu    int m_control_msg_size;
1197154Sgblack@eecs.umich.edu    int m_data_msg_size;
1207155Sgblack@eecs.umich.edu};
1217155Sgblack@eecs.umich.edu
1227155Sgblack@eecs.umich.eduinline std::ostream&
1237155Sgblack@eecs.umich.eduoperator<<(std::ostream& out, const Network& obj)
1247155Sgblack@eecs.umich.edu{
1257155Sgblack@eecs.umich.edu    obj.print(out);
1267155Sgblack@eecs.umich.edu    out << std::flush;
1277281Sgblack@eecs.umich.edu    return out;
1287281Sgblack@eecs.umich.edu}
1297155Sgblack@eecs.umich.edu
1307155Sgblack@eecs.umich.edu#endif // __MEM_RUBY_NETWORK_NETWORK_HH__
1317155Sgblack@eecs.umich.edu