gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fa_lru.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013,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) 2003-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_TAGS_FA_LRU_HH__
49 #define __MEM_CACHE_TAGS_FA_LRU_HH__
50 
51 #include <list>
52 #include <unordered_map>
53 
54 #include "mem/cache/base.hh"
55 #include "mem/cache/blk.hh"
56 #include "mem/cache/tags/base.hh"
57 #include "mem/packet.hh"
58 #include "params/FALRU.hh"
59 
63 class FALRUBlk : public CacheBlk
64 {
65 public:
71  bool isTouched;
72 
81  int inCache;
82 };
83 
88 class FALRU : public BaseTags
89 {
90  public:
92  typedef FALRUBlk BlkType;
93 
94  protected:
98  int cacheMask;
100  unsigned numCaches;
101 
104 
109 
111  typedef std::unordered_map<Addr, FALRUBlk *, std::hash<Addr> > hash_t;
113  typedef hash_t::const_iterator tagIterator;
114 
117 
123  FALRUBlk * hashLookup(Addr addr) const;
124 
129  void moveToHead(FALRUBlk *blk);
130 
136  bool check();
137 
151 
156 public:
157 
158  typedef FALRUParams Params;
159 
163  FALRU(const Params *p);
164  ~FALRU();
165 
170  void regStats() override;
171 
176  void invalidate(CacheBlk *blk) override;
177 
189  CacheBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat,
190  int *inCache);
191 
195  CacheBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat) override;
196 
204  CacheBlk* findBlock(Addr addr, bool is_secure) const override;
205 
211  CacheBlk* findVictim(Addr addr) override;
212 
213  void insertBlock(PacketPtr pkt, CacheBlk *blk) override;
214 
221  CacheBlk* findBlockBySetAndWay(int set, int way) const override;
222 
229  Addr extractTag(Addr addr) const override
230  {
231  return blkAlign(addr);
232  }
233 
239  int extractSet(Addr addr) const override
240  {
241  return 0;
242  }
243 
250  Addr regenerateBlkAddr(Addr tag, unsigned set) const override
251  {
252  return (tag);
253  }
254 
258  virtual std::string print() const override { return ""; }
259 
272  void forEachBlk(CacheBlkVisitor &visitor) override {
273  for (int i = 0; i < numBlocks; i++) {
274  if (!visitor(blks[i]))
275  return;
276  }
277  }
278 
279 };
280 
281 #endif // __MEM_CACHE_TAGS_FA_LRU_HH__
Declares a basic cache interface BaseCache.
FALRU(const Params *p)
Construct and initialize this cache tagstore.
Definition: fa_lru.cc:58
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Bitfield< 7 > i
Definition: miscregs.hh:1378
CacheBlk * findVictim(Addr addr) override
Find a replacement block for the address provided.
Definition: fa_lru.cc:250
ip6_addr_t addr
Definition: inet.hh:335
FALRUBlk * head
The MRU block.
Definition: fa_lru.hh:106
A fully associative LRU cache.
Definition: fa_lru.hh:88
CacheBlk * findBlock(Addr addr, bool is_secure) const override
Find the block in the cache, do not update the replacement data.
Definition: fa_lru.cc:229
A vector of scalar stats.
Definition: statistics.hh:2499
FALRUBlk * next
The next block in LRU order.
Definition: fa_lru.hh:69
void insertBlock(PacketPtr pkt, CacheBlk *blk) override
Definition: fa_lru.cc:272
int cacheMask
A mask for the FALRUBlk::inCache bits.
Definition: fa_lru.hh:98
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
FALRUBlk ** cacheBoundaries
Array of pointers to blocks at the cache size boundaries.
Definition: fa_lru.hh:96
FALRUBlk * tail
The LRU block.
Definition: fa_lru.hh:108
Declaration of a common base class for cache tagstore objects.
Addr blkAlign(Addr addr) const
Align an address to the block size.
Definition: base.hh:196
BaseTagsParams Params
Definition: base.hh:151
A Basic Cache block.
Definition: blk.hh:79
unsigned numBlocks
the number of blocks in the cache
Definition: base.hh:94
A fully associative cache block.
Definition: fa_lru.hh:63
std::unordered_map< Addr, FALRUBlk *, std::hash< Addr > > hash_t
Hash table type mapping addresses to cache block pointers.
Definition: fa_lru.hh:111
Stats::Vector hits
Hits in each cache size >= 128K.
Definition: fa_lru.hh:146
void invalidate(CacheBlk *blk) override
Invalidate a cache block.
Definition: fa_lru.cc:167
void forEachBlk(CacheBlkVisitor &visitor) override
Visit each block in the tag store and apply a visitor to the block.
Definition: fa_lru.hh:272
Addr regenerateBlkAddr(Addr tag, unsigned set) const override
Regenerate the block address from the tag and the set.
Definition: fa_lru.hh:250
unsigned numCaches
The number of different size caches being tracked.
Definition: fa_lru.hh:100
hash_t tagHash
The address hash table.
Definition: fa_lru.hh:116
void moveToHead(FALRUBlk *blk)
Move a cache block to the MRU position.
Definition: fa_lru.cc:277
Definitions of a simple cache block class.
Stats::Scalar accesses
Total number of accesses.
Definition: fa_lru.hh:150
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
~FALRU()
Definition: fa_lru.cc:113
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
Stats::Vector misses
Misses in each cache size >= 128K.
Definition: fa_lru.hh:148
int inCache
A bit mask of the sizes of cache that this block is resident in.
Definition: fa_lru.hh:81
void regStats() override
Register the stats for this object.
Definition: fa_lru.cc:122
Declaration of the Packet class.
bool isTouched
Has this block been touched?
Definition: fa_lru.hh:71
Addr extractTag(Addr addr) const override
Generate the tag from the addres.
Definition: fa_lru.hh:229
CacheBlk * accessBlock(Addr addr, bool is_secure, Cycles &lat, int *inCache)
Access block and update replacement data.
Definition: fa_lru.cc:180
FALRUBlk * blks
The cache blocks.
Definition: fa_lru.hh:103
virtual std::string print() const override
Definition: fa_lru.hh:258
FALRUBlk * prev
The previous block in LRU order.
Definition: fa_lru.hh:67
FALRUBlk * hashLookup(Addr addr) const
Find the cache block for the given address.
Definition: fa_lru.cc:157
FALRUParams Params
Definition: fa_lru.hh:158
int extractSet(Addr addr) const override
Return the set of an address.
Definition: fa_lru.hh:239
hash_t::const_iterator tagIterator
Iterator into the address hash table.
Definition: fa_lru.hh:113
FALRUBlk BlkType
Typedef the block type used in this class.
Definition: fa_lru.hh:92
Bitfield< 0 > p
A common base class of Cache tagstore objects.
Definition: base.hh:65
Base class for cache block visitor, operating on the cache block base class (later subclassed for the...
Definition: blk.hh:397
bool check()
Check to make sure all the cache boundaries are still where they should be.
Definition: fa_lru.cc:306
CacheBlk * findBlockBySetAndWay(int set, int way) const override
Find the cache block given set and way.
Definition: fa_lru.cc:243

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