All problems
Cache Set Index Bits
Problem
Split a physical address into cache tag, set index, and block offset.
block_size is the cache line size and num_sets is the number of sets. The offset is the address modulo block_size, the set index is the block number modulo num_sets, and the tag is the block number divided by num_sets.
Return [tag, set_index, offset].
Hint
The tag counts how many complete set-groups precede the address.
Test cases
case 1
in: [0,4,2]
expected: [0,0,0]
case 2
in: [5,4,2]
expected: [0,1,1]
case 3
in: [100,8,4]
expected: [3,0,4]
case 4
in: [37,16,8]
expected: [0,2,5]
Starter codePython
def cache_split(address, block_size, num_sets):
# Your code here
pass4 test cases · run your code against them in the editor