gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mshr.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, 2015-2016 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) 2002-2005 The Regents of The University of Michigan
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  * Authors: Erik Hallnor
41  */
42 
48 #ifndef __MEM_CACHE_MSHR_HH__
49 #define __MEM_CACHE_MSHR_HH__
50 
51 #include <list>
52 
53 #include "base/printable.hh"
54 #include "mem/cache/queue_entry.hh"
55 
56 class Cache;
57 
63 class MSHR : public QueueEntry, public Printable
64 {
65 
69  template<typename Entry>
70  friend class Queue;
71  friend class MSHRQueue;
72 
73  private:
74 
77 
103 
106 
109 
110  public:
111 
113  bool isForward;
114 
115  class Target {
116  public:
117 
118  enum Source {
122  };
123 
124  const Tick recvTime;
125  const Tick readyTime;
126  const Counter order;
127  const PacketPtr pkt;
128  const Source source;
129 
146 
147  const bool allocOnFill;
148 
150  Target(PacketPtr _pkt, Tick _readyTime, Counter _order,
151  Source _source, bool _markedPending, bool alloc_on_fill)
152  : recvTime(curTick()), readyTime(_readyTime), order(_order),
153  pkt(_pkt), source(_source), markedPending(_markedPending),
154  allocOnFill(alloc_on_fill)
155  {}
156  };
157 
158  class TargetList : public std::list<Target> {
159 
160  public:
165 
166  TargetList();
167 
176  void updateFlags(PacketPtr pkt, Target::Source source,
177  bool alloc_on_fill);
178 
180 
187  void populateFlags();
188 
193  bool isReset() const {
194  return !needsWritable && !hasUpgrade && !allocOnFill;
195  }
196 
210  Target::Source source, bool markPending,
211  bool alloc_on_fill);
212 
217  void replaceUpgrades();
218 
219  void clearDownstreamPending();
220  bool checkFunctional(PacketPtr pkt);
221  void print(std::ostream &os, int verbosity,
222  const std::string &prefix) const;
223  };
224 
228  typedef List::iterator Iterator;
229 
236  bool needsWritable() const { return targets.needsWritable; }
237 
238  bool isPendingModified() const {
239  assert(inService); return pendingModified;
240  }
241 
242  bool hasPostInvalidate() const {
243  assert(inService); return postInvalidate;
244  }
245 
246  bool hasPostDowngrade() const {
247  assert(inService); return postDowngrade;
248  }
249 
250  bool sendPacket(Cache &cache);
251 
252  bool allocOnFill() const {
253  return targets.allocOnFill;
254  }
255  private:
256 
262 
268 
271 
273 
274  public:
275 
285  void allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt,
286  Tick when_ready, Counter _order, bool alloc_on_fill);
287 
288  void markInService(bool pending_modified_resp);
289 
290  void clearDownstreamPending();
291 
295  void deallocate();
296 
301  void allocateTarget(PacketPtr target, Tick when, Counter order,
302  bool alloc_on_fill);
303  bool handleSnoop(PacketPtr target, Counter order);
304 
306  MSHR();
307 
312  int getNumTargets() const
313  { return targets.size() + deferredTargets.size(); }
314 
327  TargetList extractServiceableTargets(PacketPtr pkt);
328 
333  bool hasTargets() const { return !targets.empty(); }
334 
340  {
341  assert(hasTargets());
342  return &targets.front();
343  }
344 
348  void popTarget()
349  {
350  targets.pop_front();
351  }
352 
353  bool promoteDeferredTargets();
354 
355  void promoteWritable();
356 
357  bool checkFunctional(PacketPtr pkt);
358 
362  void print(std::ostream &os,
363  int verbosity = 0,
364  const std::string &prefix = "") const;
371  std::string print() const;
372 };
373 
374 #endif // __MEM_CACHE_MSHR_HH__
Iterator readyIter
Pointer to this MSHR on the ready list.
Definition: mshr.hh:261
std::string print() const
A no-args wrapper of print(std::ostream...) meant to be invoked from DPRINTFs avoiding string overhea...
Definition: mshr.cc:589
bool inService
True if the entry has been sent downstream.
Definition: queue_entry.hh:80
const Tick readyTime
Time when request is ready to be serviced.
Definition: mshr.hh:125
A Class for maintaining a list of pending and allocated memory requests.
Definition: mshr_queue.hh:59
std::list< MSHR * > List
A list of MSHRs.
Definition: mshr.hh:226
void resetFlags()
Definition: mshr.hh:179
bool needsWritable() const
The pending* and post* flags are only valid if inService is true.
Definition: mshr.hh:236
bool isReset() const
Tests if the flags of this TargetList have their default values.
Definition: mshr.hh:193
const Source source
Request from cpu, memory, or prefetcher?
Definition: mshr.hh:128
int getNumTargets() const
Returns the current number of allocated targets.
Definition: mshr.hh:312
bool allocOnFill
Set when the response should allocate on fill.
Definition: mshr.hh:164
const PacketPtr pkt
Pending request packet.
Definition: mshr.hh:127
bool checkFunctional(PacketPtr pkt)
Definition: mshr.cc:200
void print(std::ostream &os, int verbosity, const std::string &prefix) const
Definition: mshr.cc:213
void promoteWritable()
Definition: mshr.cc:518
Tick readyTime
Tick when ready to issue.
Definition: queue_entry.hh:72
Counter order
Order number assigned to disambiguate writes and misses.
Definition: queue_entry.hh:83
TargetList deferredTargets
Definition: mshr.hh:272
A high-level queue interface, to be used by both the MSHR queue and the write buffer.
Definition: queue.hh:64
Bitfield< 17 > os
Definition: misc.hh:804
A template-policy based cache.
Definition: cache.hh:74
List::iterator Iterator
MSHR list iterator.
Definition: mshr.hh:228
bool postInvalidate
Did we snoop an invalidate while waiting for data?
Definition: mshr.hh:105
Target(PacketPtr _pkt, Tick _readyTime, Counter _order, Source _source, bool _markedPending, bool alloc_on_fill)
Definition: mshr.hh:150
const bool allocOnFill
Should the response servicing this target list allocate in the cache?
Definition: mshr.hh:147
void popTarget()
Pop first target.
Definition: mshr.hh:348
Tick curTick()
The current simulated tick.
Definition: core.hh:47
void allocateTarget(PacketPtr target, Tick when, Counter order, bool alloc_on_fill)
Add a request to the list of targets.
Definition: mshr.cc:303
void markInService(bool pending_modified_resp)
Definition: mshr.cc:274
Target * getTarget()
Returns a reference to the first target.
Definition: mshr.hh:339
bool needsWritable
Definition: mshr.hh:161
Generic queue entry.
uint64_t Tick
Tick count type.
Definition: types.hh:63
bool hasTargets() const
Returns true if there are targets left.
Definition: mshr.hh:333
Miss Status and handling Register.
Definition: mshr.hh:63
STL list class.
Definition: stl.hh:54
void clearDownstreamPending()
Definition: mshr.cc:179
TargetList targets
List of all requests that match the address.
Definition: mshr.hh:270
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
bool markedPending
We use this flag to track whether we have cleared the downstreamPending flag for the MSHR of the cach...
Definition: mshr.hh:145
int64_t Counter
Statistics counter type.
Definition: types.hh:58
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
Abstract base class for objects which support being printed to a stream for debugging.
Definition: printable.hh:44
const Counter order
Global order (for memory consistency mgmt)
Definition: mshr.hh:126
A queue entry base class, to be used by both the MSHRs and write-queue entries.
Definition: queue_entry.hh:60
void updateFlags(PacketPtr pkt, Target::Source source, bool alloc_on_fill)
Use the provided packet and the source to update the flags of this TargetList.
Definition: mshr.cc:78
bool sendPacket(Cache &cache)
Send this queue entry as a downstream packet, with the exact behaviour depending on the specific entr...
Definition: mshr.cc:558
void populateFlags()
Goes through the list of targets and uses them to populate the flags of this TargetList.
Definition: mshr.cc:100
bool hasUpgrade
Definition: mshr.hh:162
void clearDownstreamPending()
Definition: mshr.cc:264
bool hasPostDowngrade() const
Definition: mshr.hh:246
bool handleSnoop(PacketPtr target, Counter order)
Definition: mshr.cc:345
void replaceUpgrades()
Convert upgrades to the equivalent request if the cache line they refer to would have been invalid (U...
Definition: mshr.cc:165
TargetList extractServiceableTargets(PacketPtr pkt)
Extracts the subset of the targets that can be serviced given a received response.
Definition: mshr.cc:458
bool isForward
True if the entry is just a simple forward from an upper level.
Definition: mshr.hh:113
MSHR()
A simple constructor.
Definition: mshr.cc:65
bool promoteDeferredTargets()
Definition: mshr.cc:491
bool pendingModified
Here we use one flag to track both if:
Definition: mshr.hh:102
const Tick recvTime
Time when request was received (for stats)
Definition: mshr.hh:124
void deallocate()
Mark this MSHR as free.
Definition: mshr.cc:291
bool checkFunctional(PacketPtr pkt)
Definition: mshr.cc:543
Iterator allocIter
Pointer to this MSHR on the allocated list.
Definition: mshr.hh:267
void add(PacketPtr pkt, Tick readyTime, Counter order, Target::Source source, bool markPending, bool alloc_on_fill)
Add the specified packet in the TargetList.
Definition: mshr.cc:109
void allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, Tick when_ready, Counter _order, bool alloc_on_fill)
Allocate a miss to this MSHR.
Definition: mshr.cc:240
bool hasPostInvalidate() const
Definition: mshr.hh:242
bool isPendingModified() const
Definition: mshr.hh:238
bool downstreamPending
Flag set by downstream caches.
Definition: mshr.hh:76
bool allocOnFill() const
Definition: mshr.hh:252
bool postDowngrade
Did we snoop a read while waiting for data?
Definition: mshr.hh:108

Generated on Fri Jun 9 2017 13:03:48 for gem5 by doxygen 1.8.6