Log Log 64 6: Theline
Log Log 64 6: Theline
Answer
To get the number of in the offset field of a line in cache is the log 2 ¿ theline
log 2 64=6
Cache line has 6 bits
2. A set-associative cache consists of 64 lines, or slots, divided into four-line sets. Main
memory contains 4K blocks of 128 words each. Show the format of main memory
addresses.
Answer
The cache is divided into 16 sets of 4 lines each. Therefore, 4 bits are needed to identify
the set number. Main memory consists of 4 K=212 blocks. Therefore, the set plus tag
lengths must be 12 bits and therefore the tag length is 8 bits. Each block contains 128
words. Therefore, 7 bits are needed to specify the word.
3. A two-way set-associative cache has lines of 16 bytes and a total size of 8 kB. The 64-
MB main memory is byte addressable. Show the format of main memory addresses.
Answer
8 bytes
There are a total of =512lines ∈the . Thus the cache consists of 256 sets of 2
16 bytes
lines each. Therefore 8 bits are needed to identify the set number. For the 64-Mbyte main
64 Mbytes 22
memory, a 26-bit address is needed. Main memory consists of =2 blocks.
16 bytes
Therefore, the set plus tag lengths must be 22 bits, so the tag length is 14 bits and the
word field length is 4 bits
Tag=14 Set=8 Word =4
4. For the hexadecimal main memory addresses 111111, 666666, BBBBBB, show the
following information, in hexadecimal format:
111111 = 0001 0001 0001 0001 0001 0001
a. Tag, Line, and Word values for a direct- mapped cache, using the format of
Figure 5.7
Answer
111111
- Tag : 0001 0001 = 11
- Line : 00 0100 0100 0100 = 0444
- word : 01 = 1
666666
- Tag : 0110 0110 = 66
- Line : 01100110011001 = 1999
- Word : 10 = 2
BBBBBB
- Tag : 1011 1011 = BB
- Line 1011 1011 1011 10 = 2EEE
- Word : 11 = 3
b. Tag and Word values for an associative cache, using the format of Figure 5.10
Answer
111111
- Tag : 0001 0001 0001 0001 0001 00 = 044444
- word : 01 = 1
666666
- Tag : 011001100110011001100 = 199999
- Word : 10 = 2
BBBBBB
- Tag : 1011 1011 1011 1011 1011 10 = 2EEEEE
- Word : 11 = 3
c. Tag, Set, and Word values for a two- way set- associative cache, using the format
of Figure 5.13
Answer
111111
- Tag : 000100010 = 22
- Set : 001 0001 0001 00 = 0444
- word : 01 = 1
666666
- Tag : 0110 0110 0 = CC
- Set : 110 0110 0110 01 = 1999
- Word : 10 = 2
BBBBBB
- Tag : 101110111 = 177
- Set 10111011101110 = EEE
- Word : 11 = 3
Answer
Address length: 24 bits
Addressable units: 2 24
Block size: 4 words
Blocks in main memory: 2 22
Lines in cache: 2 14
Size of tag: 8
b. For the associative cache example of Figure 5.10 : address length, number of
addressable units, block size, number of blocks in main memory, number of lines
in cache, size of tag
Answer
Address length: 24 bits
Addressable units: 2 24
Block size: 4 words
Blocks in main memory: 2 22
Lines in cache: 2 14
Size of tag: 22
c. For the two-way set-associative cache example of Figure 5.13 : address length,
number of addressable units, block size, number of blocks in main memory,
number of lines in set, number of sets, number of lines in cache, size of tag
Answer
Address length: 24 bits
Addressable units: 2 24
Block size: 4 words
Blocks in main memory: 2 22
Lines in set: 2
Number of sets: 2 13
Lines in cache: 2 14
Size of tag: 9
6. Consider a machine with a byte addressable main memory of 2 bytes and block size
of 8 bytes. Assume that a direct mapped cache consisting of 32 lines is used with this
machine.
a. How is a 16-bit memory address divided into tag, line number, and byte
number?
Answer
Block size = 8 bytes ) 3 bits are used for byte offset. 32 cache lines ) 5 bits are used as
index bits. Remaining 16-(5+3) = 8 bits are used as tag bits.
b. Into what line would bytes with each of the following addresses be stored?
0001 0001 0001 1011
1100 0011 0011 0100
1101 0000 0001 1101
1010 1010 1010 1010
Answer
Index bits (3-7) specify the cache line. The above addresses are stored in line 3, line
6, line 3, and line 21 respectively.
c. Suppose the byte with address 0001 1010 0001 1010 is stored in the cache. What
are the addresses of the other bytes stored along with it?
Answer
Bytes with addresses 0001 1010 0001 1000 through 0001 1010 0001 1111 are stored in
the cache. The tag and index bits of other addresses should match. Other addresses
include: 0001 1010 0001 1xyz, where x, y and z can be 0 or 1
Answer
32 lines × 8 bytes/line = 256 bytes.
Answer
Several addresses map to the same cache line. Tags help in identifying addresses in a
line uniquely.( The tags are used to distinguish between possible entries in a cache
line ).