pipe_rx13_valid, pipe_rx12_valid, 
         pipe_rx11_valid, pipe_rx10_valid, 
	       pipe_rx09_valid, pipe_rx08_valid, 
         pipe_rx07_valid, pipe_rx06_valid, 
	       pipe_rx05_valid, pipe_rx04_valid, 
         pipe_rx03_valid, pipe_rx02_valid, 
	       pipe_rx01_valid, pipe_rx00_valid} = (PL_LINK_CAP_MAX_LINK_WIDTH == 16 ? PHY_RXVALID_i : {{((16-PL_LINK_CAP_MAX_LINK_WIDTH) * 1){1'b0}},PHY_RXVALID_i});


// Soft fix to pass phystatus[0] (the last-done lane) to all other lanes in TO_2_DETECT state to make sure all other lanes are done.

always @(posedge pipe_clk or posedge sys_or_hot_rst) begin
   if (sys_or_hot_rst) begin
      pipe_tx_rate_ff   <= 3'b000;
   end else begin
      pipe_tx_rate_ff   <= pipe_tx_rate_i;
   end
end

always @(posedge pipe_clk or posedge sys_or_hot_rst) begin
   if (sys_or_hot_rst) begin
      speed_change_in_progress <= 1'b0;
   end else if (pipe_tx_rate_i != pipe_tx_rate_ff) begin
      speed_change_in_progress <= 1'b1;
   end else if (pipe_rx00_phy_status) begin
      speed_change_in_progress <= 1'b0;
   end
end

assign phy_status_fix   = (speed_change_in_progress)? {PL_LINK_CAP_MAX_LINK_WIDTH{PHY_PHYSTATUS_i[0]}}: PHY_PHYSTATUS_i;
assign { pipe_rx15_phy_status, pipe_rx14_phy_status, 
	       pipe_rx13_phy_status, pipe_rx12_phy_status, 
         pipe_rx11_phy_status, pipe_rx10_phy_status, 
	       pipe_rx09_phy_status, pipe_rx08_phy_status, 
         pipe_rx07_phy_status, pipe_rx06_phy_status, 
	       pipe_rx05_phy_status, pipe_rx04_phy_status, 
         pipe_rx03_phy_status, pipe_rx02_phy_status, 
	       pipe_rx01_phy_status, pipe_rx00_phy_status} = (PL_LINK_CAP_MAX_LINK_WIDTH == 16 ? phy_status_fix : {{((16-PL_LINK_CAP_MAX_LINK_WIDTH) * 1){1'b0}},phy_status_fix});

assign { pipe_rx15_elec_idle, pipe_rx14_elec_idle, pipe_rx13_elec_idle, pipe_rx12_elec_idle, 
         pipe_rx11_elec_idle, pipe_rx10_elec_idle, pipe_rx09_elec_idle, pipe_rx08_elec_idle, 
         pipe_rx07_elec_idle, pipe_rx06_elec_idle, pipe_rx05_elec_idle, pipe_rx04_elec_idle, 
         pipe_rx03_elec_idle, p