Question

Module 10 Assignment - Direct-mapped Cache Direct-Mapped Cache In this question youre given a 16-byte memory segment and an

1 0
Add a comment Improve this question Transcribed image text
Answer #1

Cache Type => Direct Mapped Cache

Memory Size = 16 Bytes

Cache Size = 8 Bytes

Block Size = 1 Byte

=> Byte Offset = \small log_2(#block\;size) = log_2(1) = 0 bits

So, Number of cache blocks = Cache Size / Block Size = 8/1 = 8

=> Index Bits Size = \small log_2(#cache\;blocks) = log_2(8) = 3 bits

Cache Index = Memory Block Number % #Cache Blocks = Memory Block Number % 8

Let's understand first memory access 0x48 and how can it map to cache block

Memory Access = 0x48

  • Memory address in Binary = 0100 1000
  • Cache Index = 000 => 0th Cache Block
  • Tag = 01001
  • Cache Miss
  • Contents from memory = J

Memory Access = 0x4C

  • Memory address in Binary = 0100 1100
  • Cache Index = 100 => 4th Cache Block
  • Tag = 01001
  • Cache Miss
  • Contents from memory = s

Memory Access = 0x46

  • Memory address in Binary = 0100 0110
  • Cache Index = 110 => 6th Cache Block
  • Tag = 01000
  • Cache Miss
  • Contents from memory = p

Memory Access = 0x4D

  • Memory address in Binary = 0100 1101
  • Cache Index = 101 => 5th Cache Block
  • Tag = 01001
  • Cache Miss
  • Contents from memory = A

Memory Access = 0x42

  • Memory address in Binary = 0100 0010
  • Cache Index = 010 => 2nd Cache Block
  • Tag = 01000
  • Cache Miss
  • Contents from memory = 9

Memory Access = 0x4B

  • Memory address in Binary = 0100 1011
  • Cache Index = 011 => 3rd Cache Block
  • Tag = 01001
  • Cache Miss
  • Contents from memory = V

Memory Access = 0x45

  • Memory address in Binary = 0100 0101
  • Cache Index = 101 => 5th Cache Block
  • Tag = 01000
  • Cache Miss
  • Contents from memory = 8

Memory Access = 0x41

  • Memory address in Binary = 0100 0001
  • Cache Index = 001 => 1st Cache Block
  • Tag = 01000
  • Cache Miss
  • Contents from memory = a

Memory Access = 0x48

  • Memory address in Binary = 0100 1000
  • Cache Index = 000 => 0th Cache Block
  • Tag = 01001
  • Cache Hit

Memory Access = 0x4F

  • Memory address in Binary = 0100 1111
  • Cache Index = 111 => 7th Cache Block
  • Tag = 01001
  • Cache Miss
  • Contents from memory = 4

Memory Access = 0x4A

  • Memory address in Binary = 0100 1010
  • Cache Index = 010 => 2nd Cache Block
  • Tag = 01001
  • Cache Miss
  • Contents from memory = ?

Memory Access = 0x47

  • Memory address in Binary = 0100 0111
  • Cache Index = 111 => 7th Cache Block
  • Tag = 01000
  • Cache Miss
  • Contents from memory = d

Memory Access = 0x40

  • Memory address in Binary = 0100 0000
  • Cache Index = 000 => 0th Cache Block
  • Tag = 01000
  • Cache Miss
  • Contents from memory = 3

Memory Access = 0x43

  • Memory address in Binary = 0100 0011
  • Cache Index = 011 => 3rd Cache Block
  • Tag = 01000
  • Cache Miss
  • Contents from memory = R

Memory Access = 0x4C

  • Memory address in Binary = 0100 1100
  • Cache Index = 100 => 4th Cache Block
  • Tag = 01001
  • Cache Hit

Memory Access = 0x4E

  • Memory address in Binary = 0100 1110
  • Cache Index = 110 => 6th Cache Block
  • Tag = 01001
  • Cache Miss
  • Contents from memory = T

Memory Access = 0x40

  • Memory address in Binary = 0100 0000
  • Cache Index = 000 => 0th Cache Block
  • Tag = 01000
  • Cache Hit

Memory Access = 0x49

  • Memory address in Binary = 0100 1001
  • Cache Index = 001 => 1st Cache Block
  • Tag = 01001
  • Cache Miss
  • Contents from memory = 7

Memory Access = 0x47

  • Memory address in Binary = 0100 0111
  • Cache Index = 111 => 7th Cache Block
  • Tag = 01000
  • Cache Hit
Index Contents Tag Contents Tag
000 J 1001 3 1000
001 a 1000 7 1001
010 9 1000 ? 1001
011 V 1001 R 1000
100 s 1001
101 A 1001 8 1000
110 p 1000 T 1001
111 4 1001 d 1000

Total Cache Misses = 15

Total Cache Hits = 4

In Direct Mapped cache, replacement policy is in-built policy as indexed slot is always replaced if it is full. There is no other choice.

The major dis-advatage of this replacement approach is that if multiple block which are mapped to same slot are continuously referenced then they will be swapped in and out multiple times which can lead to thrashing. Also the blocks which are not used for long time but mapped to different cache slot will always be present and never chosen for replacement.

Add a comment
Know the answer?
Add Answer to:
Module 10 Assignment - Direct-mapped Cache Direct-Mapped Cache In this question you're given a 16-byte memory...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 6. (30) Consider a 64B direct-mapped cache with 16B blocks and 4 sets for an 8-bit architecture (...

    6. (30) Consider a 64B direct-mapped cache with 16B blocks and 4 sets for an 8-bit architecture (i.e., 256 bytes of memory): a. (5) Write a C function unsigned char getTag(unsigned char address) that returns the cache tag for the specified address using bitwise operators: b. (5) Write a C function unsigned char getSet(unsigned char address) that returns the cache set for the specified address using bitwise operators: c. (10) Considering the following sequence of memory addresses, which addresses will...

  • Question 33 10 pts For a direct mapped cache of 4 blocks with a cache block...

    Question 33 10 pts For a direct mapped cache of 4 blocks with a cache block size of 1 byte, in which cache block will each memory location map to? The order of accesses if given by the operation number. Indicate if each access is a hit or a miss, and what the tag value is for each entry. Assume that the cache is initially empty, and the accesses are in order of appearance. REDRAW AND COMPLETE THE CACHE TABLE...

  • Let's start with a memory system that is byte addressable and has 14-bit addresses. Now let's...

    Let's start with a memory system that is byte addressable and has 14-bit addresses. Now let's add a direct mapped cache that can hold 16 blocks (or has 16 lines) and each block is 4 bytes. The table shoun below details the contents of the cache at a particular point in time. if the valid bit is 1 there is a cache block loaded into the cache with Tag as detailed in the tag column. The columns B0-D3 then show...

  • 1 Overview The goal of this assignment is to help you understand caches better. You are...

    1 Overview The goal of this assignment is to help you understand caches better. You are required to write a cache simulator using the C programming language. The programs have to run on iLab machines. We are providing real program memory traces as input to your cache simulator. The format and structure of the memory traces are described below. We will not give you improperly formatted files. You can assume all your input files will be in proper format as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT