SimpleNetwork.hh revision 7054:7d6862b80049
12810Srdreslin@umich.edu/*
211375Sandreas.hansson@arm.com * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
38702Sandreas.hansson@arm.com * All rights reserved.
48702Sandreas.hansson@arm.com *
58702Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without
68702Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
78702Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
88702Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
98702Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
108702Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the
118702Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution;
128702Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its
138702Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from
142810Srdreslin@umich.edu * this software without specific prior written permission.
152810Srdreslin@umich.edu *
162810Srdreslin@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172810Srdreslin@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182810Srdreslin@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192810Srdreslin@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202810Srdreslin@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212810Srdreslin@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222810Srdreslin@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232810Srdreslin@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242810Srdreslin@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252810Srdreslin@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262810Srdreslin@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272810Srdreslin@umich.edu */
282810Srdreslin@umich.edu
292810Srdreslin@umich.edu/*
302810Srdreslin@umich.edu * The SimpleNetwork class implements the interconnection
312810Srdreslin@umich.edu * SimpleNetwork between components (processor/cache components and
322810Srdreslin@umich.edu * memory/directory components).  The interconnection network as
332810Srdreslin@umich.edu * described here is not a physical network, but a programming concept
342810Srdreslin@umich.edu * used to implement all communication between components.  Thus parts
352810Srdreslin@umich.edu * of this 'network' may model the on-chip connections between cache
362810Srdreslin@umich.edu * controllers and directory controllers as well as the links between
372810Srdreslin@umich.edu * chip and network switches.
382810Srdreslin@umich.edu *
392810Srdreslin@umich.edu * Two conceptual networks, an address and data network, are modeled.
402810Srdreslin@umich.edu * The data network is unordered, where the address network provides
412810Srdreslin@umich.edu * and conforms to a global ordering of all transactions.
422810Srdreslin@umich.edu *
434458Sstever@eecs.umich.edu * Currently the data network is point-to-point and the address
448856Sandreas.hansson@arm.com * network is a broadcast network. These two distinct conceptual
452810Srdreslin@umich.edu * network can be modeled as physically separate networks or
462810Srdreslin@umich.edu * multiplexed over a single physical network.
472810Srdreslin@umich.edu *
482810Srdreslin@umich.edu * The network encapsulates all notion of virtual global time and is
492810Srdreslin@umich.edu * responsible for ordering the network transactions received.  This
502810Srdreslin@umich.edu * hides all of these ordering details from the processor/cache and
512810Srdreslin@umich.edu * directory/memory modules.
5211051Sandreas.hansson@arm.com *
5311051Sandreas.hansson@arm.com * FIXME: Various flavor of networks are provided as a compiler time
542810Srdreslin@umich.edu *        configurable. We currently include this SimpleNetwork in the
5511859Sandreas.hansson@arm.com *        makefile's vpath, so that SimpleNetwork.cc can provide an alternative
5611859Sandreas.hansson@arm.com *        version constructor for the abstract Network class. It is easy to
5712334Sgabeblack@google.com *        modify this to make network a runtime configuable. Just make the
5811197Sandreas.hansson@arm.com *        abstract Network class take a enumeration parameter, and based on
595338Sstever@gmail.com *        that to initial proper network. Or even better, just make the ruby
605338Sstever@gmail.com *        system initializer choose the proper network to initiate.
615338Sstever@gmail.com */
6210815Sdavid.guillen@arm.com
6311053Sandreas.hansson@arm.com#ifndef __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
644458Sstever@eecs.umich.edu#define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
654458Sstever@eecs.umich.edu
662813Srdreslin@umich.edu#include "mem/gems_common/Vector.hh"
673861Sstever@eecs.umich.edu#include "mem/ruby/common/Global.hh"
682810Srdreslin@umich.edu#include "mem/ruby/network/Network.hh"
692810Srdreslin@umich.edu#include "mem/ruby/system/NodeID.hh"
702810Srdreslin@umich.edu#include "params/SimpleNetwork.hh"
712810Srdreslin@umich.edu#include "sim/sim_object.hh"
729264Sdjordje.kovacevic@arm.com
732810Srdreslin@umich.educlass NetDest;
742810Srdreslin@umich.educlass MessageBuffer;
752810Srdreslin@umich.educlass Throttle;
762810Srdreslin@umich.educlass Switch;
772810Srdreslin@umich.educlass Topology;
788856Sandreas.hansson@arm.com
798856Sandreas.hansson@arm.comclass SimpleNetwork : public Network
808856Sandreas.hansson@arm.com{
818856Sandreas.hansson@arm.com  public:
828856Sandreas.hansson@arm.com    typedef SimpleNetworkParams Params;
833738Sstever@eecs.umich.edu    SimpleNetwork(const Params *p);
848856Sandreas.hansson@arm.com    ~SimpleNetwork();
853738Sstever@eecs.umich.edu
868856Sandreas.hansson@arm.com    void init();
8710815Sdavid.guillen@arm.com
883738Sstever@eecs.umich.edu    void printStats(ostream& out) const;
898856Sandreas.hansson@arm.com    void clearStats();
904478Sstever@eecs.umich.edu    void printConfig(ostream& out) const;
918975Sandreas.hansson@arm.com
928948Sandreas.hansson@arm.com    void reset();
9312343Snikos.nikoleris@arm.com
9412343Snikos.nikoleris@arm.com    // returns the queue requested for the given component
958975Sandreas.hansson@arm.com    MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num);
963738Sstever@eecs.umich.edu    MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num);
973738Sstever@eecs.umich.edu    virtual const Vector<Throttle*>* getThrottles(NodeID id) const;
983738Sstever@eecs.umich.edu
993738Sstever@eecs.umich.edu    bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
1008856Sandreas.hansson@arm.com    bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
1019090Sandreas.hansson@arm.com
1028856Sandreas.hansson@arm.com    int getNumNodes() {return m_nodes; }
1038856Sandreas.hansson@arm.com
1048856Sandreas.hansson@arm.com    // Methods used by Topology to setup the network
10510815Sdavid.guillen@arm.com    void makeOutLink(SwitchID src, NodeID dest,
1068856Sandreas.hansson@arm.com        const NetDest& routing_table_entry, int link_latency, int link_weight,
1078856Sandreas.hansson@arm.com        int bw_multiplier, bool isReconfiguration);
1083738Sstever@eecs.umich.edu    void makeInLink(SwitchID src, NodeID dest,
1093738Sstever@eecs.umich.edu        const NetDest& routing_table_entry, int link_latency,
1108856Sandreas.hansson@arm.com        int bw_multiplier, bool isReconfiguration);
1118914Sandreas.hansson@arm.com    void makeInternalLink(SwitchID src, NodeID dest,
1128914Sandreas.hansson@arm.com        const NetDest& routing_table_entry, int link_latency, int link_weight,
1138914Sandreas.hansson@arm.com        int bw_multiplier, bool isReconfiguration);
1148914Sandreas.hansson@arm.com
1158914Sandreas.hansson@arm.com    void print(ostream& out) const;
11610713Sandreas.hansson@arm.com
1178914Sandreas.hansson@arm.com  private:
1188914Sandreas.hansson@arm.com    void checkNetworkAllocation(NodeID id, bool ordered, int network_num);
1198914Sandreas.hansson@arm.com    void addLink(SwitchID src, SwitchID dest, int link_latency);
1208914Sandreas.hansson@arm.com    void makeLink(SwitchID src, SwitchID dest,
12110815Sdavid.guillen@arm.com        const NetDest& routing_table_entry, int link_latency);
12210713Sandreas.hansson@arm.com    SwitchID createSwitch();
1238914Sandreas.hansson@arm.com    void makeTopology();
1248914Sandreas.hansson@arm.com    void linkTopology();
1258914Sandreas.hansson@arm.com
12610815Sdavid.guillen@arm.com    // Private copy constructor and assignment operator
12710713Sandreas.hansson@arm.com    SimpleNetwork(const SimpleNetwork& obj);
12810713Sandreas.hansson@arm.com    SimpleNetwork& operator=(const SimpleNetwork& obj);
12910713Sandreas.hansson@arm.com
13010713Sandreas.hansson@arm.com    // vector of queues from the components
1318914Sandreas.hansson@arm.com    Vector<Vector<MessageBuffer*> > m_toNetQueues;
1328914Sandreas.hansson@arm.com    Vector<Vector<MessageBuffer*> > m_fromNetQueues;
1338914Sandreas.hansson@arm.com
1348914Sandreas.hansson@arm.com    Vector<bool> m_in_use;
1358914Sandreas.hansson@arm.com    Vector<bool> m_ordered;
1368914Sandreas.hansson@arm.com    Vector<Switch*> m_switch_ptr_vector;
1378914Sandreas.hansson@arm.com    Vector<MessageBuffer*> m_buffers_to_free;
1388914Sandreas.hansson@arm.com    Vector<Switch*> m_endpoint_switches;
13911375Sandreas.hansson@arm.com};
14011375Sandreas.hansson@arm.com
14111375Sandreas.hansson@arm.cominline ostream&
14211375Sandreas.hansson@arm.comoperator<<(ostream& out, const SimpleNetwork& obj)
14311375Sandreas.hansson@arm.com{
14411375Sandreas.hansson@arm.com    obj.print(out);
14511375Sandreas.hansson@arm.com    out << flush;
14611375Sandreas.hansson@arm.com    return out;
14711375Sandreas.hansson@arm.com}
14811375Sandreas.hansson@arm.com
14911375Sandreas.hansson@arm.com#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
15011375Sandreas.hansson@arm.com