Question

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 result in cache hits and which will result in misses (assuming that the cache is initially empty)? For each address, show the tag, set, offset, and whether it resulted in hit or miss:

0x00
0x46
0x06
0x40
0x12
0x0c

d. (10) Now assume that cache is 2-way set associative with 2 sets rather than direct mapped with 4 sets, but that the parameters are otherwise unchaged. Use the Least Recently Used (LRU) eviction policy if evictions are necessary. Again consider the following sequence of memory addresses; for each address, show the tag, set, offset, and whether it resulted in hit or miss:

0x00
0x46
0x06
0x40
0x12
0x0c
0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a)C program

#include<stdio.h>

//least 3 bit is offset (block size = 8byte offset = 3 bit)
unsigned char getOffset(unsigned char address){
   return address&0x07;
}
//next 2 bit left to offset is set bit(set = (cache size)/block size 32/8 = 4 (2 bit))
unsigned char getSet(unsigned char address){
   return (address>>3)&(0x03);
}

int main(){
   unsigned char ch = 'M';
   printf("Offset : %d\n",getOffset(ch));
   printf("Set : %d",getSet(ch));
  
   return 0;
}

//sample output

CUsers IshuManish\Documents\ offset.exe ffset 5 et 1 Process exited after 0.008848 seconds with return value 7 Press any key

(C)bit- ser 26,七 y bit 0ト00 lo,Looleno ser, o, @us.ohadr Toa cloes nt maton(D)d) cache sizes 648 set NO- T Line 2 Set- 3 bit miss ct(mis) Olo TY-o (miss〉 0xoc

Add a comment
Know the answer?
Add Answer to:
6. (30) Consider a 64B direct-mapped cache with 16B blocks and 4 sets for an 8-bit architecture (...
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
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
ADVERTISEMENT