SimpleNetwork.hh revision 11663
16145Snate@binkert.org/*
26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
36145Snate@binkert.org * All rights reserved.
46145Snate@binkert.org *
56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without
66145Snate@binkert.org * modification, are permitted provided that the following conditions are
76145Snate@binkert.org * met: redistributions of source code must retain the above copyright
86145Snate@binkert.org * notice, this list of conditions and the following disclaimer;
96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright
106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
116145Snate@binkert.org * documentation and/or other materials provided with the distribution;
126145Snate@binkert.org * neither the name of the copyright holders nor the names of its
136145Snate@binkert.org * contributors may be used to endorse or promote products derived from
146145Snate@binkert.org * this software without specific prior written permission.
156145Snate@binkert.org *
166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276145Snate@binkert.org */
286145Snate@binkert.org
297054Snate@binkert.org#ifndef __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
307054Snate@binkert.org#define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
316145Snate@binkert.org
327055Snate@binkert.org#include <iostream>
337454Snate@binkert.org#include <vector>
347055Snate@binkert.org
356154Snate@binkert.org#include "mem/ruby/network/Network.hh"
367054Snate@binkert.org#include "params/SimpleNetwork.hh"
376145Snate@binkert.org
386145Snate@binkert.orgclass NetDest;
396145Snate@binkert.orgclass MessageBuffer;
406145Snate@binkert.orgclass Throttle;
416145Snate@binkert.orgclass Switch;
426145Snate@binkert.org
437054Snate@binkert.orgclass SimpleNetwork : public Network
447054Snate@binkert.org{
457054Snate@binkert.org  public:
466876Ssteve.reinhardt@amd.com    typedef SimpleNetworkParams Params;
476876Ssteve.reinhardt@amd.com    SimpleNetwork(const Params *p);
487054Snate@binkert.org    ~SimpleNetwork();
496145Snate@binkert.org
507054Snate@binkert.org    void init();
516145Snate@binkert.org
528259SBrad.Beckmann@amd.com    int getBufferSize() { return m_buffer_size; }
538259SBrad.Beckmann@amd.com    int getEndpointBandwidth() { return m_endpoint_bandwidth; }
548259SBrad.Beckmann@amd.com    bool getAdaptiveRouting() {return m_adaptive_routing; }
558259SBrad.Beckmann@amd.com
569863Snilay@cs.wisc.edu    void collateStats();
579863Snilay@cs.wisc.edu    void regStats();
586145Snate@binkert.org
5911064Snilay@cs.wisc.edu    bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
606145Snate@binkert.org
617054Snate@binkert.org    // Methods used by Topology to setup the network
6211663Stushar@ece.gatech.edu    void makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
639799Snilay@cs.wisc.edu                     const NetDest& routing_table_entry);
6411663Stushar@ece.gatech.edu    void makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
659799Snilay@cs.wisc.edu                    const NetDest& routing_table_entry);
668257SBrad.Beckmann@amd.com    void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
679799Snilay@cs.wisc.edu                          const NetDest& routing_table_entry);
686145Snate@binkert.org
697055Snate@binkert.org    void print(std::ostream& out) const;
706145Snate@binkert.org
719302Snilay@cs.wisc.edu    bool functionalRead(Packet *pkt);
729302Snilay@cs.wisc.edu    uint32_t functionalWrite(Packet *pkt);
739302Snilay@cs.wisc.edu
747054Snate@binkert.org  private:
757054Snate@binkert.org    void addLink(SwitchID src, SwitchID dest, int link_latency);
767054Snate@binkert.org    void makeLink(SwitchID src, SwitchID dest,
777054Snate@binkert.org        const NetDest& routing_table_entry, int link_latency);
787054Snate@binkert.org    void makeTopology();
796145Snate@binkert.org
807054Snate@binkert.org    // Private copy constructor and assignment operator
817054Snate@binkert.org    SimpleNetwork(const SimpleNetwork& obj);
827054Snate@binkert.org    SimpleNetwork& operator=(const SimpleNetwork& obj);
8310311Snilay@cs.wisc.edu
849858Snilay@cs.wisc.edu    std::vector<Switch*> m_switches;
8511021Sjthestness@gmail.com    std::vector<MessageBuffer*> m_int_link_buffers;
8611021Sjthestness@gmail.com    int m_num_connected_buffers;
8711124Snilay@cs.wisc.edu    const int m_buffer_size;
8811124Snilay@cs.wisc.edu    const int m_endpoint_bandwidth;
8911124Snilay@cs.wisc.edu    const bool m_adaptive_routing;
909863Snilay@cs.wisc.edu
919863Snilay@cs.wisc.edu    //Statistical variables
929866Sjthestness@gmail.com    Stats::Formula m_msg_counts[MessageSizeType_NUM];
939866Sjthestness@gmail.com    Stats::Formula m_msg_bytes[MessageSizeType_NUM];
946145Snate@binkert.org};
956145Snate@binkert.org
967055Snate@binkert.orginline std::ostream&
977055Snate@binkert.orgoperator<<(std::ostream& out, const SimpleNetwork& obj)
986145Snate@binkert.org{
997054Snate@binkert.org    obj.print(out);
1007055Snate@binkert.org    out << std::flush;
1017054Snate@binkert.org    return out;
1026145Snate@binkert.org}
1036145Snate@binkert.org
1047054Snate@binkert.org#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
105