📄 pci_delayed_sync.v
字号:
////////////////////////////////////////////////////////////////////////// //////// File name "delayed_sync.v" //////// //////// This file is part of the "PCI bridge" project //////// http://www.opencores.org/cores/pci/ //////// //////// Author(s): //////// - Miha Dolenc (mihad@opencores.org) //////// //////// All additional information is avaliable in the README //////// file. //////// //////// ////////////////////////////////////////////////////////////////////////////// //////// Copyright (C) 2001 Miha Dolenc, mihad@opencores.org //////// //////// 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 source file is free software; you can redistribute it //////// and/or modify it under the terms of the GNU Lesser General //////// Public License as published by the Free Software Foundation; //////// either version 2.1 of the License, or (at your option) any //////// later version. //////// //////// This source is distributed in the hope that it will be //////// useful, but WITHOUT ANY WARRANTY; without even the implied //////// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //////// PURPOSE. See the GNU Lesser General Public License for more //////// details. //////// //////// You should have received a copy of the GNU Lesser General //////// Public License along with this source; if not, download it //////// from http://www.opencores.org/lgpl.shtml //////// ////////////////////////////////////////////////////////////////////////////// CVS Revision History//// $Log: pci_delayed_sync.v,v $// Revision 1.3 2003/08/14 13:06:02 simons// synchronizer_flop replaced with pci_synchronizer_flop, artisan ram instance updated.//// Revision 1.2 2003/03/26 13:16:18 mihad// Added the reset value parameter to the synchronizer flop module.// Added resets to all synchronizer flop instances.// Repaired initial sync value in fifos.//// Revision 1.1 2003/01/27 16:49:31 mihad// Changed module and file names. Updated scripts accordingly. FIFO synchronizations changed.//// Revision 1.5 2002/09/25 09:54:50 mihad// Added completion expiration test for WB Slave unit. Changed expiration signalling//// Revision 1.4 2002/03/05 11:53:47 mihad// Added some testcases, removed un-needed fifo signals//// Revision 1.3 2002/02/01 15:25:12 mihad// Repaired a few bugs, updated specification, added test bench files and design document//// Revision 1.2 2001/10/05 08:14:28 mihad// Updated all files with inclusion of timescale file for simulation purposes.//// Revision 1.1.1.1 2001/10/02 15:33:46 mihad// New project directory structure////// module provides synchronization mechanism between requesting and completing side of the bridge`include "pci_constants.v"`include "bus_commands.v"// synopsys translate_off`include "timescale.v"// synopsys translate_onmodule pci_delayed_sync( reset_in, req_clk_in, comp_clk_in, req_in, comp_in, done_in, in_progress_in, comp_req_pending_out, req_req_pending_out, req_comp_pending_out, comp_comp_pending_out, addr_in, be_in, addr_out, be_out, we_in, we_out, bc_in, bc_out, status_in, status_out, comp_flush_out, burst_in, burst_out, retry_expired_in);// system inputsinput reset_in, // reset input req_clk_in, // requesting clock input comp_clk_in ; // completing clock input// request, completion, done and in progress indication inputsinput req_in, // request qualifier - when 1 it indicates that valid request data is provided on inputs comp_in, // completion qualifier - when 1, completing side indicates that request has completed done_in, // done input - when 1 indicates that requesting side of the bridge has completed a transaction on requesting bus in_progress_in ; // in progress indicator - indicates that current completion is in progress on requesting side of the bridge// pending indication outputsoutput comp_req_pending_out, // completion side request output - resynchronized from requesting clock to completing clock req_req_pending_out, // request pending output for requesting side req_comp_pending_out, // completion pending output for requesting side of the bridge - it indicates when completion is ready for completing on requesting bus comp_comp_pending_out ; // completion pending output for completing side of the bridge// additional signals and wires for clock domain passage of signalsreg comp_req_pending, req_req_pending, req_comp_pending, req_comp_pending_sample, comp_comp_pending, req_done_reg, comp_done_reg_main, comp_done_reg_clr, req_rty_exp_reg, req_rty_exp_clr, comp_rty_exp_reg, comp_rty_exp_clr ;wire sync_comp_req_pending, sync_req_comp_pending, sync_comp_done, sync_req_rty_exp, sync_comp_rty_exp_clr ;// inputs from requesting side - only this side can set address, bus command, byte enables, write enable and burst - outputs are common for both sides// all signals that identify requests are stored in this moduleinput [31:0] addr_in ; // address bus inputinput [3:0] be_in ; // byte enable inputinput we_in ; // write enable input - read/write request indication 1 = write request / 0 = read requestinput [3:0] bc_in ; // bus command inputinput burst_in ; // burst indicator - qualifies operation as burst/single transfer 1 = burst / 0 = single transfer// common request outputs used both by completing and requesting sides// this outputs are not resynchronized, since flags determine the request statusoutput [31:0] addr_out ;output [3:0] be_out ;output we_out ;output [3:0] bc_out ;output burst_out ;// completion side signals encoded termination status - 0 = normal completion / 1 = error terminated completioninput status_in ;output status_out ;// input signals that delayed transaction has been retried for max number of times// on this signal request is ditched, otherwise it would cause a deadlock// requestor can issue another request and procedure will be repeatedinput retry_expired_in ;// completion flush output - if in 2^^16 clock cycles transaction is not repeated by requesting agent - flush completion dataoutput comp_flush_out ;// output registers for common signalsreg [31:0] addr_out ;reg [3:0] be_out ;reg we_out ;reg [3:0] bc_out ;reg burst_out ;// delayed transaction information is stored only when request is issued and request nor completion are pendingwire new_request = req_in && ~req_comp_pending_out && ~req_req_pending_out ;always@(posedge req_clk_in or posedge reset_in)begin if (reset_in) begin addr_out <= #`FF_DELAY 32'h0000_0000 ; be_out <= #`FF_DELAY 4'h0 ; we_out <= #`FF_DELAY 1'b0 ; bc_out <= #`FF_DELAY `BC_RESERVED0 ; burst_out <= #`FF_DELAY 1'b0 ; end else if (new_request) begin addr_out <= #`FF_DELAY addr_in ; be_out <= #`FF_DELAY be_in ; we_out <= #`FF_DELAY we_in ; bc_out <= #`FF_DELAY bc_in ; burst_out <= #`FF_DELAY burst_in ; endend// completion pending cycle counterreg [16:0] comp_cycle_count ;/*=================================================================================================================================Passing of requests between clock domains:request originates on requesting side. It's then synchronized with two flip-flops to cross to completing clock domain=================================================================================================================================*/// main request flip-flop triggered on requesting side's clock// request is cleared whenever completion or retry expired is signalled from opposite side of the bridgewire 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)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -