Adding more details here
Tag-Directory-size = ( Tag bits * # of blocks )
For a k-way set associative cache, k is the no. of blocks in a set.
No. of blocks can be calculated as follows for each type of cache.
- I-Cache – Direct mapped cache – Tag dir = (18 tag bits * ( # of blocks ) ) = (18-bit * 1K )
- D-Cache – Set associative – Tag dir = (19 tag bits * No of sets * set associativity ) = (19 * 2$^9$ * 2 ) = ( 19-bit * 1K )
- L2-Cache – Set associative – Tag dir = ( 16 tag bits * No of sets * set associativity )
= ( 16 * 2$^{10}$ * 4 ) = ( 16 * 2$^{12}$ ) = ( 16-bit * 4K )
Similarly, for a fully-associative cache, tag dir = ( Tag bits * (# of blocks) )
A fully associative cache is also a B-way set associative cache ( only 1 set and B is the # of blocks and all blocks remain in single set )
So, Tag-directory-size for fully associative = ( tag bits * No of sets * set associativity ) = ( tag bits * 1 * ( # of blocks ) )
Hope this helps