2016-01-19 13:28:47 -05:00
|
|
|
//########################################################################
|
|
|
|
//# FIFO based clock Domain Crosser
|
|
|
|
//########################################################################
|
2015-11-30 15:07:28 -05:00
|
|
|
module oh_fifo_cdc (/*AUTOARG*/
|
2015-05-01 17:13:44 -04:00
|
|
|
// Outputs
|
2015-05-03 23:17:23 -04:00
|
|
|
wait_out, access_out, packet_out,
|
2015-05-01 17:13:44 -04:00
|
|
|
// Inputs
|
2015-11-09 13:20:46 -05:00
|
|
|
nreset, clk_in, access_in, packet_in, clk_out, wait_in
|
2015-05-01 17:13:44 -04:00
|
|
|
);
|
|
|
|
|
2016-01-19 13:28:47 -05:00
|
|
|
//#####################################################################
|
|
|
|
//# INTERFACE
|
|
|
|
//#####################################################################
|
2015-07-02 16:59:38 -04:00
|
|
|
parameter DW = 104;
|
2015-10-07 19:21:04 -04:00
|
|
|
parameter DEPTH = 32;
|
2015-11-24 01:05:04 -05:00
|
|
|
parameter WAIT = 0;
|
2015-05-01 17:13:44 -04:00
|
|
|
|
2016-01-19 13:28:47 -05:00
|
|
|
//shared async reset
|
|
|
|
input nreset;
|
|
|
|
|
|
|
|
//input packet
|
2015-11-09 13:20:46 -05:00
|
|
|
|
|
|
|
input clk_in;
|
2015-05-07 23:50:34 -04:00
|
|
|
input access_in;
|
2015-08-14 17:15:38 -04:00
|
|
|
input [DW-1:0] packet_in;
|
2015-05-07 23:50:34 -04:00
|
|
|
output wait_out;
|
2015-05-01 17:13:44 -04:00
|
|
|
|
2016-01-19 13:28:47 -05:00
|
|
|
//output packet
|
2015-05-14 22:47:25 -04:00
|
|
|
input clk_out;
|
2015-05-07 23:50:34 -04:00
|
|
|
output access_out;
|
2015-08-14 17:15:38 -04:00
|
|
|
output [DW-1:0] packet_out;
|
2015-05-07 23:50:34 -04:00
|
|
|
input wait_in;
|
2015-05-01 17:13:44 -04:00
|
|
|
|
2016-01-19 13:28:47 -05:00
|
|
|
//#####################################################################
|
|
|
|
//# BODY
|
|
|
|
//#####################################################################
|
2015-05-07 23:50:34 -04:00
|
|
|
//Local wires
|
|
|
|
wire wr_en;
|
|
|
|
wire rd_en;
|
|
|
|
wire empty;
|
|
|
|
wire full;
|
2015-11-11 22:32:21 -05:00
|
|
|
wire prog_full;
|
2015-05-07 23:50:34 -04:00
|
|
|
reg access_out;
|
|
|
|
|
2016-01-19 13:28:47 -05:00
|
|
|
//We use the prog_full clean out any buffers in pipe
|
2015-11-30 15:07:28 -05:00
|
|
|
//Assumption: The "full" state should never be reached!
|
|
|
|
assign wr_en = access_in;
|
2015-05-03 23:17:23 -04:00
|
|
|
assign rd_en = ~empty & ~wait_in;
|
2015-11-11 22:32:21 -05:00
|
|
|
assign wait_out = prog_full;
|
2015-05-03 23:17:23 -04:00
|
|
|
|
2016-01-19 13:28:47 -05:00
|
|
|
//Holds access high while waiting
|
2015-11-09 13:20:46 -05:00
|
|
|
always @ (posedge clk_out or negedge nreset)
|
|
|
|
if(!nreset)
|
2016-01-11 20:50:40 -05:00
|
|
|
access_out <= 1'b0;
|
2015-05-04 17:07:55 -04:00
|
|
|
else if(~wait_in)
|
2016-01-11 20:50:40 -05:00
|
|
|
access_out <= rd_en;
|
2015-05-21 22:54:29 -04:00
|
|
|
|
2015-05-01 17:13:44 -04:00
|
|
|
//Read response fifo (from master)
|
2016-01-19 13:28:47 -05:00
|
|
|
oh_fifo_async #(.DW(DW),
|
|
|
|
.DEPTH(DEPTH),
|
|
|
|
.WAIT(WAIT))
|
|
|
|
fifo (.prog_full (prog_full),
|
|
|
|
.full (full),
|
2016-01-20 10:51:57 -05:00
|
|
|
.rd_count (),
|
2016-01-19 13:28:47 -05:00
|
|
|
.nreset (nreset),
|
|
|
|
.dout (packet_out[DW-1:0]),
|
|
|
|
.empty (empty),
|
|
|
|
.wr_clk (clk_in),
|
|
|
|
.rd_clk (clk_out),
|
|
|
|
.wr_en (wr_en),
|
|
|
|
.din (packet_in[DW-1:0]),
|
|
|
|
.rd_en (rd_en)
|
|
|
|
);
|
|
|
|
|
2015-05-01 17:13:44 -04:00
|
|
|
endmodule // fifo_cdc
|