资源描述:
《基于verilog hdl 硬件描语言的fifo设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、RTLschematic基于verilogHDL硬件描语言的FIFO设计一、设计描述设计一个宽度为32位,深度为8的FIFO,要求根据读写控制输入输出32位数据,并在输出端以低电平有效给出空态(empyt_n),满态(full_n),几乎空(first_n),几乎满(last_n),以及差2位满(slast_n)的标志信号。二、RTLschematic24RTL源代码三、RTL源代码//--------------------------------------------------------------------
2、-----------------------------//Filename:fifo_ctrl.v--------xjy//------------------------------------------------------------------------------------------------//`timescale1ns/1psmodulefifo_ctrl(clk,rst_n,wrt_strobe_n,rd_strobe_n,//clr_n,rd_ptr,wrt_ptr,full_n,emp
3、ty_n,last_n,slast_n,first_n);inputclk;//FIFOclockdomaininputrst_n;//FIFOreset,activelowinputwrt_strobe_n;//fifowritestrobe,activelowinputrd_strobe_n;//fiforeadstrobe,activelow//inputclr_n;//clearsignal,activelowoutput[2:0]rd_ptr;//readpointertoregfileoutput[2:0]w
4、rt_ptr;//writepointertoregfileoutputfull_n;//fifofullindicator,activelowoutputempty_n;//fifoemptyindicator,activelowoutputlast_n;//indicateonespaceinfifo,activelowoutputslast_n;//indicatetwospaceinfifo,activelowoutputfirst_n;//indicateonlyonedatainfifo,activelowr
5、eg[2:0]rd_ptr;reg[2:0]wrt_ptr;wirefull_n,empty_n,last_n,slast_n,first_n;reg[3:0]reg_count;///////////////////writepointer////////////////////////always@(posedgeclkornegedgerst_n)beginif(!rst_n)wrt_ptr<=3'b0;elseif(wrt_ptr==3'b111)wrt_ptr<=0;elseif((!wrt_strobe_n)
6、&&(full_n)&&(rd_strobe_n))begin24RTL源代码wrt_ptr<=(wrt_ptr+1);//wr_mark<=1;endelsebeginwrt_ptr<=wrt_ptr;//wr_mark<=0;endend///////////////////readpointer/////////////////////always@(posedgeclkornegedgerst_n)beginif(!rst_n)rd_ptr<=3'b0;elseif(rd_ptr==3'b111)rd_ptr<=
7、0;elseif((!rd_strobe_n)&&(empty_n)&&(wrt_strobe_n))beginrd_ptr<=(rd_ptr+1);//rd_mark<=1;endelsebeginrd_ptr<=rd_ptr;//rd_mark<=0;endend//////////registercounter:from0(empty)to8(full)////////always@(posedgeclkornegedgerst_n)beginif(!rst_n)reg_count<=0;elsecasez({wr
8、t_strobe_n,rd_strobe_n})2'b01:reg_count<=(full_n)?(reg_count+1):reg_count;//write---count+12'b10:reg_count<=(empty_n)?(reg_count-1):reg_count;//read---count-1d