2015-05-01 17:13:44 -04:00
|
|
|
/*
|
|
|
|
########################################################################
|
|
|
|
Generic Clock Domain Crossing Block
|
|
|
|
########################################################################
|
|
|
|
*/
|
|
|
|
|
|
|
|
module fifo_cdc (/*AUTOARG*/
|
|
|
|
// 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-05-03 23:17:23 -04:00
|
|
|
clk_in, clk_out, reset, access_in, packet_in, wait_in
|
2015-05-01 17:13:44 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
parameter FD = 16; //minimum depth
|
|
|
|
parameter AW = $clog2(FD);
|
2015-05-03 23:17:23 -04:00
|
|
|
parameter DW = 104;
|
2015-05-01 17:13:44 -04:00
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/*Clocks/reset */
|
|
|
|
/********************************/
|
|
|
|
input clk_in;
|
|
|
|
input clk_out;
|
|
|
|
input reset;
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/*Input Packet*/
|
|
|
|
/********************************/
|
|
|
|
input access_in;
|
2015-05-03 23:17:23 -04:00
|
|
|
input [DW-1:0] packet_in;
|
|
|
|
output wait_out;
|
2015-05-01 17:13:44 -04:00
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/*Register RD/WR Packet to ERX*/
|
|
|
|
/********************************/
|
|
|
|
output access_out;
|
2015-05-03 23:17:23 -04:00
|
|
|
output [DW-1:0] packet_out;
|
|
|
|
input wait_in;
|
2015-05-01 17:13:44 -04:00
|
|
|
|
2015-05-03 23:17:23 -04:00
|
|
|
//Local wires
|
|
|
|
wire wr_en;
|
|
|
|
wire rd_en;
|
2015-05-01 17:13:44 -04:00
|
|
|
wire empty;
|
|
|
|
wire full;
|
2015-05-03 23:17:23 -04:00
|
|
|
reg access_out;
|
2015-05-01 17:13:44 -04:00
|
|
|
|
|
|
|
|
2015-05-03 23:17:23 -04:00
|
|
|
assign wr_en = access_in & ~full;
|
|
|
|
assign rd_en = ~empty & ~wait_in;
|
|
|
|
assign wait_out = full;
|
|
|
|
|
|
|
|
//Keep access high until "acknowledge"
|
2015-05-04 17:07:55 -04:00
|
|
|
always @ (posedge clk_out or posedge reset)
|
|
|
|
if(reset)
|
|
|
|
access_out <=1'b0;
|
|
|
|
else if(~wait_in)
|
2015-05-03 23:17:23 -04:00
|
|
|
access_out <=rd_en;
|
2015-05-01 17:13:44 -04:00
|
|
|
|
|
|
|
//Read response fifo (from master)
|
2015-05-04 10:37:08 -04:00
|
|
|
fifo_async #(.DW(DW), .AW(5)) fifo(
|
2015-05-01 17:13:44 -04:00
|
|
|
.prog_full (),
|
|
|
|
.full (full),
|
|
|
|
// Outputs
|
2015-05-03 23:17:23 -04:00
|
|
|
.dout (packet_out[DW-1:0]),
|
2015-05-01 17:13:44 -04:00
|
|
|
.empty (empty),
|
2015-05-03 23:17:23 -04:00
|
|
|
.valid (),
|
2015-05-01 17:13:44 -04:00
|
|
|
// Inputs
|
|
|
|
.reset (reset),
|
|
|
|
.wr_clk (clk_in),
|
|
|
|
.rd_clk (clk_out),
|
|
|
|
.wr_en (wr_en),
|
2015-05-03 23:17:23 -04:00
|
|
|
.din (packet_in[DW-1:0]),
|
2015-05-01 17:13:44 -04:00
|
|
|
.rd_en (rd_en)
|
|
|
|
);
|
|
|
|
|
|
|
|
endmodule // fifo_cdc
|
|
|
|
|
|
|
|
/*
|
|
|
|
Copyright (C) 2013 Adapteva, Inc.
|
|
|
|
Contributed by Andreas Olofsson <andreas@adapteva.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.This program 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 General Public License for more details. You should have received a copy
|
|
|
|
of the GNU General Public License along with this program (see the file
|
|
|
|
COPYING). If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|