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{ 52 private: 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 member variables when a block insertion occurs. Resets reference 106 * count to 1 (the insertion counts as a reference), and touch block if 107 * it hadn't been touched previously. Sets the insertion tick to the
| 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{ 52 private: 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 member variables when a block insertion occurs. Resets reference 106 * count to 1 (the insertion counts as a reference), and touch block if 107 * it hadn't been touched previously. Sets the insertion tick to the
|
109 * 110 * @param tag Block address tag. 111 * @param is_secure Whether the block is in secure space or not. 112 * @param src_master_ID The source requestor ID. 113 * @param task_ID The new task ID. 114 */ 115 void insert(const Addr tag, const bool is_secure, const int src_master_ID, 116 const uint32_t task_ID) override; 117 118 /** 119 * Pretty-print sector offset and other CacheBlk information. 120 * 121 * @return string with basic state information 122 */ 123 std::string print() const override; 124}; 125 126/** 127 * A Basic Sector block. 128 * Contains the tag and a list of blocks associated to this sector. 129 */ 130class SectorBlk : public ReplaceableEntry 131{ 132 private: 133 /** 134 * Sector tag value. A sector's tag is the tag of all its sub-blocks. 135 */ 136 Addr _tag; 137 138 public: 139 SectorBlk() : ReplaceableEntry(), _tag(MaxAddr) {} 140 SectorBlk(const SectorBlk&) = delete; 141 SectorBlk& operator=(const SectorBlk&) = delete; 142 ~SectorBlk() {}; 143 144 /** List of blocks associated to this sector. */ 145 std::vector<SectorSubBlk*> blks; 146 147 /** 148 * Checks that a sector block is valid. 149 * 150 * @return True if any of the blocks in the sector is valid. 151 */ 152 bool isValid() const; 153 154 /** 155 * Checks that a sector block is secure. A single secure block suffices 156 * to imply that the whole sector is secure, as the insertion proccess 157 * asserts that different secure spaces can't coexist in the same sector. 158 * 159 * @return True if any of the blocks in the sector is secure. 160 */ 161 bool isSecure() const; 162 163 /** 164 * Set tag associated to this block. 165 * 166 * @param The tag value. 167 */ 168 void setTag(const Addr tag); 169 170 /** 171 * Get tag associated to this block. 172 * 173 * @return The tag value. 174 */ 175 Addr getTag() const; 176}; 177 178#endif //__MEM_CACHE_TAGS_SECTOR_BLK_HH__
| 109 * 110 * @param tag Block address tag. 111 * @param is_secure Whether the block is in secure space or not. 112 * @param src_master_ID The source requestor ID. 113 * @param task_ID The new task ID. 114 */ 115 void insert(const Addr tag, const bool is_secure, const int src_master_ID, 116 const uint32_t task_ID) override; 117 118 /** 119 * Pretty-print sector offset and other CacheBlk information. 120 * 121 * @return string with basic state information 122 */ 123 std::string print() const override; 124}; 125 126/** 127 * A Basic Sector block. 128 * Contains the tag and a list of blocks associated to this sector. 129 */ 130class SectorBlk : public ReplaceableEntry 131{ 132 private: 133 /** 134 * Sector tag value. A sector's tag is the tag of all its sub-blocks. 135 */ 136 Addr _tag; 137 138 public: 139 SectorBlk() : ReplaceableEntry(), _tag(MaxAddr) {} 140 SectorBlk(const SectorBlk&) = delete; 141 SectorBlk& operator=(const SectorBlk&) = delete; 142 ~SectorBlk() {}; 143 144 /** List of blocks associated to this sector. */ 145 std::vector<SectorSubBlk*> blks; 146 147 /** 148 * Checks that a sector block is valid. 149 * 150 * @return True if any of the blocks in the sector is valid. 151 */ 152 bool isValid() const; 153 154 /** 155 * Checks that a sector block is secure. A single secure block suffices 156 * to imply that the whole sector is secure, as the insertion proccess 157 * asserts that different secure spaces can't coexist in the same sector. 158 * 159 * @return True if any of the blocks in the sector is secure. 160 */ 161 bool isSecure() const; 162 163 /** 164 * Set tag associated to this block. 165 * 166 * @param The tag value. 167 */ 168 void setTag(const Addr tag); 169 170 /** 171 * Get tag associated to this block. 172 * 173 * @return The tag value. 174 */ 175 Addr getTag() const; 176}; 177 178#endif //__MEM_CACHE_TAGS_SECTOR_BLK_HH__
|