编写测试基准,对存储器ram和rom进行仿真

上传人:j****9 文档编号:54698441 上传时间:2018-09-17 格式:PPT 页数:31 大小:119KB
返回 下载 相关 举报
编写测试基准,对存储器ram和rom进行仿真_第1页
第1页 / 共31页
编写测试基准,对存储器ram和rom进行仿真_第2页
第2页 / 共31页
编写测试基准,对存储器ram和rom进行仿真_第3页
第3页 / 共31页
编写测试基准,对存储器ram和rom进行仿真_第4页
第4页 / 共31页
编写测试基准,对存储器ram和rom进行仿真_第5页
第5页 / 共31页
点击查看更多>>
资源描述

《编写测试基准,对存储器ram和rom进行仿真》由会员分享,可在线阅读,更多相关《编写测试基准,对存储器ram和rom进行仿真(31页珍藏版)》请在金锄头文库上搜索。

1、典型的存储器模块有:寻址存储器:ROM RAM顺序存储器:FIFO Stack (LIFO),存储器模块的VHDL设计,ROM和RAM属于通用大规模器件,一般不需要自行设计;但是在数字系统中,有时也需要设计一些小型的存储器件,用于特定的用途:例如,临时存放数据,构成查表运算等。此类器件的特点为地址与存储内容直接对应,设计时将输入地址作为给出输出内容的条件,采用条件赋值方式进行设计。,寻址存储器的VHDL设计,设计思想: (1)将每个8位数组作为一个字(word);总共存储16个字; (2)将RAM作为由16个字构成的数组,以地 址为下标; (3)通过读写控制模式实现对特定地址上字的读出或写入;

2、,寻址存储器设计: 16x8位RAM,library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;entity kram isport ( clk,wr,cs: in std_logic;d: inout std_logic_vector(7 downto 0);adr: in std_logic_vector(3 downto 0); end kram;,寻址存储器设计: 16x8位RAM,architecture beh of kram is subtype word is std_logic_vec

3、tor(7 downto 0); type memory is array (0 to 15) of word; signal adr_in:integer range 0 to 15; signal sram:memory; begin adr_in=conv_integer (adr); -将地址转换为数组下标 process(clk)begin,寻址存储器设计: 16x8位RAM,if(clkevent and clk=1) thenif (cs=1and wr=1) then -片选、写sram (adr_in)=d;end if;if (cs=1and wr=0 ) then -片选

4、、读 d=sram (adr_in);end if;end if; end process; end beh;,寻址存储器设计: 16x8位RAM,ROM的内容是初始设计电路时就写入到内部的,通常采用电路的固定结构来实现存储;ROM只需设置数据输出端口和地址输入端口;设计思想:采用二进制译码器的设计方式,将每个输入组态对应的输出与一组存储数据对应起来;,寻址存储器设计: 16x8位ROM,library ieee; use ieee.std_logic_1164.all;entity rom isport(dataout: out std_logic_vector(7 downto 0);ad

5、dr: in std_logic_vector(3 downto 0);ce: in std_logic); end rom;,寻址存储器设计: 16x8位ROM,architecture d of rom issignal id: std_logic_vector(4 downto 0);beginid = addr dataout = “00001111“ when id =“00000“ else“11110000“ when id =“00010“ else“11001100“ when id =“00100“ else“00110011“ when id =“00110“ else“

6、10101010“ when id =“01000“ else“01010101“ when id =“01010“ else“10011001“ when id =“01100“ else,寻址存储器设计: 16x8位ROM,“01100110“ when id =“01110“ else“00000000“ when id =“10000“ else“11111111“ when id =“10010“ else“00010001“ when id =“10100“ else“10001000“ when id =“10110“ else“10011001“ when id =“11000

7、“ else“01100110“ when id =“11010“ else“10100110“ when id =“11100“ else“01100111“ when id =“11110“ else“XXXXXXXX“; end d;,寻址存储器设计: 16x8位ROM,顺序存储器的特点是不设置地址,所有数据的写入和读出都按顺序进行;数据写入或读出时通常采用移位操作设计;在设计时必须考虑各存储单元的存储状态;,顺序存储器(堆栈和FIFO)的设计,设计要求: 存入数据按顺序排放; 存储器全满时给出信号并拒绝继续存入; 数据读出时按后进先出(先进后出)原则; 存储数据一旦读出就从存储器中消失

8、;,堆栈(后进先出存储器)的设计,设计思想:将每个存储单元设置为字(word);存储器整体作为由字构成的数组;为每个字设置一个标记(flag),用以表达该存储单元是否已经存放了数据;每写入或读出一个数据时,字的数组内容进行相应的移动,标记也做相应的变化;,堆栈(后进先出存储器)的设计,library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_signed.all;entity stack isport(datain: in std_logic_vector(7 down

9、to 0);push,pop,reset,clk:in std_logic;stackfull:out std_logic;dataout: buffer std_logic_vector(7 downto 0); end stack;,堆栈设计:移位寄存器方式,architecture b of stack is type arraylogic is array(15 downto 0) of std_logic_vector(7 downto 0); signal data :arraylogic; signal stackflag:std_logic_vector(15 downto 0

10、); beginstackfull=stackflag(0);process(clk,reset,pop,push)variable selfunction: std_logic_vector(1 downto 0);beginselfunction:=push ,堆栈设计:移位寄存器方式,if reset=1 then stackflag0); dataout0);for i in 0 to 15 loopdata(i)if stackflag(0)=0 then data(15)=datain;stackflagdataoutnull;end case;end if; end proces

11、s; end b;,堆栈设计:移位寄存器方式,architecture b of stack is type arraylogic is array(15 downto 0) of std_logic_vector(7 downto 0); signal data :arraylogic; begin process(clk,reset,pop,push)variable p:natural range 0 to 15;variable selfunction: std_logic_vector(1 downto 0);variable s:std_logic;begin,堆栈设计:地址指针方

12、式,stackfull0);s:=0;for i in 0 to 15 loopdata(i)=“00000000“;end loop;elsif clkevent and clk=1 thenif p15 and selfunction=“10“ then data(p)=datain; p:=p+1;end if;,堆栈设计:地址指针方式,if p=15 and selfunction=“10“ and s=0 then data(p)0 and selfunction=“01“ and s=0 then p:=p-1; dataout=data(p);end if;if p=15 and

13、 selfunction=“01“ and s=1 then dataout=data(p); s:=0;end if;end if; end process; end b;,堆栈设计:地址指针方式,设计要求: 存入数据按顺序排放; 存储器全满时给出信号并拒绝继续存入;全空时也给出信号并拒绝读出; 读出时按先进先出原则; 存储数据一旦读出就从存储器中消失;,FIFO(先进先出存储器)的设计,设计思想:结合堆栈指针的设计思想,采用环行寄存器方式进行设计;分别设置写入指针wp和读出指针rp,标记下一个写入地址和读出地址;地址随写入或读出过程顺序变动;设计时需要注意处理好从地址最高位到地址最地位的变

14、化;,FIFO(先进先出存储器)的设计,library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_signed.all;entity kfifo isport(datain: in std_logic_vector(7 downto 0);push,pop,reset,clk:in std_logic;full,empty:out std_logic;dataout: out std_logic_vector(7 downto 0); end kfifo;,FIFO设计

15、:地址指针方式,architecture b of kfifo is type arraylogic is array(15 downto 0) of std_logic_vector(7 downto 0); signal data :arraylogic; signal fi,ei:std_logic; -为全满全空设置内部信号,以便内部调用; signal wp,rp:natural range 0 to 15; -写入指针和读出指针; begin,FIFO设计:地址指针方式,process(clk,reset,pop,push)variable selfunction: std_log

16、ic_vector(1 downto 0);beginfull0);for i in 0 to 15 loopdata(i)=“00000000“;end loop;,FIFO设计:地址指针方式,elsif clkevent and clk=1 then if fi=0 and selfunction=“10“ and wp15 then data(wp)=datain; -写入数据;wp=wp+1;if wp=rp then fi=1;end if;if ei=1 then ei=0;end if;end if; if fi=0 and selfunction=“10“ and wp=15 then data(wp)=datain;wp=0;if wp=rp then fi=1;end if;if ei=1 then ei=0;end if;end if;,

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号