113225Sodanrc@yahoo.com.br/** 213225Sodanrc@yahoo.com.br * Copyright (c) 2018 Inria 313225Sodanrc@yahoo.com.br * All rights reserved. 413225Sodanrc@yahoo.com.br * 513225Sodanrc@yahoo.com.br * Redistribution and use in source and binary forms, with or without 613225Sodanrc@yahoo.com.br * modification, are permitted provided that the following conditions are 713225Sodanrc@yahoo.com.br * met: redistributions of source code must retain the above copyright 813225Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer; 913225Sodanrc@yahoo.com.br * redistributions in binary form must reproduce the above copyright 1013225Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer in the 1113225Sodanrc@yahoo.com.br * documentation and/or other materials provided with the distribution; 1213225Sodanrc@yahoo.com.br * neither the name of the copyright holders nor the names of its 1313225Sodanrc@yahoo.com.br * contributors may be used to endorse or promote products derived from 1413225Sodanrc@yahoo.com.br * this software without specific prior written permission. 1513225Sodanrc@yahoo.com.br * 1613225Sodanrc@yahoo.com.br * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1713225Sodanrc@yahoo.com.br * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1813225Sodanrc@yahoo.com.br * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1913225Sodanrc@yahoo.com.br * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2013225Sodanrc@yahoo.com.br * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2113225Sodanrc@yahoo.com.br * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2213225Sodanrc@yahoo.com.br * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2313225Sodanrc@yahoo.com.br * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2413225Sodanrc@yahoo.com.br * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2513225Sodanrc@yahoo.com.br * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2613225Sodanrc@yahoo.com.br * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2713225Sodanrc@yahoo.com.br * 2813225Sodanrc@yahoo.com.br * Authors: Daniel Carvalho 2913225Sodanrc@yahoo.com.br */ 3013225Sodanrc@yahoo.com.br 3113225Sodanrc@yahoo.com.br#ifndef __MEM_CACHE_REPLACEMENT_POLICIES_REPLACEABLE_ENTRY_HH__ 3213225Sodanrc@yahoo.com.br#define __MEM_CACHE_REPLACEMENT_POLICIES_REPLACEABLE_ENTRY_HH__ 3313225Sodanrc@yahoo.com.br 3413225Sodanrc@yahoo.com.br#include <cstdint> 3513225Sodanrc@yahoo.com.br#include <memory> 3613225Sodanrc@yahoo.com.br 3713225Sodanrc@yahoo.com.br/** 3813225Sodanrc@yahoo.com.br * The replacement data needed by replacement policies. Each replacement policy 3913225Sodanrc@yahoo.com.br * should have its own implementation of replacement data. 4013225Sodanrc@yahoo.com.br */ 4113225Sodanrc@yahoo.com.brstruct ReplacementData {}; 4213225Sodanrc@yahoo.com.br 4313225Sodanrc@yahoo.com.br/** 4413225Sodanrc@yahoo.com.br * A replaceable entry is a basic entry in a 2d table-like structure that needs 4513225Sodanrc@yahoo.com.br * to have replacement functionality. This entry is located in a specific row 4613225Sodanrc@yahoo.com.br * and column of the table (set and way in cache nomenclature), which are 4713225Sodanrc@yahoo.com.br * stored within the entry itself. 4813225Sodanrc@yahoo.com.br * 4913225Sodanrc@yahoo.com.br * It contains the replacement data pointer, which must be instantiated by the 5013225Sodanrc@yahoo.com.br * replacement policy before being used. 5113225Sodanrc@yahoo.com.br * @sa Replacement Policies 5213225Sodanrc@yahoo.com.br */ 5313225Sodanrc@yahoo.com.brclass ReplaceableEntry 5413225Sodanrc@yahoo.com.br{ 5513225Sodanrc@yahoo.com.br private: 5613225Sodanrc@yahoo.com.br /** 5713225Sodanrc@yahoo.com.br * Set to which this entry belongs. 5813225Sodanrc@yahoo.com.br */ 5913225Sodanrc@yahoo.com.br uint32_t _set; 6013225Sodanrc@yahoo.com.br 6113225Sodanrc@yahoo.com.br /** 6213225Sodanrc@yahoo.com.br * Way (relative position within the set) to which this entry belongs. 6313225Sodanrc@yahoo.com.br */ 6413225Sodanrc@yahoo.com.br uint32_t _way; 6513225Sodanrc@yahoo.com.br 6614131Sodanrc@yahoo.com.br public: 6714131Sodanrc@yahoo.com.br ReplaceableEntry() = default; 6814131Sodanrc@yahoo.com.br virtual ~ReplaceableEntry() = default; 6914131Sodanrc@yahoo.com.br 7014131Sodanrc@yahoo.com.br /** 7114131Sodanrc@yahoo.com.br * Replacement data associated to this entry. 7214131Sodanrc@yahoo.com.br * It must be instantiated by the replacement policy before being used. 7314131Sodanrc@yahoo.com.br */ 7414131Sodanrc@yahoo.com.br std::shared_ptr<ReplacementData> replacementData; 7513225Sodanrc@yahoo.com.br 7613225Sodanrc@yahoo.com.br /** 7713225Sodanrc@yahoo.com.br * Set both the set and way. Should be called only once. 7813225Sodanrc@yahoo.com.br * 7913225Sodanrc@yahoo.com.br * @param set The set of this entry. 8013225Sodanrc@yahoo.com.br * @param way The way of this entry. 8113225Sodanrc@yahoo.com.br */ 8214117Sodanrc@yahoo.com.br virtual void 8314117Sodanrc@yahoo.com.br setPosition(const uint32_t set, const uint32_t way) 8414117Sodanrc@yahoo.com.br { 8513225Sodanrc@yahoo.com.br _set = set; 8613225Sodanrc@yahoo.com.br _way = way; 8713225Sodanrc@yahoo.com.br } 8813225Sodanrc@yahoo.com.br 8913225Sodanrc@yahoo.com.br /** 9013225Sodanrc@yahoo.com.br * Get set number. 9113225Sodanrc@yahoo.com.br * 9213225Sodanrc@yahoo.com.br * @return The set to which this entry belongs. 9313225Sodanrc@yahoo.com.br */ 9413225Sodanrc@yahoo.com.br uint32_t getSet() const { return _set; } 9513225Sodanrc@yahoo.com.br 9613225Sodanrc@yahoo.com.br /** 9713225Sodanrc@yahoo.com.br * Get way number. 9813225Sodanrc@yahoo.com.br * 9913225Sodanrc@yahoo.com.br * @return The way to which this entry belongs. 10013225Sodanrc@yahoo.com.br */ 10113225Sodanrc@yahoo.com.br uint32_t getWay() const { return _way; } 10213225Sodanrc@yahoo.com.br}; 10313225Sodanrc@yahoo.com.br 10413225Sodanrc@yahoo.com.br#endif // __MEM_CACHE_REPLACEMENT_POLICIES_REPLACEABLE_ENTRY_HH_ 105