Solving Memory Cache Exercise: Addressing Memory & Tags

  • Thread starter MaxR2018
  • Start date
  • Tags
    Memory
In summary, the physical address used for words, lines of blocks or sets and labels in a system with main memory of 32 MB and a cache of 256 KB with blocks of 32 bytes (1 word = 2 Bytes) is as follows: - Tag = 10 bits - Set = 10 bits - Word = 5 bits - Offset = 5 bits The total number of address bits is 25 bits. However, if we consider a word to be 2 bytes, then the number of address bits per word would be 16 bits. The cache has 1024 sets, not 1000 as originally mentioned. It is also important to note the units given in the problem statement.
  • #1
MaxR2018
5
0
Homework Statement
System with main memory of 32 MB and a cache of 256 KB with blocks of 32 bytes (1 word = 2 Bytes), determine the bits of the physical address used for words, lines of blocks or sets and labels if the cache memory has associative mapping by sets of 8 ways.
Relevant Equations
Not required
I'm triying to do thiS way, but I'm not sure.

First: I have 32Mb of so 32Mb=2^25, so the memory adress has 25 bits.
Second: with blocks of 32 bytes =2^5 bytes so the word has 5 bits.
Third: If cache has 256kb and each block has 32 bytes, so 256kb/32bytes=8000, that means i have 8000 ways. If a set has with 8 ways each one, so 8000/8=1000 sets =2^10. So set has 10 bits in the adress.

At last if the adress has 25 bits, so tag has:

25 bits - 5 bits - 10 bits = 10 bits.

End result:

Adress memory=32 bits
Tag=10bits
Set=10bits
Word=5bits

Is this well resolved?
 
Physics news on Phys.org
  • #2
MaxR2018 said:
Problem Statement: System with main memory of 32 MB and a cache of 256 KB with blocks of 32 bytes (1 word = 2 Bytes), determine the bits of the physical address used for words, lines of blocks or sets and labels if the cache memory has associative mapping by sets of 8 ways.
Relevant Equations: Not required

I'm triying to do thiS way, but I'm not sure.

First: I have 32Mb of so 32Mb=2^25, so the memory adress has 25 bits.
Second: with blocks of 32 bytes =2^5 bytes so the word has 5 bits.
Third: If cache has 256kb and each block has 32 bytes, so 256kb/32bytes=8000, that means i have 8000 ways. If a set has with 8 ways each one, so 8000/8=1000 sets =2^10. So set has 10 bits in the adress.

At last if the adress has 25 bits, so tag has:

25 bits - 5 bits - 10 bits = 10 bits.

End result:

Adress memory=32 bits
Tag=10bits
Set=10bits
Word=5bits

Is this well resolved?
Your answer kind of agrees with what I came up with for the associative cache part, but with different terminology. Using the more common parlance of TAG, SET, and OFFSET, I got
TAG = 10 bits
SET = 10 bits
OFFSET = 5 bits.

I also agree with your original answer that the physical address contains 25 bits. But then at the end you say it's 32 bits. ?! I don't know what you mean there.

However the question also asks you how many address bits per word, where a word is two bytes. I don't think you've done that yet.

Also, I'm not sure what "label" refers to here. Is that the same thing as OFFSET? I'm not sure. Whatever the case, you'll have to answer how many address bits used to index words, lines of blocks or sets and labels.

One last thing: The problem statement says the cache is 256 KB. Notice the units "KB." This is different than "kB" and is also different than "KiB." It's important that you know what it means exactly. I interpret this as meaning 256 killobytes (same as 256 KiB [or kibibyte], but not 256 kB), where a kilobyte = 1024 bits bytes. That means the cache has 1024 sets, not the 1000 sets that you claimed. To be sure, check with your coursework, textbook, or instructor.
 
Last edited:
  • Like
Likes MaxR2018

1. What is a memory cache exercise?

A memory cache exercise is a problem-solving activity that involves addressing memory and tags. It typically involves identifying the location of data in a memory cache based on its address and tag, and understanding how the cache operates to retrieve data efficiently.

2. Why is it important to understand memory cache?

Understanding memory cache is important because it plays a crucial role in computer performance. By understanding how the cache operates and how to optimize its use, programmers and computer scientists can improve the speed and efficiency of data retrieval, leading to faster and more efficient computing.

3. What is the difference between memory and cache?

Memory refers to the physical storage component of a computer, where data and instructions are stored for later use. Cache, on the other hand, is a smaller and faster form of memory that is used to temporarily store frequently accessed data for quick retrieval. Cache is designed to speed up the performance of a computer by reducing the time it takes to access data from the main memory.

4. How do you address memory in a cache exercise?

In a cache exercise, memory is addressed using a combination of an index and a tag. The index specifies the location of the data in the cache, and the tag is used to identify whether the data is present in the cache or not. The address of a memory location is divided into these two components to determine the location of the data in the cache.

5. What are some strategies for optimizing memory cache performance?

Some strategies for optimizing memory cache performance include using a larger cache size, implementing an efficient replacement policy, and organizing data in the cache based on access patterns. Additionally, using multi-level caches and prefetching data can also improve cache performance.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
850
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
15
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
6K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Nuclear Engineering
Replies
7
Views
543
Back
Top