Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
486 views
in Technique[技术] by (71.8m points)

caching - How many bits are in the address field for a directly mapped cache?

This is a question based on Direct Mapped Cache so I am assuming that it's ok to ask here as well.

Here is the problem I am working on:
The Problem: " A high speed workstation has 64 bit words and 64 bit addresses with address resolution at the byte level. Assuming a direct mapped cache with 8192 64 byte lines, how many bits are in each of the following address fields for the cache? 1) byte 2) Index 3) Tag?"

First I defined the terms in this problem and used the other Stack Overflow Direct Mapped Cache question and my other question on Caching as references(Please correct me if any of my definitions are wrong)

  • 64 bit words - processor can process 64 bits at a time
  • 64 bit addresses w byte level addressing - there are 2^64 memory locations in RAM and each memory location stores a byte.
  • Cache is high speed and is partitioned into cache lines
  • Directly Mapped Cache is where a RAM memory block is mapped into one cache line(not sure of the significance of this

Now working off Direct Mapped Cache as a reference

  1. Byte - Because a byte line is made up of 64 bytes, you need 6 bits to indentify a single byte within that byte line
  2. Index- Because there are 8192 "rows" of byte lines, you need at least 10 bits to identify every row

Now heres the part of where I am stuck. The other post said "All the other bits are TAG bits." while this lecture post said "Each line has a tag that indicates the address in M from which the line has been copied". I am guessing that M means the RAM.

So here, all the other bits would be 64 - 6 - 10 = 48 bits. But wouldn't you need all 64 bits in the TAG to indicate what memory location in the RAM the data in the cache came from? Can someone clarify the confusion I have here?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After watching this Caching Video, I was able to figure this out. (Highly recommend this video)
Please correct me if any of this is wrong

In total the address has 64 bits. Now for the different components of the cache address

  • Byte - There are 64 bytes in a byte line. A word is 64 bits or 8 bytes long. Therefore a byte line can hold 8 words. Because you need to identify which word is to be processed(Processor processes one word at a time), you're going to need 3 bits for this
  • Index - You need to identify which cache line the address refers to. Thanks to @Leeor's comment, youre going to need 13 bits to do this because there are 8192 cache lines
  • Tag - the rest of the bits are for the TAG. That be 64 - 3 - 13 = 48 bits

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...