0
$\begingroup$

enter image description here

My question is, how can I get the line number just by dividing the number by the cache line size(64)?

For example, let's take 510,

510 in binary is 000000000(00111)111110 , so 00111 is show the line and 7 ,But it can be get easily by 510/64=7 ,How it can happen ,becasue the address contain all the information other than line like tag,offset.What is the idea behind it, and does it always work?

asked 13 hours ago
New contributor
Hasintha Hewage is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
1
  • $\begingroup$ What about 4650? $\endgroup$ Commented 7 hours ago

1 Answer 1

0
$\begingroup$

Since cache block (also called cache line) size is given as 64 byte and the system is assumed to be byte addressable, the first 64 bytes of main memory (RAM) will go in first cache block (index 0) i.e. memory cells at 0, 1, 2 .... 63 will go in cache block 0.

Then memory cells 64, 65, 66 .... 127 will go in the cache block 1.

Do you see a pattern?

The pattern is that the cache $$ \text{Cache Block No.} = \left\lfloor \frac{A}{B} \right\rfloor $$

Where:

  • (A) = memory address (in decimal form) of memory cells
  • (B) = cache block size

Note that memory address is assumed to be in decimal form. This formula wont work for case when address is given in other form eg binary or hexadecimal form.

answered 9 hours ago
New contributor
Osmium is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
1
  • $\begingroup$ What about 4650? $\endgroup$ Commented 7 hours ago

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.