Mem: Use cycles to express cache-related latencies
[gem5.git] / src / mem / cache / tags / cacheset.hh
1 /*
2 * Copyright (c) 2009 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Lisa Hsu
29 */
30
31 /**
32 * @file
33 * Declaration of an associative set
34 */
35
36 #ifndef __CACHESET_HH__
37 #define __CACHESET_HH__
38
39 #include <cassert>
40
41 #include "mem/cache/blk.hh" // base class
42
43 /**
44 * An associative set of cache blocks.
45 */
46 class CacheSet
47 {
48 public:
49 /** The associativity of this set. */
50 int assoc;
51
52 /** Cache blocks in this set, maintained in LRU order 0 = MRU. */
53 CacheBlk **blks;
54
55 /**
56 * Find a block matching the tag in this set.
57 * @param asid The address space ID.
58 * @param tag The Tag to find.
59 * @return Pointer to the block if found.
60 */
61 CacheBlk* findBlk(Addr tag) const;
62
63 /**
64 * Move the given block to the head of the list.
65 * @param blk The block to move.
66 */
67 void moveToHead(CacheBlk *blk);
68
69 /**
70 * Move the given block to the tail of the list.
71 * @param blk The block to move
72 */
73 void moveToTail(CacheBlk *blk);
74
75 };
76
77 #endif