📄 pci_delayed_sync(1).v
字号:
wire req_req_clear = req_comp_pending || (req_rty_exp_reg && ~req_rty_exp_clr) ;always@(posedge req_clk_in or posedge reset_in)begin if ( reset_in ) req_req_pending <= #`FF_DELAY 1'b0 ; else if ( req_req_clear ) req_req_pending <= #`FF_DELAY 1'b0 ; else if ( req_in ) req_req_pending <= #`FF_DELAY 1'b1 ;end// interemediate stage request synchronization flip - flop - this one is prone to metastability// and should have setup and hold times disabled during simulationpci_synchronizer_flop #(1, 0) req_sync( .data_in (req_req_pending), .clk_out (comp_clk_in), .sync_data_out (sync_comp_req_pending), .async_reset (reset_in)) ;// wire for clearing completion side request flag - whenever completion or retry expired are signalledwire comp_req_pending_clear = comp_req_pending && ( comp_in || retry_expired_in) ;// wire for enabling request flip - flop - it is enabled when completion is not active and done is not activewire comp_req_pending_ena = ~comp_comp_pending && ~comp_done_reg_main && ~comp_rty_exp_reg ;// completion side request flip flop - gets a value from intermediate stage sync flip flopalways@(posedge comp_clk_in or posedge reset_in)begin if ( reset_in ) comp_req_pending <= #`FF_DELAY 1'b0 ; else if ( comp_req_pending_clear ) comp_req_pending <= #`FF_DELAY 1'b0 ; else if ( comp_req_pending_ena ) comp_req_pending <= #`FF_DELAY sync_comp_req_pending ;end// completion side request output assignment - when request ff is set and completion ff is not setassign comp_req_pending_out = comp_req_pending ;// requesting side request pending outputassign req_req_pending_out = req_req_pending ;/*=================================================================================================================================Passing of completions between clock domains:completion originates on completing side. It's then synchronized with two flip-flops to cross to requesting clock domain=================================================================================================================================*/// main completion Flip - Flop - triggered by completing side's clock// completion side completion pending flag is cleared when done flag propagates through clock domainswire comp_comp_clear = comp_done_reg_main && ~comp_done_reg_clr ;always@(posedge comp_clk_in or posedge reset_in)begin if ( reset_in ) comp_comp_pending <= #`FF_DELAY 1'b0 ; else if ( comp_comp_clear ) comp_comp_pending <= #`FF_DELAY 1'b0 ; else if ( comp_in && comp_req_pending ) comp_comp_pending <= #`FF_DELAY 1'b1 ;endassign comp_comp_pending_out = comp_comp_pending ;// interemediate stage completion synchronization flip - flop - this one is prone to metastabilitypci_synchronizer_flop #(1, 0) comp_sync( .data_in (comp_comp_pending), .clk_out (req_clk_in), .sync_data_out (sync_req_comp_pending), .async_reset (reset_in)) ;// request side completion pending flip flop is cleared whenever done is signalled or completion counter expires - 2^^16 clock cycleswire req_comp_pending_clear = done_in || comp_cycle_count[16];// request side completion pending flip flop is disabled while done flag is setwire req_comp_pending_ena = ~req_done_reg ;// request side completion flip flop - gets a value from intermediate stage sync flip flopalways@(posedge req_clk_in or posedge reset_in)begin if ( reset_in ) req_comp_pending <= #`FF_DELAY 1'b0 ; else if ( req_comp_pending_clear ) req_comp_pending <= #`FF_DELAY 1'b0 ; else if ( req_comp_pending_ena ) req_comp_pending <= #`FF_DELAY sync_req_comp_pending ;end// sampling FF - used for sampling incoming completion flag from completing sidealways@(posedge req_clk_in or posedge reset_in)begin if ( reset_in ) req_comp_pending_sample <= #`FF_DELAY 1'b0 ; else req_comp_pending_sample <= #`FF_DELAY sync_req_comp_pending ;end// requesting side completion pending output assignmentassign req_comp_pending_out = req_comp_pending && ~req_req_pending ;/*==================================================================================================================================Passing of delayed transaction done signal between clock domains.Done is signalled by requesting side of the bridge and is passed to completing side of the bridge==================================================================================================================================*/// main done flip-flop triggered on requesting side's clock// when completing side removes completion flag, done flag is also removed, so requests can proceedewire req_done_clear = ~req_comp_pending_sample ;always@(posedge req_clk_in or posedge reset_in)begin if ( reset_in ) req_done_reg <= #`FF_DELAY 1'b0 ; else if ( req_done_clear ) req_done_reg <= #`FF_DELAY 1'b0 ; else if ( done_in || comp_cycle_count[16] ) req_done_reg <= #`FF_DELAY 1'b1 ;endpci_synchronizer_flop #(1, 0) done_sync( .data_in (req_done_reg), .clk_out (comp_clk_in), .sync_data_out (sync_comp_done), .async_reset (reset_in)) ;always@(posedge comp_clk_in or posedge reset_in)begin if ( reset_in ) comp_done_reg_main <= #`FF_DELAY 1'b0 ; else comp_done_reg_main <= #`FF_DELAY sync_comp_done ;endalways@(posedge comp_clk_in or posedge reset_in)begin if ( reset_in ) comp_done_reg_clr <= #`FF_DELAY 1'b0 ; else comp_done_reg_clr <= #`FF_DELAY comp_done_reg_main ;end/*=================================================================================================================================Passing of retry expired signal between clock domainsRetry expiration originates on completing side. It's then synchronized with two flip-flops to cross to requesting clock domain=================================================================================================================================*/// main retry expired Flip - Flop - triggered by completing side's clockwire comp_rty_exp_clear = comp_rty_exp_clr && comp_rty_exp_reg ;// retry expired is a special case of transaction removal - retry expired propagates from completing// clock domain to requesting clock domain to remove all pending requests and than propagates back// to completing side to qualify valid new requestsalways@(posedge comp_clk_in or posedge reset_in)begin if ( reset_in ) comp_rty_exp_reg <= #`FF_DELAY 1'b0 ; else if ( comp_rty_exp_clear ) comp_rty_exp_reg <= #`FF_DELAY 1'b0 ; else if ( retry_expired_in && comp_req_pending) comp_rty_exp_reg <= #`FF_DELAY 1'b1 ;end// interemediate stage retry expired synchronization flip - flop - this one is prone to metastabilitypci_synchronizer_flop #(1, 0) rty_exp_sync( .data_in (comp_rty_exp_reg), .clk_out (req_clk_in), .sync_data_out (sync_req_rty_exp), .async_reset (reset_in)) ;// request retry expired flip flop - gets a value from intermediate stage sync flip flopalways@(posedge req_clk_in or posedge reset_in)begin if ( reset_in ) req_rty_exp_reg <= #`FF_DELAY 1'b0 ; else req_rty_exp_reg <= #`FF_DELAY sync_req_rty_exp ;endalways@(posedge req_clk_in or posedge reset_in)begin if ( reset_in ) req_rty_exp_clr <= #`FF_DELAY 1'b0 ; else req_rty_exp_clr <= #`FF_DELAY req_rty_exp_reg ;endpci_synchronizer_flop #(1, 0) rty_exp_back_prop_sync( .data_in (req_rty_exp_reg && req_rty_exp_clr), .clk_out (comp_clk_in), .sync_data_out (sync_comp_rty_exp_clr), .async_reset (reset_in)) ;always@(posedge comp_clk_in or posedge reset_in)begin if ( reset_in ) comp_rty_exp_clr <= #`FF_DELAY 1'b0 ; else comp_rty_exp_clr <= #`FF_DELAY sync_comp_rty_exp_clr ;end// completion status flip flop - if 0 when completion is signalled it's finished OK otherwise it means errorreg status_out ;always@(posedge comp_clk_in or posedge reset_in)begin if (reset_in) status_out <= #`FF_DELAY 1'b0 ; else if (comp_in && comp_req_pending) status_out <= #`FF_DELAY status_in ;end// clocks counter - it counts how many clock cycles completion is present without beeing repeated// if it counts to 2^^16 cycles the completion must be ditched// wire for clearing this counterwire clear_count = in_progress_in || ~req_comp_pending_out || comp_cycle_count[16] ;always@(posedge req_clk_in or posedge reset_in)begin if (reset_in) comp_cycle_count <= #`FF_DELAY 17'h0_0000 ; else if (clear_count) comp_cycle_count <= #`FF_DELAY 17'h0_0000 ; else comp_cycle_count <= #`FF_DELAY comp_cycle_count + 1'b1 ;end// completion flush output - used for flushing fifos when counter expires// if counter doesn't expire, fifo flush is up to WISHBONE slave or PCI target state machinesreg comp_flush_out ;always@(posedge req_clk_in or posedge reset_in)begin if (reset_in) comp_flush_out <= #`FF_DELAY 1'b0 ; else comp_flush_out <= #`FF_DELAY comp_cycle_count[16] ;endendmodule //delayed_sync</pre><hr /><address><span style="font-size: smaller">FreeBSD-CVSweb <<a href="mailto:freebsd-cvsweb@FreeBSD.org">freebsd-cvsweb@FreeBSD.org</a>></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> <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> </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. </td></tr><tr><td> </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 + -