base_set_assoc.hh (13378:038ea95fd793) | base_set_assoc.hh (13418:08101e89101e) |
---|---|
1/* 2 * Copyright (c) 2012-2014,2017 ARM Limited 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 101 unchanged lines hidden (view full) --- 110 * updates the replacement data. 111 * 112 * @param blk The block to invalidate. 113 */ 114 void invalidate(CacheBlk *blk) override; 115 116 /** 117 * Access block and update replacement data. May not succeed, in which case | 1/* 2 * Copyright (c) 2012-2014,2017 ARM Limited 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 101 unchanged lines hidden (view full) --- 110 * updates the replacement data. 111 * 112 * @param blk The block to invalidate. 113 */ 114 void invalidate(CacheBlk *blk) override; 115 116 /** 117 * Access block and update replacement data. May not succeed, in which case |
118 * nullptr is returned. This has all the implications of a cache 119 * access and should only be used as such. Returns the access latency as a 120 * side effect. | 118 * nullptr is returned. This has all the implications of a cache access and 119 * should only be used as such. Returns the tag lookup latency as a side 120 * effect. 121 * |
121 * @param addr The address to find. 122 * @param is_secure True if the target memory space is secure. | 122 * @param addr The address to find. 123 * @param is_secure True if the target memory space is secure. |
123 * @param lat The access latency. | 124 * @param lat The latency of the tag lookup. |
124 * @return Pointer to the cache block if found. 125 */ 126 CacheBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat) override 127 { 128 CacheBlk *blk = findBlock(addr, is_secure); 129 130 // Access all tags in parallel, hence one in each way. The data side 131 // either accesses all blocks in parallel, or one block sequentially on 132 // a hit. Sequential access with a miss doesn't access data. 133 tagAccesses += allocAssoc; 134 if (sequentialAccess) { 135 if (blk != nullptr) { 136 dataAccesses += 1; 137 } 138 } else { 139 dataAccesses += allocAssoc; 140 } 141 | 125 * @return Pointer to the cache block if found. 126 */ 127 CacheBlk* accessBlock(Addr addr, bool is_secure, Cycles &lat) override 128 { 129 CacheBlk *blk = findBlock(addr, is_secure); 130 131 // Access all tags in parallel, hence one in each way. The data side 132 // either accesses all blocks in parallel, or one block sequentially on 133 // a hit. Sequential access with a miss doesn't access data. 134 tagAccesses += allocAssoc; 135 if (sequentialAccess) { 136 if (blk != nullptr) { 137 dataAccesses += 1; 138 } 139 } else { 140 dataAccesses += allocAssoc; 141 } 142 |
143 // If a cache hit |
|
142 if (blk != nullptr) { | 144 if (blk != nullptr) { |
143 // If a cache hit 144 lat = accessLatency; 145 // Check if the block to be accessed is available. If not, 146 // apply the accessLatency on top of block->whenReady. 147 if (blk->whenReady > curTick() && 148 cache->ticksToCycles(blk->whenReady - curTick()) > 149 accessLatency) { 150 lat = cache->ticksToCycles(blk->whenReady - curTick()) + 151 accessLatency; 152 } 153 | |
154 // Update number of references to accessed block 155 blk->refCount++; 156 157 // Update replacement data of accessed block 158 replacementPolicy->touch(blk->replacementData); | 145 // Update number of references to accessed block 146 blk->refCount++; 147 148 // Update replacement data of accessed block 149 replacementPolicy->touch(blk->replacementData); |
159 } else { 160 // If a cache miss 161 lat = lookupLatency; | |
162 } 163 | 150 } 151 |
152 // The tag lookup latency is the same for a hit or a miss 153 lat = lookupLatency; 154 |
|
164 return blk; 165 } 166 167 /** 168 * Find replacement victim based on address. The list of evicted blocks 169 * only contains the victim. 170 * 171 * @param addr Address to find a victim for. --- 91 unchanged lines hidden --- | 155 return blk; 156 } 157 158 /** 159 * Find replacement victim based on address. The list of evicted blocks 160 * only contains the victim. 161 * 162 * @param addr Address to find a victim for. --- 91 unchanged lines hidden --- |