gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Network.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /*
30  * The Network class is the base class for classes that implement the
31  * interconnection network between components (processor/cache
32  * components and memory/directory components). The interconnection
33  * network as described here is not a physical network, but a
34  * programming concept used to implement all communication between
35  * components. Thus parts of this 'network' will model the on-chip
36  * connections between cache controllers and directory controllers as
37  * well as the links between chip and network switches.
38  */
39 
40 #ifndef __MEM_RUBY_NETWORK_NETWORK_HH__
41 #define __MEM_RUBY_NETWORK_NETWORK_HH__
42 
43 #include <iostream>
44 #include <string>
45 #include <vector>
46 
47 #include "mem/protocol/LinkDirection.hh"
48 #include "mem/protocol/MessageSizeType.hh"
51 #include "mem/packet.hh"
52 #include "params/RubyNetwork.hh"
53 #include "sim/clocked_object.hh"
54 
55 class NetDest;
56 class MessageBuffer;
57 
58 class Network : public ClockedObject
59 {
60  public:
61  typedef RubyNetworkParams Params;
62  Network(const Params *p);
63  const Params * params() const
64  { return dynamic_cast<const Params *>(_params); }
65 
66  virtual ~Network();
67  virtual void init();
68 
69  static uint32_t getNumberOfVirtualNetworks() { return m_virtual_networks; }
70  int getNumNodes() const { return m_nodes; }
71 
72  static uint32_t MessageSizeType_to_int(MessageSizeType size_type);
73 
74  // returns the queue requested for the given component
75  void setToNetQueue(NodeID id, bool ordered, int netNumber,
76  std::string vnet_type, MessageBuffer *b);
77  virtual void setFromNetQueue(NodeID id, bool ordered, int netNumber,
78  std::string vnet_type, MessageBuffer *b);
79 
80  virtual void checkNetworkAllocation(NodeID id, bool ordered,
81  int network_num, std::string vnet_type);
82 
83  virtual void makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
84  const NetDest& routing_table_entry) = 0;
85  virtual void makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
86  const NetDest& routing_table_entry) = 0;
87  virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
88  const NetDest& routing_table_entry,
89  PortDirection src_outport,
90  PortDirection dst_inport) = 0;
91 
92  virtual void collateStats() = 0;
93  virtual void print(std::ostream& out) const = 0;
94 
95  /*
96  * Virtual functions for functionally reading and writing packets in
97  * the network. Each network needs to implement these for functional
98  * accesses to work correctly.
99  */
100  virtual bool functionalRead(Packet *pkt)
101  { fatal("Functional read not implemented.\n"); }
102  virtual uint32_t functionalWrite(Packet *pkt)
103  { fatal("Functional write not implemented.\n"); }
104 
105  protected:
106  // Private copy constructor and assignment operator
107  Network(const Network& obj);
108  Network& operator=(const Network& obj);
109 
110  uint32_t m_nodes;
111  static uint32_t m_virtual_networks;
114  static uint32_t m_control_msg_size;
115  static uint32_t m_data_msg_size;
116 
117  // vector of queues from the components
121 
122  private:
125  class StatsCallback : public Callback
126  {
127  private:
129 
130  public:
131  virtual ~StatsCallback() {}
132 
134  : ctr(_ctr)
135  {
136  }
137 
138  void process() {ctr->collateStats();}
139  };
140 };
141 
142 inline std::ostream&
143 operator<<(std::ostream& out, const Network& obj)
144 {
145  obj.print(out);
146  out << std::flush;
147  return out;
148 }
149 
150 #endif // __MEM_RUBY_NETWORK_NETWORK_HH__
Network & operator=(const Network &obj)
Generic callback class.
Definition: callback.hh:41
virtual void makeExtInLink(NodeID src, SwitchID dest, BasicLink *link, const NetDest &routing_table_entry)=0
std::vector< std::vector< MessageBuffer * > > m_toNetQueues
Definition: Network.hh:118
StatsCallback(Network *_ctr)
Definition: Network.hh:133
void setToNetQueue(NodeID id, bool ordered, int netNumber, std::string vnet_type, MessageBuffer *b)
Definition: Network.cc:155
static uint32_t getNumberOfVirtualNetworks()
Definition: Network.hh:69
Callback class used for collating statistics from all the controller of this type.
Definition: Network.hh:125
virtual bool functionalRead(Packet *pkt)
Definition: Network.hh:100
virtual void collateStats()=0
std::vector< bool > m_ordered
Definition: Network.hh:120
virtual void makeExtOutLink(SwitchID src, NodeID dest, BasicLink *link, const NetDest &routing_table_entry)=0
std::vector< std::string > m_vnet_type_names
Definition: Network.hh:112
unsigned int size_type
Definition: types.hh:56
virtual ~StatsCallback()
Definition: Network.hh:131
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: Network.cc:104
virtual void checkNetworkAllocation(NodeID id, bool ordered, int network_num, std::string vnet_type)
Definition: Network.cc:139
Topology * m_topology_ptr
Definition: Network.hh:113
Bitfield< 7 > b
Definition: miscregs.hh:1564
unsigned int NodeID
Definition: TypeDefines.hh:34
static uint32_t m_control_msg_size
Definition: Network.hh:114
unsigned int SwitchID
Definition: TypeDefines.hh:35
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
virtual ~Network()
Definition: Network.cc:86
std::string PortDirection
Definition: Topology.hh:55
ClockedObject declaration and implementation.
#define fatal(...)
Definition: misc.hh:163
const Params * params() const
Definition: Network.hh:63
virtual void setFromNetQueue(NodeID id, bool ordered, int netNumber, std::string vnet_type, MessageBuffer *b)
Definition: Network.cc:166
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
static uint32_t MessageSizeType_to_int(MessageSizeType size_type)
Definition: Network.cc:110
RubyNetworkParams Params
Definition: Network.hh:61
Network(const Params *p)
Definition: Network.cc:39
static uint32_t m_data_msg_size
Definition: Network.hh:115
virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink *link, const NetDest &routing_table_entry, PortDirection src_outport, PortDirection dst_inport)=0
Declaration of the Packet class.
virtual uint32_t functionalWrite(Packet *pkt)
Definition: Network.hh:102
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:107
uint32_t m_nodes
Definition: Network.hh:110
virtual void print(std::ostream &out) const =0
static uint32_t m_virtual_networks
Definition: Network.hh:111
std::ostream & operator<<(std::ostream &out, const Network &obj)
Definition: Network.hh:143
Bitfield< 0 > p
std::vector< std::vector< MessageBuffer * > > m_fromNetQueues
Definition: Network.hh:119
void process()
virtual process function that is invoked when the callback queue is executed.
Definition: Network.hh:138
int getNumNodes() const
Definition: Network.hh:70

Generated on Fri Jun 9 2017 13:03:50 for gem5 by doxygen 1.8.6