Verifycations
Verifycations

Reputation: 69

Direct mapped cache example

i am really confused on the topic Direct Mapped Cache i've been looking around for an example with a good explanation and it's making me more confused then ever.

For example: I have

so the addres would be like this: 5 for the tag, 3 for the index and 3 for the byte offset

Do i have this figured out correctly?

Upvotes: 4

Views: 2322

Answers (1)

Hari Krishnan
Hari Krishnan

Reputation: 6302

Do i figured out correctly? YES

Explanation

1) Main memmory size is 2048 bytes = 211. So you need 11 bits to address a byte (If your word size is 1 byte) [word = smallest individual unit that will be accessed with the address]

2) You can calculating tag bits in direct mapping by doing (main memmory size / cash size). But i will explain a little more about tag bits.

Here the size of a cashe line( which is always same as size of a main memmory block) is 8 bytes. which is 23 bytes. So you need 3 bits to represent a byte within a cashe line. Now you have 8 bits (11 - 3) are remaining in the address.

Now the total number of lines present in the cache is (cashe size / line size) = 26 / 23 = 23

So, you have 3 bits to represent the line in which the your required byte is present.

The number of remaining bits now are 5 (8 - 3).

These 5 bits can be used to represent a tag. :)

3) 3 bit for index. If you were trying to label the number of bits needed to represent a line as index. Yes you are right.

4) 3 bits will be used to access a byte withing a cache line. (8 = 23)

So,

11 bits total address length = 5 tag bits + 3 bits to represent a line + 3 bits to represent a byte(word) withing a line

Hope there is no confusion now.

Upvotes: 3

Related Questions