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

--- 27 unchanged lines hidden (view full) ---

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/protocol/LinkDirection.hh"
64#include "mem/protocol/MessageSizeType.hh"
65#include "mem/ruby/common/MachineID.hh"
66#include "mem/ruby/common/TypeDefines.hh"
67#include "mem/ruby/network/Topology.hh"
51#include "mem/packet.hh"
68#include "params/RubyNetwork.hh"
69#include "sim/clocked_object.hh"
70
71class NetDest;
72class MessageBuffer;
73
74class Network : public ClockedObject
75{

--- 37 unchanged lines hidden (view full) ---

113 * the network. Each network needs to implement these for functional
114 * accesses to work correctly.
115 */
116 virtual bool functionalRead(Packet *pkt)
117 { fatal("Functional read not implemented.\n"); }
118 virtual uint32_t functionalWrite(Packet *pkt)
119 { fatal("Functional write not implemented.\n"); }
120
121 /**
122 * Map an address to the correct NodeID
123 *
124 * This function traverses the global address map to find the
125 * NodeID that corresponds to the given address and the type of
126 * the destination. For example for a request to a directory this
127 * function will return the NodeID of the right directory.
128 *
129 * @param the destination address
130 * @param the type of the destination
131 * @return the NodeID of the destination
132 */
133 NodeID addressToNodeID(Addr addr, MachineType mtype);
134
135 protected:
136 // Private copy constructor and assignment operator
137 Network(const Network& obj);
138 Network& operator=(const Network& obj);
139
140 uint32_t m_nodes;
141 static uint32_t m_virtual_networks;
142 std::vector<std::string> m_vnet_type_names;

--- 19 unchanged lines hidden (view full) ---

162
163 StatsCallback(Network *_ctr)
164 : ctr(_ctr)
165 {
166 }
167
168 void process() {ctr->collateStats();}
169 };
170
171 // Global address map
172 struct AddrMapNode {
173 NodeID id;
174 AddrRangeList ranges;
175 };
176 std::unordered_multimap<MachineType, AddrMapNode> addrMap;
177};
178
179inline std::ostream&
180operator<<(std::ostream& out, const Network& obj)
181{
182 obj.print(out);
183 out << std::flush;
184 return out;
185}
186
187#endif // __MEM_RUBY_NETWORK_NETWORK_HH__