SimpleNetwork.hh revision 11113
1955SN/A/*
2955SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
31762SN/A * All rights reserved.
4955SN/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 */
282665Ssaidi@eecs.umich.edu
294762Snate@binkert.org#ifndef __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
30955SN/A#define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
314762Snate@binkert.org
32955SN/A#include <iostream>
33955SN/A#include <vector>
344202Sbinkertn@umich.edu
355342Sstever@gmail.com#include "mem/ruby/network/Network.hh"
36955SN/A#include "params/SimpleNetwork.hh"
374381Sbinkertn@umich.edu
384381Sbinkertn@umich.educlass NetDest;
39955SN/Aclass MessageBuffer;
40955SN/Aclass Throttle;
41955SN/Aclass Switch;
424202Sbinkertn@umich.edu
43955SN/Aclass SimpleNetwork : public Network
444382Sbinkertn@umich.edu{
454382Sbinkertn@umich.edu  public:
464382Sbinkertn@umich.edu    typedef SimpleNetworkParams Params;
474762Snate@binkert.org    SimpleNetwork(const Params *p);
484762Snate@binkert.org    ~SimpleNetwork();
494762Snate@binkert.org
504762Snate@binkert.org    void init();
514762Snate@binkert.org
524762Snate@binkert.org    int getBufferSize() { return m_buffer_size; }
534762Snate@binkert.org    int getEndpointBandwidth() { return m_endpoint_bandwidth; }
544762Snate@binkert.org    bool getAdaptiveRouting() {return m_adaptive_routing; }
554762Snate@binkert.org
564762Snate@binkert.org    void collateStats();
574762Snate@binkert.org    void regStats();
584762Snate@binkert.org
594762Snate@binkert.org    bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
604762Snate@binkert.org
614762Snate@binkert.org    // Methods used by Topology to setup the network
624762Snate@binkert.org    void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
634762Snate@binkert.org                     LinkDirection direction,
644762Snate@binkert.org                     const NetDest& routing_table_entry);
654762Snate@binkert.org    void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
664762Snate@binkert.org                    LinkDirection direction,
674762Snate@binkert.org                    const NetDest& routing_table_entry);
684762Snate@binkert.org    void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
694762Snate@binkert.org                          LinkDirection direction,
704762Snate@binkert.org                          const NetDest& routing_table_entry);
714762Snate@binkert.org
724762Snate@binkert.org    void print(std::ostream& out) const;
734762Snate@binkert.org
744762Snate@binkert.org    bool functionalRead(Packet *pkt);
754762Snate@binkert.org    uint32_t functionalWrite(Packet *pkt);
764762Snate@binkert.org
774762Snate@binkert.org  private:
784762Snate@binkert.org    void addLink(SwitchID src, SwitchID dest, int link_latency);
794762Snate@binkert.org    void makeLink(SwitchID src, SwitchID dest,
804382Sbinkertn@umich.edu        const NetDest& routing_table_entry, int link_latency);
814762Snate@binkert.org    void makeTopology();
824382Sbinkertn@umich.edu
834762Snate@binkert.org    // Private copy constructor and assignment operator
844381Sbinkertn@umich.edu    SimpleNetwork(const SimpleNetwork& obj);
854762Snate@binkert.org    SimpleNetwork& operator=(const SimpleNetwork& obj);
864762Snate@binkert.org
874762Snate@binkert.org    std::vector<Switch*> m_switches;
884762Snate@binkert.org    std::vector<MessageBuffer*> m_int_link_buffers;
894762Snate@binkert.org    int m_num_connected_buffers;
904762Snate@binkert.org    std::vector<Switch*> m_endpoint_switches;
914762Snate@binkert.org
924762Snate@binkert.org    int m_buffer_size;
934762Snate@binkert.org    int m_endpoint_bandwidth;
944762Snate@binkert.org    bool m_adaptive_routing;
954762Snate@binkert.org
964762Snate@binkert.org    //Statistical variables
974762Snate@binkert.org    Stats::Formula m_msg_counts[MessageSizeType_NUM];
984762Snate@binkert.org    Stats::Formula m_msg_bytes[MessageSizeType_NUM];
994762Snate@binkert.org};
1004762Snate@binkert.org
1014762Snate@binkert.orginline std::ostream&
1024762Snate@binkert.orgoperator<<(std::ostream& out, const SimpleNetwork& obj)
1034762Snate@binkert.org{
1044762Snate@binkert.org    obj.print(out);
1054762Snate@binkert.org    out << std::flush;
1064762Snate@binkert.org    return out;
1074762Snate@binkert.org}
1084762Snate@binkert.org
1094762Snate@binkert.org#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
1104762Snate@binkert.org