From 8f58d9fb87c521674f11c78b8939e5ffdf851d39 Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Fri, 7 Sep 2018 14:33:00 +0200 Subject: mem-cache: Use set and way for ReplaceableEntry Replaceable entries belong to table-like structures, and therefore they should be indexable by combining a row and a column. These, using conventional cache nomenclature translate to sets and ways. Make these entries aware of their sets and ways. The idea is to make indexing policies usable by other table-like structures. In order to do so we move sets and ways to ReplaceableEntry, which will be the common base among table entries. Change-Id: If0e3dacf9ea2f523af9cface067469ccecf82648 Reviewed-on: https://gem5-review.googlesource.com/c/12764 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- src/mem/cache/replacement_policies/base.hh | 44 +++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'src/mem/cache/replacement_policies') diff --git a/src/mem/cache/replacement_policies/base.hh b/src/mem/cache/replacement_policies/base.hh index 0ce86d091..6ac7dca85 100644 --- a/src/mem/cache/replacement_policies/base.hh +++ b/src/mem/cache/replacement_policies/base.hh @@ -50,12 +50,48 @@ struct ReplacementData {}; */ class ReplaceableEntry { - public: + private: + /** + * Set to which this entry belongs. + */ + uint32_t _set; + + /** + * Way (relative position within the set) to which this entry belongs. + */ + uint32_t _way; + + public: + /** + * Replacement data associated to this entry. + * It is instantiated by the replacement policy. + */ + std::shared_ptr replacementData; + /** - * Replacement data associated to this entry. - * It is instantiated by the replacement policy. + * Set both the set and way. Should be called only once. + * + * @param set The set of this entry. + * @param way The way of this entry. + */ + void setPosition(const uint32_t set, const uint32_t way) { + _set = set; + _way = way; + } + + /** + * Get set number. + * + * @return The set to which this entry belongs. + */ + uint32_t getSet() const { return _set; } + + /** + * Get way number. + * + * @return The way to which this entry belongs. */ - std::shared_ptr replacementData; + uint32_t getWay() const { return _way; } }; /** -- cgit v1.2.3