Direct mapped vs set associative6/11/2023 ![]() Now to the more interesting part of caching. The lower $\log_2 x$ bits are called offset bits and they are used to tell the cache which address within the block we wish to access. That is, to get the block number out of a specific address we can simply ignore the last $\log_2 x$ bits (LSB), and the rest will indicate the number of the block associated with these $x$ addresses. Given a specific address in the memory, we can look at its bits representation: the MSB will be the "block number" and the LSB would be the offset inside the block. If a block contains $x$ addresses of the memory, then any $x$ consecutive addresses constitute a single block. Since the cache "knows" only blocks rather than specific addresses, we need a way to distinguish different addresses within a specific block. Maybe it contains 128 consecutive addresses. It is possible that a block contains the data of 2 (consecutive) addresses. It is possible that each block in the cache contains the data of only 1 memory-address. The cache always hold blocks of consecutive memory addresses. This "chunk" of information that we bring into the cache is called a block. So maybe when we first access address 0, and put it in the cache, it will be smart to bring along addresses 1 and 2 and 3 and put them in the cache as well. That is, many times if we access address 0, then shortly after we will access address 1 (and 2, and 3.). Many times, when we access the memory, we access consecutive addresses. But before we get there, let’s make things a bit more complex: we stop discussing addresses of the main memory and start discussing memory blocks. The index and tag bits will do just that (see below for a better explanation). In general we would like to be able to put in the cache any part of the main memory,Īnd we would need to figure out where to put each memory-address in the cache, and how to identify which memory-address lies in each cache-cell. ![]() We don’t know in advance - this would depend on the actual usage of the data (i.e., it depends on the software we run). Instead, it will hold some part of the data stored in the main memory. However, the cache is small, so it cannot hold the entire data of the main memory. So we better save data in our small and fast cache rather than in our big and slow main memory. It might take a long time to access data in the main memory, but it is very fast to access the cache. CacheĪ cache is just a faster, yet smaller, memory. If you prefer to learn by examples, jump to after the fold. Sorry if it doesn't seem like I have put a lot of work into this, but I am familiar with only directly mapped cache and the sample problems I have seen aren't very explanatory.īefore getting to your question, let's recall what set-associativity means, and how one can figure out how to split the address into tag, index and offset. Helping me understand the fundamentals of this problem would be so helpful and I appreciate all the help I can get. But in class, this is how I remember it being explained. Somehow I feel like this is all wrong, because of some sample problems I have seen. Since I have 3 sets, is it: $3 \bmod 3 = 0$, so $0$ is the index? $180 \bmod 3 = 0$ index as well? And would it looks like the following: My main problem is trying to figure out how to find the index and offset of associative (3-way set) cache. I have a 3 way set associative cache with 2 word blocks, total size of 24 words. Level 4 or Secondary Memory: It is external memory that is not as fast as the main memory but data stays permanently in this memory.My main issue of a homework problem is trying to figure out the different parts of the chart.It is small in size and once power is off data no longer stays in this memory. Level 3 or Main Memory: It is the memory on which the computer works currently.Level 2 or Cache memory: It is the fastest memory that has faster access time where data is temporarily stored for faster access.The most commonly used register is Accumulator, Program counter, Address Register, etc. Level 1 or Register: It is a type of memory in which data is stored and accepted that are immediately stored in the CPU.ISRO CS Syllabus for Scientist/Engineer Exam.ISRO CS Original Papers and Official Keys.GATE CS Original Papers and Official Keys.DevOps Engineering - Planning to Production. ![]() Python Backend Development with Django(Live).Android App Development with Kotlin(Live).Full Stack Development with React
0 Comments
Leave a Reply. |