in CO and Architecture edited by
8,528 views
29 votes
29 votes

Consider a machine with a byte addressable main memory of $2^{20}$ bytes, block size of $16$ bytes and a direct mapped cache having $2^{12}$ cache lines. Let the addresses of two consecutive bytes in main memory be $\textsf{(E201F)}_{16}$ and $\textsf{(E2020)}_{16}$. What are the tag and cache line addresses ( in hex) for main memory address $\textsf{(E201F)}_{16}$?

  1. $\textsf{E, 201}$
  2. $\textsf{F, 201}$
  3. $\textsf{E, E20}$
  4. $\textsf{2, 01F}$
in CO and Architecture edited by
8.5k views

2 Comments

repetitive concept

GATE 2020 also
1
1
this is a beautiful question
0
0

4 Answers

42 votes
42 votes
Best answer

Block size of $16$ bytes means we need $4$ offset bits. (The lowest $4$ digits of memory address are offset bits)

Number of sets in cache (cache lines) $= 2^{12}$ so the next lower $12$ bits are used for set indexing. 

The top $4\;\text{bits}\; ($out of $20)$ are tag bits.

So, the answer is A. 

edited by
by

4 Comments

If you convert the given hexadecimal numbers into binary you will come to know that these are two adjacent bytes in main memeory .

E201F- 1110 0010 0000 0001 1111

E2020- 1110 0010 0000 0010 0000

I think it is just given as a representation and doesnt have much significance in solving this question .
4
4
@ Abhishek

for this question for block or for cache line u have to consider 12 bits while u consider only 4 bit

As MM size given 2^20 B so , to represent physical address we need 20 bits.

Here block size given 16 B so to represent block offset we need 4 bit which will be 4 LSB of PA

Here cache line given 2^12 so we need 12 bits to represent line number

Since 4 bit for block offset and 12 bit for line number so 4 MSB will represent tag (as tag + line + offset =20)

So Tag = 4 MSB =E

cache line =12 bit after tag= 201

 to solve this question we are not getting any information from (E201F) and (E2020) and we not required too, to solve this question
0
0

@Upasana singh @Swati Rauniyar 

If some information is given in question its not that we have to use it to get the answer. Many a times such information are given just to confuse the aspirants.

0
0
5 votes
5 votes

Let the addresses of two consecutive bytes in main memory be $(E201F)_{16}$ and $(E2020)_{16}$

$E20$ is common to both hex numbers, so ignore it.

$1F=0001 \ 1111=31 \ (decimal)$

$20=0010 \ 0000=32 \ (decimal)$

 

So, difference between two consecutive memory locations = $1 \ B$ Hence, the memory is byte addressable.


First $4$ bits would be tag bits, and next $12$ bits would be index bits.

Tag Line Offset
4 12 4

So, for $(E201F)_{16}$

Tag = $E$; Line = $201$

2 votes
2 votes
Block Size = 16 bytes
Block Offset = 4 


No. of sets or cache lines = 2
12 Number of index bits = 12 Size of main memory = 220 Number of tag bits = 20 - 12 - 4 = 4 Let us consider the hex address E201F Tag lines = First 4 bits = E (in hex) Cache lines = Next 12 bits = 201 (In Hex)
1 vote
1 vote

……………………………………………...……………………

Answer:

Related questions