2014-11-08 00:23:23 -08:00
|
|
|
/*
|
|
|
|
|
2021-08-25 22:56:22 -07:00
|
|
|
Copyright (c) 2014-2021 Alex Forencich
|
2014-11-08 00:23:23 -08:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Language: Verilog 2001
|
|
|
|
|
|
|
|
`timescale 1ns / 1ps
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AXI4-Stream asynchronous FIFO
|
|
|
|
*/
|
|
|
|
module axis_async_fifo #
|
|
|
|
(
|
2019-07-24 13:54:21 -07:00
|
|
|
// FIFO depth in words
|
|
|
|
// KEEP_WIDTH words per cycle if KEEP_ENABLE set
|
|
|
|
// Rounded up to nearest power of 2 cycles
|
2019-07-18 11:27:25 -07:00
|
|
|
parameter DEPTH = 4096,
|
2019-07-24 13:54:21 -07:00
|
|
|
// Width of AXI stream interfaces in bits
|
2017-11-20 20:11:08 -08:00
|
|
|
parameter DATA_WIDTH = 8,
|
2019-07-24 13:54:21 -07:00
|
|
|
// Propagate tkeep signal
|
|
|
|
// If disabled, tkeep assumed to be 1'b1
|
2017-11-20 20:11:08 -08:00
|
|
|
parameter KEEP_ENABLE = (DATA_WIDTH>8),
|
2019-07-24 13:54:21 -07:00
|
|
|
// tkeep signal width (words per cycle)
|
2017-11-20 20:11:08 -08:00
|
|
|
parameter KEEP_WIDTH = (DATA_WIDTH/8),
|
2019-07-24 13:54:21 -07:00
|
|
|
// Propagate tlast signal
|
2017-11-20 20:11:08 -08:00
|
|
|
parameter LAST_ENABLE = 1,
|
2019-07-24 13:54:21 -07:00
|
|
|
// Propagate tid signal
|
2017-11-20 20:11:08 -08:00
|
|
|
parameter ID_ENABLE = 0,
|
2019-07-24 13:54:21 -07:00
|
|
|
// tid signal width
|
2017-11-20 20:11:08 -08:00
|
|
|
parameter ID_WIDTH = 8,
|
2019-07-24 13:54:21 -07:00
|
|
|
// Propagate tdest signal
|
2017-11-20 20:11:08 -08:00
|
|
|
parameter DEST_ENABLE = 0,
|
2019-07-24 13:54:21 -07:00
|
|
|
// tdest signal width
|
2017-11-20 20:11:08 -08:00
|
|
|
parameter DEST_WIDTH = 8,
|
2019-07-24 13:54:21 -07:00
|
|
|
// Propagate tuser signal
|
2017-11-20 20:11:08 -08:00
|
|
|
parameter USER_ENABLE = 1,
|
2019-07-24 13:54:21 -07:00
|
|
|
// tuser signal width
|
2018-10-25 09:53:38 -07:00
|
|
|
parameter USER_WIDTH = 1,
|
2020-09-07 00:14:22 -07:00
|
|
|
// number of output pipeline registers
|
|
|
|
parameter PIPELINE_OUTPUT = 2,
|
2019-07-24 13:54:21 -07:00
|
|
|
// Frame FIFO mode - operate on frames instead of cycles
|
|
|
|
// When set, m_axis_tvalid will not be deasserted within a frame
|
|
|
|
// Requires LAST_ENABLE set
|
2018-10-25 09:53:38 -07:00
|
|
|
parameter FRAME_FIFO = 0,
|
2019-07-24 13:54:21 -07:00
|
|
|
// tuser value for bad frame marker
|
2018-10-25 09:53:38 -07:00
|
|
|
parameter USER_BAD_FRAME_VALUE = 1'b1,
|
2019-07-24 13:54:21 -07:00
|
|
|
// tuser mask for bad frame marker
|
2018-10-25 09:53:38 -07:00
|
|
|
parameter USER_BAD_FRAME_MASK = 1'b1,
|
2021-08-25 22:56:22 -07:00
|
|
|
// Drop frames larger than FIFO
|
2019-07-24 13:54:21 -07:00
|
|
|
// Requires FRAME_FIFO set
|
2021-08-25 22:56:22 -07:00
|
|
|
parameter DROP_OVERSIZE_FRAME = FRAME_FIFO,
|
|
|
|
// Drop frames marked bad
|
|
|
|
// Requires FRAME_FIFO and DROP_OVERSIZE_FRAME set
|
2018-10-25 09:53:38 -07:00
|
|
|
parameter DROP_BAD_FRAME = 0,
|
2019-07-24 13:54:21 -07:00
|
|
|
// Drop incoming frames when full
|
|
|
|
// When set, s_axis_tready is always asserted
|
2021-08-25 22:56:22 -07:00
|
|
|
// Requires FRAME_FIFO and DROP_OVERSIZE_FRAME set
|
2018-10-25 09:53:38 -07:00
|
|
|
parameter DROP_WHEN_FULL = 0
|
2014-11-08 00:23:23 -08:00
|
|
|
)
|
|
|
|
(
|
|
|
|
/*
|
|
|
|
* AXI input
|
|
|
|
*/
|
2018-10-25 09:53:38 -07:00
|
|
|
input wire s_clk,
|
2021-10-13 14:05:13 -07:00
|
|
|
input wire s_rst,
|
2018-10-25 09:53:38 -07:00
|
|
|
input wire [DATA_WIDTH-1:0] s_axis_tdata,
|
|
|
|
input wire [KEEP_WIDTH-1:0] s_axis_tkeep,
|
|
|
|
input wire s_axis_tvalid,
|
|
|
|
output wire s_axis_tready,
|
|
|
|
input wire s_axis_tlast,
|
|
|
|
input wire [ID_WIDTH-1:0] s_axis_tid,
|
|
|
|
input wire [DEST_WIDTH-1:0] s_axis_tdest,
|
|
|
|
input wire [USER_WIDTH-1:0] s_axis_tuser,
|
2017-11-20 20:11:08 -08:00
|
|
|
|
2014-11-08 00:23:23 -08:00
|
|
|
/*
|
|
|
|
* AXI output
|
|
|
|
*/
|
2018-10-25 09:53:38 -07:00
|
|
|
input wire m_clk,
|
2021-10-13 14:05:13 -07:00
|
|
|
input wire m_rst,
|
2018-10-25 09:53:38 -07:00
|
|
|
output wire [DATA_WIDTH-1:0] m_axis_tdata,
|
|
|
|
output wire [KEEP_WIDTH-1:0] m_axis_tkeep,
|
|
|
|
output wire m_axis_tvalid,
|
|
|
|
input wire m_axis_tready,
|
|
|
|
output wire m_axis_tlast,
|
|
|
|
output wire [ID_WIDTH-1:0] m_axis_tid,
|
|
|
|
output wire [DEST_WIDTH-1:0] m_axis_tdest,
|
|
|
|
output wire [USER_WIDTH-1:0] m_axis_tuser,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Status
|
|
|
|
*/
|
|
|
|
output wire s_status_overflow,
|
|
|
|
output wire s_status_bad_frame,
|
|
|
|
output wire s_status_good_frame,
|
|
|
|
output wire m_status_overflow,
|
|
|
|
output wire m_status_bad_frame,
|
|
|
|
output wire m_status_good_frame
|
2014-11-08 00:23:23 -08:00
|
|
|
);
|
|
|
|
|
2019-07-18 11:27:25 -07:00
|
|
|
parameter ADDR_WIDTH = (KEEP_ENABLE && KEEP_WIDTH > 1) ? $clog2(DEPTH/KEEP_WIDTH) : $clog2(DEPTH);
|
|
|
|
|
2018-10-25 09:53:38 -07:00
|
|
|
// check configuration
|
|
|
|
initial begin
|
2020-09-07 00:14:22 -07:00
|
|
|
if (PIPELINE_OUTPUT < 1) begin
|
|
|
|
$error("Error: PIPELINE_OUTPUT must be at least 1 (instance %m)");
|
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
|
2018-10-25 09:53:38 -07:00
|
|
|
if (FRAME_FIFO && !LAST_ENABLE) begin
|
2019-07-25 16:30:10 -07:00
|
|
|
$error("Error: FRAME_FIFO set requires LAST_ENABLE set (instance %m)");
|
2018-10-25 09:53:38 -07:00
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
|
2021-08-25 22:56:22 -07:00
|
|
|
if (DROP_OVERSIZE_FRAME && !FRAME_FIFO) begin
|
|
|
|
$error("Error: DROP_OVERSIZE_FRAME set requires FRAME_FIFO set (instance %m)");
|
2018-10-25 09:53:38 -07:00
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
|
2021-08-25 22:56:22 -07:00
|
|
|
if (DROP_BAD_FRAME && !(FRAME_FIFO && DROP_OVERSIZE_FRAME)) begin
|
|
|
|
$error("Error: DROP_BAD_FRAME set requires FRAME_FIFO and DROP_OVERSIZE_FRAME set (instance %m)");
|
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
|
|
|
|
if (DROP_WHEN_FULL && !(FRAME_FIFO && DROP_OVERSIZE_FRAME)) begin
|
|
|
|
$error("Error: DROP_WHEN_FULL set requires FRAME_FIFO and DROP_OVERSIZE_FRAME set (instance %m)");
|
2018-10-25 09:53:38 -07:00
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
|
|
|
|
if (DROP_BAD_FRAME && (USER_BAD_FRAME_MASK & {USER_WIDTH{1'b1}}) == 0) begin
|
2019-07-25 16:30:10 -07:00
|
|
|
$error("Error: Invalid USER_BAD_FRAME_MASK value (instance %m)");
|
2018-10-25 09:53:38 -07:00
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-11-20 20:11:08 -08:00
|
|
|
localparam KEEP_OFFSET = DATA_WIDTH;
|
|
|
|
localparam LAST_OFFSET = KEEP_OFFSET + (KEEP_ENABLE ? KEEP_WIDTH : 0);
|
|
|
|
localparam ID_OFFSET = LAST_OFFSET + (LAST_ENABLE ? 1 : 0);
|
|
|
|
localparam DEST_OFFSET = ID_OFFSET + (ID_ENABLE ? ID_WIDTH : 0);
|
|
|
|
localparam USER_OFFSET = DEST_OFFSET + (DEST_ENABLE ? DEST_WIDTH : 0);
|
|
|
|
localparam WIDTH = USER_OFFSET + (USER_ENABLE ? USER_WIDTH : 0);
|
|
|
|
|
2020-09-06 22:57:56 -07:00
|
|
|
reg [ADDR_WIDTH:0] wr_ptr_reg = {ADDR_WIDTH+1{1'b0}};
|
|
|
|
reg [ADDR_WIDTH:0] wr_ptr_cur_reg = {ADDR_WIDTH+1{1'b0}};
|
|
|
|
reg [ADDR_WIDTH:0] wr_ptr_gray_reg = {ADDR_WIDTH+1{1'b0}};
|
|
|
|
reg [ADDR_WIDTH:0] wr_ptr_sync_gray_reg = {ADDR_WIDTH+1{1'b0}};
|
|
|
|
reg [ADDR_WIDTH:0] wr_ptr_cur_gray_reg = {ADDR_WIDTH+1{1'b0}};
|
|
|
|
reg [ADDR_WIDTH:0] rd_ptr_reg = {ADDR_WIDTH+1{1'b0}};
|
|
|
|
reg [ADDR_WIDTH:0] rd_ptr_gray_reg = {ADDR_WIDTH+1{1'b0}};
|
|
|
|
|
|
|
|
reg [ADDR_WIDTH:0] wr_ptr_temp;
|
|
|
|
reg [ADDR_WIDTH:0] rd_ptr_temp;
|
2014-11-08 00:23:23 -08:00
|
|
|
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2015-11-07 01:15:11 -08:00
|
|
|
reg [ADDR_WIDTH:0] wr_ptr_gray_sync1_reg = {ADDR_WIDTH+1{1'b0}};
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2015-11-07 01:15:11 -08:00
|
|
|
reg [ADDR_WIDTH:0] wr_ptr_gray_sync2_reg = {ADDR_WIDTH+1{1'b0}};
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2015-11-07 01:15:11 -08:00
|
|
|
reg [ADDR_WIDTH:0] rd_ptr_gray_sync1_reg = {ADDR_WIDTH+1{1'b0}};
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2015-11-07 01:15:11 -08:00
|
|
|
reg [ADDR_WIDTH:0] rd_ptr_gray_sync2_reg = {ADDR_WIDTH+1{1'b0}};
|
2015-05-08 01:41:35 -07:00
|
|
|
|
2020-09-06 22:57:56 -07:00
|
|
|
reg wr_ptr_update_valid_reg = 1'b0;
|
|
|
|
reg wr_ptr_update_reg = 1'b0;
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2019-03-26 18:45:54 -07:00
|
|
|
reg wr_ptr_update_sync1_reg = 1'b0;
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2019-03-26 18:45:54 -07:00
|
|
|
reg wr_ptr_update_sync2_reg = 1'b0;
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2019-03-26 18:45:54 -07:00
|
|
|
reg wr_ptr_update_sync3_reg = 1'b0;
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2019-03-26 18:45:54 -07:00
|
|
|
reg wr_ptr_update_ack_sync1_reg = 1'b0;
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2019-03-26 18:45:54 -07:00
|
|
|
reg wr_ptr_update_ack_sync2_reg = 1'b0;
|
|
|
|
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2018-10-25 09:53:38 -07:00
|
|
|
reg s_rst_sync1_reg = 1'b1;
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2018-10-25 09:53:38 -07:00
|
|
|
reg s_rst_sync2_reg = 1'b1;
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2018-10-25 09:53:38 -07:00
|
|
|
reg s_rst_sync3_reg = 1'b1;
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2018-10-25 09:53:38 -07:00
|
|
|
reg m_rst_sync1_reg = 1'b1;
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2018-10-25 09:53:38 -07:00
|
|
|
reg m_rst_sync2_reg = 1'b1;
|
2020-09-07 18:54:18 -07:00
|
|
|
(* SHREG_EXTRACT = "NO" *)
|
2018-10-25 09:53:38 -07:00
|
|
|
reg m_rst_sync3_reg = 1'b1;
|
2014-11-08 00:23:23 -08:00
|
|
|
|
2017-11-20 20:11:08 -08:00
|
|
|
reg [WIDTH-1:0] mem[(2**ADDR_WIDTH)-1:0];
|
|
|
|
reg [WIDTH-1:0] mem_read_data_reg;
|
2020-09-06 22:57:56 -07:00
|
|
|
reg mem_read_data_valid_reg = 1'b0;
|
2014-11-08 00:23:23 -08:00
|
|
|
|
2018-10-25 09:53:38 -07:00
|
|
|
wire [WIDTH-1:0] s_axis;
|
2016-08-04 18:03:00 -07:00
|
|
|
|
2020-09-07 00:14:22 -07:00
|
|
|
reg [WIDTH-1:0] m_axis_pipe_reg[PIPELINE_OUTPUT-1:0];
|
|
|
|
reg [PIPELINE_OUTPUT-1:0] m_axis_tvalid_pipe_reg = 1'b0;
|
2014-11-08 00:23:23 -08:00
|
|
|
|
|
|
|
// full when first TWO MSBs do NOT match, but rest matches
|
|
|
|
// (gray code equivalent of first MSB different but rest same)
|
2020-09-06 18:28:32 -07:00
|
|
|
wire full = wr_ptr_gray_reg == (rd_ptr_gray_sync2_reg ^ {2'b11, {ADDR_WIDTH-1{1'b0}}});
|
|
|
|
wire full_cur = wr_ptr_cur_gray_reg == (rd_ptr_gray_sync2_reg ^ {2'b11, {ADDR_WIDTH-1{1'b0}}});
|
2014-11-08 00:23:23 -08:00
|
|
|
// empty when pointers match exactly
|
2019-03-26 18:45:54 -07:00
|
|
|
wire empty = rd_ptr_gray_reg == (FRAME_FIFO ? wr_ptr_gray_sync1_reg : wr_ptr_gray_sync2_reg);
|
2018-10-25 09:53:38 -07:00
|
|
|
// overflow within packet
|
2020-09-06 18:28:32 -07:00
|
|
|
wire full_wr = wr_ptr_reg == (wr_ptr_cur_reg ^ {1'b1, {ADDR_WIDTH{1'b0}}});
|
2014-11-08 00:23:23 -08:00
|
|
|
|
2015-11-07 01:15:11 -08:00
|
|
|
// control signals
|
|
|
|
reg write;
|
|
|
|
reg read;
|
2016-08-04 18:03:00 -07:00
|
|
|
reg store_output;
|
2014-11-08 00:23:23 -08:00
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
reg s_frame_reg = 1'b0;
|
|
|
|
reg m_frame_reg = 1'b0;
|
|
|
|
|
2020-09-06 22:57:56 -07:00
|
|
|
reg drop_frame_reg = 1'b0;
|
2021-08-25 22:56:22 -07:00
|
|
|
reg send_frame_reg = 1'b0;
|
2020-09-06 22:57:56 -07:00
|
|
|
reg overflow_reg = 1'b0;
|
|
|
|
reg bad_frame_reg = 1'b0;
|
|
|
|
reg good_frame_reg = 1'b0;
|
2018-10-25 09:53:38 -07:00
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
reg m_drop_frame_reg = 1'b0;
|
|
|
|
reg m_terminate_frame_reg = 1'b0;
|
|
|
|
|
2018-10-25 09:53:38 -07:00
|
|
|
reg overflow_sync1_reg = 1'b0;
|
|
|
|
reg overflow_sync2_reg = 1'b0;
|
|
|
|
reg overflow_sync3_reg = 1'b0;
|
|
|
|
reg overflow_sync4_reg = 1'b0;
|
|
|
|
reg bad_frame_sync1_reg = 1'b0;
|
|
|
|
reg bad_frame_sync2_reg = 1'b0;
|
|
|
|
reg bad_frame_sync3_reg = 1'b0;
|
|
|
|
reg bad_frame_sync4_reg = 1'b0;
|
|
|
|
reg good_frame_sync1_reg = 1'b0;
|
|
|
|
reg good_frame_sync2_reg = 1'b0;
|
|
|
|
reg good_frame_sync3_reg = 1'b0;
|
|
|
|
reg good_frame_sync4_reg = 1'b0;
|
|
|
|
|
2021-08-25 22:56:22 -07:00
|
|
|
assign s_axis_tready = (FRAME_FIFO ? (!full_cur || (full_wr && DROP_OVERSIZE_FRAME) || DROP_WHEN_FULL) : !full) && !s_rst_sync3_reg;
|
2014-11-08 00:23:23 -08:00
|
|
|
|
2017-11-20 20:11:08 -08:00
|
|
|
generate
|
2018-10-25 09:53:38 -07:00
|
|
|
assign s_axis[DATA_WIDTH-1:0] = s_axis_tdata;
|
|
|
|
if (KEEP_ENABLE) assign s_axis[KEEP_OFFSET +: KEEP_WIDTH] = s_axis_tkeep;
|
|
|
|
if (LAST_ENABLE) assign s_axis[LAST_OFFSET] = s_axis_tlast;
|
|
|
|
if (ID_ENABLE) assign s_axis[ID_OFFSET +: ID_WIDTH] = s_axis_tid;
|
|
|
|
if (DEST_ENABLE) assign s_axis[DEST_OFFSET +: DEST_WIDTH] = s_axis_tdest;
|
|
|
|
if (USER_ENABLE) assign s_axis[USER_OFFSET +: USER_WIDTH] = s_axis_tuser;
|
2017-11-20 20:11:08 -08:00
|
|
|
endgenerate
|
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
wire m_axis_tvalid_pipe = m_axis_tvalid_pipe_reg[PIPELINE_OUTPUT-1];
|
2018-10-25 09:53:38 -07:00
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
wire [DATA_WIDTH-1:0] m_axis_tdata_pipe = m_axis_pipe_reg[PIPELINE_OUTPUT-1][DATA_WIDTH-1:0];
|
|
|
|
wire [KEEP_WIDTH-1:0] m_axis_tkeep_pipe = KEEP_ENABLE ? m_axis_pipe_reg[PIPELINE_OUTPUT-1][KEEP_OFFSET +: KEEP_WIDTH] : {KEEP_WIDTH{1'b1}};
|
|
|
|
wire m_axis_tlast_pipe = LAST_ENABLE ? m_axis_pipe_reg[PIPELINE_OUTPUT-1][LAST_OFFSET] : 1'b1;
|
|
|
|
wire [ID_WIDTH-1:0] m_axis_tid_pipe = ID_ENABLE ? m_axis_pipe_reg[PIPELINE_OUTPUT-1][ID_OFFSET +: ID_WIDTH] : {ID_WIDTH{1'b0}};
|
|
|
|
wire [DEST_WIDTH-1:0] m_axis_tdest_pipe = DEST_ENABLE ? m_axis_pipe_reg[PIPELINE_OUTPUT-1][DEST_OFFSET +: DEST_WIDTH] : {DEST_WIDTH{1'b0}};
|
|
|
|
wire [USER_WIDTH-1:0] m_axis_tuser_pipe = USER_ENABLE ? m_axis_pipe_reg[PIPELINE_OUTPUT-1][USER_OFFSET +: USER_WIDTH] : {USER_WIDTH{1'b0}};
|
|
|
|
|
|
|
|
assign m_axis_tvalid = m_axis_tvalid_pipe;
|
|
|
|
|
|
|
|
assign m_axis_tdata = m_axis_tdata_pipe;
|
|
|
|
assign m_axis_tkeep = m_axis_tkeep_pipe;
|
|
|
|
assign m_axis_tlast = (m_terminate_frame_reg ? 1'b1 : m_axis_tlast_pipe);
|
|
|
|
assign m_axis_tid = m_axis_tid_pipe;
|
|
|
|
assign m_axis_tdest = m_axis_tdest_pipe;
|
|
|
|
assign m_axis_tuser = (m_terminate_frame_reg ? USER_BAD_FRAME_VALUE : m_axis_tuser_pipe);
|
2018-10-25 09:53:38 -07:00
|
|
|
|
|
|
|
assign s_status_overflow = overflow_reg;
|
|
|
|
assign s_status_bad_frame = bad_frame_reg;
|
|
|
|
assign s_status_good_frame = good_frame_reg;
|
2016-06-27 12:10:36 -07:00
|
|
|
|
2018-10-25 09:53:38 -07:00
|
|
|
assign m_status_overflow = overflow_sync3_reg ^ overflow_sync4_reg;
|
|
|
|
assign m_status_bad_frame = bad_frame_sync3_reg ^ bad_frame_sync4_reg;
|
|
|
|
assign m_status_good_frame = good_frame_sync3_reg ^ good_frame_sync4_reg;
|
2014-11-08 00:23:23 -08:00
|
|
|
|
2015-05-08 01:41:35 -07:00
|
|
|
// reset synchronization
|
2021-10-13 14:05:13 -07:00
|
|
|
always @(posedge m_clk or posedge m_rst) begin
|
|
|
|
if (m_rst) begin
|
2018-10-25 09:53:38 -07:00
|
|
|
s_rst_sync1_reg <= 1'b1;
|
2015-05-08 01:41:35 -07:00
|
|
|
end else begin
|
2018-10-25 09:53:38 -07:00
|
|
|
s_rst_sync1_reg <= 1'b0;
|
2015-05-08 01:41:35 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
always @(posedge s_clk) begin
|
|
|
|
s_rst_sync2_reg <= s_rst_sync1_reg;
|
|
|
|
s_rst_sync3_reg <= s_rst_sync2_reg;
|
|
|
|
end
|
|
|
|
|
|
|
|
always @(posedge s_clk or posedge s_rst) begin
|
|
|
|
if (s_rst) begin
|
2018-10-25 09:53:38 -07:00
|
|
|
m_rst_sync1_reg <= 1'b1;
|
2015-05-08 01:41:35 -07:00
|
|
|
end else begin
|
2018-10-25 09:53:38 -07:00
|
|
|
m_rst_sync1_reg <= 1'b0;
|
2015-11-07 01:15:11 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
always @(posedge m_clk) begin
|
|
|
|
m_rst_sync2_reg <= m_rst_sync1_reg;
|
|
|
|
m_rst_sync3_reg <= m_rst_sync2_reg;
|
|
|
|
end
|
|
|
|
|
2015-11-07 01:15:11 -08:00
|
|
|
// Write logic
|
2020-09-06 22:57:56 -07:00
|
|
|
always @(posedge s_clk) begin
|
|
|
|
overflow_reg <= 1'b0;
|
|
|
|
bad_frame_reg <= 1'b0;
|
|
|
|
good_frame_reg <= 1'b0;
|
2019-03-26 18:45:54 -07:00
|
|
|
|
|
|
|
if (FRAME_FIFO && wr_ptr_update_valid_reg) begin
|
|
|
|
// have updated pointer to sync
|
2020-09-06 22:57:56 -07:00
|
|
|
if (wr_ptr_update_reg == wr_ptr_update_ack_sync2_reg) begin
|
2019-03-26 18:45:54 -07:00
|
|
|
// no sync in progress; sync update
|
2020-09-06 22:57:56 -07:00
|
|
|
wr_ptr_update_valid_reg <= 1'b0;
|
|
|
|
wr_ptr_sync_gray_reg <= wr_ptr_gray_reg;
|
|
|
|
wr_ptr_update_reg <= !wr_ptr_update_ack_sync2_reg;
|
2019-03-26 18:45:54 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
if (s_axis_tready && s_axis_tvalid && LAST_ENABLE) begin
|
|
|
|
// track input frame status
|
|
|
|
s_frame_reg <= !s_axis_tlast;
|
|
|
|
end
|
|
|
|
|
|
|
|
if (s_rst_sync3_reg && LAST_ENABLE) begin
|
|
|
|
// if sink side is reset during transfer, drop partial frame
|
|
|
|
if (s_frame_reg && !(s_axis_tready && s_axis_tvalid && s_axis_tlast)) begin
|
|
|
|
drop_frame_reg <= 1'b1;
|
|
|
|
end
|
|
|
|
if (s_axis_tready && s_axis_tvalid && !s_axis_tlast) begin
|
|
|
|
drop_frame_reg <= 1'b1;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-09 00:01:38 -08:00
|
|
|
if (s_axis_tready && s_axis_tvalid) begin
|
|
|
|
// transfer in
|
|
|
|
if (!FRAME_FIFO) begin
|
|
|
|
// normal FIFO mode
|
2020-09-06 22:57:56 -07:00
|
|
|
mem[wr_ptr_reg[ADDR_WIDTH-1:0]] <= s_axis;
|
2021-10-13 14:05:13 -07:00
|
|
|
if (drop_frame_reg && LAST_ENABLE) begin
|
|
|
|
// currently dropping frame
|
|
|
|
// (only for frame transfers interrupted by sink reset)
|
|
|
|
if (s_axis_tlast) begin
|
|
|
|
// end of frame, clear drop flag
|
|
|
|
drop_frame_reg <= 1'b0;
|
|
|
|
end
|
|
|
|
end else begin
|
|
|
|
// update pointers
|
|
|
|
wr_ptr_temp = wr_ptr_reg + 1;
|
|
|
|
wr_ptr_reg <= wr_ptr_temp;
|
|
|
|
wr_ptr_gray_reg <= wr_ptr_temp ^ (wr_ptr_temp >> 1);
|
|
|
|
end
|
2021-08-25 22:56:22 -07:00
|
|
|
end else if ((full_cur && DROP_WHEN_FULL) || (full_wr && DROP_OVERSIZE_FRAME) || drop_frame_reg) begin
|
2018-12-09 00:01:38 -08:00
|
|
|
// full, packet overflow, or currently dropping frame
|
|
|
|
// drop frame
|
2020-09-06 22:57:56 -07:00
|
|
|
drop_frame_reg <= 1'b1;
|
2018-12-09 00:01:38 -08:00
|
|
|
if (s_axis_tlast) begin
|
|
|
|
// end of frame, reset write pointer
|
2020-09-06 22:57:56 -07:00
|
|
|
wr_ptr_temp = wr_ptr_reg;
|
|
|
|
wr_ptr_cur_reg <= wr_ptr_temp;
|
|
|
|
wr_ptr_cur_gray_reg <= wr_ptr_temp ^ (wr_ptr_temp >> 1);
|
|
|
|
drop_frame_reg <= 1'b0;
|
|
|
|
overflow_reg <= 1'b1;
|
2018-12-09 00:01:38 -08:00
|
|
|
end
|
|
|
|
end else begin
|
2020-09-06 22:57:56 -07:00
|
|
|
mem[wr_ptr_cur_reg[ADDR_WIDTH-1:0]] <= s_axis;
|
|
|
|
wr_ptr_temp = wr_ptr_cur_reg + 1;
|
|
|
|
wr_ptr_cur_reg <= wr_ptr_temp;
|
|
|
|
wr_ptr_cur_gray_reg <= wr_ptr_temp ^ (wr_ptr_temp >> 1);
|
2021-08-25 22:56:22 -07:00
|
|
|
if (s_axis_tlast || (!DROP_OVERSIZE_FRAME && (full_wr || send_frame_reg))) begin
|
|
|
|
// end of frame or send frame
|
|
|
|
send_frame_reg <= !s_axis_tlast;
|
|
|
|
if (s_axis_tlast && DROP_BAD_FRAME && USER_BAD_FRAME_MASK & ~(s_axis_tuser ^ USER_BAD_FRAME_VALUE)) begin
|
2018-12-09 00:01:38 -08:00
|
|
|
// bad packet, reset write pointer
|
2020-09-06 22:57:56 -07:00
|
|
|
wr_ptr_temp = wr_ptr_reg;
|
|
|
|
wr_ptr_cur_reg <= wr_ptr_temp;
|
|
|
|
wr_ptr_cur_gray_reg <= wr_ptr_temp ^ (wr_ptr_temp >> 1);
|
|
|
|
bad_frame_reg <= 1'b1;
|
2018-12-09 00:01:38 -08:00
|
|
|
end else begin
|
2021-08-25 22:56:22 -07:00
|
|
|
// good packet or packet overflow, update write pointer
|
2020-09-06 22:57:56 -07:00
|
|
|
wr_ptr_temp = wr_ptr_cur_reg + 1;
|
|
|
|
wr_ptr_reg <= wr_ptr_temp;
|
|
|
|
wr_ptr_gray_reg <= wr_ptr_temp ^ (wr_ptr_temp >> 1);
|
2019-03-26 18:45:54 -07:00
|
|
|
|
2020-09-06 22:57:56 -07:00
|
|
|
if (wr_ptr_update_reg == wr_ptr_update_ack_sync2_reg) begin
|
2019-03-26 18:45:54 -07:00
|
|
|
// no sync in progress; sync update
|
2020-09-06 22:57:56 -07:00
|
|
|
wr_ptr_update_valid_reg <= 1'b0;
|
|
|
|
wr_ptr_sync_gray_reg <= wr_ptr_temp ^ (wr_ptr_temp >> 1);
|
|
|
|
wr_ptr_update_reg <= !wr_ptr_update_ack_sync2_reg;
|
2019-03-26 18:45:54 -07:00
|
|
|
end else begin
|
|
|
|
// sync in progress; flag it for later
|
2020-09-06 22:57:56 -07:00
|
|
|
wr_ptr_update_valid_reg <= 1'b1;
|
2019-03-26 18:45:54 -07:00
|
|
|
end
|
|
|
|
|
2021-08-25 22:56:22 -07:00
|
|
|
good_frame_reg <= s_axis_tlast;
|
2018-10-25 09:53:38 -07:00
|
|
|
end
|
|
|
|
end
|
2015-11-07 01:15:11 -08:00
|
|
|
end
|
2021-08-25 22:56:22 -07:00
|
|
|
end else if (s_axis_tvalid && full_wr && FRAME_FIFO && !DROP_OVERSIZE_FRAME) begin
|
|
|
|
// data valid with packet overflow
|
|
|
|
// update write pointer
|
|
|
|
send_frame_reg <= 1'b1;
|
|
|
|
wr_ptr_temp = wr_ptr_cur_reg;
|
|
|
|
wr_ptr_reg <= wr_ptr_temp;
|
|
|
|
wr_ptr_gray_reg <= wr_ptr_temp ^ (wr_ptr_temp >> 1);
|
|
|
|
|
|
|
|
if (wr_ptr_update_reg == wr_ptr_update_ack_sync2_reg) begin
|
|
|
|
// no sync in progress; sync update
|
|
|
|
wr_ptr_update_valid_reg <= 1'b0;
|
|
|
|
wr_ptr_sync_gray_reg <= wr_ptr_temp ^ (wr_ptr_temp >> 1);
|
|
|
|
wr_ptr_update_reg <= !wr_ptr_update_ack_sync2_reg;
|
|
|
|
end else begin
|
|
|
|
// sync in progress; flag it for later
|
|
|
|
wr_ptr_update_valid_reg <= 1'b1;
|
|
|
|
end
|
2015-05-08 01:41:35 -07:00
|
|
|
end
|
2020-09-06 17:55:10 -07:00
|
|
|
|
2018-10-25 09:53:38 -07:00
|
|
|
if (s_rst_sync3_reg) begin
|
2015-11-07 01:15:11 -08:00
|
|
|
wr_ptr_reg <= {ADDR_WIDTH+1{1'b0}};
|
2018-10-25 09:53:38 -07:00
|
|
|
wr_ptr_cur_reg <= {ADDR_WIDTH+1{1'b0}};
|
2015-11-07 01:15:11 -08:00
|
|
|
wr_ptr_gray_reg <= {ADDR_WIDTH+1{1'b0}};
|
2019-03-26 18:45:54 -07:00
|
|
|
wr_ptr_sync_gray_reg <= {ADDR_WIDTH+1{1'b0}};
|
2018-12-09 00:01:38 -08:00
|
|
|
wr_ptr_cur_gray_reg <= {ADDR_WIDTH+1{1'b0}};
|
2018-10-25 09:53:38 -07:00
|
|
|
|
2019-03-26 18:45:54 -07:00
|
|
|
wr_ptr_update_valid_reg <= 1'b0;
|
|
|
|
wr_ptr_update_reg <= 1'b0;
|
2021-10-13 14:05:13 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
if (s_rst) begin
|
|
|
|
wr_ptr_reg <= {ADDR_WIDTH+1{1'b0}};
|
|
|
|
wr_ptr_cur_reg <= {ADDR_WIDTH+1{1'b0}};
|
|
|
|
wr_ptr_gray_reg <= {ADDR_WIDTH+1{1'b0}};
|
|
|
|
wr_ptr_sync_gray_reg <= {ADDR_WIDTH+1{1'b0}};
|
|
|
|
wr_ptr_cur_gray_reg <= {ADDR_WIDTH+1{1'b0}};
|
|
|
|
|
|
|
|
wr_ptr_update_valid_reg <= 1'b0;
|
|
|
|
wr_ptr_update_reg <= 1'b0;
|
|
|
|
|
|
|
|
s_frame_reg <= 1'b0;
|
2019-03-26 18:45:54 -07:00
|
|
|
|
2018-10-25 09:53:38 -07:00
|
|
|
drop_frame_reg <= 1'b0;
|
2021-08-25 22:56:22 -07:00
|
|
|
send_frame_reg <= 1'b0;
|
2018-10-25 09:53:38 -07:00
|
|
|
overflow_reg <= 1'b0;
|
|
|
|
bad_frame_reg <= 1'b0;
|
|
|
|
good_frame_reg <= 1'b0;
|
2014-11-08 00:23:23 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-05-08 01:41:35 -07:00
|
|
|
// pointer synchronization
|
2018-10-25 09:53:38 -07:00
|
|
|
always @(posedge s_clk) begin
|
2020-09-06 22:57:56 -07:00
|
|
|
rd_ptr_gray_sync1_reg <= rd_ptr_gray_reg;
|
|
|
|
rd_ptr_gray_sync2_reg <= rd_ptr_gray_sync1_reg;
|
|
|
|
wr_ptr_update_ack_sync1_reg <= wr_ptr_update_sync3_reg;
|
|
|
|
wr_ptr_update_ack_sync2_reg <= wr_ptr_update_ack_sync1_reg;
|
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
if (s_rst) begin
|
2015-11-07 01:15:11 -08:00
|
|
|
rd_ptr_gray_sync1_reg <= {ADDR_WIDTH+1{1'b0}};
|
|
|
|
rd_ptr_gray_sync2_reg <= {ADDR_WIDTH+1{1'b0}};
|
2019-03-26 18:45:54 -07:00
|
|
|
wr_ptr_update_ack_sync1_reg <= 1'b0;
|
|
|
|
wr_ptr_update_ack_sync2_reg <= 1'b0;
|
2015-05-08 01:41:35 -07:00
|
|
|
end
|
2014-11-08 00:23:23 -08:00
|
|
|
end
|
|
|
|
|
2018-10-25 09:53:38 -07:00
|
|
|
always @(posedge m_clk) begin
|
2020-09-06 22:57:56 -07:00
|
|
|
if (!FRAME_FIFO) begin
|
|
|
|
wr_ptr_gray_sync1_reg <= wr_ptr_gray_reg;
|
|
|
|
end else if (wr_ptr_update_sync2_reg ^ wr_ptr_update_sync3_reg) begin
|
|
|
|
wr_ptr_gray_sync1_reg <= wr_ptr_sync_gray_reg;
|
|
|
|
end
|
|
|
|
wr_ptr_gray_sync2_reg <= wr_ptr_gray_sync1_reg;
|
|
|
|
wr_ptr_update_sync1_reg <= wr_ptr_update_reg;
|
|
|
|
wr_ptr_update_sync2_reg <= wr_ptr_update_sync1_reg;
|
|
|
|
wr_ptr_update_sync3_reg <= wr_ptr_update_sync2_reg;
|
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
if (m_rst) begin
|
2015-11-07 01:15:11 -08:00
|
|
|
wr_ptr_gray_sync1_reg <= {ADDR_WIDTH+1{1'b0}};
|
|
|
|
wr_ptr_gray_sync2_reg <= {ADDR_WIDTH+1{1'b0}};
|
2019-03-26 18:45:54 -07:00
|
|
|
wr_ptr_update_sync1_reg <= 1'b0;
|
|
|
|
wr_ptr_update_sync2_reg <= 1'b0;
|
|
|
|
wr_ptr_update_sync3_reg <= 1'b0;
|
2014-11-08 00:23:23 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-25 09:53:38 -07:00
|
|
|
// status synchronization
|
|
|
|
always @(posedge s_clk) begin
|
2020-09-06 22:57:56 -07:00
|
|
|
overflow_sync1_reg <= overflow_sync1_reg ^ overflow_reg;
|
|
|
|
bad_frame_sync1_reg <= bad_frame_sync1_reg ^ bad_frame_reg;
|
|
|
|
good_frame_sync1_reg <= good_frame_sync1_reg ^ good_frame_reg;
|
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
if (s_rst) begin
|
2018-10-25 09:53:38 -07:00
|
|
|
overflow_sync1_reg <= 1'b0;
|
|
|
|
bad_frame_sync1_reg <= 1'b0;
|
|
|
|
good_frame_sync1_reg <= 1'b0;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
always @(posedge m_clk) begin
|
2020-09-06 22:57:56 -07:00
|
|
|
overflow_sync2_reg <= overflow_sync1_reg;
|
|
|
|
overflow_sync3_reg <= overflow_sync2_reg;
|
|
|
|
overflow_sync4_reg <= overflow_sync3_reg;
|
|
|
|
bad_frame_sync2_reg <= bad_frame_sync1_reg;
|
|
|
|
bad_frame_sync3_reg <= bad_frame_sync2_reg;
|
|
|
|
bad_frame_sync4_reg <= bad_frame_sync3_reg;
|
|
|
|
good_frame_sync2_reg <= good_frame_sync1_reg;
|
|
|
|
good_frame_sync3_reg <= good_frame_sync2_reg;
|
|
|
|
good_frame_sync4_reg <= good_frame_sync3_reg;
|
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
if (m_rst) begin
|
2018-10-25 09:53:38 -07:00
|
|
|
overflow_sync2_reg <= 1'b0;
|
|
|
|
overflow_sync3_reg <= 1'b0;
|
2019-03-26 16:19:49 -07:00
|
|
|
overflow_sync4_reg <= 1'b0;
|
2018-10-25 09:53:38 -07:00
|
|
|
bad_frame_sync2_reg <= 1'b0;
|
|
|
|
bad_frame_sync3_reg <= 1'b0;
|
2019-03-26 16:19:49 -07:00
|
|
|
bad_frame_sync4_reg <= 1'b0;
|
2018-10-25 09:53:38 -07:00
|
|
|
good_frame_sync2_reg <= 1'b0;
|
|
|
|
good_frame_sync3_reg <= 1'b0;
|
2019-03-26 16:19:49 -07:00
|
|
|
good_frame_sync4_reg <= 1'b0;
|
2018-10-25 09:53:38 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-07 01:15:11 -08:00
|
|
|
// Read logic
|
2020-09-07 00:14:22 -07:00
|
|
|
integer j;
|
|
|
|
|
2020-09-06 22:57:56 -07:00
|
|
|
always @(posedge m_clk) begin
|
2020-09-07 00:14:22 -07:00
|
|
|
if (m_axis_tready) begin
|
|
|
|
// output ready; invalidate stage
|
|
|
|
m_axis_tvalid_pipe_reg[PIPELINE_OUTPUT-1] <= 1'b0;
|
2021-10-13 14:05:13 -07:00
|
|
|
m_terminate_frame_reg <= 1'b0;
|
2020-09-07 00:14:22 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
for (j = PIPELINE_OUTPUT-1; j > 0; j = j - 1) begin
|
|
|
|
if (m_axis_tready || ((~m_axis_tvalid_pipe_reg) >> j)) begin
|
|
|
|
// output ready or bubble in pipeline; transfer down pipeline
|
|
|
|
m_axis_tvalid_pipe_reg[j] <= m_axis_tvalid_pipe_reg[j-1];
|
|
|
|
m_axis_pipe_reg[j] <= m_axis_pipe_reg[j-1];
|
|
|
|
m_axis_tvalid_pipe_reg[j-1] <= 1'b0;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if (m_axis_tready || ~m_axis_tvalid_pipe_reg) begin
|
|
|
|
// output ready or bubble in pipeline; read new data from FIFO
|
|
|
|
m_axis_tvalid_pipe_reg[0] <= 1'b0;
|
|
|
|
m_axis_pipe_reg[0] <= mem[rd_ptr_reg[ADDR_WIDTH-1:0]];
|
2021-10-13 14:05:13 -07:00
|
|
|
if (!empty && !m_rst_sync3_reg && !m_drop_frame_reg) begin
|
2020-09-07 00:14:22 -07:00
|
|
|
// not empty, increment pointer
|
|
|
|
m_axis_tvalid_pipe_reg[0] <= 1'b1;
|
2020-09-06 22:57:56 -07:00
|
|
|
rd_ptr_temp = rd_ptr_reg + 1;
|
|
|
|
rd_ptr_reg <= rd_ptr_temp;
|
|
|
|
rd_ptr_gray_reg <= rd_ptr_temp ^ (rd_ptr_temp >> 1);
|
2015-11-07 01:15:11 -08:00
|
|
|
end
|
2015-05-08 01:41:35 -07:00
|
|
|
end
|
2020-09-06 17:55:10 -07:00
|
|
|
|
2021-10-13 14:05:13 -07:00
|
|
|
if (m_axis_tvalid && LAST_ENABLE) begin
|
|
|
|
// track output frame status
|
|
|
|
if (m_axis_tlast && m_axis_tready) begin
|
|
|
|
m_frame_reg <= 1'b0;
|
|
|
|
end else begin
|
|
|
|
m_frame_reg <= 1'b1;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if (m_drop_frame_reg && (m_axis_tready || !m_axis_tvalid_pipe) && LAST_ENABLE) begin
|
|
|
|
// terminate frame
|
|
|
|
// (only for frame transfers interrupted by source reset)
|
|
|
|
m_axis_tvalid_pipe_reg[PIPELINE_OUTPUT-1] <= 1'b1;
|
|
|
|
m_terminate_frame_reg <= 1'b1;
|
|
|
|
m_drop_frame_reg <= 1'b0;
|
|
|
|
end
|
|
|
|
|
|
|
|
if (m_rst_sync3_reg && LAST_ENABLE) begin
|
|
|
|
// if source side is reset during transfer, drop partial frame
|
|
|
|
|
|
|
|
// empty output pipeline, except for last stage
|
|
|
|
if (PIPELINE_OUTPUT > 1) begin
|
|
|
|
m_axis_tvalid_pipe_reg[PIPELINE_OUTPUT-2:0] <= 0;
|
|
|
|
end
|
|
|
|
|
|
|
|
if (m_frame_reg && (!m_axis_tvalid || (m_axis_tvalid && !m_axis_tlast)) &&
|
|
|
|
!(m_drop_frame_reg || m_terminate_frame_reg)) begin
|
|
|
|
// terminate frame
|
|
|
|
m_drop_frame_reg <= 1'b1;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-25 09:53:38 -07:00
|
|
|
if (m_rst_sync3_reg) begin
|
2015-11-07 01:15:11 -08:00
|
|
|
rd_ptr_reg <= {ADDR_WIDTH+1{1'b0}};
|
|
|
|
rd_ptr_gray_reg <= {ADDR_WIDTH+1{1'b0}};
|
2021-10-13 14:05:13 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
if (m_rst) begin
|
|
|
|
rd_ptr_reg <= {ADDR_WIDTH+1{1'b0}};
|
|
|
|
rd_ptr_gray_reg <= {ADDR_WIDTH+1{1'b0}};
|
2020-09-07 00:14:22 -07:00
|
|
|
m_axis_tvalid_pipe_reg <= {PIPELINE_OUTPUT{1'b0}};
|
2021-10-13 14:05:13 -07:00
|
|
|
m_frame_reg <= 1'b0;
|
|
|
|
m_drop_frame_reg <= 1'b0;
|
|
|
|
m_terminate_frame_reg <= 1'b0;
|
2020-09-06 17:55:10 -07:00
|
|
|
end
|
2016-08-04 18:03:00 -07:00
|
|
|
end
|
|
|
|
|
2014-11-08 00:23:23 -08:00
|
|
|
endmodule
|