2017-05-17 17:28:50 +00:00
|
|
|
//
|
|
|
|
// The ADI JESD204 Core is released under the following license, which is
|
|
|
|
// different than all other HDL cores in this repository.
|
|
|
|
//
|
|
|
|
// Please read this, and understand the freedoms and responsibilities you have
|
|
|
|
// by using this source code/core.
|
|
|
|
//
|
|
|
|
// The JESD204 HDL, is copyright © 2016-2017 Analog Devices Inc.
|
|
|
|
//
|
|
|
|
// This core is free software, you can use run, copy, study, change, ask
|
|
|
|
// questions about and improve this core. Distribution of source, or resulting
|
|
|
|
// binaries (including those inside an FPGA or ASIC) require you to release the
|
|
|
|
// source of the entire project (excluding the system libraries provide by the
|
|
|
|
// tools/compiler/FPGA vendor). These are the terms of the GNU General Public
|
|
|
|
// License version 2 as published by the Free Software Foundation.
|
|
|
|
//
|
|
|
|
// This core 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 General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License version 2
|
|
|
|
// along with this source code, and binary. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
//
|
|
|
|
// Commercial licenses (with commercial support) of this JESD204 core are also
|
|
|
|
// available under terms different than the General Public License. (e.g. they
|
|
|
|
// do not require you to accompany any image (FPGA or ASIC) using the JESD204
|
|
|
|
// core with any corresponding source code.) For these alternate terms you must
|
|
|
|
// purchase a license from Analog Devices Technology Licensing Office. Users
|
|
|
|
// interested in such a license should contact jesd204-licensing@analog.com for
|
|
|
|
// more information. This commercial license is sub-licensable (if you purchase
|
|
|
|
// chips from Analog Devices, incorporate them into your PCB level product, and
|
|
|
|
// purchase a JESD204 license, end users of your product will also have a
|
|
|
|
// license to use this core in a commercial setting without releasing their
|
|
|
|
// source code).
|
|
|
|
//
|
|
|
|
// In addition, we kindly ask you to acknowledge ADI in any program, application
|
|
|
|
// or publication in which you use this JESD204 HDL core. (You are not required
|
|
|
|
// to do so; it is up to your common sense to decide whether you want to comply
|
|
|
|
// with this request or not.) For general publications, we suggest referencing :
|
|
|
|
// “The design and implementation of the JESD204 HDL Core used in this project
|
|
|
|
// is copyright © 2016-2017, Analog Devices, Inc.”
|
|
|
|
//
|
|
|
|
|
2018-08-27 07:14:54 +00:00
|
|
|
`timescale 1ns/100ps
|
|
|
|
|
2017-05-17 17:28:50 +00:00
|
|
|
module jesd204_rx #(
|
2018-03-27 14:45:46 +00:00
|
|
|
parameter NUM_LANES = 1,
|
2019-04-04 13:53:53 +00:00
|
|
|
parameter NUM_LINKS = 1,
|
2019-10-10 07:21:17 +00:00
|
|
|
parameter NUM_INPUT_PIPELINE = 1,
|
|
|
|
parameter LINK_MODE = 1, // 2 - 64B/66B; 1 - 8B/10B
|
|
|
|
/* Only 4 is supported at the moment for 8b/10b and 8 for 64b */
|
2020-01-29 14:41:43 +00:00
|
|
|
parameter DATA_PATH_WIDTH = LINK_MODE == 2 ? 8 : 4,
|
|
|
|
parameter ENABLE_FRAME_ALIGN_CHECK = 1,
|
2020-10-09 06:25:13 +00:00
|
|
|
parameter ENABLE_FRAME_ALIGN_ERR_RESET = 0,
|
|
|
|
parameter ENABLE_CHAR_REPLACE = 0
|
2017-05-17 17:28:50 +00:00
|
|
|
) (
|
|
|
|
input clk,
|
|
|
|
input reset,
|
|
|
|
|
2019-10-10 07:21:17 +00:00
|
|
|
input [DATA_PATH_WIDTH*8*NUM_LANES-1:0] phy_data,
|
|
|
|
input [2*NUM_LANES-1:0] phy_header,
|
|
|
|
input [DATA_PATH_WIDTH*NUM_LANES-1:0] phy_charisk,
|
|
|
|
input [DATA_PATH_WIDTH*NUM_LANES-1:0] phy_notintable,
|
|
|
|
input [DATA_PATH_WIDTH*NUM_LANES-1:0] phy_disperr,
|
|
|
|
input [NUM_LANES-1:0] phy_block_sync,
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
input sysref,
|
|
|
|
output lmfc_edge,
|
|
|
|
output lmfc_clk,
|
|
|
|
|
|
|
|
output event_sysref_alignment_error,
|
|
|
|
output event_sysref_edge,
|
2020-07-21 07:07:57 +00:00
|
|
|
output event_frame_alignment_error,
|
2020-07-21 15:53:23 +00:00
|
|
|
output event_unexpected_lane_state_error,
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2018-03-27 14:45:46 +00:00
|
|
|
output [NUM_LINKS-1:0] sync,
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
output phy_en_char_align,
|
|
|
|
|
2019-10-10 07:21:17 +00:00
|
|
|
output [DATA_PATH_WIDTH*8*NUM_LANES-1:0] rx_data,
|
2017-05-17 17:28:50 +00:00
|
|
|
output rx_valid,
|
2019-10-10 07:21:17 +00:00
|
|
|
output [DATA_PATH_WIDTH-1:0] rx_eof,
|
|
|
|
output [DATA_PATH_WIDTH-1:0] rx_sof,
|
2020-09-28 14:29:47 +00:00
|
|
|
output [DATA_PATH_WIDTH-1:0] rx_eomf,
|
|
|
|
output [DATA_PATH_WIDTH-1:0] rx_somf,
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
input [NUM_LANES-1:0] cfg_lanes_disable,
|
2018-03-27 14:45:46 +00:00
|
|
|
input [NUM_LINKS-1:0] cfg_links_disable,
|
2020-01-30 22:05:13 +00:00
|
|
|
input [9:0] cfg_octets_per_multiframe,
|
2017-05-17 17:28:50 +00:00
|
|
|
input [7:0] cfg_octets_per_frame,
|
|
|
|
input [7:0] cfg_lmfc_offset,
|
2017-05-17 17:28:50 +00:00
|
|
|
input cfg_sysref_disable,
|
2017-05-17 17:28:50 +00:00
|
|
|
input cfg_sysref_oneshot,
|
|
|
|
input cfg_buffer_early_release,
|
|
|
|
input [7:0] cfg_buffer_delay,
|
|
|
|
input cfg_disable_char_replacement,
|
|
|
|
input cfg_disable_scrambler,
|
|
|
|
|
2018-05-07 12:33:00 +00:00
|
|
|
input ctrl_err_statistics_reset,
|
2019-10-10 07:21:17 +00:00
|
|
|
input [6:0] ctrl_err_statistics_mask,
|
2018-05-07 12:33:00 +00:00
|
|
|
|
2020-01-29 14:41:43 +00:00
|
|
|
input [7:0] cfg_frame_align_err_threshold,
|
|
|
|
|
2018-05-07 12:33:00 +00:00
|
|
|
output [32*NUM_LANES-1:0] status_err_statistics_cnt,
|
|
|
|
|
2017-05-17 17:28:50 +00:00
|
|
|
output [NUM_LANES-1:0] ilas_config_valid,
|
|
|
|
output [NUM_LANES*2-1:0] ilas_config_addr,
|
2020-01-30 22:05:13 +00:00
|
|
|
output [NUM_LANES*DATA_PATH_WIDTH*8-1:0] ilas_config_data,
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2017-08-22 13:06:34 +00:00
|
|
|
output [1:0] status_ctrl_state,
|
2017-05-17 17:28:50 +00:00
|
|
|
output [2*NUM_LANES-1:0] status_lane_cgs_state,
|
|
|
|
output [NUM_LANES-1:0] status_lane_ifs_ready,
|
2019-10-10 07:21:17 +00:00
|
|
|
output [14*NUM_LANES-1:0] status_lane_latency,
|
2020-01-29 14:41:43 +00:00
|
|
|
output [3*NUM_LANES-1:0] status_lane_emb_state,
|
|
|
|
output [8*NUM_LANES-1:0] status_lane_frame_align_err_cnt
|
2017-05-17 17:28:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Can be used to enable additional pipeline stages to ease timing. Usually not
|
|
|
|
* necessary.
|
|
|
|
*/
|
|
|
|
localparam CHAR_INFO_REGISTERED = 0;
|
2020-01-30 22:05:13 +00:00
|
|
|
localparam ALIGN_MUX_REGISTERED = 1;
|
2017-05-17 17:28:50 +00:00
|
|
|
localparam SCRAMBLER_REGISTERED = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximum number of octets per multiframe for ADI JESD204 DACs is 256 (Adjust
|
|
|
|
* as necessary). Divide by data path width.
|
|
|
|
*/
|
2020-01-30 22:05:13 +00:00
|
|
|
localparam MAX_OCTETS_PER_FRAME = 32;
|
2017-05-17 17:28:50 +00:00
|
|
|
localparam MAX_OCTETS_PER_MULTIFRAME =
|
|
|
|
(MAX_OCTETS_PER_FRAME * 32) > 1024 ? 1024 : (MAX_OCTETS_PER_FRAME * 32);
|
|
|
|
localparam MAX_BEATS_PER_MULTIFRAME = MAX_OCTETS_PER_MULTIFRAME / DATA_PATH_WIDTH;
|
|
|
|
localparam ELASTIC_BUFFER_SIZE = MAX_BEATS_PER_MULTIFRAME;
|
2020-01-30 22:05:13 +00:00
|
|
|
localparam DPW_LOG2 = DATA_PATH_WIDTH == 8 ? 3 : DATA_PATH_WIDTH == 4 ? 2 : 1;
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
localparam LMFC_COUNTER_WIDTH = MAX_BEATS_PER_MULTIFRAME > 256 ? 9 :
|
|
|
|
MAX_BEATS_PER_MULTIFRAME > 128 ? 8 :
|
|
|
|
MAX_BEATS_PER_MULTIFRAME > 64 ? 7 :
|
|
|
|
MAX_BEATS_PER_MULTIFRAME > 32 ? 6 :
|
|
|
|
MAX_BEATS_PER_MULTIFRAME > 16 ? 5 :
|
|
|
|
MAX_BEATS_PER_MULTIFRAME > 8 ? 4 :
|
|
|
|
MAX_BEATS_PER_MULTIFRAME > 4 ? 3 :
|
|
|
|
MAX_BEATS_PER_MULTIFRAME > 2 ? 2 : 1;
|
|
|
|
|
|
|
|
/* Helper for common expressions */
|
|
|
|
localparam DW = 8*DATA_PATH_WIDTH*NUM_LANES;
|
|
|
|
localparam CW = DATA_PATH_WIDTH*NUM_LANES;
|
2019-10-10 07:21:17 +00:00
|
|
|
localparam HW = 2*NUM_LANES;
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2020-01-30 22:05:13 +00:00
|
|
|
wire [7:0] cfg_beats_per_multiframe = cfg_octets_per_multiframe[9:DPW_LOG2];
|
|
|
|
|
2017-05-17 17:28:50 +00:00
|
|
|
wire [NUM_LANES-1:0] cgs_reset;
|
|
|
|
wire [NUM_LANES-1:0] cgs_ready;
|
|
|
|
wire [NUM_LANES-1:0] ifs_reset;
|
|
|
|
|
|
|
|
reg buffer_release_n = 1'b1;
|
|
|
|
reg buffer_release_d1 = 1'b0;
|
|
|
|
wire [NUM_LANES-1:0] buffer_ready_n;
|
2019-10-10 07:21:17 +00:00
|
|
|
wire all_buffer_ready_n;
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
reg eof_reset = 1'b1;
|
|
|
|
|
|
|
|
wire [DW-1:0] phy_data_r;
|
2019-10-10 07:21:17 +00:00
|
|
|
wire [HW-1:0] phy_header_r;
|
2017-05-17 17:28:50 +00:00
|
|
|
wire [CW-1:0] phy_charisk_r;
|
|
|
|
wire [CW-1:0] phy_notintable_r;
|
|
|
|
wire [CW-1:0] phy_disperr_r;
|
2019-10-10 07:21:17 +00:00
|
|
|
wire [NUM_LANES-1:0] phy_block_sync_r;
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
wire [DW-1:0] rx_data_s;
|
|
|
|
|
|
|
|
wire rx_valid_s = buffer_release_d1;
|
|
|
|
|
|
|
|
wire [7:0] lmfc_counter;
|
|
|
|
wire latency_monitor_reset;
|
|
|
|
|
2020-01-30 22:05:13 +00:00
|
|
|
wire [3*NUM_LANES-1:0] frame_align;
|
2017-05-17 17:28:50 +00:00
|
|
|
wire [NUM_LANES-1:0] ifs_ready;
|
|
|
|
|
2020-09-03 15:37:20 +00:00
|
|
|
wire event_data_phase;
|
|
|
|
wire err_statistics_reset;
|
|
|
|
|
2020-01-29 14:41:43 +00:00
|
|
|
reg [NUM_LANES-1:0] frame_align_err_thresh_met = {NUM_LANES{1'b0}};
|
2020-07-21 07:07:57 +00:00
|
|
|
reg [NUM_LANES-1:0] event_frame_alignment_error_per_lane = {NUM_LANES{1'b0}};
|
2020-01-29 14:41:43 +00:00
|
|
|
|
2017-05-17 17:28:50 +00:00
|
|
|
reg buffer_release_opportunity = 1'b0;
|
|
|
|
|
|
|
|
always @(posedge clk) begin
|
|
|
|
if (lmfc_counter == cfg_buffer_delay ||
|
|
|
|
cfg_buffer_early_release == 1'b1) begin
|
|
|
|
buffer_release_opportunity <= 1'b1;
|
|
|
|
end else begin
|
|
|
|
buffer_release_opportunity <= 1'b0;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-10 07:21:17 +00:00
|
|
|
assign all_buffer_ready_n = |(buffer_ready_n & ~cfg_lanes_disable);
|
|
|
|
|
2017-05-17 17:28:50 +00:00
|
|
|
always @(posedge clk) begin
|
|
|
|
if (reset == 1'b1) begin
|
|
|
|
buffer_release_n <= 1'b1;
|
|
|
|
end else begin
|
|
|
|
if (buffer_release_opportunity == 1'b1) begin
|
2019-10-10 07:21:17 +00:00
|
|
|
buffer_release_n <= all_buffer_ready_n;
|
2017-05-17 17:28:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
buffer_release_d1 <= ~buffer_release_n;
|
|
|
|
eof_reset <= buffer_release_n;
|
|
|
|
end
|
|
|
|
|
|
|
|
pipeline_stage #(
|
2019-10-10 07:21:17 +00:00
|
|
|
.WIDTH(NUM_LANES + (3 * CW) + HW + DW),
|
2019-04-04 13:53:53 +00:00
|
|
|
.REGISTERED(NUM_INPUT_PIPELINE)
|
2017-05-17 17:28:50 +00:00
|
|
|
) i_input_pipeline_stage (
|
|
|
|
.clk(clk),
|
|
|
|
.in({
|
|
|
|
phy_data,
|
2019-10-10 07:21:17 +00:00
|
|
|
phy_header,
|
2017-05-17 17:28:50 +00:00
|
|
|
phy_charisk,
|
|
|
|
phy_notintable,
|
2019-10-10 07:21:17 +00:00
|
|
|
phy_disperr,
|
|
|
|
phy_block_sync
|
2017-05-17 17:28:50 +00:00
|
|
|
}),
|
|
|
|
.out({
|
|
|
|
phy_data_r,
|
2019-10-10 07:21:17 +00:00
|
|
|
phy_header_r,
|
2017-05-17 17:28:50 +00:00
|
|
|
phy_charisk_r,
|
|
|
|
phy_notintable_r,
|
2019-10-10 07:21:17 +00:00
|
|
|
phy_disperr_r,
|
|
|
|
phy_block_sync_r
|
2017-05-17 17:28:50 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
pipeline_stage #(
|
|
|
|
.WIDTH(DW+1),
|
|
|
|
.REGISTERED(1)
|
|
|
|
) i_output_pipeline_stage (
|
|
|
|
.clk(clk),
|
|
|
|
.in({
|
|
|
|
rx_data_s,
|
|
|
|
rx_valid_s
|
|
|
|
}),
|
|
|
|
.out({
|
|
|
|
rx_data,
|
|
|
|
rx_valid
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2020-01-30 22:05:13 +00:00
|
|
|
jesd204_lmfc #(
|
|
|
|
.LINK_MODE(LINK_MODE),
|
|
|
|
.DATA_PATH_WIDTH(DATA_PATH_WIDTH)
|
|
|
|
) i_lmfc (
|
2017-05-17 17:28:50 +00:00
|
|
|
.clk(clk),
|
2020-01-30 22:05:13 +00:00
|
|
|
.reset(reset),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2020-01-30 22:05:13 +00:00
|
|
|
.cfg_octets_per_multiframe(cfg_octets_per_multiframe),
|
2017-05-17 17:28:50 +00:00
|
|
|
.cfg_lmfc_offset(cfg_lmfc_offset),
|
|
|
|
.cfg_sysref_oneshot(cfg_sysref_oneshot),
|
2017-05-17 17:28:50 +00:00
|
|
|
.cfg_sysref_disable(cfg_sysref_disable),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
.sysref(sysref),
|
|
|
|
.lmfc_edge(lmfc_edge),
|
|
|
|
.lmfc_clk(lmfc_clk),
|
|
|
|
.lmfc_counter(lmfc_counter),
|
2019-10-10 07:21:17 +00:00
|
|
|
.lmc_edge(),
|
|
|
|
.lmc_quarter_edge(),
|
|
|
|
.eoemb(),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
.sysref_edge(event_sysref_edge),
|
2017-06-20 14:00:03 +00:00
|
|
|
.sysref_alignment_error(event_sysref_alignment_error)
|
2017-05-17 17:28:50 +00:00
|
|
|
);
|
|
|
|
|
2020-01-30 22:05:13 +00:00
|
|
|
jesd204_frame_mark #(
|
|
|
|
.DATA_PATH_WIDTH (DATA_PATH_WIDTH)
|
|
|
|
) i_frame_mark (
|
|
|
|
.clk (clk),
|
|
|
|
.reset (eof_reset),
|
|
|
|
.cfg_octets_per_multiframe (cfg_octets_per_multiframe),
|
|
|
|
.cfg_octets_per_frame (cfg_octets_per_frame),
|
|
|
|
.sof (rx_sof),
|
|
|
|
.eof (rx_eof),
|
2020-09-28 14:29:47 +00:00
|
|
|
.somf (rx_somf),
|
|
|
|
.eomf (rx_eomf)
|
2019-10-10 07:21:17 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
generate
|
|
|
|
genvar i;
|
|
|
|
|
|
|
|
if (LINK_MODE[0] == 1) begin : mode_8b10b
|
|
|
|
|
2020-07-21 15:53:23 +00:00
|
|
|
wire unexpected_lane_state_error;
|
|
|
|
reg unexpected_lane_state_error_d = 1'b0;
|
|
|
|
|
2017-05-17 17:28:50 +00:00
|
|
|
jesd204_rx_ctrl #(
|
2018-03-27 14:45:46 +00:00
|
|
|
.NUM_LANES(NUM_LANES),
|
2020-01-30 22:05:13 +00:00
|
|
|
.NUM_LINKS(NUM_LINKS),
|
|
|
|
.ENABLE_FRAME_ALIGN_ERR_RESET(ENABLE_FRAME_ALIGN_ERR_RESET)
|
2017-05-17 17:28:50 +00:00
|
|
|
) i_rx_ctrl (
|
|
|
|
.clk(clk),
|
2020-01-30 22:05:13 +00:00
|
|
|
.reset(reset),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
.cfg_lanes_disable(cfg_lanes_disable),
|
2018-03-27 14:45:46 +00:00
|
|
|
.cfg_links_disable(cfg_links_disable),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
.phy_ready(1'b1),
|
|
|
|
.phy_en_char_align(phy_en_char_align),
|
|
|
|
|
|
|
|
.lmfc_edge(lmfc_edge),
|
2020-01-30 22:05:13 +00:00
|
|
|
.frame_align_err_thresh_met(frame_align_err_thresh_met),
|
2017-05-17 17:28:50 +00:00
|
|
|
.sync(sync),
|
|
|
|
|
|
|
|
.latency_monitor_reset(latency_monitor_reset),
|
|
|
|
|
|
|
|
.cgs_reset(cgs_reset),
|
|
|
|
.cgs_ready(cgs_ready),
|
|
|
|
|
|
|
|
.ifs_reset(ifs_reset),
|
|
|
|
|
2020-09-03 15:37:20 +00:00
|
|
|
.status_state(status_ctrl_state),
|
|
|
|
|
|
|
|
.event_data_phase(event_data_phase)
|
2017-05-17 17:28:50 +00:00
|
|
|
);
|
|
|
|
|
2020-09-03 15:37:20 +00:00
|
|
|
assign err_statistics_reset = ctrl_err_statistics_reset ||
|
|
|
|
event_data_phase;
|
|
|
|
|
2017-07-11 16:46:28 +00:00
|
|
|
for (i = 0; i < NUM_LANES; i = i + 1) begin: gen_lane
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
localparam D_START = i * DATA_PATH_WIDTH*8;
|
|
|
|
localparam D_STOP = D_START + DATA_PATH_WIDTH*8-1;
|
|
|
|
localparam C_START = i * DATA_PATH_WIDTH;
|
|
|
|
localparam C_STOP = C_START + DATA_PATH_WIDTH-1;
|
|
|
|
|
|
|
|
jesd204_rx_lane #(
|
|
|
|
.DATA_PATH_WIDTH(DATA_PATH_WIDTH),
|
|
|
|
.CHAR_INFO_REGISTERED(CHAR_INFO_REGISTERED),
|
|
|
|
.ALIGN_MUX_REGISTERED(ALIGN_MUX_REGISTERED),
|
|
|
|
.SCRAMBLER_REGISTERED(SCRAMBLER_REGISTERED),
|
2020-01-29 14:41:43 +00:00
|
|
|
.ELASTIC_BUFFER_SIZE(ELASTIC_BUFFER_SIZE),
|
2020-10-09 06:25:13 +00:00
|
|
|
.ENABLE_FRAME_ALIGN_CHECK(ENABLE_FRAME_ALIGN_CHECK),
|
|
|
|
.ENABLE_CHAR_REPLACE(ENABLE_CHAR_REPLACE)
|
2017-05-17 17:28:50 +00:00
|
|
|
) i_lane (
|
|
|
|
.clk(clk),
|
2020-01-30 22:05:13 +00:00
|
|
|
.reset(reset),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
|
|
|
.phy_data(phy_data_r[D_STOP:D_START]),
|
|
|
|
.phy_charisk(phy_charisk_r[C_STOP:C_START]),
|
|
|
|
.phy_notintable(phy_notintable_r[C_STOP:C_START]),
|
|
|
|
.phy_disperr(phy_disperr_r[C_STOP:C_START]),
|
|
|
|
|
|
|
|
.cgs_reset(cgs_reset[i]),
|
|
|
|
.cgs_ready(cgs_ready[i]),
|
|
|
|
|
|
|
|
.ifs_reset(ifs_reset[i]),
|
|
|
|
|
|
|
|
.rx_data(rx_data_s[D_STOP:D_START]),
|
|
|
|
|
|
|
|
.buffer_release_n(buffer_release_n),
|
|
|
|
.buffer_ready_n(buffer_ready_n[i]),
|
|
|
|
|
2020-01-30 22:05:13 +00:00
|
|
|
.cfg_octets_per_multiframe(cfg_octets_per_multiframe),
|
2020-01-29 14:41:43 +00:00
|
|
|
.cfg_octets_per_frame(cfg_octets_per_frame),
|
2020-01-30 22:05:13 +00:00
|
|
|
.cfg_disable_char_replacement(cfg_disable_char_replacement),
|
2020-01-29 14:41:43 +00:00
|
|
|
.cfg_disable_scrambler(cfg_disable_scrambler),
|
|
|
|
|
2020-09-03 15:37:20 +00:00
|
|
|
.err_statistics_reset(err_statistics_reset),
|
2019-10-10 07:21:17 +00:00
|
|
|
.ctrl_err_statistics_mask(ctrl_err_statistics_mask[2:0]),
|
2018-05-07 12:33:00 +00:00
|
|
|
.status_err_statistics_cnt(status_err_statistics_cnt[32*i+31:32*i]),
|
|
|
|
|
2017-05-17 17:28:50 +00:00
|
|
|
.ilas_config_valid(ilas_config_valid[i]),
|
|
|
|
.ilas_config_addr(ilas_config_addr[2*i+1:2*i]),
|
|
|
|
.ilas_config_data(ilas_config_data[D_STOP:D_START]),
|
|
|
|
|
|
|
|
.status_cgs_state(status_lane_cgs_state[2*i+1:2*i]),
|
|
|
|
.status_ifs_ready(ifs_ready[i]),
|
2020-01-30 22:05:13 +00:00
|
|
|
.status_frame_align(frame_align[3*i+2:3*i]),
|
2020-01-29 14:41:43 +00:00
|
|
|
|
|
|
|
.status_frame_align_err_cnt(status_lane_frame_align_err_cnt[8*i+7:8*i])
|
2017-05-17 17:28:50 +00:00
|
|
|
);
|
2020-01-29 14:41:43 +00:00
|
|
|
|
2020-07-21 07:07:57 +00:00
|
|
|
if(ENABLE_FRAME_ALIGN_CHECK) begin : gen_frame_align_err_thresh
|
2020-01-29 14:41:43 +00:00
|
|
|
always @(posedge clk) begin
|
2020-09-25 06:12:34 +00:00
|
|
|
if (reset) begin
|
2020-07-21 07:07:57 +00:00
|
|
|
frame_align_err_thresh_met[i] <= 1'b0;
|
|
|
|
event_frame_alignment_error_per_lane[i] <= 1'b0;
|
2020-09-25 06:12:34 +00:00
|
|
|
end else begin
|
|
|
|
if (status_lane_frame_align_err_cnt[8*i+7:8*i] >= cfg_frame_align_err_threshold) begin
|
|
|
|
frame_align_err_thresh_met[i] <= cgs_ready[i];
|
|
|
|
event_frame_alignment_error_per_lane[i] <= ~frame_align_err_thresh_met[i];
|
|
|
|
end else begin
|
|
|
|
frame_align_err_thresh_met[i] <= 1'b0;
|
|
|
|
event_frame_alignment_error_per_lane[i] <= 1'b0;
|
|
|
|
end
|
2020-07-21 07:07:57 +00:00
|
|
|
end
|
2020-01-29 14:41:43 +00:00
|
|
|
end
|
2020-01-30 22:05:13 +00:00
|
|
|
end else begin : gen_no_frame_align_err_thresh
|
|
|
|
always @(*) begin
|
|
|
|
frame_align_err_thresh_met[i] <= 1'b0;
|
|
|
|
event_frame_alignment_error_per_lane[i] <= 1'b0;
|
|
|
|
end
|
2020-01-29 14:41:43 +00:00
|
|
|
end
|
2017-05-17 17:28:50 +00:00
|
|
|
end
|
|
|
|
|
2020-07-21 07:07:57 +00:00
|
|
|
assign event_frame_alignment_error = |event_frame_alignment_error_per_lane;
|
2020-01-29 14:41:43 +00:00
|
|
|
|
2020-07-21 15:53:23 +00:00
|
|
|
/* If one of the enabled lanes falls out of DATA phase while the link is in DATA phase
|
|
|
|
* report an error event */
|
|
|
|
assign unexpected_lane_state_error = |(~(cgs_ready|cfg_lanes_disable)) & &status_ctrl_state;
|
|
|
|
always @(posedge clk) begin
|
|
|
|
unexpected_lane_state_error_d <= unexpected_lane_state_error;
|
|
|
|
end
|
|
|
|
assign event_unexpected_lane_state_error = unexpected_lane_state_error & ~unexpected_lane_state_error_d;
|
|
|
|
|
|
|
|
|
2017-05-17 17:28:50 +00:00
|
|
|
/* Delay matching based on the number of pipeline stages */
|
|
|
|
reg [NUM_LANES-1:0] ifs_ready_d1 = 1'b0;
|
|
|
|
reg [NUM_LANES-1:0] ifs_ready_d2 = 1'b0;
|
|
|
|
reg [NUM_LANES-1:0] ifs_ready_mux;
|
|
|
|
|
|
|
|
always @(posedge clk) begin
|
|
|
|
ifs_ready_d1 <= ifs_ready;
|
|
|
|
ifs_ready_d2 <= ifs_ready_d1;
|
|
|
|
end
|
|
|
|
|
|
|
|
always @(*) begin
|
|
|
|
case (SCRAMBLER_REGISTERED + ALIGN_MUX_REGISTERED)
|
2020-09-25 08:38:45 +00:00
|
|
|
1: ifs_ready_mux = ifs_ready_d1;
|
|
|
|
2: ifs_ready_mux = ifs_ready_d2;
|
|
|
|
default: ifs_ready_mux = ifs_ready;
|
2017-05-17 17:28:50 +00:00
|
|
|
endcase
|
|
|
|
end
|
|
|
|
|
|
|
|
jesd204_lane_latency_monitor #(
|
2020-01-30 22:05:13 +00:00
|
|
|
.NUM_LANES(NUM_LANES),
|
|
|
|
.DATA_PATH_WIDTH(DATA_PATH_WIDTH)
|
2017-05-17 17:28:50 +00:00
|
|
|
) i_lane_latency_monitor (
|
|
|
|
.clk(clk),
|
|
|
|
.reset(latency_monitor_reset),
|
|
|
|
|
|
|
|
.lane_ready(ifs_ready_mux),
|
|
|
|
.lane_frame_align(frame_align),
|
|
|
|
.lane_latency_ready(status_lane_ifs_ready),
|
|
|
|
.lane_latency(status_lane_latency)
|
|
|
|
);
|
|
|
|
|
2020-01-30 22:05:13 +00:00
|
|
|
assign status_lane_emb_state = 'b0;
|
|
|
|
|
2019-10-10 07:21:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if (LINK_MODE[1] == 1) begin : mode_64b66b
|
|
|
|
|
|
|
|
wire [NUM_LANES-1:0] emb_lock;
|
|
|
|
|
|
|
|
jesd204_rx_ctrl_64b #(
|
|
|
|
.NUM_LANES(NUM_LANES)
|
|
|
|
) i_jesd204_rx_ctrl_64b (
|
|
|
|
.clk(clk),
|
2020-01-30 22:05:13 +00:00
|
|
|
.reset(reset),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
|
|
|
.cfg_lanes_disable(cfg_lanes_disable),
|
|
|
|
|
|
|
|
.phy_block_sync(phy_block_sync_r),
|
|
|
|
.emb_lock(emb_lock),
|
|
|
|
|
|
|
|
.all_emb_lock(all_emb_lock),
|
|
|
|
.buffer_release_n(buffer_release_n),
|
|
|
|
|
2020-07-21 15:53:23 +00:00
|
|
|
.status_state(status_ctrl_state),
|
|
|
|
.event_unexpected_lane_state_error(event_unexpected_lane_state_error)
|
2019-10-10 07:21:17 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_LANES; i = i + 1) begin: gen_lane
|
|
|
|
|
|
|
|
localparam D_START = i * DATA_PATH_WIDTH*8;
|
|
|
|
localparam D_STOP = D_START + DATA_PATH_WIDTH*8-1;
|
|
|
|
localparam H_START = i * 2;
|
|
|
|
localparam H_STOP = H_START + 2-1;
|
|
|
|
|
|
|
|
wire [7:0] status_lane_skew;
|
|
|
|
|
|
|
|
jesd204_rx_lane_64b #(
|
|
|
|
.ELASTIC_BUFFER_SIZE(ELASTIC_BUFFER_SIZE)
|
|
|
|
) i_lane (
|
|
|
|
.clk(clk),
|
2020-01-30 22:05:13 +00:00
|
|
|
.reset(reset),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
|
|
|
.phy_data(phy_data_r[D_STOP:D_START]),
|
|
|
|
.phy_header(phy_header_r[H_STOP:H_START]),
|
|
|
|
.phy_block_sync(phy_block_sync_r[i]),
|
|
|
|
|
|
|
|
.cfg_disable_scrambler(cfg_disable_scrambler),
|
|
|
|
.cfg_header_mode(2'b0),
|
|
|
|
.cfg_rx_thresh_emb_err(5'd8),
|
|
|
|
.cfg_beats_per_multiframe(cfg_beats_per_multiframe),
|
|
|
|
|
|
|
|
.rx_data(rx_data_s[D_STOP:D_START]),
|
|
|
|
|
|
|
|
.buffer_release_n(buffer_release_n),
|
|
|
|
.buffer_ready_n(buffer_ready_n[i]),
|
|
|
|
.all_buffer_ready_n(all_buffer_ready_n),
|
|
|
|
|
|
|
|
.lmfc_edge(lmfc_edge),
|
|
|
|
.emb_lock(emb_lock[i]),
|
|
|
|
|
|
|
|
.ctrl_err_statistics_reset(ctrl_err_statistics_reset),
|
|
|
|
.ctrl_err_statistics_mask(ctrl_err_statistics_mask[6:3]),
|
|
|
|
.status_err_statistics_cnt(status_err_statistics_cnt[32*i+31:32*i]),
|
|
|
|
|
|
|
|
.status_lane_emb_state(status_lane_emb_state[3*i+2:3*i]),
|
|
|
|
.status_lane_skew(status_lane_skew)
|
|
|
|
);
|
|
|
|
|
|
|
|
assign status_lane_latency[14*(i+1)-1:14*i] = {3'b0,status_lane_skew,3'b0};
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-01-29 14:41:43 +00:00
|
|
|
// Assign unused outputs
|
2019-10-10 07:21:17 +00:00
|
|
|
assign sync = 'b0;
|
|
|
|
assign phy_en_char_align = 1'b0;
|
|
|
|
|
|
|
|
assign ilas_config_valid ='b0;
|
|
|
|
assign ilas_config_addr = 'b0;
|
|
|
|
assign ilas_config_data = 'b0;
|
|
|
|
assign status_lane_cgs_state = 'b0;
|
|
|
|
assign status_lane_ifs_ready = {NUM_LANES{1'b1}};
|
2020-07-21 07:07:57 +00:00
|
|
|
assign event_frame_alignment_error = 1'b0;
|
2019-10-10 07:21:17 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
endgenerate
|
|
|
|
|
|
|
|
|
2017-05-17 17:28:50 +00:00
|
|
|
endmodule
|