gem5  v20.1.0.0
Network.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 ARM Limited
3  * All rights reserved.
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 /*
42  * The Network class is the base class for classes that implement the
43  * interconnection network between components (processor/cache
44  * components and memory/directory components). The interconnection
45  * network as described here is not a physical network, but a
46  * programming concept used to implement all communication between
47  * components. Thus parts of this 'network' will model the on-chip
48  * connections between cache controllers and directory controllers as
49  * well as the links between chip and network switches.
50  */
51 
52 #ifndef __MEM_RUBY_NETWORK_NETWORK_HH__
53 #define __MEM_RUBY_NETWORK_NETWORK_HH__
54 
55 #include <iostream>
56 #include <string>
57 #include <unordered_map>
58 #include <vector>
59 
60 #include "base/addr_range.hh"
61 #include "base/types.hh"
62 #include "mem/packet.hh"
63 #include "mem/port.hh"
68 #include "mem/ruby/protocol/LinkDirection.hh"
69 #include "mem/ruby/protocol/MessageSizeType.hh"
70 #include "params/RubyNetwork.hh"
71 #include "sim/clocked_object.hh"
72 
73 class NetDest;
74 class MessageBuffer;
75 
76 class Network : public ClockedObject
77 {
78  public:
79  typedef RubyNetworkParams Params;
80  Network(const Params *p);
81  const Params * params() const
82  { return dynamic_cast<const Params *>(_params); }
83 
84  virtual ~Network();
85  void init() override;
86 
87  static uint32_t getNumberOfVirtualNetworks() { return m_virtual_networks; }
88  int getNumNodes() const { return m_nodes; }
89 
90  static uint32_t MessageSizeType_to_int(MessageSizeType size_type);
91 
92  // returns the queue requested for the given component
93  void setToNetQueue(NodeID global_id, bool ordered, int netNumber,
94  std::string vnet_type, MessageBuffer *b);
95  virtual void setFromNetQueue(NodeID global_id, bool ordered, int netNumber,
96  std::string vnet_type, MessageBuffer *b);
97 
98  virtual void checkNetworkAllocation(NodeID local_id, bool ordered,
99  int network_num, std::string vnet_type);
100 
101  virtual void makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
102  std::vector<NetDest>& routing_table_entry) = 0;
103  virtual void makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
104  std::vector<NetDest>& routing_table_entry) = 0;
105  virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
106  std::vector<NetDest>& routing_table_entry,
107  PortDirection src_outport,
108  PortDirection dst_inport) = 0;
109 
110  virtual void collateStats() = 0;
111  virtual void print(std::ostream& out) const = 0;
112 
113  /*
114  * Virtual functions for functionally reading and writing packets in
115  * the network. Each network needs to implement these for functional
116  * accesses to work correctly.
117  */
118  virtual bool functionalRead(Packet *pkt)
119  { fatal("Functional read not implemented.\n"); }
120  virtual uint32_t functionalWrite(Packet *pkt)
121  { fatal("Functional write not implemented.\n"); }
122 
135  NodeID addressToNodeID(Addr addr, MachineType mtype);
136 
137  Port &
138  getPort(const std::string &, PortID idx=InvalidPortID) override
139  {
140  return RubyDummyPort::instance();
141  }
142 
143  NodeID getLocalNodeID(NodeID global_id) const;
144 
145  protected:
146  // Private copy constructor and assignment operator
147  Network(const Network& obj);
148  Network& operator=(const Network& obj);
149 
150  uint32_t m_nodes;
151  static uint32_t m_virtual_networks;
154  static uint32_t m_control_msg_size;
155  static uint32_t m_data_msg_size;
156 
157  // vector of queues from the components
161 
162  private:
163  // Global address map
164  struct AddrMapNode {
167  };
168  std::unordered_multimap<MachineType, AddrMapNode> addrMap;
169 
170  // Global NodeID to local node map. If there are not multiple networks in
171  // the same RubySystem, this is a one-to-one mapping of global to local.
172  std::unordered_map<NodeID, NodeID> globalToLocalMap;
173 };
174 
175 inline std::ostream&
176 operator<<(std::ostream& out, const Network& obj)
177 {
178  obj.print(out);
179  out << std::flush;
180  return out;
181 }
182 
183 #endif // __MEM_RUBY_NETWORK_NETWORK_HH__
MachineID.hh
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:183
Network::m_vnet_type_names
std::vector< std::string > m_vnet_type_names
Definition: Network.hh:152
Network::setFromNetQueue
virtual void setFromNetQueue(NodeID global_id, bool ordered, int netNumber, std::string vnet_type, MessageBuffer *b)
Definition: Network.cc:218
Network::Network
Network(const Params *p)
Definition: Network.cc:52
operator<<
std::ostream & operator<<(std::ostream &out, const Network &obj)
Definition: Network.hh:176
Network::Params
RubyNetworkParams Params
Definition: Network.hh:79
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
Network::collateStats
virtual void collateStats()=0
Network::m_toNetQueues
std::vector< std::vector< MessageBuffer * > > m_toNetQueues
Definition: Network.hh:158
Network::addressToNodeID
NodeID addressToNodeID(Addr addr, MachineType mtype)
Map an address to the correct NodeID.
Definition: Network.cc:231
Network::makeExtOutLink
virtual void makeExtOutLink(SwitchID src, NodeID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry)=0
Network::AddrMapNode::ranges
AddrRangeList ranges
Definition: Network.hh:166
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
std::vector< NetDest >
Network::m_virtual_networks
static uint32_t m_virtual_networks
Definition: Network.hh:151
Network::AddrMapNode
Definition: Network.hh:164
Network::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: Network.cc:154
ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:231
packet.hh
Network::makeExtInLink
virtual void makeExtInLink(NodeID src, SwitchID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry)=0
Network::globalToLocalMap
std::unordered_map< NodeID, NodeID > globalToLocalMap
Definition: Network.hh:172
Network::getLocalNodeID
NodeID getLocalNodeID(NodeID global_id) const
Definition: Network.cc:249
RubyDummyPort::instance
static RubyDummyPort & instance()
Definition: dummy_port.hh:50
Network::m_control_msg_size
static uint32_t m_control_msg_size
Definition: Network.hh:154
Network::addrMap
std::unordered_multimap< MachineType, AddrMapNode > addrMap
Definition: Network.hh:168
TypeDefines.hh
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
port.hh
Network::m_ordered
std::vector< bool > m_ordered
Definition: Network.hh:160
Network::MessageSizeType_to_int
static uint32_t MessageSizeType_to_int(MessageSizeType size_type)
Definition: Network.cc:160
Network::setToNetQueue
void setToNetQueue(NodeID global_id, bool ordered, int netNumber, std::string vnet_type, MessageBuffer *b)
Definition: Network.cc:205
Network::~Network
virtual ~Network()
Definition: Network.cc:136
Network::m_data_msg_size
static uint32_t m_data_msg_size
Definition: Network.hh:155
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Network
Definition: Network.hh:76
Network::getNumberOfVirtualNetworks
static uint32_t getNumberOfVirtualNetworks()
Definition: Network.hh:87
addr_range.hh
Network::m_fromNetQueues
std::vector< std::vector< MessageBuffer * > > m_fromNetQueues
Definition: Network.hh:159
Network::params
const Params * params() const
Definition: Network.hh:81
Topology.hh
Network::operator=
Network & operator=(const Network &obj)
Network::makeInternalLink
virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry, PortDirection src_outport, PortDirection dst_inport)=0
ArmISA::b
Bitfield< 7 > b
Definition: miscregs_types.hh:376
dummy_port.hh
types.hh
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
clocked_object.hh
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
addr
ip6_addr_t addr
Definition: inet.hh:423
PortDirection
std::string PortDirection
Definition: Topology.hh:62
NodeID
unsigned int NodeID
Definition: TypeDefines.hh:34
Network::checkNetworkAllocation
virtual void checkNetworkAllocation(NodeID local_id, bool ordered, int network_num, std::string vnet_type)
Definition: Network.cc:189
Stats::size_type
unsigned int size_type
Definition: types.hh:54
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Topology
Definition: Topology.hh:74
std::list< AddrRange >
MessageBuffer
Definition: MessageBuffer.hh:68
Network::getPort
Port & getPort(const std::string &, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: Network.hh:138
Network::getNumNodes
int getNumNodes() const
Definition: Network.hh:88
Network::m_nodes
uint32_t m_nodes
Definition: Network.hh:150
NetDest
Definition: NetDest.hh:39
Network::AddrMapNode::id
NodeID id
Definition: Network.hh:165
SwitchID
unsigned int SwitchID
Definition: TypeDefines.hh:35
Network::functionalRead
virtual bool functionalRead(Packet *pkt)
Definition: Network.hh:118
Network::print
virtual void print(std::ostream &out) const =0
Network::m_topology_ptr
Topology * m_topology_ptr
Definition: Network.hh:153
Network::functionalWrite
virtual uint32_t functionalWrite(Packet *pkt)
Definition: Network.hh:120

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17