Cache Simulator in C
You’ve got two problems. Firstly, Scott Wales is correct about your hex2bin() function – you have a ‘x’ where you mean ‘4’. Secondly, you are not correctly counting a cache miss when you hit an invalid cache slot. You can simply handle “invalid” with exactly the same code path you use for a miss: