base.hh (13218:5e7df60c6cab) base.hh (13225:8d1621fc586e)
1/**
2 * Copyright (c) 2018 Inria
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;

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

28 * Authors: Daniel Carvalho
29 */
30
31#ifndef __MEM_CACHE_REPLACEMENT_POLICIES_BASE_HH__
32#define __MEM_CACHE_REPLACEMENT_POLICIES_BASE_HH__
33
34#include <memory>
35
1/**
2 * Copyright (c) 2018 Inria
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;

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

28 * Authors: Daniel Carvalho
29 */
30
31#ifndef __MEM_CACHE_REPLACEMENT_POLICIES_BASE_HH__
32#define __MEM_CACHE_REPLACEMENT_POLICIES_BASE_HH__
33
34#include <memory>
35
36#include "mem/cache/replacement_policies/replaceable_entry.hh"
36#include "params/BaseReplacementPolicy.hh"
37#include "sim/sim_object.hh"
38
39/**
37#include "params/BaseReplacementPolicy.hh"
38#include "sim/sim_object.hh"
39
40/**
40 * The replacement data needed by the replacement policy.
41 * Each replacement policy should have its own replacement data.
42 */
43struct ReplacementData {};
44
45/**
46 * A replaceable entry is used by any table-like structure that needs to
47 * implement replacement functionality. It provides the replacement data
48 * pointer instantiated and needed by the replacement policy used.
49 * @sa Replacement Policies
50 */
51class ReplaceableEntry
52{
53 private:
54 /**
55 * Set to which this entry belongs.
56 */
57 uint32_t _set;
58
59 /**
60 * Way (relative position within the set) to which this entry belongs.
61 */
62 uint32_t _way;
63
64 public:
65 /**
66 * Replacement data associated to this entry.
67 * It is instantiated by the replacement policy.
68 */
69 std::shared_ptr<ReplacementData> replacementData;
70
71 /**
72 * Set both the set and way. Should be called only once.
73 *
74 * @param set The set of this entry.
75 * @param way The way of this entry.
76 */
77 void setPosition(const uint32_t set, const uint32_t way) {
78 _set = set;
79 _way = way;
80 }
81
82 /**
83 * Get set number.
84 *
85 * @return The set to which this entry belongs.
86 */
87 uint32_t getSet() const { return _set; }
88
89 /**
90 * Get way number.
91 *
92 * @return The way to which this entry belongs.
93 */
94 uint32_t getWay() const { return _way; }
95};
96
97/**
98 * Replacement candidates as chosen by the indexing policy.
99 */
100typedef std::vector<ReplaceableEntry*> ReplacementCandidates;
101
102/**
103 * A common base class of cache replacement policy objects.
104 */
105class BaseReplacementPolicy : public SimObject

--- 59 unchanged lines hidden ---
41 * Replacement candidates as chosen by the indexing policy.
42 */
43typedef std::vector<ReplaceableEntry*> ReplacementCandidates;
44
45/**
46 * A common base class of cache replacement policy objects.
47 */
48class BaseReplacementPolicy : public SimObject

--- 59 unchanged lines hidden ---