root / usrp2 / fifo / ll8_to_fifo19.v @ 37fa8da5
History | View | Annotate | Download (2.76 KB)
| 1 |
|
|---|---|
| 2 |
module ll8_to_fifo19 |
| 3 |
(input clk, input reset, input clear, |
| 4 |
input [7:0] ll_data, |
| 5 |
input ll_sof, |
| 6 |
input ll_eof, |
| 7 |
input ll_src_rdy, |
| 8 |
output ll_dst_rdy, |
| 9 |
|
| 10 |
output [18:0] f19_data, |
| 11 |
output f19_src_rdy_o, |
| 12 |
input f19_dst_rdy_i ); |
| 13 |
|
| 14 |
// Short FIFO on input to guarantee no deadlock |
| 15 |
wire [7:0] ll_data_int; |
| 16 |
wire ll_sof_int, ll_eof_int, ll_src_rdy_int, ll_dst_rdy_int; |
| 17 |
|
| 18 |
ll8_shortfifo head_fifo |
| 19 |
(.clk(clk), .reset(reset), .clear(clear), |
| 20 |
.datain(ll_data), .sof_i(ll_sof), .eof_i(ll_eof), |
| 21 |
.error_i(0), .src_rdy_i(ll_src_rdy), .dst_rdy_o(ll_dst_rdy), |
| 22 |
.dataout(ll_data_int), .sof_o(ll_sof_int), .eof_o(ll_eof_int), |
| 23 |
.error_o(), .src_rdy_o(ll_src_rdy_int), .dst_rdy_i(ll_dst_rdy_int)); |
| 24 |
|
| 25 |
// Actual ll8_to_fifo19 which could deadlock if not connected to a shortfifo |
| 26 |
localparam XFER_EMPTY = 0; |
| 27 |
localparam XFER_HALF = 1; |
| 28 |
localparam XFER_HALF_WRITE = 3; |
| 29 |
|
| 30 |
wire [18:0] f19_data_int; |
| 31 |
wire f19_sof_int, f19_eof_int, f19_occ_int, f19_src_rdy_int, f19_dst_rdy_int; |
| 32 |
|
| 33 |
wire xfer_out = f19_src_rdy_int & f19_dst_rdy_int; |
| 34 |
wire xfer_in = ll_src_rdy_int & ll_dst_rdy_int; |
| 35 |
reg hold_sof; |
| 36 |
|
| 37 |
reg [1:0] state; |
| 38 |
reg [7:0] hold_reg; |
| 39 |
|
| 40 |
always @(posedge clk) |
| 41 |
if(ll_src_rdy_int & (state==XFER_EMPTY)) |
| 42 |
hold_reg <= ll_data_int; |
| 43 |
|
| 44 |
always @(posedge clk) |
| 45 |
if(ll_sof_int & (state==XFER_EMPTY)) |
| 46 |
hold_sof <= 1; |
| 47 |
else if(xfer_out) |
| 48 |
hold_sof <= 0; |
| 49 |
|
| 50 |
always @(posedge clk) |
| 51 |
if(reset | clear) |
| 52 |
state <= XFER_EMPTY; |
| 53 |
else |
| 54 |
case(state) |
| 55 |
XFER_EMPTY : |
| 56 |
if(ll_src_rdy_int) |
| 57 |
if(ll_eof_int) |
| 58 |
state <= XFER_HALF_WRITE; |
| 59 |
else |
| 60 |
state <= XFER_HALF; |
| 61 |
XFER_HALF : |
| 62 |
if(ll_src_rdy_int & f19_dst_rdy_int) |
| 63 |
state <= XFER_EMPTY; |
| 64 |
XFER_HALF_WRITE : |
| 65 |
if(f19_dst_rdy_int) |
| 66 |
state <= XFER_EMPTY; |
| 67 |
endcase // case (state) |
| 68 |
|
| 69 |
assign ll_dst_rdy_int = (state==XFER_EMPTY) | ((state==XFER_HALF)&f19_dst_rdy_int); |
| 70 |
assign f19_src_rdy_int= (state==XFER_HALF_WRITE) | ((state==XFER_HALF)&ll_src_rdy_int); |
| 71 |
|
| 72 |
assign f19_sof_int = hold_sof | (ll_sof_int & (state==XFER_HALF)); |
| 73 |
assign f19_eof_int = (state == XFER_HALF_WRITE) | ll_eof_int; |
| 74 |
assign f19_occ_int = (state == XFER_HALF_WRITE); |
| 75 |
|
| 76 |
assign f19_data_int = {f19_occ_int,f19_eof_int,f19_sof_int,hold_reg,ll_data_int};
|
| 77 |
|
| 78 |
// Shortfifo on output to guarantee no deadlock |
| 79 |
fifo_short #(.WIDTH(19)) tail_fifo |
| 80 |
(.clk(clk),.reset(reset),.clear(clear), |
| 81 |
.datain(f19_data_int), .src_rdy_i(f19_src_rdy_int), .dst_rdy_o(f19_dst_rdy_int), |
| 82 |
.dataout(f19_data), .src_rdy_o(f19_src_rdy_o), .dst_rdy_i(f19_dst_rdy_i), |
| 83 |
.space(),.occupied() ); |
| 84 |
|
| 85 |
|
| 86 |
endmodule // ll8_to_fifo19 |
| 87 |
|