URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [video/] [src/] [avf_line_buffer.sv] - Rev 50
Go to most recent revision | Compare with Previous | Blame | View Log
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2019 Authors and OPENCORES.ORG ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer. ////
//// ////
//// This source file is free software; you can redistribute it ////
//// and/or modify it under the terms of the GNU Lesser General ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any ////
//// later version. ////
//// ////
//// This source 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 Lesser General Public License for more ////
//// details. ////
//// ////
//// You should have received a copy of the GNU Lesser General ////
//// Public License along with this source; if not, download it ////
//// from http://www.opencores.org/lgpl.shtml ////
//// ////
//////////////////////////////////////////////////////////////////////
module
avf_line_buffer #(N, U, L, AW)
(
axis_if axis_in,
axis_if axis_out,
input aclk,
input aresetn
);
// --------------------------------------------------------------------
localparam W = (N*8) + U + 1; // tdata + tuser + tlast
localparam F = 2; // fanout for the buffer row output
// --------------------------------------------------------------------
axis_if #(.N(N), .U(U)) row_out[L][F](.*);
axis_if #(.N(N), .U(U)) buffer_out[L-1](.*);
wire [L-2:0] zero_pad;
wire [L-2:0] initialized;
wire all_initialized = &initialized;
wire enable;
wire eof_trailing = row_out[0][0].tready & row_out[0][0].tvalid & row_out[0][0].tuser[2];
wire eof_leading = row_out[L-1][0].tready & row_out[L-1][0].tvalid & row_out[L-1][0].tuser[2];
// --------------------------------------------------------------------
generate
for(genvar j = 0; j < L-1; j++)
begin: buffer_gen
avf_line_buffer_row #(N, W, AW, j)
row_i
(
.axis_in(row_out[j+1][1]),
.axis_out(buffer_out[j]),
.zero_pad(zero_pad[j]),
.initialized(initialized[j]),
.*
);
end
endgenerate
// --------------------------------------------------------------------
generate
for(genvar j = 1; j < L-1; j++)
begin: middle_fanout_gen
axis_fanout #(F)
fanout_i(.axis_in(buffer_out[j]), .axis_out(row_out[j]), .*);
end
endgenerate
// --------------------------------------------------------------------
axis_fanout #(F) trailing_row_i(.axis_out(row_out[L-1]), .*);
axis_alias leading_row_i(buffer_out[0], row_out[0][0]);
// --------------------------------------------------------------------
enum reg [3:0]
{
INITIALIZE = 4'b0001,
ACTIVE = 4'b0010,
// READY = 4'b0100,
FLUSH = 4'b1000
} state, next_state;
// --------------------------------------------------------------------
always_ff @(posedge aclk)
if(~aresetn)
state <= INITIALIZE;
else
state <= next_state;
// --------------------------------------------------------------------
always_comb
case(state)
INITIALIZE: if(all_initialized)
next_state = ACTIVE;
else
next_state = INITIALIZE;
ACTIVE: if(eof_leading)
next_state = FLUSH;
else
next_state = ACTIVE;
FLUSH: if(eof_trailing)
next_state = INITIALIZE;
else
next_state = FLUSH;
default: next_state = INITIALIZE;
endcase
// --------------------------------------------------------------------
assign enable = (state == ACTIVE);
// --------------------------------------------------------------------
wire init = ((state == INITIALIZE) & (next_state == INITIALIZE));
wire flush = ((state == FLUSH) & (next_state == FLUSH));
axis_if #(.N(N), .U(U)) merge_in[L](.*);
generate
for(genvar j = 0; j < L; j++)
begin: merge_gen
axis_alias row_i(row_out[j][0], merge_in[j]);
end
endgenerate
avf_line_buffer_merge #(N, U, L) merge_i(.*);
// --------------------------------------------------------------------
endmodule
Go to most recent revision | Compare with Previous | Blame | View Log