Question

In: Computer Science

A direct-mapped cache consists of 8 blocks. Byte-addressable main memory contains 4K blocks of 8 bytes...

  1. A direct-mapped cache consists of 8 blocks. Byte-addressable main memory contains 4K blocks of 8 bytes each. Access time for the cache is 22ns, and the time required to fill a cache slot from main memory is 300ns. (This time allows us to determine the block is missing and bring it into cache.) Assume a request is always started in parallel to both cache and to main memory(so if it is not found in cache, we do not have to add this cache search time to the memory access). If a block is missing from cache, the entire block is brought into the cache and the access is restarted. Initially, the cache is empty.  You MUST show your work for all parts of this problem to receive full credit!
    1. Show the main memory address format that allows us to map addresses from main memory to cache. Be sure to include the fields as well as their sizes.
    2. Compute the hit rate for a program that loops 4 times from locations 0x0 to 0x43 (address 0 hex to address 43 hex).
    3. Compute the effective access time for this program.

Redo the previous problem, assuming a 2-way set associative cache. If a cache set is full and a block has to be removed to make room for another, remove the block that has been in cache the longest (FIFO).

Solutions

Expert Solution

2-Way Set Associative Cache

Number of blocks in cache = 8 = 23.

Number of blocks in Main memory = 4K = 212

Block size = 8 bytes = 23.

Cache access time =  22 ns

Page fault time = 300 ns.

a)

Main memory size = 212 * 23 = 215 so address = 15 bits

Number of sets in cache = 23 / 2 = 22

Byte offset = 3 bits (required to access each byte in the block)

Set offset = 2 bits (required to access each set in cache)

Tag = 15-2-3= 10 bits

Main Memory Address = Tag(10 bits) Set Offset (2 bits) Byte Offset(3 bits)

b)

Loop runs from 0x0 to 0x43 (67 in decimal)

Each block of memory contains 8 bytes. So first time miss will happen for starting address of block but subsequent 7 addresses will be hit. Please note that number of cache blocks are 8 divided into 4 sets. Each set will have two blocks.

If particular set is full then we remove the block in FIFO order.

Pass 1 of Loop

Main Memory Block

Addresses Cache (Set, Block) Number of Misses Number of Hits
0 0x0 - 0x7 0, 0 1 7
1 0x8 - 0xF 1, 0 1 7
2 0x10 - 0x17 2, 0 1 7
3 0x18 - 0x1F 3, 0 1 7
4 0x20 - 0x27 0, 1 1 7
5 0x28 - 0x2F 1, 1 1 7
6 0x30 - 0x37 2, 1 1 7
7 0x38 - 0x3F 3, 1 1 7
8 0x40 - 0x43 0, 0 1 3

Pass 2 of Loop

Main Memory Block

Addresses Cache (Set, Block) Number of Misses Number of Hits
0 0x0 - 0x7 0, 1 1 7
1 0x8 - 0xF 1, 0 0 8
2 0x10 - 0x17 2, 0 0 8
3 0x18 - 0x1F 3, 0 0 8
4 0x20 - 0x27 0, 0 1 7
5 0x28 - 0x2F 1, 1 0 8
6 0x30 - 0x37 2, 1 0 8
7 0x38 - 0x3F 3, 1 0 8
8 0x40 - 0x43 0, 1 1 3

Pass 3 of Loop

Main Memory Block

Addresses Cache (Set, Block) Number of Misses Number of Hits
0 0x0 - 0x7 0, 0 1 7
1 0x8 - 0xF 1, 0 0 8
2 0x10 - 0x17 2, 0 0 8
3 0x18 - 0x1F 3, 0 0 8
4 0x20 - 0x27 0, 1 1 7
5 0x28 - 0x2F 1, 1 0 8
6 0x30 - 0x37 2, 1 0 8
7 0x38 - 0x3F 3, 1 0 8
8 0x40 - 0x43 0, 0 1 3

Pass 4 of Loop

Main Memory Block

Addresses Cache (Set, Block) Number of Misses Number of Hits
0 0x0 - 0x7 0, 1 1 7
1 0x8 - 0xF 1, 0 0 8
2 0x10 - 0x17 2, 0 0 8
3 0x18 - 0x1F 3, 0 0 8
4 0x20 - 0x27 0, 0 1 7
5 0x28 - 0x2F 1, 1 0 8
6 0x30 - 0x37 2, 1 0 8
7 0x38 - 0x3F 3, 1 0 8
8 0x40 - 0x43 0, 1 1 3

So Hit ratio = Number of hits / total access (hit+miss)

= 254/272

= 0.94485 = 93.38%

c)

Effective access time = Hit rate * cache access time + miss rate * page fault time

= (254/272) * 22 + (18/272)*300

= 40.39 ns


Related Solutions

Suppose a computer using direct mapped cache has 224 bytes of byte-addressable main memory, and a...
Suppose a computer using direct mapped cache has 224 bytes of byte-addressable main memory, and a cache of 128 blocks, where each cache block contains 8 bytes. For fully associative cache, to which block of cache the address 0x189B5A maps? Group of answer choices Block 6 Block 75 Not enough information Block 10
A direct mapped cache has 16 blocks and block size is 64-bits (8 bytes). a. Where...
A direct mapped cache has 16 blocks and block size is 64-bits (8 bytes). a. Where will the memory block 45 reside in cache? (5 b. Where will be the memory address 1667 mapped in cache
a) consider a direct mapped cache with 10 blocks of 10 words each. Suppose main memory...
a) consider a direct mapped cache with 10 blocks of 10 words each. Suppose main memory is 1000 words. For ewach memory address below say what cache block it maps to, what is the offset, and what is the tag. 934, 666, 348, 522
A direct mapped cache has 32 cache lines.Each cache line consists of 4 words, and each...
A direct mapped cache has 32 cache lines.Each cache line consists of 4 words, and each word is four bytes.The address bus consists of 16 bits. How many bits are required for the tag in this direct-mapped cache?
Suppose we have a direct-mapped cache that can hold a total of 1024 blocks with 4...
Suppose we have a direct-mapped cache that can hold a total of 1024 blocks with 4 words per block. Compute the block index, block offset, and the tag for the following addresses: (a) 0x11001001 (b) 0x00010014 (c) 0x01000004 (d) 0x01001018 (e) 0x7bdcca10
Given an 8-word, direct mapped cache, and the sequence of address accesses below, enter the number...
Given an 8-word, direct mapped cache, and the sequence of address accesses below, enter the number of misses. CACHE CONFIG 24 13 24 10 8 8 Given an 8-word, 2-way set associative cache, and the sequence of address accesses below, enter the number of misses. CACHE CONFIG 22 1 9 22 22 22 Given an 8-word, 2-way set associative cache, and the sequence of address accesses below, enter the number of misses. CACHE CONFIG 23 23 8 20 9 20...
Below are listed parameters for different direct-mapped cache designs. Cache Data Size: 32 KiB Cache Block...
Below are listed parameters for different direct-mapped cache designs. Cache Data Size: 32 KiB Cache Block Size: 2 words Cache Access Time: 1 cycle Word: 4 bytes. Calculate the total number of bits required for the cache listed above, assuming a 32-bit address. Given that total size, find the total size of the closest direct-mapped cache with 16-word blocks of equal size or greater. Explain why the second cache, despite its larger data size, might provide slower performance than the...
For a direct mapped cache design with 32 bit address, the following bits of the address...
For a direct mapped cache design with 32 bit address, the following bits of the address are used to access the cache Tag Index Offset 31 - 8 7 - 4 3 - 0 What is the cache block size (in words)? How many entries does the cache have? What is the ratio between total bits required for such a cache implementation over the data storage bits? Starting from power on, the following byte-addressed cache references are recorded. Address 0...
A computer uses direct-mapped cache with four16-bit words, and each word has an associ-ated13-bit tag. Consider...
A computer uses direct-mapped cache with four16-bit words, and each word has an associ-ated13-bit tag. Consider the following loop (three instructions) in a program. Before the loop,the values in registersR0,R1,R2are 0, 054E, and 2 respectively. Consider that instructions arealready in separate cache memory. (See Table1.)The loop starts at location LOOP=02EC.LOOPAdd(R1)+,R0;DCRR2; BR>0LOOPShow the content of cache at the end of each pass of this loop if direct mapping cache is used.Compute hit rate.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT