⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb1_fifo.v

📁 usb1.1 ip核
💻 V
字号:
/////////////////////////////////////////////////////////////////////////                                                             ////////  Generic FIFO                                               ////////                                                             ////////                                                             ////////  Author: Rudolf Usselmann                                   ////////          rudi@asics.ws                                      ////////                                                             ////////                                                             ////////                                                             /////////////////////////////////////////////////////////////////////////////                                                             //////// Copyright (C) 2001 Rudolf Usselmann                         ////////                    rudi@asics.ws                            ////////                                                             //////// This source file may be used and distributed without        //////// restriction provided that this copyright statement is not   //////// removed from the file and that any derivative work contains //////// the original copyright notice and the associated disclaimer.////////                                                             ////////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     //////// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   //////// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   //////// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      //////// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         //////// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    //////// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   //////// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        //////// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  //////// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  //////// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  //////// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         //////// POSSIBILITY OF SUCH DAMAGE.                                 ////////                                                             ///////////////////////////////////////////////////////////////////////////  CVS Log////  $Id: usb1_fifo.v,v 1.1.1.1 2002/09/19 12:07:32 rudi Exp $////  $Date: 2002/09/19 12:07:32 $//  $Revision: 1.1.1.1 $//  $Author: rudi $//  $Locker:  $//  $State: Exp $//// Change History://               $Log: usb1_fifo.v,v $//               Revision 1.1.1.1  2002/09/19 12:07:32  rudi//               Initial Checkin/////////////////////*Special feature:full_n  - indicates if there is no more space for 'n' bytes in the FIFO.empty_n - indicates if there is less than 'n' bytes in the FIFO.'n' is a parameter.*/module usb1_fifo(clk, rst, clr, din, we, dout, re,		full, empty, full_n, empty_n);parameter dw=8;parameter aw=8;parameter n=32;parameter max_size = 1<<aw;input			clk, rst, clr;input	[dw-1:0]	din;input			we;output	[dw-1:0]	dout;input			re;output			full;output			empty;output			full_n;output			empty_n;//////////////////////////////////////////////////////////////////////// Local Wires//reg	[aw-1:0]	wp;wire	[aw-1:0]	wp_pl1;reg	[aw-1:0]	rp;wire	[aw-1:0]	ra;wire	[aw-1:0]	rp_pl1;reg			gb;reg	[aw:0]		cnt;wire			full_n, empty_n;//////////////////////////////////////////////////////////////////////// Memory Block//generic_dpram  #(aw,dw) u0(	.rclk(		clk		),	.rrst(		!rst		),	.rce(		1'b1		),	.oe(		1'b1		),	.raddr(		ra		),	.do(		dout		),	.wclk(		clk		),	.wrst(		!rst		),	.wce(		1'b1		),	.we(		we		),	.waddr(		wp		),	.di(		din		)	);//////////////////////////////////////////////////////////////////////// Misc Logic//assign ra = rp;always @(posedge clk)	if(!rst)		wp <= #1 {aw{1'b0}};	else	if(clr)			wp <= #1 {aw{1'b0}};	else	if(we & !full)		wp <= #1 wp_pl1;assign wp_pl1 = wp + { {aw-1{1'b0}}, 1'b1};always @(posedge clk)	if(!rst)		rp <= #1 {aw{1'b0}};	else	if(clr)			rp <= #1 {aw{1'b0}};	else	if(re & !empty)		rp <= #1 rp_pl1;assign rp_pl1 = rp + { {aw-1{1'b0}}, 1'b1};// Statusassign empty = ((wp == rp) & !gb);assign full  = ((wp == rp) &  gb);// Guard Bit ...always @(posedge clk)	if(!rst)			gb <= #1 1'b0;	else	if(clr)				gb <= #1 1'b0;	else	if((wp_pl1 == rp) & we)		gb <= #1 1'b1;	else	if(re)				gb <= #1 1'b0;always @(posedge clk)	if(!rst)	cnt <= #1 {aw+1{1'b0}};	else	if(clr)		cnt <= #1 {aw+1{1'b0}};	else	if( re & !we)	cnt <= #1 cnt + { {aw{1'b1}}, 1'b1};	else	if(!re &  we)	cnt <= #1 cnt + { {aw{1'b0}}, 1'b1};assign empty_n = cnt < n;assign full_n  = !(cnt < (max_size-n+1));endmodule

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -