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; 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: Daniel Carvalho 29 */ 30 31/** @file 32 * Definition of a simple sector block class. Each sector consists of a 33 * sequence of cache blocks that may or may not be present in the cache. 34 */ 35 36#ifndef __MEM_CACHE_TAGS_SECTOR_BLK_HH__ 37#define __MEM_CACHE_TAGS_SECTOR_BLK_HH__ 38 39#include <vector> 40 41#include "mem/cache/cache_blk.hh" 42#include "mem/cache/replacement_policies/replaceable_entry.hh" 43 44class SectorBlk; 45 46/** 47 * A sector is composed of sub-blocks, and each sub-block has information 48 * regarding its sector and a pointer to its sector tag. 49 */ 50class SectorSubBlk : public CacheBlk 51{
|
53 /** 54 * Sector block associated to this block. 55 */ 56 SectorBlk* _sectorBlk; 57 58 /** 59 * The offset of this sub-block in the sector. 60 */ 61 int _sectorOffset; 62 63 public: 64 SectorSubBlk() : CacheBlk(), _sectorBlk(nullptr), _sectorOffset(0) {} 65 SectorSubBlk(const SectorSubBlk&) = delete; 66 SectorSubBlk& operator=(const SectorSubBlk&) = delete; 67 ~SectorSubBlk() {}; 68 69 /** 70 * Set sector block associated to this block. 71 * 72 * @param sector_blk The sector block pointer. 73 */ 74 void setSectorBlock(SectorBlk* sector_blk); 75 76 /** 77 * Get sector block associated to this block. 78 * 79 * @return The sector block pointer. 80 */ 81 const SectorBlk* getSectorBlock() const; 82 83 /** 84 * Set offset of this sub-block within the sector. 85 * 86 * @param sector_offset The block's offset. 87 */ 88 void setSectorOffset(const int sector_offset); 89 90 /** 91 * Get offset of this sub-block within the sector. 92 * 93 * @return sector_offset The block's offset. 94 */ 95 int getSectorOffset() const; 96 97 /** 98 * Get tag associated to this block. 99 * 100 * @return The tag value. 101 */ 102 Addr getTag() const; 103 104 /** 105 * Set valid bit and inform sector block. 106 */ 107 void setValid() override; 108 109 /** 110 * Set secure bit and inform sector block. 111 */ 112 void setSecure() override; 113 114 /** 115 * Invalidate the block and inform sector block. 116 */ 117 void invalidate() override; 118 119 /** 120 * Set member variables when a block insertion occurs. Resets reference 121 * count to 1 (the insertion counts as a reference), and touch block if 122 * it hadn't been touched previously. Sets the insertion tick to the 123 * current tick. Marks the block valid. 124 * 125 * @param tag Block address tag. 126 * @param is_secure Whether the block is in secure space or not. 127 * @param src_master_ID The source requestor ID. 128 * @param task_ID The new task ID. 129 */ 130 void insert(const Addr tag, const bool is_secure, const int src_master_ID, 131 const uint32_t task_ID) override; 132 133 /** 134 * Pretty-print sector offset and other CacheBlk information. 135 * 136 * @return string with basic state information 137 */ 138 std::string print() const override; 139}; 140 141/** 142 * A Basic Sector block. 143 * Contains the tag and a list of blocks associated to this sector. 144 */ 145class SectorBlk : public ReplaceableEntry 146{
|