cache原理学习(作者 gooogleman)

本文深入探讨了ARM处理器中的Cache和Write Buffer原理。Cache作为快速内存,位于处理器核心和主内存之间,减少处理器访问慢速内存的时间。Write Buffer用于释放处理器和Cache,避免慢速写入主内存的影响。文章详细介绍了Cache的基本单位——Cache Line,包括其有效性、位置选择以及多路Cache的概念。此外,还讲解了Tag、Status位,以及如何在ARM920T中启用和禁用ICache和DCache,确保系统性能和内存一致性。
摘要由CSDN通过智能技术生成
               

作者:wogoyixikexie@gliet

           cache是ARM最难理解,也是最具有闪光点的地方之一,现在是解决他的时候了。

           对于这么经典的东西,我还是引用ARM工程师的书籍吧,免得误人子弟。

cache以及write buffer的介绍

    A cache is a small, fast array of memory placed between the processor core and main
memory that stores portions of recently referenced main memory. The processor uses
cachememory instead ofmainmemory whenever possible to increase systemperformance.
The goal of a cache is to reduce the memory access bottleneck imposed on the processor
core by slow memory.
    Often used with a cache is a write buffer—a very small first-in-first-out (FIFO) memory
placed between the processor core and main memory. The purpose of a write buffer is to
free the processor core and cache memory from the slow write time associated with writing
to main memory.

cache是否有效以及使能等造成的后果

    The basic unit of storage in a cache is the cache line. A cache line is said to be valid when it contains cached
data or instructions, and invalid when it does not. All cache lines in a cache are invalidated on reset. A cache
line becomes valid when data or instructions are loaded into it from memory.
    When a cache line is valid, it contains up-to-date values for a block of consecutive main memory locations.
The length of a cache line is always a power of two, and is typically in the range of 16 to 64 bytes. If the
cache line length is 2L bytes, the block of main memory locations is always 2L-byte aligned. Because of this
alignment requirement, virtual address bits[31:L] are identical for all bytes in a cache line

cache所在的位置

——————————————————————————————————————————

由此可知,cache是可以选择不同位置的,分为物理和虚拟/逻辑类型,但是对于2440是逻辑cache的,请看下图

++++++++++++++++++++++++++++++++++++++==========================================+++++++++++++++++

多路cache(单一cache效率很低,不做介绍)

____________________________________________________________________________________________

Tag对应内存中数据的位置,status有两位,一位是有效位(表示所在cache行是否有激活),另外一位

是脏位(判断cache中的内容和内存中的内容是否一致:注意不一致一定要想办法一致,否则后患无穷)

 

===================================================================================

现在来看看和2440靠谱的文档吧(ARM920T)

=====ICache=====
The ARM920T includes a 16KB ICache. The ICache has 512 lines of 32 bytes (8 words),arranged as a 64-way set-associative cache and uses MVAs, translated by CP15 register 13 (see Address translation on page 3-6), from the ARM9TDMI core.The ICache implements allocate-on-read-miss. Random or round-robin replacement can be selected under software control using the RR bit (CP15 register 1, bit 14). Random replacement is selected at reset.Instructions can also be locked in the ICache so that they cannot be overwritten by a linefill.This operates with a granularity of 1/64th of the cache, which is 64 words (256 bytes).All instruction accesses are subject to MMU permission and translation checks. Instruction fetches that are aborted by the MMU do not cause linefills or instruction fetches to appear on the AMBA ASB interface.

 

Note

————————————————————
 For clarity, the I bit (bit 12 in CP15 register 1) is called the Icr bit throughout the
following text. The C bit from the MMU translation table descriptor corresponding to
the address being accessed is called the Ctt bit.

 

ICache organization(ICache 操作)

——————————————————————————————————————————————————

The ICache is organized as eight segments, each containing 64 lines, and each line
containing eight words. The position of the line within the segment is a number from 0
to 63. This is called the index. A line in the cache can be uniquely identified

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值