版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、典型的存储器模块有:寻址存储器:ROMRAM顺序存储器:FIFOStack(LIFO),存储器模块的VHDL设计,ROM和RAM属于通用大规模器件,一般不需要自行设计;但是在数字系统中,有时也需要设计一些小型的存储器件,用于特定的用途:l例如临时存放数据,构成查表运算等。此类器件的特点为地址与存储内容直接对应,设计时将输入地址作为给出输出内容的条件,采用条件赋值方式进行设计。,寻址存储器的VHDL设计,设计思想:将每个8位数组作为一个字(word);总共存储16个字;将ram作为由16个字构成的数组,以地址为下标;通过读写控制模式实现对特定地址上字的读出或写入;,寻址存储器设计:16x8位RA
2、M,libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitykramisport(clk,wr,cs:instd_logic;d:inoutstd_logic_vector(7downto0);adr:instd_logic_vector(3downto0);endkram;,寻址存储器设计:16x8位RAM,architecturebehofkramissubtypewordisstd_logic_vector(7downto0);typememoryisarray(0to15)ofword;si
3、gnaladr_in:integerrange0to15;signalsram:memory;beginadr_in=conv_integer(adr);-将地址转换为数组下标process(clk)begin,寻址存储器设计:16x8位RAM,if(clkeventandclk=1)thenif(cs=1andwr=1)then-片选、写sram(adr_in)=d;endif;if(cs=1andwr=0)then-片选、读d=sram(adr_in);endif;endif;endprocess;endbeh;,寻址存储器设计:16x8位RAM,ROM的内容是初始设计电路时就写入到内部的
4、,通常采用电路的固定结构来实现存储;ROM只需设置数据输出端口和地址输入端口;设计思想:采用二进制译码器的设计方式,将每个输入组态对应的输出与一组存储数据对应起来;,寻址存储器设计:16x8位ROM,libraryieee;useieee.std_logic_1164.all;entityromisport(dataout:outstd_logic_vector(7downto0);addr:instd_logic_vector(3downto0);ce:instd_logic);endrom;,寻址存储器设计:16x8位ROM,architecturedofromissignalid:std
5、_logic_vector(4downto0);beginid=addrdataout=00001111whenid=00000else11110000whenid=00010else11001100whenid=00100else00110011whenid=00110else10101010whenid=01000else01010101whenid=01010else10011001whenid=01100else,寻址存储器设计:16x8位ROM,01100110whenid=01110else00000000whenid=10000else11111111whenid=10010el
6、se00010001whenid=10100else10001000whenid=10110else10011001whenid=11000else01100110whenid=11010else10100110whenid=11100else01100111whenid=11110elseXXXXXXXX;endd;,寻址存储器设计:16x8位ROM,顺序存储器的特点是不设置地址,所有数据的写入和读出都按顺序进行;数据写入或读出时通常采用移位操作设计;在设计时必须考虑各存储单元的存储状态;,顺序存储器(堆栈和FIFO)的设计,设计要求:存入数据按顺序排放;存储器全满时给出信号并拒绝继续存入;
7、数据读出时按后进先出原则;存储数据一旦读出就从存储器中消失;,堆栈(后进先出存储器)的设计,设计思想:将每个存储单元设置为字(word);存储器整体作为由字构成的数组;为每个字设置一个标记(flag),用以表达该存储单元是否已经存放了数据;每写入或读出一个数据时,字的数组内容进行相应的移动,标记也做相应的变化;,堆栈(后进先出存储器)的设计,libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_signed.all;entitystackisport(datain:instd_l
8、ogic_vector(7downto0);push,pop,reset,clk:instd_logic;stackfull:outstd_logic;dataout:bufferstd_logic_vector(7downto0);endstack;,堆栈设计:移位寄存器方式,architecturebofstackistypearraylogicisarray(15downto0)ofstd_logic_vector(7downto0);signaldata:arraylogic;signalstackflag:std_logic_vector(15downto0);beginstackf
9、ull=stackflag(0);process(clk,reset,pop,push)variableselfunction:std_logic_vector(1downto0);beginselfunction:=push,堆栈设计:移位寄存器方式,ifreset=1thenstackflag0);dataout0);foriin0to15loopdata(i)ifstackflag(0)=0thendata(15)=datain;stackflagdataoutnull;endcase;endif;endprocess;endb;,堆栈设计:移位寄存器方式,architecturebof
10、stackistypearraylogicisarray(15downto0)ofstd_logic_vector(7downto0);signaldata:arraylogic;beginprocess(clk,reset,pop,push)variablep:naturalrange0to15;variableselfunction:std_logic_vector(1downto0);variables:std_logic;begin,堆栈设计:地址指针方式,stackfull0);s:=0;foriin0to15loopdata(i)=00000000;endloop;elsifclk
11、eventandclk=1thenifp15andselfunction=10thendata(p)=datain;p:=p+1;endif;,堆栈设计:地址指针方式,ifp=15andselfunction=10ands=0thendata(p)0andselfunction=01ands=0thenp:=p-1;dataout=data(p);endif;ifp=15andselfunction=01ands=1thendataout=data(p);s:=0;endif;endif;endprocess;endb;,堆栈设计:地址指针方式,设计要求:存入数据按顺序排放;存储器全满时给出信
12、号并拒绝继续存入;全空时也给出信号并拒绝读出;读出时按先进先出原则;存储数据一旦读出就从存储器中消失;,FIFO(先进先出存储器)的设计,设计思想:结合堆栈指针的设计思想,采用环行寄存器方式进行设计;分别设置写入指针wp和读出指针rp,标记下一个写入地址和读出地址;地址随写入或读出过程顺序变动;设计时需要注意处理好从地址最高位到地址最地位的变化;,FIFO(先进先出存储器)的设计,libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_signed.all;entitykfifoi
13、sport(datain:instd_logic_vector(7downto0);push,pop,reset,clk:instd_logic;full,empty:outstd_logic;dataout:outstd_logic_vector(7downto0);endkfifo;,FIFO设计:地址指针方式,architecturebofkfifoistypearraylogicisarray(15downto0)ofstd_logic_vector(7downto0);signaldata:arraylogic;signalfi,ei:std_logic;-为全满全空设置内部信号,以
14、便内部调用;signalwp,rp:naturalrange0to15;-写入指针和读出指针;begin,FIFO设计:地址指针方式,process(clk,reset,pop,push)variableselfunction:std_logic_vector(1downto0);beginfull0);foriin0to15loopdata(i)=00000000;endloop;,FIFO设计:地址指针方式,elsifclkeventandclk=1theniffi=0andselfunction=10andwp15thendata(wp)=datain;-写入数据;wp=wp+1;ifw
15、p=rpthenfi=1;endif;ifei=1thenei=0;endif;endif;iffi=0andselfunction=10andwp=15thendata(wp)=datain;wp=0;ifwp=rpthenfi=1;endif;ifei=1thenei=0;endif;endif;,FIFO设计:地址指针方式,ifei=0andselfunction=01andrp15thendataout=data(rp);-读出数据;rp=rp+1;ifwp=rpthenei=1;endif;iffi=1thenfi=0;endif;endif;ifei=0andselfunction
16、=01andrp=15thendataout=data(rp);rp=0;ifwp=rpthenei=1;endif;iffi=1thenfi=0;endif;endif;endif;endprocess;endb;,libraryieee;useieee.std_logic_1164.all;librarylpm;uselpm.lpm_components.all;entityfifo2isport(data:instd_logic_vector(7downto0);wrreq,rdreq,clock,aclr:instd_logic;q:outstd_logic_vector(7downto0);full,empty:outstd_logic;usedw:outstd_logic_vector(3downto0);endfifo2;,FIFO设计:利用参数化模块,architecturestroffifo2issignalsub_wire0:std_logic_vector(3downto0);signalsub_wire1:std_logic;signalsub_wire2:std_logic_vector(7downto0);signalsub_wire3:std_logic;beginusedw=sub_w
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 黑龙江省2026年全国成人高等学校招生统一考试生态学基础训练题及答案
- 高级统计师资格考试(高级统计实务与案例分析)试题库及答案(2026年川自贡市)
- 安徽2026年高级统计师资格考试(高级统计实务与案例分析)模拟测试卷及答案
- (新版)机动车检测工职业技能考试题库及答案(完整版)
- 2026年资产评估师《资产评估实务一》考试题库及答案
- 2025年山东省成人高考专升本《教育理论》真题汇编及答案
- 2026年辽宁省专业技术资格考试(图书资料)(初、中级)练习题及答案
- 2026年高级统计师资格考试(高级统计实务与案例分析)模拟测试卷及答案(陕西)
- 铁矿安全员试题及答案
- 加油加氢站主要负责人运行操作安全操作规程
- 自控分包合同范本
- 保险中介合规培训
- 西交利物浦大学线性代数课件
- 雨课堂学堂云在线《核反应堆物理分析(下)(华北电大 )》单元测试考核答案
- 2025年希望杯IHC-三年级真题(含答案)
- 呼吸功能训练指导
- 2025年全国消毒技能竞赛试题(附答案)
- 水钟课件教学课件
- 国投集团考试题及答案
- 煤矿爆破三员培训课件
- 工会法知识培训资料课件
评论
0/150
提交评论