Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the address mapping methods between main memory block and cache

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are the address mapping methods of main memory block and cache". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

There are three mapping modes: full association mode, direct mode and group association mode. Direct mapping can store a main memory block into a unique Cache line; fully associative mapping can store a main memory block into any Cache line; group associative mapping can store a main memory block into any line in a unique Cache group.

Operating environment of this tutorial: Windows 10 system, Dell G3 computer.

Cache is a kind of cache register, which is an important technique to solve the speed mismatch between CPU and main memory.

CPU access to memory, usually read and write a word unit at a time. When CPU accesses Cache miss, it needs to transfer the word unit stored in main memory together with several subsequent words into Cache, so that subsequent accesses can hit in Cache.

Therefore, the unit of data exchanged between main memory and Cache should be a block of data. The size of the data block is fixed, composed of several words, and the data block size of main memory and Cache is the same.

From the point of view of Cache-main memory hierarchy, on the one hand, the CPU access speed should be close to the Cache access speed, on the other hand, the running space provided for user programs should be kept as large as the main memory capacity.

In a Cache-main-memory system, the Cache is transparent to the user program, that is, the user program may not need to know about the cache. Thus, each CPU memory access is still given a main memory address, as in the case where Cache is not used. But in the Cache-main memory hierarchy, the CPU accesses Cache first, not main memory.

To do this, a mechanism is needed to translate CPU memory access addresses into Cache access addresses. The translation between main memory address and Cache address is closely related to the mapping relationship between main memory block and Cache block, that is to say, when CPU accesses Cache miss, it needs to transfer the block in main memory where the word to be accessed is located into Cache. What kind of strategy is used to transfer directly affects the corresponding relationship between main memory address and Cache address, which is the address mapping problem between main memory and Cache to be solved in this subsection.

There are three ways of address mapping between main memory and cache: full association, direct association and group association.

direct mapping

Store a main memory block into a single Cache line.

fully associative mapping

A block of main memory can be stored in any Cache line.

group associative mapping

A block of main memory can be stored in any row in a unique Cache group.

direct mapping

Many-to-one mapping, but a block of main memory can only be copied to a specific line location in cache.

cache line number i and main memory block number j have the following functional relationship: i=j mod m (m is the total number of lines in cache)

Advantages: Simple hardware, easy to implement

Disadvantages: low hit rate, low utilization of Cache storage space

totally associative mapping

A block of main memory is copied directly to any line in cache

Advantages: High hit rate, high utilization of Cache storage space

Disadvantages: complex lines, high cost, low speed

group-associative mapping

Divide cache into u groups, v rows in each group, which group main memory block is stored in is fixed, and which row is stored in this group is flexible, that is, the following functional relationship exists: Total cache number m=u×v group number q=j mod u

Direct mapping is used between groups, and full association is used within groups.

Simple hardware, faster speed, higher hit rate

"What are the address mapping methods of main memory blocks and caches?" The content is introduced here. Thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report