root / usrp2 / vrt / vita_pkt_gen.v @ 531a7910
History | View | Annotate | Download (1.49 KB)
| 1 |
// |
|---|---|
| 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 |
|
| 19 |
|
| 20 |
module vita_pkt_gen |
| 21 |
(input clk, input reset, input clear, |
| 22 |
input [15:0] len, |
| 23 |
output [35:0] data_o, output src_rdy_o, input dst_rdy_i); |
| 24 |
|
| 25 |
reg [15:0] state; |
| 26 |
reg [31:0] seq, data; |
| 27 |
|
| 28 |
wire sof = (state == 0); |
| 29 |
wire eof = (state == (len-1)); |
| 30 |
wire consume = src_rdy_o & dst_rdy_i; |
| 31 |
|
| 32 |
assign src_rdy_o = 1; |
| 33 |
|
| 34 |
always @(posedge clk) |
| 35 |
if(reset | clear) |
| 36 |
begin |
| 37 |
state <= 0; |
| 38 |
seq <= 0; |
| 39 |
end |
| 40 |
else |
| 41 |
if(consume) |
| 42 |
if(eof) |
| 43 |
begin |
| 44 |
state <= 0; |
| 45 |
seq <= seq + 1; |
| 46 |
end |
| 47 |
else |
| 48 |
state <= state + 1; |
| 49 |
|
| 50 |
always @* |
| 51 |
case(state) |
| 52 |
0 : data <= {24'h000,seq[3:0],len};
|
| 53 |
1 : data <= seq; |
| 54 |
default : data <= {~state,state};
|
| 55 |
endcase // case (state) |
| 56 |
|
| 57 |
assign data_o = {2'b00, eof, sof, data};
|
| 58 |
|
| 59 |
endmodule // vita_pkt_gen |