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/** 32 * @file 33 * Declaration of a compressed set associative tag store using superblocks. 34 */ 35 36#ifndef __MEM_CACHE_TAGS_COMPRESSED_TAGS_HH__ 37#define __MEM_CACHE_TAGS_COMPRESSED_TAGS_HH__ 38 39#include <vector> 40 41#include "mem/cache/tags/sector_tags.hh" 42#include "mem/cache/tags/super_blk.hh" 43 44class BaseCache; 45struct CompressedTagsParams; 46 47/** 48 * A CompressedTags cache tag store. 49 * @sa \ref gem5MemorySystem "gem5 Memory System" 50 * 51 * The Compression Ratio (CR) of a superblock is defined by 52 * CR = uncompressed_size / compressed_size. 53 * 54 * The CompressedTags placement policy divides the cache into s sets of w 55 * superblocks (ways). Each superblock can then contain up to CR compressed 56 * blocks. 57 * 58 * For each tag entry there can be multiple data blocks. We have the same 59 * number of tags a conventional cache would have, but we instantiate the 60 * maximum number of data blocks (according to the compression ratio) per 61 * tag, to virtually implement compression without increasing the complexity 62 * of the simulator. 63 * 64 * This is a simple implementation of cache compression, where superblocks 65 * can only have at most numBlocksPerSector compressed blocks, each compressed 66 * to at least (100/numBlocksPerSector)% of its size. 67 * 68 * numBlocksPerSector holds the maximum number of blocks a superblock with 69 * the best possible compression factor would hold. It is equivalent to CR 70 * from the previous definition. 71 */ 72class CompressedTags : public SectorTags 73{ 74 private: 75 /** The cache blocks. */ 76 std::vector<CompressionBlk> blks; 77 /** The cache superblocks. */ 78 std::vector<SuperBlk> superBlks; 79 80 public: 81 /** Convenience typedef. */ 82 typedef CompressedTagsParams Params; 83 84 /** 85 * Construct and initialize this tag store. 86 */ 87 CompressedTags(const Params *p); 88 89 /** 90 * Destructor. 91 */ 92 virtual ~CompressedTags() {}; 93 94 /** 95 * Initialize blocks as SuperBlk and CompressionBlk instances. 96 */ 97 void tagsInit() override; 98 99 /**
|