2023-08-18 07:55:04 +00:00
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
// Copyright (C) 2017-2022 Analog Devices, Inc. All rights reserved.
|
|
|
|
// SPDX short identifier: ADIJESD204
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
2017-05-17 17:28:50 +00:00
|
|
|
|
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,
|
2021-02-22 09:24:50 +00:00
|
|
|
parameter NUM_OUTPUT_PIPELINE = 1,
|
2019-10-10 07:21:17 +00:00
|
|
|
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,
|
2020-10-27 15:40:37 +00:00
|
|
|
parameter ENABLE_CHAR_REPLACE = 0,
|
|
|
|
parameter ASYNC_CLK = 1,
|
|
|
|
parameter TPL_DATA_PATH_WIDTH = LINK_MODE == 2 ? 8 : 4
|
2017-05-17 17:28:50 +00:00
|
|
|
) (
|
2020-10-27 15:40:37 +00:00
|
|
|
input clk, // Link clock, lane rate / 40 or lane rate / 20 or lane rate / 66
|
2017-05-17 17:28:50 +00:00
|
|
|
input reset,
|
|
|
|
|
2020-10-27 15:40:37 +00:00
|
|
|
input device_clk, // Integer multiple of frame clock
|
|
|
|
input device_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,
|
|
|
|
|
2020-10-27 15:40:37 +00:00
|
|
|
output device_event_sysref_alignment_error,
|
|
|
|
output device_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,
|
|
|
|
|
2020-10-27 15:40:37 +00:00
|
|
|
output [TPL_DATA_PATH_WIDTH*8*NUM_LANES-1:0] rx_data,
|
2017-05-17 17:28:50 +00:00
|
|
|
output rx_valid,
|
2020-10-27 15:40:37 +00:00
|
|
|
output [TPL_DATA_PATH_WIDTH-1:0] rx_eof,
|
|
|
|
output [TPL_DATA_PATH_WIDTH-1:0] rx_sof,
|
|
|
|
output [TPL_DATA_PATH_WIDTH-1:0] rx_eomf,
|
|
|
|
output [TPL_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 cfg_disable_scrambler,
|
2020-10-27 15:40:37 +00:00
|
|
|
input cfg_disable_char_replacement,
|
|
|
|
input [7:0] cfg_frame_align_err_threshold,
|
|
|
|
|
|
|
|
input [9:0] device_cfg_octets_per_multiframe,
|
|
|
|
input [7:0] device_cfg_octets_per_frame,
|
|
|
|
input [7:0] device_cfg_beats_per_multiframe,
|
|
|
|
input [7:0] device_cfg_lmfc_offset,
|
|
|
|
input device_cfg_sysref_oneshot,
|
|
|
|
input device_cfg_sysref_disable,
|
|
|
|
input device_cfg_buffer_early_release,
|
|
|
|
input [7:0] device_cfg_buffer_delay,
|
2017-05-17 17:28:50 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
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,
|
2020-12-03 13:59:33 +00:00
|
|
|
output [8*NUM_LANES-1:0] status_lane_frame_align_err_cnt,
|
|
|
|
|
|
|
|
output [31:0] status_synth_params0,
|
|
|
|
output [31:0] status_synth_params1,
|
|
|
|
output [31:0] status_synth_params2
|
2017-05-17 17:28:50 +00:00
|
|
|
);
|
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
/*
|
|
|
|
* Can be used to enable additional pipeline stages to ease timing. Usually not
|
|
|
|
* necessary.
|
|
|
|
*/
|
|
|
|
localparam CHAR_INFO_REGISTERED = 0;
|
|
|
|
localparam ALIGN_MUX_REGISTERED = 1;
|
|
|
|
localparam SCRAMBLER_REGISTERED = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximum number of octets per multiframe for ADI JESD204 DACs is 256 (Adjust
|
|
|
|
* as necessary). Divide by data path width.
|
|
|
|
*/
|
|
|
|
localparam MAX_OCTETS_PER_FRAME = 32;
|
|
|
|
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;
|
|
|
|
localparam DPW_LOG2 = DATA_PATH_WIDTH == 8 ? 3 : DATA_PATH_WIDTH == 4 ? 2 : 1;
|
|
|
|
|
|
|
|
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 ODW = 8*TPL_DATA_PATH_WIDTH*NUM_LANES;
|
|
|
|
localparam CW = DATA_PATH_WIDTH*NUM_LANES;
|
|
|
|
localparam HW = 2*NUM_LANES;
|
|
|
|
|
|
|
|
wire [7:0] cfg_beats_per_multiframe = cfg_octets_per_multiframe >> DPW_LOG2;
|
|
|
|
wire [7:0] device_cfg_beats_per_multiframe_s;
|
|
|
|
|
|
|
|
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;
|
|
|
|
wire all_buffer_ready_n;
|
|
|
|
wire dev_all_buffer_ready_n;
|
|
|
|
|
|
|
|
reg eof_reset = 1'b1;
|
|
|
|
|
|
|
|
wire [DW-1:0] phy_data_r;
|
|
|
|
wire [HW-1:0] phy_header_r;
|
|
|
|
wire [CW-1:0] phy_charisk_r;
|
|
|
|
wire [CW-1:0] phy_notintable_r;
|
|
|
|
wire [CW-1:0] phy_disperr_r;
|
|
|
|
wire [NUM_LANES-1:0] phy_block_sync_r;
|
|
|
|
|
|
|
|
wire [ODW-1:0] rx_data_s;
|
|
|
|
|
|
|
|
wire rx_valid_s = buffer_release_d1;
|
|
|
|
|
|
|
|
wire [7:0] lmfc_counter;
|
|
|
|
wire latency_monitor_reset;
|
|
|
|
|
|
|
|
wire [3*NUM_LANES-1:0] frame_align;
|
|
|
|
wire [NUM_LANES-1:0] ifs_ready;
|
|
|
|
|
|
|
|
wire event_data_phase;
|
|
|
|
wire err_statistics_reset;
|
|
|
|
|
|
|
|
wire lmfc_edge_synced;
|
|
|
|
|
|
|
|
reg [NUM_LANES-1:0] frame_align_err_thresh_met = {NUM_LANES{1'b0}};
|
|
|
|
reg [NUM_LANES-1:0] event_frame_alignment_error_per_lane = {NUM_LANES{1'b0}};
|
|
|
|
|
|
|
|
reg buffer_release_opportunity = 1'b0;
|
|
|
|
|
|
|
|
always @(posedge device_clk) begin
|
|
|
|
if (lmfc_counter == device_cfg_buffer_delay ||
|
|
|
|
device_cfg_buffer_early_release == 1'b1) begin
|
|
|
|
buffer_release_opportunity <= 1'b1;
|
|
|
|
end else begin
|
|
|
|
buffer_release_opportunity <= 1'b0;
|
|
|
|
end
|
2017-05-17 17:28:50 +00:00
|
|
|
end
|
2020-10-27 15:40:37 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
assign all_buffer_ready_n = |(buffer_ready_n & ~cfg_lanes_disable);
|
|
|
|
|
|
|
|
sync_bits #(
|
|
|
|
.NUM_OF_BITS (1),
|
|
|
|
.ASYNC_CLK(ASYNC_CLK)
|
|
|
|
) i_all_buffer_ready_cdc (
|
|
|
|
.in_bits(all_buffer_ready_n),
|
|
|
|
.out_clk(device_clk),
|
|
|
|
.out_resetn(1'b1),
|
|
|
|
.out_bits(dev_all_buffer_ready_n));
|
|
|
|
|
|
|
|
always @(posedge device_clk) begin
|
|
|
|
if (device_reset == 1'b1) begin
|
|
|
|
buffer_release_n <= 1'b1;
|
|
|
|
end else begin
|
|
|
|
if (buffer_release_opportunity == 1'b1) begin
|
|
|
|
buffer_release_n <= dev_all_buffer_ready_n;
|
|
|
|
end
|
2017-05-17 17:28:50 +00:00
|
|
|
end
|
2022-04-08 10:21:52 +00:00
|
|
|
buffer_release_d1 <= ~buffer_release_n;
|
|
|
|
eof_reset <= buffer_release_n;
|
2017-05-17 17:28:50 +00:00
|
|
|
end
|
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
pipeline_stage #(
|
|
|
|
.WIDTH(NUM_LANES + (3 * CW) + HW + DW),
|
|
|
|
.REGISTERED(NUM_INPUT_PIPELINE)
|
|
|
|
) i_input_pipeline_stage (
|
|
|
|
.clk(clk),
|
|
|
|
.in({
|
|
|
|
phy_data,
|
|
|
|
phy_header,
|
|
|
|
phy_charisk,
|
|
|
|
phy_notintable,
|
|
|
|
phy_disperr,
|
|
|
|
phy_block_sync
|
|
|
|
}),
|
|
|
|
.out({
|
|
|
|
phy_data_r,
|
|
|
|
phy_header_r,
|
|
|
|
phy_charisk_r,
|
|
|
|
phy_notintable_r,
|
|
|
|
phy_disperr_r,
|
|
|
|
phy_block_sync_r
|
|
|
|
}));
|
|
|
|
|
|
|
|
pipeline_stage #(
|
|
|
|
.WIDTH(ODW+2),
|
|
|
|
.REGISTERED(NUM_OUTPUT_PIPELINE)
|
|
|
|
) i_output_pipeline_stage (
|
|
|
|
.clk(device_clk),
|
|
|
|
.in({
|
|
|
|
eof_reset,
|
|
|
|
rx_data_s,
|
|
|
|
rx_valid_s
|
|
|
|
}),
|
|
|
|
.out({
|
|
|
|
eof_reset_d,
|
|
|
|
rx_data,
|
|
|
|
rx_valid
|
|
|
|
}));
|
|
|
|
|
|
|
|
// If input and output widths are symmetric keep the calculation for backwards
|
|
|
|
// compatibility of the software.
|
|
|
|
assign device_cfg_beats_per_multiframe_s = (TPL_DATA_PATH_WIDTH == DATA_PATH_WIDTH) ?
|
|
|
|
device_cfg_octets_per_multiframe >> DPW_LOG2 :
|
|
|
|
device_cfg_beats_per_multiframe;
|
|
|
|
|
|
|
|
jesd204_lmfc #(
|
|
|
|
.LINK_MODE (LINK_MODE),
|
|
|
|
.DATA_PATH_WIDTH (TPL_DATA_PATH_WIDTH)
|
|
|
|
) i_lmfc (
|
|
|
|
.clk (device_clk),
|
|
|
|
.reset (device_reset),
|
|
|
|
|
|
|
|
.cfg_octets_per_multiframe (device_cfg_octets_per_multiframe),
|
|
|
|
.cfg_beats_per_multiframe (device_cfg_beats_per_multiframe_s),
|
|
|
|
.cfg_lmfc_offset (device_cfg_lmfc_offset),
|
|
|
|
.cfg_sysref_oneshot (device_cfg_sysref_oneshot),
|
|
|
|
.cfg_sysref_disable (device_cfg_sysref_disable),
|
|
|
|
|
|
|
|
.sysref (sysref),
|
|
|
|
.lmfc_edge (lmfc_edge),
|
|
|
|
.lmfc_clk (lmfc_clk),
|
|
|
|
.lmfc_counter (lmfc_counter),
|
|
|
|
.lmc_edge (),
|
|
|
|
.lmc_quarter_edge (),
|
|
|
|
.eoemb (),
|
|
|
|
|
|
|
|
.sysref_edge (device_event_sysref_edge),
|
|
|
|
.sysref_alignment_error (device_event_sysref_alignment_error));
|
|
|
|
|
|
|
|
jesd204_frame_mark #(
|
|
|
|
.DATA_PATH_WIDTH (TPL_DATA_PATH_WIDTH)
|
|
|
|
) i_frame_mark (
|
|
|
|
.clk (device_clk),
|
|
|
|
.reset (eof_reset_d),
|
|
|
|
.cfg_beats_per_multiframe (device_cfg_beats_per_multiframe_s),
|
|
|
|
.cfg_octets_per_multiframe (device_cfg_octets_per_multiframe),
|
|
|
|
.cfg_octets_per_frame (device_cfg_octets_per_frame),
|
|
|
|
.sof (rx_sof),
|
|
|
|
.eof (rx_eof),
|
|
|
|
.somf (rx_somf),
|
|
|
|
.eomf (rx_eomf));
|
|
|
|
|
|
|
|
generate
|
|
|
|
genvar i;
|
|
|
|
|
|
|
|
sync_event #(
|
|
|
|
.NUM_OF_EVENTS (1),
|
|
|
|
.ASYNC_CLK(ASYNC_CLK)
|
|
|
|
) i_sync_lmfc (
|
|
|
|
.in_clk(device_clk),
|
|
|
|
.in_event(lmfc_edge),
|
|
|
|
.out_clk(clk),
|
|
|
|
.out_event(lmfc_edge_synced));
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
if (LINK_MODE[0] == 1) begin : mode_8b10b
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
wire unexpected_lane_state_error;
|
|
|
|
reg unexpected_lane_state_error_d = 1'b0;
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
jesd204_rx_ctrl #(
|
|
|
|
.NUM_LANES (NUM_LANES),
|
|
|
|
.NUM_LINKS (NUM_LINKS),
|
|
|
|
.ENABLE_FRAME_ALIGN_ERR_RESET (ENABLE_FRAME_ALIGN_ERR_RESET)
|
|
|
|
) i_rx_ctrl (
|
|
|
|
.clk (clk),
|
|
|
|
.reset (reset),
|
2020-10-27 15:40:37 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.cfg_lanes_disable (cfg_lanes_disable),
|
|
|
|
.cfg_links_disable (cfg_links_disable),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.phy_ready (1'b1),
|
|
|
|
.phy_en_char_align (phy_en_char_align),
|
2020-07-21 15:53:23 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.lmfc_edge (lmfc_edge_synced),
|
|
|
|
.frame_align_err_thresh_met (frame_align_err_thresh_met),
|
|
|
|
.sync (sync),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.latency_monitor_reset (latency_monitor_reset),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.cgs_reset (cgs_reset),
|
|
|
|
.cgs_ready (cgs_ready),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.ifs_reset (ifs_reset),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.status_state (status_ctrl_state),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.event_data_phase (event_data_phase));
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
assign err_statistics_reset = ctrl_err_statistics_reset ||
|
|
|
|
event_data_phase;
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
for (i = 0; i < NUM_LANES; i = i + 1) begin: gen_lane
|
2020-09-03 15:37:20 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
localparam D_START = i * DATA_PATH_WIDTH*8;
|
|
|
|
localparam D_STOP = D_START + DATA_PATH_WIDTH*8-1;
|
|
|
|
localparam OD_START = i * TPL_DATA_PATH_WIDTH*8;
|
|
|
|
localparam OD_STOP = OD_START + TPL_DATA_PATH_WIDTH*8-1;
|
|
|
|
localparam C_START = i * DATA_PATH_WIDTH;
|
|
|
|
localparam C_STOP = C_START + DATA_PATH_WIDTH-1;
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
jesd204_rx_lane #(
|
|
|
|
.DATA_PATH_WIDTH(DATA_PATH_WIDTH),
|
|
|
|
.TPL_DATA_PATH_WIDTH(TPL_DATA_PATH_WIDTH),
|
|
|
|
.CHAR_INFO_REGISTERED(CHAR_INFO_REGISTERED),
|
|
|
|
.ALIGN_MUX_REGISTERED(ALIGN_MUX_REGISTERED),
|
|
|
|
.SCRAMBLER_REGISTERED(SCRAMBLER_REGISTERED),
|
|
|
|
.ELASTIC_BUFFER_SIZE(ELASTIC_BUFFER_SIZE),
|
|
|
|
.ENABLE_FRAME_ALIGN_CHECK(ENABLE_FRAME_ALIGN_CHECK),
|
|
|
|
.ENABLE_CHAR_REPLACE(ENABLE_CHAR_REPLACE),
|
|
|
|
.ASYNC_CLK(ASYNC_CLK)
|
|
|
|
) i_lane (
|
|
|
|
.clk(clk),
|
|
|
|
.reset(reset),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.device_clk(device_clk),
|
|
|
|
.device_reset(device_reset),
|
2020-10-27 15:40:37 +00:00
|
|
|
|
2022-04-08 10:21:52 +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]),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.cgs_reset(cgs_reset[i]),
|
|
|
|
.cgs_ready(cgs_ready[i]),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.ifs_reset(ifs_reset[i]),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.rx_data(rx_data_s[OD_STOP:OD_START]),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.buffer_release_n(buffer_release_n),
|
|
|
|
.buffer_ready_n(buffer_ready_n[i]),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.cfg_octets_per_multiframe(cfg_octets_per_multiframe),
|
|
|
|
.cfg_octets_per_frame(cfg_octets_per_frame),
|
|
|
|
.cfg_disable_char_replacement(cfg_disable_char_replacement),
|
|
|
|
.cfg_disable_scrambler(cfg_disable_scrambler),
|
2020-01-29 14:41:43 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.err_statistics_reset(err_statistics_reset),
|
|
|
|
.ctrl_err_statistics_mask(ctrl_err_statistics_mask[2:0]),
|
|
|
|
.status_err_statistics_cnt(status_err_statistics_cnt[32*i+31:32*i]),
|
2018-05-07 12:33:00 +00:00
|
|
|
|
2022-04-08 10:21:52 +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]),
|
2017-05-17 17:28:50 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.status_cgs_state(status_lane_cgs_state[2*i+1:2*i]),
|
|
|
|
.status_ifs_ready(ifs_ready[i]),
|
|
|
|
.status_frame_align(frame_align[3*i+2:3*i]),
|
2020-01-29 14:41:43 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.status_frame_align_err_cnt(status_lane_frame_align_err_cnt[8*i+7:8*i]));
|
2020-01-29 14:41:43 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
if(ENABLE_FRAME_ALIGN_CHECK) begin : gen_frame_align_err_thresh
|
|
|
|
always @(posedge clk) begin
|
|
|
|
if (reset) begin
|
2020-09-25 06:12:34 +00:00
|
|
|
frame_align_err_thresh_met[i] <= 1'b0;
|
|
|
|
event_frame_alignment_error_per_lane[i] <= 1'b0;
|
2022-04-08 10:21:52 +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-09-25 06:12:34 +00:00
|
|
|
end
|
2020-07-21 07:07:57 +00:00
|
|
|
end
|
2022-04-08 10:21:52 +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-30 22:05:13 +00:00
|
|
|
end
|
2020-01-29 14:41:43 +00:00
|
|
|
end
|
2020-01-30 22:05:13 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
assign event_frame_alignment_error = |event_frame_alignment_error_per_lane;
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +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;
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +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;
|
2020-10-27 15:40:37 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
always @(posedge clk) begin
|
|
|
|
ifs_ready_d1 <= ifs_ready;
|
|
|
|
ifs_ready_d2 <= ifs_ready_d1;
|
|
|
|
end
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
always @(*) begin
|
|
|
|
case (SCRAMBLER_REGISTERED + ALIGN_MUX_REGISTERED)
|
|
|
|
1: ifs_ready_mux = ifs_ready_d1;
|
|
|
|
2: ifs_ready_mux = ifs_ready_d2;
|
|
|
|
default: ifs_ready_mux = ifs_ready;
|
|
|
|
endcase
|
|
|
|
end
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
jesd204_lane_latency_monitor #(
|
|
|
|
.NUM_LANES(NUM_LANES),
|
|
|
|
.DATA_PATH_WIDTH(DATA_PATH_WIDTH)
|
|
|
|
) i_lane_latency_monitor (
|
|
|
|
.clk(clk),
|
|
|
|
.reset(latency_monitor_reset),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.lane_ready(ifs_ready_mux),
|
|
|
|
.lane_frame_align(frame_align),
|
|
|
|
.lane_latency_ready(status_lane_ifs_ready),
|
|
|
|
.lane_latency(status_lane_latency));
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
assign status_lane_emb_state = 'b0;
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
end
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
if (LINK_MODE[1] == 1) begin : mode_64b66b
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
wire [NUM_LANES-1:0] emb_lock;
|
|
|
|
wire link_buffer_release_n;
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
sync_bits #(
|
|
|
|
.NUM_OF_BITS (1),
|
2020-10-27 15:40:37 +00:00
|
|
|
.ASYNC_CLK(ASYNC_CLK)
|
2022-04-08 10:21:52 +00:00
|
|
|
) i_buffer_release_cdc (
|
|
|
|
.in_bits(buffer_release_n),
|
|
|
|
.out_clk(clk),
|
|
|
|
.out_resetn(1'b1),
|
|
|
|
.out_bits(link_buffer_release_n));
|
|
|
|
|
|
|
|
jesd204_rx_ctrl_64b #(
|
|
|
|
.NUM_LANES(NUM_LANES)
|
|
|
|
) i_jesd204_rx_ctrl_64b (
|
2019-10-10 07:21:17 +00:00
|
|
|
.clk(clk),
|
2020-01-30 22:05:13 +00:00
|
|
|
.reset(reset),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +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(link_buffer_release_n),
|
|
|
|
|
|
|
|
.status_state(status_ctrl_state),
|
|
|
|
.event_unexpected_lane_state_error(event_unexpected_lane_state_error));
|
2020-10-27 15:40:37 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
for (i = 0; i < NUM_LANES; i = i + 1) begin: gen_lane
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
localparam D_START = i * DATA_PATH_WIDTH*8;
|
|
|
|
localparam D_STOP = D_START + DATA_PATH_WIDTH*8-1;
|
|
|
|
localparam TPL_D_START = i * TPL_DATA_PATH_WIDTH*8;
|
|
|
|
localparam TPL_D_STOP = TPL_D_START + TPL_DATA_PATH_WIDTH*8-1;
|
|
|
|
localparam H_START = i * 2;
|
|
|
|
localparam H_STOP = H_START + 2-1;
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
wire [7:0] status_lane_skew;
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
jesd204_rx_lane_64b #(
|
|
|
|
.ELASTIC_BUFFER_SIZE(ELASTIC_BUFFER_SIZE),
|
|
|
|
.TPL_DATA_PATH_WIDTH(TPL_DATA_PATH_WIDTH),
|
|
|
|
.ASYNC_CLK(ASYNC_CLK)
|
|
|
|
) i_lane (
|
|
|
|
.clk(clk),
|
|
|
|
.reset(reset),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.device_clk(device_clk),
|
|
|
|
.device_reset(device_reset),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +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]),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.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),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.rx_data(rx_data_s[TPL_D_STOP:TPL_D_START]),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.buffer_release_n(buffer_release_n),
|
|
|
|
.buffer_ready_n(buffer_ready_n[i]),
|
|
|
|
.all_buffer_ready_n(all_buffer_ready_n),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.lmfc_edge(lmfc_edge_synced),
|
|
|
|
.emb_lock(emb_lock[i]),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.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]),
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
.status_lane_emb_state(status_lane_emb_state[3*i+2:3*i]),
|
|
|
|
.status_lane_skew(status_lane_skew));
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
assign status_lane_latency[14*(i+1)-1:14*i] = {3'b0,status_lane_skew,3'b0};
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
// Assign unused outputs
|
|
|
|
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}};
|
|
|
|
assign event_frame_alignment_error = 1'b0;
|
|
|
|
|
|
|
|
end
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
endgenerate
|
|
|
|
|
|
|
|
// Core static parameters
|
|
|
|
assign status_synth_params0 = {NUM_LANES};
|
|
|
|
assign status_synth_params1 = {
|
|
|
|
/*31:16 */ 16'b0,
|
|
|
|
/*15: 8 */ 1'b0,TPL_DATA_PATH_WIDTH[6:0],
|
|
|
|
/* 7: 0 */ 4'b0,DPW_LOG2[3:0]};
|
|
|
|
assign status_synth_params2 = {
|
|
|
|
/*31:19 */ 13'b0,
|
|
|
|
/* 18 */ ENABLE_CHAR_REPLACE[0],
|
|
|
|
/* 17 */ ENABLE_FRAME_ALIGN_ERR_RESET[0],
|
|
|
|
/* 16 */ ENABLE_FRAME_ALIGN_CHECK[0],
|
|
|
|
/*15:13 */ 3'b0,
|
|
|
|
/* 12 */ ASYNC_CLK[0],
|
|
|
|
/*11:10 */ 2'b0,
|
|
|
|
/* 9: 8 */ LINK_MODE[1:0],
|
|
|
|
/* 7: 0 */ NUM_LINKS[7:0]};
|
2019-10-10 07:21:17 +00:00
|
|
|
|
2017-05-17 17:28:50 +00:00
|
|
|
endmodule
|