1/* 2 * Copyright (c) 2011-2015, 2018 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 --- 102 unchanged lines hidden (view full) --- 111 * back when drained. 112 * 113 * @param de drain event to call once drained 114 * 115 * @return 1 if busy or waiting to retry, or 0 if idle 116 */ 117 DrainState drain() override; 118 |
119 const std::string name() const { return xbar.name() + _name; } 120 121 122 /** 123 * Determine if the layer accepts a packet from a specific 124 * port. If not, the port in question is also added to the 125 * retry list. In either case the state of the layer is 126 * updated accordingly. --- 19 unchanged lines hidden (view full) --- 146 * not already at the front) and occupying the layer 147 * accordingly. 148 * 149 * @param src_port Source port 150 * @param busy_time Time to spend as a result of a failed send 151 */ 152 void failedTiming(SrcType* src_port, Tick busy_time); 153 |
154 void occupyLayer(Tick until); 155 156 /** 157 * Send a retry to the port at the head of waitingForLayer. The 158 * caller must ensure that the list is not empty. 159 */ 160 void retryWaiting(); 161 162 /** 163 * Handle a retry from a neighbouring module. This wraps 164 * retryWaiting by verifying that there are ports waiting 165 * before calling retryWaiting. 166 */ 167 void recvRetry(); 168 |
169 void regStats(); 170 171 protected: 172 173 /** 174 * Sending the actual retry, in a manner specific to the 175 * individual layers. Note that for a MasterPort, there is 176 * both a RequestLayer and a SnoopResponseLayer using the same --- 4 unchanged lines hidden (view full) --- 181 private: 182 183 /** The destination port this layer converges at. */ 184 DstType& port; 185 186 /** The crossbar this layer is a part of. */ 187 BaseXBar& xbar; 188 |
189 std::string _name; 190 191 /** 192 * We declare an enum to track the state of the layer. The 193 * starting point is an idle state where the layer is waiting 194 * for a packet to arrive. Upon arrival, the layer 195 * transitions to the busy state, where it remains either 196 * until the packet transfer is done, or the header time is --- 4 unchanged lines hidden (view full) --- 201 * idle to retry if the layer receives a retry from one of 202 * its connected ports. The retry state lasts until the port 203 * in questions calls sendTiming and returns control to the 204 * layer, or goes to a busy state if the port does not 205 * immediately react to the retry by calling sendTiming. 206 */ 207 enum State { IDLE, BUSY, RETRY }; 208 |
209 State state; 210 211 /** 212 * A deque of ports that retry should be called on because 213 * the original send was delayed due to a busy layer. 214 */ 215 std::deque<SrcType*> waitingForLayer; 216 --- 4 unchanged lines hidden (view full) --- 221 SrcType* waitingForPeer; 222 223 /** 224 * Release the layer after being occupied and return to an 225 * idle state where we proceed to send a retry to any 226 * potential waiting port, or drain if asked to do so. 227 */ 228 void releaseLayer(); |
229 EventFunctionWrapper releaseEvent; 230 231 /** 232 * Stats for occupancy and utilization. These stats capture 233 * the time the layer spends in the busy state and are thus only 234 * relevant when the memory system is in timing mode. 235 */ 236 Stats::Scalar occupancy; 237 Stats::Formula utilization; 238 239 }; 240 |
241 class ReqLayer : public Layer<SlavePort, MasterPort> |
242 { 243 public: 244 /** 245 * Create a request layer and give it a name. 246 * 247 * @param _port destination port the layer converges at 248 * @param _xbar the crossbar this layer belongs to 249 * @param _name the layer's name 250 */ 251 ReqLayer(MasterPort& _port, BaseXBar& _xbar, const std::string& _name) : |
252 Layer(_port, _xbar, _name) 253 {} |
254 255 protected: |
256 void 257 sendRetry(SlavePort* retry_port) override 258 { 259 retry_port->sendRetryReq(); 260 } |
261 }; 262 |
263 class RespLayer : public Layer<MasterPort, SlavePort> |
264 { 265 public: 266 /** 267 * Create a response layer and give it a name. 268 * 269 * @param _port destination port the layer converges at 270 * @param _xbar the crossbar this layer belongs to 271 * @param _name the layer's name 272 */ |
273 RespLayer(SlavePort& _port, BaseXBar& _xbar, 274 const std::string& _name) : 275 Layer(_port, _xbar, _name) 276 {} |
277 278 protected: |
279 void 280 sendRetry(MasterPort* retry_port) override 281 { 282 retry_port->sendRetryResp(); 283 } |
284 }; 285 |
286 class SnoopRespLayer : public Layer<SlavePort, MasterPort> |
287 { 288 public: 289 /** 290 * Create a snoop response layer and give it a name. 291 * 292 * @param _port destination port the layer converges at 293 * @param _xbar the crossbar this layer belongs to 294 * @param _name the layer's name 295 */ 296 SnoopRespLayer(MasterPort& _port, BaseXBar& _xbar, 297 const std::string& _name) : |
298 Layer(_port, _xbar, _name) 299 {} |
300 301 protected: 302 |
303 void 304 sendRetry(SlavePort* retry_port) override 305 { 306 retry_port->sendRetrySnoopResp(); 307 } |
308 }; 309 310 /** 311 * Cycles of front-end pipeline including the delay to accept the request 312 * and to decode the address. 313 */ 314 const Cycles frontendLatency; |
315 const Cycles forwardLatency; |
316 const Cycles responseLatency; 317 /** the width of the xbar in bytes */ 318 const uint32_t width; 319 320 AddrRangeMap<PortID, 3> portMap; 321 322 /** 323 * Remember where request packets came from so that we can route --- 86 unchanged lines hidden (view full) --- 410 411 void init() override; 412 413 /** A function used to return the port associated with this object. */ 414 Port &getPort(const std::string &if_name, 415 PortID idx=InvalidPortID) override; 416 417 void regStats() override; |
418}; 419 420#endif //__MEM_XBAR_HH__ |