当前位置:网站首页>Mapping mode of cache

Mapping mode of cache

2022-06-25 09:00:00 Picchu moving forward

The hierarchy of the storage system

To address capacity , Speed , The contradiction between prices , Put all kinds of different storage capacity , Different access speeds , Memory at different prices , Organized according to a certain architecture , The stored programs and data are distributed in each memory according to the hierarchy , Form a multi tiered storage system
 Insert picture description here

  • view in its entirety ,Cache—— The access speed of main memory level is close to Cache Access speed of , But the capacity is close to the main memory
  • It solves the contradiction between high-speed and low-cost
  • This layer is completely implemented by hardware , Transparent to users
  •  Insert picture description here

How cache memory works

The principle of program locality : Time locality and space locality

The locality principle of program access
The principle of time locality : Data or instructions currently in use will be used in the near future , Then the instruction or data currently in use , We should put Cache, When used in the future , Directly from Cache Remove from
The principle of spatial locality : Data or instructions currently in use in the near future , Adjacent instructions or data may be used , We put the data or instructions currently in use from memory into Cache, At the same time, you also need to put adjacent instructions and data into Cache in .
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

Cache Address mapping ( image ) The way

  • Address mapping : Apply a function to map the main memory address to Cache Address , It is called address mapping
  • All associative mapping
  • Direct mapping
  • Group associative mapping
    For the convenience of follow-up study , Let's assume first
     Insert picture description here

All associative mapping

CPU and Cache Interact , however Cache The contents are stored from the master
 Insert picture description here
 Insert picture description here
The lower five bits of the address indicate the address within the block
The upper four digits of the address indicate which block , That is, the block number , stay 0 Block ,1 Block …
Cache Inside tag( Mark ) The table name is the block number , That is, record the block number of the corresponding main memory , Occupy 4 position ,2^4=16
If we want to compare Cache Whether to hit , Because the full connection is arbitrary , High utilization , But we need to compare the hits line by line , Low efficiency
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

Direct mapping

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

Group associative mapping

 Insert picture description here
 Insert picture description here
 Insert picture description here

 Insert picture description here

 Insert picture description here

原网站

版权声明
本文为[Picchu moving forward]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250814002044.html