root / usrp2 / control_lib / medfifo.v @ c7adcbe4
History | View | Annotate | Download (2.07 KB)
| 1 | bfaa5d14 | Josh Blum | // |
|---|---|---|---|
| 2 | // Copyright 2011 Ettus Research LLC |
||
| 3 | // |
||
| 4 | // This program is free software: you can redistribute it and/or modify |
||
| 5 | // it under the terms of the GNU General Public License as published by |
||
| 6 | // the Free Software Foundation, either version 3 of the License, or |
||
| 7 | // (at your option) any later version. |
||
| 8 | // |
||
| 9 | // This program is distributed in the hope that it will be useful, |
||
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 12 | // GNU General Public License for more details. |
||
| 13 | // |
||
| 14 | // You should have received a copy of the GNU General Public License |
||
| 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
| 16 | // |
||
| 17 | |||
| 18 | 61f2f021 | jcorgan | |
| 19 | module medfifo |
||
| 20 | #(parameter WIDTH=32, |
||
| 21 | parameter DEPTH=1) |
||
| 22 | (input clk, input rst, |
||
| 23 | input [WIDTH-1:0] datain, |
||
| 24 | output [WIDTH-1:0] dataout, |
||
| 25 | input read, |
||
| 26 | input write, |
||
| 27 | input clear, |
||
| 28 | output full, |
||
| 29 | output empty, |
||
| 30 | output [7:0] space, |
||
| 31 | output [7:0] occupied); |
||
| 32 | |||
| 33 | localparam NUM_FIFOS = (1<<DEPTH); |
||
| 34 | |||
| 35 | wire [WIDTH-1:0] dout [0:NUM_FIFOS-1]; |
||
| 36 | wire [0:NUM_FIFOS-1] full_x; |
||
| 37 | wire [0:NUM_FIFOS-1] empty_x; |
||
| 38 | |||
| 39 | shortfifo #(.WIDTH(WIDTH)) |
||
| 40 | head (.clk(clk),.rst(rst), |
||
| 41 | .datain(datain),.write(write),.full(full), |
||
| 42 | .dataout(dout[0]),.read(~empty_x[0] & ~full_x[1]),.empty(empty_x[0]), |
||
| 43 | .clear(clear),.space(space[4:0]),.occupied() ); |
||
| 44 | |||
| 45 | shortfifo #(.WIDTH(WIDTH)) |
||
| 46 | tail (.clk(clk),.rst(rst), |
||
| 47 | .datain(dout[NUM_FIFOS-2]),.write(~empty_x[NUM_FIFOS-2] & ~full_x[NUM_FIFOS-1]),.full(full_x[NUM_FIFOS-1]), |
||
| 48 | .dataout(dataout),.read(read),.empty(empty), |
||
| 49 | .clear(clear),.space(),.occupied(occupied[4:0]) ); |
||
| 50 | |||
| 51 | genvar i; |
||
| 52 | generate |
||
| 53 | for(i = 1; i < NUM_FIFOS-1 ; i = i + 1) |
||
| 54 | begin : gen_depth |
||
| 55 | shortfifo #(.WIDTH(WIDTH)) |
||
| 56 | shortfifo (.clk(clk),.rst(rst), |
||
| 57 | .datain(dout[i-1]),.write(~full_x[i] & ~empty_x[i-1]),.full(full_x[i]), |
||
| 58 | .dataout(dout[i]),.read(~full_x[i+1] & ~empty_x[i]),.empty(empty_x[i]), |
||
| 59 | .clear(clear),.space(),.occupied() ); |
||
| 60 | end |
||
| 61 | endgenerate |
||
| 62 | |||
| 63 | assign space[7:5] = 0; |
||
| 64 | assign occupied[7:5] = 0; |
||
| 65 | |||
| 66 | endmodule // medfifo |