乔部落格

世界上有10种人:认识二进制的和不认识二进制的

主存与Cache的地址映像

joe posted @ 2010年5月29日 18:46 in 电脑基础 with tags cache , 5668 阅读

与主存容量相比,Cache的容量很小,它所保存的信息仅是主存信息的一个子集,且cache与主存的信息交换是以块为单位。为了把信息放到Cache中,必须事先规定好主存与cache之间的地址映像方式,即某一个Cache块可以作为哪些主存块的副本(即映像)。映像方式一旦确定,就决定了访问Cache时对主存地址的理解,因而也就决定了Cache的组织结构。目前有三种地址映像方式:直接映像、全相联映像和组相联映像。 
  1.直接映像(Direct Mapping)
  采用直接映像时,Cache的某一块只能和固定的一些主存块建立映像关系,主存的某一块只能对应一个Cache块。直接映像的优点是硬件简单、成本低;缺点是不够灵活,主存的若干块只能对应惟一的Cache块,即使Cache中还有空位,也不能利用。
  2.全相联映像(Associative Mapping)
  采用全相联映像时,Cache的某一块可以和任一主存块建立映像关系,而主存中某一块也可以映像到(2ache中任一块位置上。由于Cache的某一块可以和任一主存块建立映像关系,所以Cache的标记部分必须记录主存块块地址的全部信息。例如,主存分为2n块,块的地址为n位,标记也应为n位。 采用全相联映像方式时,主存地址被理解为由两部分组成:标记(主存块号)和块内地址。CPU 在访问存储器时,为了判断是否命中,主存地址的标记部分需要和Cache的所有块的标记进行比较。为了缩短比较的时间,将主存地址的标记部分和Cache 的所有块的标记同时进行比较。如果命中,则按块内地址访问Cache中的命中块(其标记与主存地址给出的标记相同);如果未命中,则访问主存。

全相联映像的优点是灵活,Cache利用率高。缺点有两个:一是标记位数增加了(需要记录主存块块地址的全部信息),使得Cache的电路规模变大,成本变高;二是比较器难于设计和实现(通常采用“按内容寻址的”相联存储器)。因此,只有小容量Cache才采用这种映像方式。
  3.组相联映像(Set Associative Mapping)
  组相联映像方式是介于直接映像和全相联映像之间的一种折中方案。设Cache中共有m个块,在采用组相联映像方式时,将m个Cache块分成u组(set),每组k个块(即m=u
×k),组间直接映像,而组内全相联映像。所谓组间直接映像,是指某组中的Cache块只能与固定的一些主存块建立映像关系。这种映像关系可用下式表示:
    i=j mod n其中i为Cache组的编号,j为主存块的编号,u为Cache的组数。例如,Cache第0组只能和满足i mod u=0的主存块(即第0块、第u块、第2u块……)建立映像关系,Cache第1组只能和满足i mod u=1的主存块(即第l块、第u+1块、第2u+l块……)建立映像关系。所谓组内全相联映像,是指和某Cache组相对应的主存块可以和该组内的任意一个Cache块建立映像关系。

组相联映像的性能及复杂性介于直接映像和全相联映像之间。事实上直接映像和全相联映像可看成组相联的两种极端情况:直接映像对应的是u=m、K=1,全相联映像对应的是u=1、K=m。组相联映像方式中的每组块数K一般取值较小,典型值是2、4、8、16。这种规模的K路比较器容易设计和实现,而主存块在Cache组内的存放又有一定的灵活性。因此实际应用中多数采用组相联映像方式。通常将每组K个块的Cache称为k路组相联(K-Way Set Associative Mapping)Cache。

전설 서구 说:
2021年3月01日 15:46

I'm going to read this. I'll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article... movies123

seo 说:
2021年10月08日 13:54

Really appreciate this wonderful post that you have provided for us.Great site and a great topic as well i really get amazed to read this. Its really good. best credit card processing company

John 说:
2021年10月09日 15:00

I have read your excellent post. This is a great job. I have enjoyed reading your post first time. I want to say thanks for this post. Thank you... how to become a merchant processor iso

John 说:
2021年10月27日 19:42

Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. kinoebi

Top SEO 说:
2021年10月30日 04:00

This post is really magnificent. I really like this post. It is one of the best posts that I ve read in a long time. Thanks a lot for this really good post. I really appreciate it! world cup 2022 tickets

John 说:
2021年10月30日 13:58

Great post, and great website. Thanks for the information! House Painters East Melbourne

John 说:
2021年10月30日 14:35

You're a person living two lives. By day you're a computer programmer, by night, a computer hacker. Your life has just been turned upside down by the collision of these two worlds. My question to you is, do you take the blue pill and wake up tomorrow morning as if it was all a dream or the red pill and see just how far these two worlds really do intersect? This is for you and only you to decide. Ativador Office 2016

John 说:
2021年10月30日 17:52

KhmerAds provides free listings of items in all provinces within Cambodia. There are lots of houses for rent and sales in Phnom Penh & Sihanouk ville. It's the best site to buy cheap land in Cambodia cars for sale in cambodia

Question Paper 2022 说:
2021年11月10日 13:02

The approaching First Term Board Exams will reveal this to students. Along with the question papers, the board has also provided all of the subjects, Question Paper 2022 which will assist in understanding the mark distribution used during the evaluation of answer copies. The download links are provided below. When the board first announced the term-by-term assessment strategy, they made it clear.

Connaught Place Esco 说:
2022年1月22日 14:15

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.

KVS Sample Paper 说:
2022年9月22日 02:36

KVS Sample Paper 2023 Pdf Download for Kendriya Vidyalaya Sangathan Class 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 & 12 Arts, KVS Model Paper Science & Commerce Stream Practice Paper Suggestions with Past years old exam Solved Question Bank for all Regional Students of English Medium, Hindi Medium & Urdu Medium Studying in KVS Schools across the Country. All the Kendriya Vidyalaya Sangathan Board Students can download the Sample Paper Suggestions with Model Papers along with Previous Years old Exam Solved Question Bank for all Languages & Subjects of the Course.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter