Computer components: memory

Memory

Classification memory

image-20200105232430297.png
Core memory: to store information by the magnetic field direction, X, Y direction to vary the magnetic field direction of energization

The semiconductor memory is volatile, and the rest is a non-volatile

image-20200105232730998.png
image-20200105233040644.png
Flash Memory: a semiconductor memory, magnetic disk faster than, slower than the memory used as a U-disk, but also as a buffer layer (SSD) between the main memory and the hard disks and high-performance secondary memory

https://zhidao.baidu.com/question/72838372.html

Currently on the market there has been a large number of portable storage devices, which are the majority of semiconductor chips as the storage medium. The advantage of using a semiconductor storage medium is that the volume change can be small, easy to carry; and the hard disk-based storage devices, however, it has no mechanical structure, so afraid of a collision, there is no mechanical noise; compared to other storage devices, the power consumption is small ; write speed is very fast. The main drawback of the semiconductor memory device is a high price and limited capacity. Now commonly used by the semiconductor memory device called "Flash Memory" technology. Understood literally as a flash memory , it is faster erase with respect to the EPROM. Flash Memory is a non-volatile memory, because the power failure, the data is not lost in the chip, so it is suitable as an external storage device for the computer. It uses electrical erase mode, Rewritable 100,000 times, flash speed, low power consumption.

It is only a special kind of semiconductor memory, non-

image-20200105233552987.png
trade-off: the storage system is complicated and the price trade-offs between speed results

By a combination of software and hardware, to connect the storage system as a whole, so that a programmer from a certain point of view, the whole memory is a transparent high speed, high capacity, low price

Storage hierarchy

image-20200105233934660.png
Cache is divided into - a main memory, a main memory - two levels of secondary memory, the cache - the main memory via hardware (for speed) and use of the main memory addressing mode; main memory - auxiliary storage connected through a combination of hardware ( capacity-based solution, the speed is less important) and the virtual address and the main memory address different secondary memory addressing problems.

Main memory

image-20200105234352714.png
image-20200106000333877.png

Main memory Technical Specifications

image-20200106000710330.png
Access time: stable address given to the data output or input length of the interval from the memory

Generally, the storage period is longer than the storage time

The semiconductor memory chip

image-20200106001149559.png
Through the address line width and the line width data chip capacity calculated:

image-20200106001235931.png
Easy to understand

片选线:现在的存储器都集成了多个芯片,片选线用来选择使用哪一个或者哪几个芯片

image-20200106002933306.png
读写控制线可以用一根,也可以用两根:

image-20200106001545459.png

半导体储存芯片的译码驱动方式

  1. 线选法

image-20200106232418315.png
输入是4位,所以有2的4次方个地址,也就是16。而输出的是每一个地址对应的数据长度,也就是8位

这种线性方法限制了容量的增大

  1. 重合法

image-20200106232831148.png
X、Y分别为行和列

行列中分别只能有一个是有效的,所以只有一个会进行输出

寻址方式由线性变成了二维,在有限的芯片大小上大大增加了存储的数据量

RAM

RAM分为静态RAM和动态RAM

静态RAM(SRAM)

image-20200106233653927.png
核心是一个触发器,双稳态电路

image-20200106233747895.png
image-20200106233844758.png
image-20200106234154758.png
WE:读写(低读高写)控制、CS:片选信号(只有在低电平的时候该芯片才会被选中)

image-20200106234402307.png
每个列选择信号控制四列,所以每次四列同时输出,也就是同时输出4位

动态RAM(DRAM)

动态RAM时候电容,有电是1,没电是0

image-20200106235131273.png
如果要读的话,先给预充电管充电,然后读选择线被导通

除了三管之外,还有单管的

image-20200106235159706.png
image-20200106235232957.png
image-20200106235258266.png
刷新放大器:对电容上的信息进行定期刷新,以应对电容漏电

对于单管芯片:

image-20200107002726402.png
注意它是1位的

对于地址要输入两次,行地址一次,列地址一次

image-20200107003257100.png
读放大器是跷跷板电路:一端设置电平为1,则另外一端就会变成0

动态RAM刷新

刷新只和行地址有关,和列地址没关系:一行一行刷新

集中刷新:

image-20200107003739809.png
在一个刷新时间间隔内,后面的128个存取周期是专门用来进行刷新的,无论是读写都无法在这段时间内进行,这段时间称为“死区”:

image-20200107003926594.png
分散刷新:

把刷新分布在每一次读写操作中,刷新过度了

image-20200107004101471.png
异步刷新:分散刷新和集中刷新的结合

image-20200107004223759.png
其实总的刷新占用时间和集中刷新是一样,但是可以通过合理设计,将刷新安排在指令译码阶段,就不会出现“死区”现象了

动态RAM和静态RAM的对比

  • 静态RAM结构比动态RAM复杂,相应的它的集成度也就比较高,功耗也比较大(一直有管子在通电,所以才不需要刷新)
  • 动态RAM行地址和列地址的传输可以通过一组地址线依次传送,地址线和芯片的引脚也就因此可以减少了;但是静态RAM为了体现它的高速访问,所以一般不这样做,所以它的芯片引脚也就比较多。

image-20200107005558478.png
正因如此,DRAM一般用于做内存(主存),SRAM用于做缓存

ROM

发展历程

image-20200107005925778.png

类型

image-20200107010608947.png
有无MOS管是厂家生产时就确定的,所以用户无法对ROM进行修改

image-20200107010647648.png
使用熔丝的硬核一次性编程,编错了就再买芯片

image-20200107010733151.png
想起了被大物支配的恐惧

通过紫外线擦除:

image-20200107010813265.png
image-20200107010850377.png

RAM and ROM in mobile phone

来源:https://www.zhihu.com/question/302518700

现在智能手机配置中的ROM指的是EEProm(电擦除可写只读存储器)类似于计算机的硬盘,手机里能存多少东西就看他的容量了。而机子的反应速度看的是RAM,就像电脑中的内存相似。容量越大机子运行越快

主存储器和CPU的连接

存储器容量扩展

  • 位扩展

image-20200107113103342.png

  • 子扩展

image-20200107113315153.png
使用11根地址线,其中一根是用来进行片选的,如果它为0,则表示使用的是第一个芯片,其余的10根地址线上的地址指的是第一个芯片上的地址;如果为1,则使用第二个

  • 字和位同时进行拓展

image-20200107113806099.png
两个芯片为一组

存储器和CPU的连接

保存系统信息和配置的要放到ROM中(因为这些数据修改不多),用户数据要放到RAM

以一道例题说明

image-20200107114600523.png
根据题目要求,上面的那个2KX8位的是系统程序区(选用ROM),下面的1KX8位是用户程序区(选用RAM)

根据题目要求,选用芯片

image-20200107114730361.png
image-20200107114836219.png
剩下的地址线作为芯片选择信号(选择是用RAM还是ROM):

使用138译码器,有CBA三个输入和三个控制端(G1高电平有效,G2A和G2B低电平有效)。但是注意CPU还有一个MREQ信号用来表示访问的是主存(低电平时)还是IO(高电平时),这个信号也要接入片选信号,与G2B相连接,以保证只有在CPU真正想要访问主存(MREQ为低电平)时才会访问主存

由上图我们也可以看到,对于RAM,除了A0-A9作为有效的地址输入外,我们还要求A10应该是0才是表示对RAM的一次访问,所以我们需要对A10的值进行验证,防止A10为1、也就是本来没有打算访问该RAM时错误地访问了该RAM:

image-20200107115840022.png

存储器的校验

  1. 为什么要对储存器的信息进行校验

    内存中的内容也会出错的(电子环境复杂时),信息可能会出错

    甚至是台式电脑,都会对信息进行校验

  2. 如何编码以校验

合法代码集合

image-20200108210246640.png
如果合法代码如上,即使出错了、某一位由零变成一或者由一变成了零,出错的代码依然在合法代码集合中,这样是很难甚至是没有办法设置进行检验的

image-20200108210426862.png
这种情况下,我们可以检测出代码是出错的,但是只凭借出错后的代码,我们没有办法推出到底是哪一位代码出错了(因为合法代码集合中有多个代码可以变成该出错代码)

介绍一下三倍存储方式:用三个0和三个1来表示0和1,这样如果有一位出错的话(一位出错的概率最大,超过90%,这一点从概率上讲也能理解,连着出错概率太小了)立马就可以知道是哪一位出错了.

image-20200108214543266.png
也有四倍存储,但是这个很鸡肋:

image-20200108214636354.png
五倍存储就好多了:

image-20200108214805627.png
具体用几位就看具体使用环境了,是正确性重要还是速度和容量重要

image-20200108214922241.png
合法代码集合中各个代码的差异越大,检测能力越强,这就引出了下一个概念:

image-20200108215106622.png

汉明码

关于汉明码,我这篇文章中有:https://www.cnblogs.com/jiading/p/11876898.html讲过,这里会更深入的去学

image-20200108215644401.png
但是汉明码使用的不是这样的一种划分方式,而是一种非划分方式:

image-20200108215831115.png
image-20200108215923500.png
注意我们不是说这里存放的数据就是1-7,而是说这些位置的编号是1-7,因为这样编号才能使得我们的各个分组的二进制校验结果拼起来就是出错位置

为什么校验位要放在1,2,4上?因为校验是对单个的分组进行校验,它只能对该分组内进行作用,所以不能放在和其他组公用的位置

image-20200108220816172.png
如果汉明码检测位有k位,原数有n位,则一共有n+k个可能出错的位置,还有一种情况是没错的,所以2^k种汉明码检测位的结果要能表示该n+k+1中可能的状态

image-20200108224647284.png
image-20200108224740909.png
image-20200108224810922.png
image-20200108224831320.png
汉明码的纠错过程:

image-20200108224909006.png
image-20200108225002797.png
image-20200108225016885.png
如果判明了是检验位有错,不影响原文信息,不纠错也行

提高访问存储器的速度

存储器的访问速度跟不上CPU速度的提升,现在是限制计算机整体性能的一个主要因素之一

提高速度的措施有:

image-20200108225154920.png

调整主存结构

image-20200108225252912.png
存储器的字长比CPU字长长,每次访问多取出几个字放在数据存储器上以便于之后使用,减少和存储器的交互,这也是顺应程序访问的局部性原理的

缺点有:

  1. 写入单个字长数据时会比较麻烦
  2. 如果下一次不访问相邻字就没用了

image-20200108225451397.png
多个独立的存储器,可以并行使用

地址的前几位是用来区分存储器的

缺点有:

  1. 对于访问相邻资源没用,因为他们非常可能都在一台存储器上,只有一台在工作
  2. 适合容量的扩展,而不是提高速度

低位交叉解决了高位交叉所存在的问题

低位交叉下,相邻数据是存储在不同存储器上的,这种并行效果好

image-20200108225816981.png
image-20200108225949422.png
image-20200108230144725.png
启动一个存储器的访问操作,在一个τ时间间隔之后,启动对下一个存储器的访问操作,这样就可以实现前一个刚刚传输完,后一个就接着传输,线路就不会空闲了

image-20200108230429743.png
如果用单个存储器的话,读取四个字所需的时间是4T+τ

高性能部件

同步DRAM:

image-20200108230617022.png
速度要和CPU匹配

RDRAM:

image-20200108230715755.png
带Cache的DRAM

image-20200108230751132.png

高速缓存存储器

Cache的工作原理

image-20200108231228663.png
Cache也可以分块,和主存的块大小是相同的

一个块在Cache和主存之间传输的时候是整体传输,块内顺序不变

Cache的标记记录了主存的主存块号,用于识别

image-20200108231622358.png
块太小的话,没运行几步就需要再次去读,再次读就不一定还在cache中了,所以块小了命中率也会小,但是太大的话会占用其他信息的进入机会,也会减小命中率

image-20200108231901681.png
命中率是最核心的指标

image-20200108232010649.png

cache的基本结构

image-20200108232041022.png
注意cache的地址映射规则

核心的几块是:

image-20200108232319069.png

cache的读写

image-20200108232421459.png
cache的写要解决和主存的一致性问题

写直达法访问内存比较频繁

写回法可能造成不一致,尤其是并行系统

image-20200108232644148.png

cache的改进

image-20200108232805236.png
现在的处理器每个核有自己的cache,多核还有共用的cache,一般cpu内的cache能达到三级

image-20200108232825111.png
将指令和数据分开,避免在流水的时候造成指令冲突

cache的地址映射

  1. 直接映射

    image-20200108232928181.png
    内存的某个块只能映射到某个指定的cache中

    主存字块在图中表示0-2^c-1,cache字块地址表示是主存储器的哪一个区(也就是去cache第几个字块去找)

    image-20200108233248156.png
    Simple structure, speed, but cache utilization can not be guaranteed a high probability of collision, even if the cache is idle elsewhere can not be stored, relatively stiff.

    Generally used in close to the CPU cache, the cache of these relatively high speed,

  2. Full map attached

    Anywhere in the cache can be put

    Drawback is looking up trouble, is also relatively long length compared to the first comparison is no shortcut to go

    image-20200108235000736.png
    Generally used in the farthest distance CPU cache, such as cache emphasis on speed is relatively low, a higher emphasis on the utilization of

  3. Set associative mapping

    1 and 2 is the integration of

    The main memory partition size of each zone and the number remains the same group of cache (note that the cache block is a group comprising more than one)

    Each word block of main memory can be placed in any region of the respective block groups cache

    image-20200108235314087.png
    1 compared to some of the good, Ye Hao to find a lot more than 2

    This approach is commonly used in modern computers cache mode

    Generally used in the middle of some of the cache

Replacement algorithm

Selecting a cache block which exits from the cache

image-20200109001751573.png
The second approach is better

Secondary storage

Characteristics of the auxiliary memory and the CPU is not the direct information exchange

image-20200109001925831.png
Fixed head type magnetic head drive requires more, but faster; hard drive to move the head on the contrary

image-20200109002137440.png
image-20200109002222047.png
image-20200109002328556.png
image-20200109002410701.png
image-20200109002512683.png
image-20200109002547246.png

Guess you like

Origin www.cnblogs.com/jiading/p/12240866.html