gem5  v22.1.0.0
Network.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017,2021 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 namespace gem5
74 {
75 
76 namespace ruby
77 {
78 
79 class NetDest;
80 class MessageBuffer;
81 
82 class Network : public ClockedObject
83 {
84  public:
85  PARAMS(RubyNetwork);
86  Network(const Params &p);
87 
88  virtual ~Network();
89 
90  static uint32_t getNumberOfVirtualNetworks() { return m_virtual_networks; }
91  int getNumNodes() const { return m_nodes; }
92 
93  static uint32_t MessageSizeType_to_int(MessageSizeType size_type);
94 
95  // returns the queue requested for the given component
96  void setToNetQueue(NodeID global_id, bool ordered, int netNumber,
97  std::string vnet_type, MessageBuffer *b);
98  virtual void setFromNetQueue(NodeID global_id, bool ordered, int netNumber,
99  std::string vnet_type, MessageBuffer *b);
100 
101  virtual void checkNetworkAllocation(NodeID local_id, bool ordered,
102  int network_num, std::string vnet_type);
103 
104  virtual void makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
105  std::vector<NetDest>& routing_table_entry) = 0;
106  virtual void makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
107  std::vector<NetDest>& routing_table_entry) = 0;
108  virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
109  std::vector<NetDest>& routing_table_entry,
110  PortDirection src_outport,
111  PortDirection dst_inport) = 0;
112 
113  virtual void collateStats() = 0;
114  virtual void print(std::ostream& out) const = 0;
115 
116  /*
117  * Virtual functions for functionally reading and writing packets in
118  * the network. Each network needs to implement these for functional
119  * accesses to work correctly.
120  */
121  virtual bool functionalRead(Packet *pkt)
122  { fatal("Functional read not implemented.\n"); }
123  virtual bool functionalRead(Packet *pkt, WriteMask& mask)
124  { fatal("Masked functional read not implemented.\n"); }
125  virtual uint32_t functionalWrite(Packet *pkt)
126  { fatal("Functional write not implemented.\n"); }
127 
140  NodeID addressToNodeID(Addr addr, MachineType mtype);
141 
142  Port &
143  getPort(const std::string &, PortID idx=InvalidPortID) override
144  {
145  return RubyDummyPort::instance();
146  }
147 
148  NodeID getLocalNodeID(NodeID global_id) const;
149 
150  protected:
151  // Private copy constructor and assignment operator
152  Network(const Network& obj);
153  Network& operator=(const Network& obj);
154 
155  uint32_t m_nodes;
156  static uint32_t m_virtual_networks;
159  static uint32_t m_control_msg_size;
160  static uint32_t m_data_msg_size;
161 
162  // vector of queues from the components
166 
167  private:
168  // Global address map
169  struct AddrMapNode
170  {
173  };
174  std::unordered_multimap<MachineType, AddrMapNode> addrMap;
175 
176  // Global NodeID to local node map. If there are not multiple networks in
177  // the same RubySystem, this is a one-to-one mapping of global to local.
178  std::unordered_map<NodeID, NodeID> globalToLocalMap;
179 };
180 
181 inline std::ostream&
182 operator<<(std::ostream& out, const Network& obj)
183 {
184  obj.print(out);
185  out << std::flush;
186  return out;
187 }
188 
189 } // namespace ruby
190 } // namespace gem5
191 
192 #endif // __MEM_RUBY_NETWORK_NETWORK_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
ClockedObjectParams Params
Parameters of ClockedObject.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Ports are used to interface objects to each other.
Definition: port.hh:62
PARAMS(RubyNetwork)
void setToNetQueue(NodeID global_id, bool ordered, int netNumber, std::string vnet_type, MessageBuffer *b)
Definition: Network.cc:209
virtual ~Network()
Definition: Network.cc:146
virtual void setFromNetQueue(NodeID global_id, bool ordered, int netNumber, std::string vnet_type, MessageBuffer *b)
Definition: Network.cc:222
std::unordered_multimap< MachineType, AddrMapNode > addrMap
Definition: Network.hh:174
virtual bool functionalRead(Packet *pkt)
Definition: Network.hh:121
std::vector< bool > m_ordered
Definition: Network.hh:165
static uint32_t m_data_msg_size
Definition: Network.hh:160
static uint32_t m_control_msg_size
Definition: Network.hh:159
static uint32_t getNumberOfVirtualNetworks()
Definition: Network.hh:90
Topology * m_topology_ptr
Definition: Network.hh:158
Port & getPort(const std::string &, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: Network.hh:143
virtual void checkNetworkAllocation(NodeID local_id, bool ordered, int network_num, std::string vnet_type)
Definition: Network.cc:193
virtual uint32_t functionalWrite(Packet *pkt)
Definition: Network.hh:125
Network(const Network &obj)
static uint32_t m_virtual_networks
Definition: Network.hh:156
static uint32_t MessageSizeType_to_int(MessageSizeType size_type)
Definition: Network.cc:164
virtual void print(std::ostream &out) const =0
std::vector< std::vector< MessageBuffer * > > m_fromNetQueues
Definition: Network.hh:164
std::unordered_map< NodeID, NodeID > globalToLocalMap
Definition: Network.hh:178
virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry, PortDirection src_outport, PortDirection dst_inport)=0
NodeID getLocalNodeID(NodeID global_id) const
Definition: Network.cc:253
int getNumNodes() const
Definition: Network.hh:91
virtual bool functionalRead(Packet *pkt, WriteMask &mask)
Definition: Network.hh:123
uint32_t m_nodes
Definition: Network.hh:155
Network & operator=(const Network &obj)
virtual void makeExtOutLink(SwitchID src, NodeID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry)=0
virtual void collateStats()=0
NodeID addressToNodeID(Addr addr, MachineType mtype)
Map an address to the correct NodeID.
Definition: Network.cc:235
Network(const Params &p)
Definition: Network.cc:58
std::vector< std::vector< MessageBuffer * > > m_toNetQueues
Definition: Network.hh:163
virtual void makeExtInLink(NodeID src, SwitchID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry)=0
std::vector< std::string > m_vnet_type_names
Definition: Network.hh:157
static RubyDummyPort & instance()
Definition: dummy_port.hh:56
STL vector class.
Definition: stl.hh:37
ClockedObject declaration and implementation.
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:190
Port Object Declaration.
Bitfield< 7 > b
Definition: misc_types.hh:388
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 3 > addr
Definition: types.hh:84
unsigned int SwitchID
Definition: TypeDefines.hh:43
std::string PortDirection
Definition: TypeDefines.hh:44
unsigned int NodeID
Definition: TypeDefines.hh:42
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
unsigned int size_type
Definition: types.hh:60
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
Declaration of the Packet class.

Generated on Wed Dec 21 2022 10:22:38 for gem5 by doxygen 1.9.1