- 1、本文档共2页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
VHDL - ( 3)
【VVHHDDLL 程序举例大全--存储器举例:((注33))】
--A First-in First-outMemory
--afirst-in firstoutmemory,usesasynchronising clock
--genericsallowfifosofdifferentsizestobeinstantiated
libraryIEEE;
useIEEE.Std_logic_1164.all;
entityFIFOMXNis
generic(m, n:Positive :=8);--misfifodepth,nisfifowidth
port(RESET,WRREQ,RDREQ,CLOCK:inStd_logic;
DATAIN :inStd_logic_vector((n-1)downto0);
DATAOUT:outStd_logic_vector((n-1)downto0);
FULL, EMPTY:inoutStd_logic);
endFIFOMXN;
architectureV2ofFIFOMXNis
typeFifo_arrayisarray(0to(m-1)) ofBit_vector((n-1)downto0);
signalFifo_memory:Fifo_array;
signalWraddr,Rdaddr,Offset:Naturalrange0to(m-1);
signalRdpulse,Wrpulse,Q1,Q2,Q3,Q4:Std_logic;
signalDatabuffer:Bit_vector((n-1)downto0);
begin
--pulsesynchronisersforWRREQandRDREQ
--modifiedforSynplify toaprocess
sync_ffs:process
begin
waituntilrising_edge(CLOCK);
Q1=WRREQ;
Q2=Q1;
Q3=RDREQ;
Q4=Q3;
endprocess;
--concurrentlogictogeneratepulses
Wrpulse=Q2andnot(Q1);
Rdpulse=Q4andnot(Q3);
Fifo_read:process
begin
waituntilrising_edge(CLOCK);
ifRESET=1 then
Rdaddr=0;
Databuffer=(others=0);
elsif(Rdpulse=1andEMPTY=0) then
Databuffer=Fifo_memory(Rdaddr);
Rdaddr=(Rdaddr+1)modm;
endif;
endprocess;
Fifo_write:process
begin
waituntilrising_edge(CLOCK);
ifRESET=1 then
Wraddr=0;
elsif(Wrpulse=1 andFULL=0)then
Fifo_memory(Wraddr)=To_Bitvector(DATAIN);
Wraddr=(Wraddr+1)mod m;
endif;
endprocess;
Offset=(Wraddr-Rdaddr)when(WraddrRdaddr)
else(m-(Rdaddr-Wraddr))when(RdaddrWraddr)
else0;
EMPTY=1 when(Offset=0)else0;
FULL=1 when(Offset=(m-1))
文档评论(0)