gem5  v21.1.0.2
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__
MachineID.hh
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:189
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:252
gem5::ruby::Network::getNumberOfVirtualNetworks
static uint32_t getNumberOfVirtualNetworks()
Definition: Network.hh:90
gem5::ruby::Network::m_virtual_networks
static uint32_t m_virtual_networks
Definition: Network.hh:156
gem5::ruby::Network::makeExtOutLink
virtual void makeExtOutLink(SwitchID src, NodeID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry)=0
gem5::ruby::WriteMask
Definition: WriteMask.hh:59
gem5::ruby::Network::m_ordered
std::vector< bool > m_ordered
Definition: Network.hh:165
gem5::ruby::Network::AddrMapNode
Definition: Network.hh:169
gem5::ruby::PortDirection
std::string PortDirection
Definition: Topology.hh:68
gem5::ruby::Network::operator=
Network & operator=(const Network &obj)
gem5::ruby::Network::MessageSizeType_to_int
static uint32_t MessageSizeType_to_int(MessageSizeType size_type)
Definition: Network.cc:164
gem5::ruby::Network::getPort
Port & getPort(const std::string &, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: Network.hh:143
gem5::ruby::Topology
Definition: Topology.hh:80
gem5::ruby::operator<<
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
gem5::ruby::Network::makeInternalLink
virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry, PortDirection src_outport, PortDirection dst_inport)=0
gem5::ruby::Network::PARAMS
PARAMS(RubyNetwork)
gem5::ruby::Network
Definition: Network.hh:82
gem5::ruby::Network::addrMap
std::unordered_multimap< MachineType, AddrMapNode > addrMap
Definition: Network.hh:174
std::vector
STL vector class.
Definition: stl.hh:37
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:253
gem5::ruby::RubyDummyPort::instance
static RubyDummyPort & instance()
Definition: dummy_port.hh:56
gem5::mask
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
packet.hh
gem5::ruby::Network::functionalRead
virtual bool functionalRead(Packet *pkt)
Definition: Network.hh:121
gem5::ruby::Network::Network
Network(const Params &p)
Definition: Network.cc:58
gem5::ArmISA::b
Bitfield< 7 > b
Definition: misc_types.hh:381
gem5::ruby::Network::m_data_msg_size
static uint32_t m_data_msg_size
Definition: Network.hh:160
gem5::ruby::Network::m_nodes
uint32_t m_nodes
Definition: Network.hh:155
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
TypeDefines.hh
gem5::ruby::Network::makeExtInLink
virtual void makeExtInLink(NodeID src, SwitchID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry)=0
gem5::ruby::Network::checkNetworkAllocation
virtual void checkNetworkAllocation(NodeID local_id, bool ordered, int network_num, std::string vnet_type)
Definition: Network.cc:193
gem5::ruby::Network::setFromNetQueue
virtual void setFromNetQueue(NodeID global_id, bool ordered, int netNumber, std::string vnet_type, MessageBuffer *b)
Definition: Network.cc:222
port.hh
gem5::ruby::Network::getLocalNodeID
NodeID getLocalNodeID(NodeID global_id) const
Definition: Network.cc:253
gem5::ruby::Network::m_fromNetQueues
std::vector< std::vector< MessageBuffer * > > m_fromNetQueues
Definition: Network.hh:164
gem5::ruby::SwitchID
unsigned int SwitchID
Definition: TypeDefines.hh:41
gem5::statistics::size_type
unsigned int size_type
Definition: types.hh:60
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::ruby::Network::collateStats
virtual void collateStats()=0
gem5::ruby::Network::~Network
virtual ~Network()
Definition: Network.cc:146
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
addr_range.hh
gem5::ruby::Network::m_toNetQueues
std::vector< std::vector< MessageBuffer * > > m_toNetQueues
Definition: Network.hh:163
gem5::ruby::Network::m_vnet_type_names
std::vector< std::string > m_vnet_type_names
Definition: Network.hh:157
Topology.hh
gem5::ruby::Network::functionalRead
virtual bool functionalRead(Packet *pkt, WriteMask &mask)
Definition: Network.hh:123
gem5::ruby::Network::m_topology_ptr
Topology * m_topology_ptr
Definition: Network.hh:158
dummy_port.hh
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
gem5::ruby::Network::addressToNodeID
NodeID addressToNodeID(Addr addr, MachineType mtype)
Map an address to the correct NodeID.
Definition: Network.cc:235
types.hh
clocked_object.hh
gem5::ruby::Network::globalToLocalMap
std::unordered_map< NodeID, NodeID > globalToLocalMap
Definition: Network.hh:178
gem5::ruby::NodeID
unsigned int NodeID
Definition: TypeDefines.hh:40
gem5::ClockedObject::Params
ClockedObjectParams Params
Parameters of ClockedObject.
Definition: clocked_object.hh:240
gem5::ruby::Network::m_control_msg_size
static uint32_t m_control_msg_size
Definition: Network.hh:159
gem5::ruby::MessageBuffer
Definition: MessageBuffer.hh:74
std::list< AddrRange >
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ruby::Network::functionalWrite
virtual uint32_t functionalWrite(Packet *pkt)
Definition: Network.hh:125
gem5::ruby::Network::AddrMapNode::ranges
AddrRangeList ranges
Definition: Network.hh:172
gem5::ruby::Network::setToNetQueue
void setToNetQueue(NodeID global_id, bool ordered, int netNumber, std::string vnet_type, MessageBuffer *b)
Definition: Network.cc:209
gem5::ruby::Network::AddrMapNode::id
NodeID id
Definition: Network.hh:171
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::ruby::Network::getNumNodes
int getNumNodes() const
Definition: Network.hh:91
gem5::ruby::Network::print
virtual void print(std::ostream &out) const =0

Generated on Tue Sep 21 2021 12:25:41 for gem5 by doxygen 1.8.17