4. Memory
4.2.1 Overview
Main memory specifications :
-
Storage capacity: binary code can be stored in the total number of bits
storage capacity of the storage unit number = x storage word length
, for example: 32-bit memory word length = 4 bytes, the storage capacity = 4 * 32 = 128MB -
Storage speed
- Storage time
- Readout time: receiving a valid memory address from the start, all the time effective to produce the desired output
- Writing time: receiving a valid memory address from the start, all of the write data to the selected time unit required
- Storage period: two independent minimum interval required for the operation of the memory (memory cycle greater than the stored time)
- Storage time
-
Memory bandwidth
4.2.2 Introduction to the semiconductor memory chip
Address lines: an input-equivalent to the house number, address lines are two, house number 2, may represent (0-99) 10 2 -headed,
decoding drive: the address bus an address signal sent to the corresponding translated a memory cell select signal, the signal for reading and writing with the write circuit and the
chip select line:
the CS: chip select signal
CE: chip enable signal
to read and write control lines:
the WE high write-read low :( )
OE :( allowed to read) WE (write enable)
The semiconductor memory chip decoding drive mode :
Address lines: 10, four data lines, chip capacity: 2 10 X = 4K bits. 4
- Route selection method
A0, A1, A2, A3, there are four address lines, 2 . 4 the root (16) address line, a data line, the figure is 16 X 1-byte memory chip method selected from the line structure of FIG.
Problems :
Assumed that the memory 1M * 8 of 20 address lines, there are two 20 -th power, that is, one million lines, memory, hard to integrate such a high, then the new method came. . . .
- Re legitimate
line selected from the memory unit is arranged to process the one-dimensional array, the coincidence method is a two-dimensional array of memory cells arranged
Difference: 20 address lines, x direction 10, there are 2 10 (1K bars), y direction 10, there 2 10 (1K bar), a total of 2k lines, select lines than the above method 1M line, saving much
4.2.3 Random Access Memory (RAM)
Static RAM
Save 0 and 1 principle: the use of information stored in the flip-flop works
Usually there is an output terminal and two input terminals ( "+", "-" end of each of a), when the input terminal "+" end with a trigger signal, the output terminal no matter what the original state, are immediately goes high and it has been a steady output high. If and when the input of the "-" end there is a trigger signal, the output end no matter what the original state will immediately goes low, and has been stable output low. This is bistable circuit.
Read:
1. select signal to travel, open T5, T6
2. column select signal is given to open the T7, T8
3. read select valid
4. A stored in the data through the transistor T6, the bit line to A, while also guiding T8 pass, send a signal to continue down the read select effective, Dout, the readout signal
Writes:
0. Din supplied to the data terminal
1. The select signal to travel, open T5, T6
2. column select signal is given to open the T7, T8
3. choose a valid write, open the Din line
4. Left Din (negated) -> the T7 -> T5-> A '
5. The right-Din-> T8-> T6-> A
Dynamic RAM
保存0与1的原理:DRAM使用电容存储,电荷维持1~2ms,所以必须隔一段时间刷新(refresh)一次,如果存储单元没有被刷新,存储的信息就会丢失。 关机就会丢失数据。
高电容表示存1
低电容表示存0
三管式动态RAM
T1,T2 ,T3三个MOS管
T4:预充电管
读操作
1.T4管放置预充电信号,读数据线达到高电平Vdd
2.读数据线打开T2
3.如果极间电容Cg原存“1”(高电荷),T1导通,因为T2,T1导通后接地,读数据线电平降为(低电荷)读出“0”
4.如果极间电容Cg原存“0”(低电荷),T1截止,读数据线电平不变 读出“1”
5.读出线因为电平改变,读出信息与原信息相反
写操作
1.写数据线有效 T3管导通
2.如果写入数据为1,写数据线为高电平,通过T3向Cg进行充电,Cg中保存1
3.如果写入数据为0,写数据线为低电平,通过T3向Cg进行放电,Cg中保存0
4.写入信息与输入信息完全相同
单管动态RAM
读操作
1.字线上的高电平使T打开,
2.如果Cs上保存“1”为高电荷,经过T管在数据线上产生高电流,可以视为读出“1”
3.如果Cs上保存“0”为高电荷,经过T管在数据线上产生低电流,可以视为读出“0”
写操作
1.子线为高电平使T管导通,
2.如果写入“1”,数据线为高电平,经过T管对Cs充电,使其存“1”
3.如果写入“0”,数据线为低电平,经过T管对Cs放电,使其无电荷存“0”
动态RAM刷新
刷新实质:先将原存信息读出,再有刷新放大器形成原信息并且重新写入的再生过程
与行地址有关
1)集中刷新
2)分散刷新
3)异步刷新
4.2.5 存储器与cpu的连接
1.存储容量的扩展
存储芯片容量有限,必须将若干存储芯片连在一起才能组成足够容量的存储器,通常有:
- 位扩展
- 字扩展
- 字 位同时扩展
位扩展:
2片1K x 4位 存储芯片怎么组成1k x 8位的存储芯片?
字扩展:
2片1K x 8位 存储芯片怎么组2k x 8位的存储芯片?
1k=210
2k=211
同时扩展:
8片1K x 4位 存储芯片怎么组成4k x 8位的存储芯片?
2.存储器与cpu的连接
1)地址线的连接
cpu的地址线比存储芯片的地址线多,通常是将cpu地址线的低位与存储芯片的地址线连接,高位扩充使用
2)数据线的连接
3)读写命令线的连接
高电平读 低电平写
4)片选线的连接(关键)
如果cpu没有访问存储器访问了I/O,来自CPU的片选有效信号MREQ为高电平,表示不要求存储器工作
5)合理选择存储芯片
ROM存放系统程序
RAM存放用户信息
4.2.6存储器的校验
设欲检测的二进制代码为n位,为使其具有纠错能力,需要添加K位检测位,组成n+k位的代码,检测位数K 应该满足 2k>= n+ k +1
检测位编号为:1 2 4 8 … 2k-1
c1 检测的小组包含1 3 5 7 9 11 。。。位
c2 检测的小组包含2 3 6 7 10 11 14 15 。。。位
c4 检测的小组包含4 5 6 7 12 13 14 15 。。。位
4.2.6提高访存速度的措施
存储器模块数为:n,存取周期为:T 总线传输周期:t 已知低位交叉的存储器,连续读取n个字所需要的时间t1为: T +(n-1)t
已知高位交叉的存储器,连续读取n个字所需要的时间t2为: nT
单体多字系统:
适用于程序和数据在存储体内是连续存放的情况。在一个存取周期内,从同一地址取出多条指令,然后再逐条将指令送至CPU执行,这样增大了存储器的带宽,提高了单体存储器的速度。这里的单体应该就是一个模块,但是每次可以读取多个字,可以和多体进行比较。
多体并行系统
有多个模块,每个模块有相同的容量以及存取速度,各模块各自都有独立的地址寄存器(MAR),数据寄存器(MDR),地址译码,驱动电路和读写电路,他们能够并行工作,同时也能交叉工作(什么是交叉工作?),但是并行读出的数据在总线上需要分时传送。
地址分为体号与体内地址。
对于高位交叉编址的多体存储器而言,程序按体内地址顺序存放,他们在每一个模块中的地址是连续的,有利于存储器的扩充。高位地址表示体号,低位地址表示体内地址。
对于低位交叉编址的多体存储器而言,程序连续存放在相邻体中(又有交叉存储之称),低位地址表示体号,高位地址表示体内地址。这种编址方式又称为模M编址,其中M为模块数。
每个模块的存取周期是不变的,但是CPU交叉访问各体,使得这几个存储体的读/写过程重叠进行。
对于低位交叉的存储器,连续读取n个字所需的时间为T+(n-1)t,
对于高位交叉的存储器,连续读取n个字所需的时间为nT,
4.3高速缓冲存储器
背景:I/o设备向主存请求的级别高于cpu访存,出现了cpu等待I/o设备访存的现象,致使cpu空等一段时间,降低了工作效率;cache的出现让cpu可以不直接访问主存,而与高速cache交换信息
程序访问的局部性:cpu从主存中存取指令的数据,只对主存局部区域地址访问,这是由于指令和数据在主存内都是连续存放的,使得cpu在执行程序中,访存具有相对局部性,这就称为程序访问的局部性;
公式:
- 一:h:命中率,Nc访问cache总命中次数,Nm访问主存的总次数
h = Nc / Nc + Nm - 二:ta = Cache -主存系统的平均访问时间
tc为:命中时的cache访问时间,tm为未命中时的主存访问时间,1-h:未命中率
ta = h tc + (1-h) tm - Three e: access efficiency
tc: cache hit access time
ta: Cache - the average access time of main memory system
e = tc / ta * 100%