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

📄 pci_wbr_fifo_control.v

📁 PCI-master的核
💻 V
📖 第 1 页 / 共 3 页
字号:
/* FIFO_CONTROL module provides read/write address and status generation for   FIFOs implemented with standard dual port SRAM cells in ASIC or FPGA designs */`include &quot;pci_constants.v&quot;// synopsys translate_off`include &quot;timescale.v&quot;// synopsys translate_onmodule pci_wbr_fifo_control(    rclock_in,    wclock_in,    renable_in,    wenable_in,    reset_in,    flush_in,    empty_out,    waddr_out,    raddr_out,    rallow_out,    wallow_out) ;parameter ADDR_LENGTH = 7 ;// independent clock inputs - rclock_in = read clock, wclock_in = write clockinput  rclock_in, wclock_in;// enable inputs - read address changes on rising edge of rclock_in when reads are allowed//                 write address changes on rising edge of wclock_in when writes are allowedinput  renable_in, wenable_in;// reset inputinput  reset_in;// flush inputinput flush_in ;// empty status outputoutput empty_out;// read and write addresses outputsoutput [(ADDR_LENGTH - 1):0] waddr_out, raddr_out;// read and write allow outputsoutput rallow_out, wallow_out ;// read address registerreg [(ADDR_LENGTH - 1):0] raddr ;// write address registerreg [(ADDR_LENGTH - 1):0] waddr;assign waddr_out = waddr ;// grey code registerreg [(ADDR_LENGTH - 1):0] wgrey_addr ;// next write gray address calculation - bitwise xor between address and shifted addresswire [(ADDR_LENGTH - 2):0] calc_wgrey_next  = waddr[(ADDR_LENGTH - 1):1] ^ waddr[(ADDR_LENGTH - 2):0] ;// grey code registerreg [(ADDR_LENGTH - 1):0] rgrey_addr ;// next read gray address calculation - bitwise xor between address and shifted addresswire [(ADDR_LENGTH - 2):0] calc_rgrey_next  = raddr[(ADDR_LENGTH - 1):1] ^ raddr[(ADDR_LENGTH - 2):0] ;// FF for registered empty flagwire empty ;// write allow wirewire wallow = wenable_in ;// write allow output assignmentassign wallow_out = wallow ;// read allow wirewire rallow ;// clear generation for FFs and registerswire clear = reset_in /*|| flush_in*/ ; // flush changed to synchronous operationassign empty_out = empty ;//rallow generationassign rallow = renable_in &amp;&amp; !empty ; // reads allowed if read enable is high and FIFO is not empty// rallow output assignmentassign rallow_out = renable_in ;// at any clock edge that rallow is high, this register provides next read address, so wait cycles are not necessary// when FIFO is empty, this register provides actual read address, so first location can be readreg [(ADDR_LENGTH - 1):0] raddr_plus_one ;// address output mux - when FIFO is empty, current actual address is driven out, when it is non - empty next address is driven out// done for zero wait state burstassign raddr_out = rallow ? raddr_plus_one : raddr ;always@(posedge rclock_in or posedge clear)begin    if (clear)    begin        raddr_plus_one &lt;= #`FF_DELAY 2 ;        raddr          &lt;= #`FF_DELAY 1 ;    end    else if (flush_in)    begin        raddr_plus_one &lt;= #`FF_DELAY waddr + 1'b1 ;         raddr          &lt;= #`FF_DELAY waddr ;    end    else if (rallow)    begin        raddr_plus_one &lt;= #`FF_DELAY raddr_plus_one + 1'b1 ;        raddr          &lt;= #`FF_DELAY raddr_plus_one ;    endend/*-----------------------------------------------------------------------------------------------Read address control consists of Read address counter and Grey Address register--------------------------------------------------------------------------------------------------*/// grey coded addressalways@(posedge rclock_in or posedge clear)begin    if (clear)    begin        rgrey_addr &lt;= #`FF_DELAY 0 ;    end    else if (flush_in)    begin        rgrey_addr &lt;= #`FF_DELAY wgrey_addr ;   // when flushed, copy value from write side    end    else if (rallow)    begin        rgrey_addr &lt;= #`FF_DELAY {raddr[ADDR_LENGTH - 1], calc_rgrey_next} ;    endend/*--------------------------------------------------------------------------------------------Write address control consists of write address counter and Grey Code Register----------------------------------------------------------------------------------------------*/// grey coded address for status generation in write clock domainalways@(posedge wclock_in or posedge clear)begin    if (clear)    begin        wgrey_addr &lt;= #1 0 ;    end    else    if (wallow)    begin        wgrey_addr &lt;= #1 {waddr[(ADDR_LENGTH - 1)], calc_wgrey_next} ;    endend// write address counter - nothing special except initial valuealways@(posedge wclock_in or posedge clear)begin    if (clear)        // initial value is 1        waddr &lt;= #`FF_DELAY 1 ;    else    if (wallow)        waddr &lt;= #`FF_DELAY waddr + 1'b1 ;end/*------------------------------------------------------------------------------------------------------------------------------Empty control:Gray coded write address pointer is synchronized to read clock domain and compared to Gray coded read address pointer.If they are equal, fifo is empty.--------------------------------------------------------------------------------------------------------------------------------*/wire [(ADDR_LENGTH - 1):0] rclk_sync_wgrey_addr ;reg  [(ADDR_LENGTH - 1):0] rclk_wgrey_addr ;pci_synchronizer_flop #(ADDR_LENGTH, 0) i_synchronizer_reg_wgrey_addr(    .data_in        (wgrey_addr),    .clk_out        (rclock_in),    .sync_data_out  (rclk_sync_wgrey_addr),    .async_reset    (clear)) ;always@(posedge rclock_in or posedge clear)begin    if (clear)        rclk_wgrey_addr &lt;= #`FF_DELAY 0 ;    else        rclk_wgrey_addr &lt;= #`FF_DELAY rclk_sync_wgrey_addr ;endassign empty = (rgrey_addr == rclk_wgrey_addr) ;endmodule</pre><hr /><address><span style="font-size: smaller">FreeBSD-CVSweb &lt;<a href="mailto:freebsd-cvsweb@FreeBSD.org">freebsd-cvsweb@FreeBSD.org</a>&gt;</span></address></body></html><!-- pf_body_end --></td><td><img width=15 src="/images/dotty.gif"></td></tr></table><xcenter><p><table width=100% cellpadding=0 cellspacing=0 border=0>      <tr><td align=right valign=bottom><a title='Top' href='#top'><img border=0 alt='Top' src='/images/hr_up.gif'></a></td></tr>      <tr><td background='/images/hpd.gif'><img height=1 border=0 src='/images/dotty.gif'></td></tr><tr><td height=4><img height=4 src='/images/dotty.gif'></td></tr></table>&nbsp;<br><!--<table border=0 cellpadding=0 cellspacing=1 bgcolor=#ffffff><tr><td><table cellpadding=0 cellspacing=0 border=0 bgcolor=#ffffff><tr><td>//--><script type="text/javascript"><!--google_ad_client = "pub-9285819221080148";google_alternate_color = "FFFFFF";google_ad_width = 728;google_ad_height = 90;google_ad_format = "728x90_as";google_ad_type = "text_image";google_ad_channel ="3034172958";google_color_border = "ffffff";google_color_bg = "ffffff";google_color_link = "444488";google_color_url = "b00000";google_color_text = "666666";//--></script><script type="text/javascript"  src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script><!--</td></tr></table></td></tr></table>//--></center><img border=0 src="/images/dotty.gif" height=1 width=400><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30><img border=0 src="/images/dotty.gif" height=1 width=30></td></tr></table>&nbsp;</td></tr><tr bgcolor=#000000><td><img height=1 src="/images/dotty.gif"></td></tr></table><table background="/images/topbg.gif" width=100% cellpadding=0 cellspacing=0 border=0 bgcolor=#aaddff><tr><td align=right>Copyright (c) 1999-2007 OPENCORES.ORG. All rights reserved. &nbsp;</td></tr><tr><td>&nbsp;</td></tr></table></td><td width=1 bgcolor=#000000><img width=1 src="/images/dotty.gif"></td><td width=1 bgcolor=#f0f0c8><img width=1 src="/images/dotty.gif"></td></tr></table></center><!-- pf_footer_start -->  </body></html><!-- pf_footer_end -->

⌨️ 快捷键说明

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