//=============================================================================
// Instructions: Add TIMING_DEBUG_LOGGER to SLVS_EC_RX.v
//=============================================================================

STEP 1: SLVS_EC_RX top module already has CALIBRATING inputs (DONE ✓)
STEP 2: SLVS_EC_RX top module already has debug outputs (DONE ✓)

STEP 3: Instantiate TIMING_DEBUG_LOGGER in SLVS_EC_RX_Native module
        (Add after line ~1250, after slvsec_phy_rx_7 instantiation)

//--------TIMING_DEBUG_LOGGER (Debug only - for timing analysis)
TIMING_DEBUG_LOGGER timing_debug_lane0 (
    // Inputs
    .clk                  ( LANE0_RX_CLK_I ),
    .rstn                 ( CAM_CLK_L0_ARST_N ),
    .rx_ready             ( LANE0_RX_READY_I ),
    .rx_valid             ( LANE0_RX_VALID_I ),
    .calibrating          ( LANE0_CALIBRATING_I ),   // Connect from top-level input
    .sync_detected        ( 1'b0 ),                  // Pattern detected from rx_data
    .start_detected       ( 1'b0 ),                  // Pattern detected from rx_data
    .rx_data              ( LANE0_RX_DATA_I ),
    // Outputs
    .time_rx_ready        ( DEBUG_TIME_RX_READY ),
    .time_rx_valid        ( DEBUG_TIME_RX_VALID ),
    .time_calib_start     ( DEBUG_TIME_CALIB_START ),
    .time_calib_done      ( DEBUG_TIME_CALIB_DONE ),
    .time_sync_detected   ( DEBUG_TIME_SYNC ),
    .time_start_detected  ( DEBUG_TIME_START ),
    .flag_rx_ready        (  ),  // Not used
    .flag_rx_valid        (  ),  // Not used
    .flag_calib_seen      (  ),  // Not used
    .flag_sync_seen       ( DEBUG_FLAG_SYNC ),
    .flag_start_seen      ( DEBUG_FLAG_START )
);


STEP 4: Pass CALIBRATING through SLVS_EC_RX_Native
        (This is complex - need to add to Native module interface)

        For now, simpler approach:

        CONNECT directly in top SLVS_EC_RX instantiation area:

// In generate if (g_FORMAT == 0) section, after SLVS_EC_RX_Native instantiation:
TIMING_DEBUG_LOGGER timing_debug_top (
    .clk                  ( LANE0_RX_CLK_I ),
    .rstn                 ( r_LANE0_RST_N ),
    .rx_ready             ( LANE0_RX_READY_I ),
    .rx_valid             ( LANE0_RX_VALID_I ),
    .calibrating          ( LANE0_CALIBRATING_I ),
    .sync_detected        ( 1'b0 ),
    .start_detected       ( 1'b0 ),
    .rx_data              ( LANE0_RX_DATA_I ),

    .time_rx_ready        ( DEBUG_TIME_RX_READY ),
    .time_rx_valid        ( DEBUG_TIME_RX_VALID ),
    .time_calib_start     ( DEBUG_TIME_CALIB_START ),
    .time_calib_done      ( DEBUG_TIME_CALIB_DONE ),
    .time_sync_detected   ( DEBUG_TIME_SYNC ),
    .time_start_detected  ( DEBUG_TIME_START ),
    .flag_rx_ready        (  ),
    .flag_rx_valid        (  ),
    .flag_calib_seen      (  ),
    .flag_sync_seen       ( DEBUG_FLAG_SYNC ),
    .flag_start_seen      ( DEBUG_FLAG_START )
);


STEP 5: In IMX_TOP, connect CALIBRATING signals:

SLVS_EC_RX_C0_0(
    ...
    .LANE0_CALIBRATING_I ( PF_XCVR_ERM_C2_0_LANE0_CALIBRATING ),
    .LANE1_CALIBRATING_I ( PF_XCVR_ERM_C2_0_LANE1_CALIBRATING ),
    ...
    .LANE7_CALIBRATING_I ( PF_XCVR_ERM_C1_0_LANE3_CALIBRATING ),

    // Debug outputs
    .DEBUG_TIME_RX_READY     ( debug_time_ready ),
    .DEBUG_TIME_RX_VALID     ( debug_time_valid ),
    .DEBUG_TIME_CALIB_START  ( debug_time_calib_start ),
    .DEBUG_TIME_CALIB_DONE   ( debug_time_calib_done ),
    .DEBUG_TIME_SYNC         ( debug_time_sync ),
    .DEBUG_TIME_START        ( debug_time_start ),
    .DEBUG_FLAG_SYNC         ( debug_flag_sync ),
    .DEBUG_FLAG_START        ( debug_flag_start )
);

// Expose to top level or ChipScope
