module io_phs_pair_couple_x48 (
input            c_in_p,
input            c_in_n,
input            phy_clk_phs_ctrl,
input            snc,
input            spc,
input      [5:0] r_gray,
input      [5:0] f_gray,
output           c_out_p,
output           c_out_n 
);

`ifdef TIMESCALE_EN
                timeunit 1ps;
                timeprecision 1ps;
`endif

parameter STEP_DELAY = 40;

reg c_in_del;

wire         c_in_p_gated;
wire         c_in_n_gated;
wire  [48:0] c_in_p_f;
wire  [48:0] c_in_p_r;

assign  {c_in_n_gated,c_in_p_gated} = phy_clk_phs_ctrl? {c_in_n,c_in_p}: 2'b10;

assign #54  c_in_p_f[0] = c_in_p_gated;
assign #57  c_in_p_f[1] = c_in_p_gated;
assign #60  c_in_p_f[2] = c_in_p_gated;
assign #63  c_in_p_f[3] = c_in_p_gated;
assign #66  c_in_p_f[4] = c_in_p_gated;
assign #69  c_in_p_f[5] = c_in_p_gated;
assign #72  c_in_p_f[6] = c_in_p_gated;
assign #75  c_in_p_f[7] = c_in_p_gated;
assign #78  c_in_p_f[8] = c_in_p_gated;
assign #81  c_in_p_f[9] = c_in_p_gated;
assign #84  c_in_p_f[10] = c_in_p_gated;
assign #87  c_in_p_f[11] = c_in_p_gated;
assign #90  c_in_p_f[12] = c_in_p_gated;
assign #93  c_in_p_f[13] = c_in_p_gated;
assign #96  c_in_p_f[14] = c_in_p_gated;
assign #99  c_in_p_f[15] = c_in_p_gated;
assign #102  c_in_p_f[16] = c_in_p_gated;
assign #105  c_in_p_f[17] = c_in_p_gated;
assign #108  c_in_p_f[18] = c_in_p_gated;
assign #111  c_in_p_f[19] = c_in_p_gated;
assign #114  c_in_p_f[20] = c_in_p_gated;
assign #117  c_in_p_f[21] = c_in_p_gated;
assign #120  c_in_p_f[22] = c_in_p_gated;
assign #123  c_in_p_f[23] = c_in_p_gated;
assign #126  c_in_p_f[24] = c_in_p_gated;
assign #129  c_in_p_f[25] = c_in_p_gated;
assign #132  c_in_p_f[26] = c_in_p_gated;
assign #135  c_in_p_f[27] = c_in_p_gated;
assign #138  c_in_p_f[28] = c_in_p_gated;
assign #141  c_in_p_f[29] = c_in_p_gated;
assign #144  c_in_p_f[30] = c_in_p_gated;
assign #147  c_in_p_f[31] = c_in_p_gated;
assign #150  c_in_p_f[32] = c_in_p_gated;
assign #153  c_in_p_f[33] = c_in_p_gated;
assign #156  c_in_p_f[34] = c_in_p_gated;
assign #159  c_in_p_f[35] = c_in_p_gated;
assign #162  c_in_p_f[36] = c_in_p_gated;
assign #165  c_in_p_f[37] = c_in_p_gated;
assign #168  c_in_p_f[38] = c_in_p_gated;
assign #171  c_in_p_f[39] = c_in_p_gated;
assign #174  c_in_p_f[40] = c_in_p_gated;
assign #177  c_in_p_f[41] = c_in_p_gated;
assign #180  c_in_p_f[42] = c_in_p_gated;
assign #183  c_in_p_f[43] = c_in_p_gated;
assign #186  c_in_p_f[44] = c_in_p_gated;
assign #189  c_in_p_f[45] = c_in_p_gated;
assign #192  c_in_p_f[46] = c_in_p_gated;
assign #195  c_in_p_f[47] = c_in_p_gated;
assign #198  c_in_p_f[48] = c_in_p_gated;

assign #54  c_in_p_r[0] = c_in_p_gated;
assign #57  c_in_p_r[1] = c_in_p_gated;
assign #60  c_in_p_r[2] = c_in_p_gated;
assign #63  c_in_p_r[3] = c_in_p_gated;
assign #66  c_in_p_r[4] = c_in_p_gated;
assign #69  c_in_p_r[5] = c_in_p_gated;
assign #72  c_in_p_r[6] = c_in_p_gated;
assign #75  c_in_p_r[7] = c_in_p_gated;
assign #78  c_in_p_r[8] = c_in_p_gated;
assign #81  c_in_p_r[9] = c_in_p_gated;
assign #84  c_in_p_r[10] = c_in_p_gated;
assign #87  c_in_p_r[11] = c_in_p_gated;
assign #90  c_in_p_r[12] = c_in_p_gated;
assign #93  c_in_p_r[13] = c_in_p_gated;
assign #96  c_in_p_r[14] = c_in_p_gated;
assign #99  c_in_p_r[15] = c_in_p_gated;
assign #102  c_in_p_r[16] = c_in_p_gated;
assign #105  c_in_p_r[17] = c_in_p_gated;
assign #108  c_in_p_r[18] = c_in_p_gated;
assign #111  c_in_p_r[19] = c_in_p_gated;
assign #114  c_in_p_r[20] = c_in_p_gated;
assign #117  c_in_p_r[21] = c_in_p_gated;
assign #120  c_in_p_r[22] = c_in_p_gated;
assign #123  c_in_p_r[23] = c_in_p_gated;
assign #126  c_in_p_r[24] = c_in_p_gated;
assign #129  c_in_p_r[25] = c_in_p_gated;
assign #132  c_in_p_r[26] = c_in_p_gated;
assign #135  c_in_p_r[27] = c_in_p_gated;
assign #138  c_in_p_r[28] = c_in_p_gated;
assign #141  c_in_p_r[29] = c_in_p_gated;
assign #144  c_in_p_r[30] = c_in_p_gated;
assign #147  c_in_p_r[31] = c_in_p_gated;
assign #150  c_in_p_r[32] = c_in_p_gated;
assign #153  c_in_p_r[33] = c_in_p_gated;
assign #156  c_in_p_r[34] = c_in_p_gated;
assign #159  c_in_p_r[35] = c_in_p_gated;
assign #162  c_in_p_r[36] = c_in_p_gated;
assign #165  c_in_p_r[37] = c_in_p_gated;
assign #168  c_in_p_r[38] = c_in_p_gated;
assign #171  c_in_p_r[39] = c_in_p_gated;
assign #174  c_in_p_r[40] = c_in_p_gated;
assign #177  c_in_p_r[41] = c_in_p_gated;
assign #180  c_in_p_r[42] = c_in_p_gated;
assign #183  c_in_p_r[43] = c_in_p_gated;
assign #186  c_in_p_r[44] = c_in_p_gated;
assign #189  c_in_p_r[45] = c_in_p_gated;
assign #192  c_in_p_r[46] = c_in_p_gated;
assign #195  c_in_p_r[47] = c_in_p_gated;
assign #198  c_in_p_r[48] = c_in_p_gated;

always @(*)
  if (c_in_p == 1'b0)
    begin
      case (f_gray[5:0])
       6'h00 : c_in_del =  c_in_p_f[0];
       6'h01 : c_in_del =  c_in_p_f[1];
       6'h03 : c_in_del =  c_in_p_f[2];
       6'h02 : c_in_del =  c_in_p_f[3];
       6'h06 : c_in_del =  c_in_p_f[4];
       6'h07 : c_in_del =  c_in_p_f[5];
       6'h05 : c_in_del =  c_in_p_f[6];
       6'h04 : c_in_del =  c_in_p_f[7];
       6'h0C : c_in_del =  c_in_p_f[8];
       6'h0D : c_in_del =  c_in_p_f[9];
       6'h0F : c_in_del =  c_in_p_f[10];
       6'h0E : c_in_del =  c_in_p_f[11];
       6'h0A : c_in_del =  c_in_p_f[12];
       6'h0B : c_in_del =  c_in_p_f[13];
       6'h09 : c_in_del =  c_in_p_f[14];
       6'h08 : c_in_del =  c_in_p_f[15];
       6'h18 : c_in_del =  c_in_p_f[16];
       6'h19 : c_in_del =  c_in_p_f[17];
       6'h1B : c_in_del =  c_in_p_f[18];
       6'h1A : c_in_del =  c_in_p_f[19];
       6'h1E : c_in_del =  c_in_p_f[20];
       6'h1F : c_in_del =  c_in_p_f[21];
       6'h1D : c_in_del =  c_in_p_f[22];
       6'h1C : c_in_del =  c_in_p_f[23];
       6'h14 : c_in_del = c_in_p_f[24];
       6'h15 : c_in_del = c_in_p_f[25];
       6'h17 : c_in_del = c_in_p_f[26];
       6'h16 : c_in_del = c_in_p_f[27];
       6'h12 : c_in_del = c_in_p_f[28];
       6'h13 : c_in_del = c_in_p_f[29];
       6'h11 : c_in_del = c_in_p_f[30];
       6'h10 : c_in_del = c_in_p_f[31];
       6'h30 : c_in_del = c_in_p_f[32];
       6'h31 : c_in_del = c_in_p_f[33];
       6'h33 : c_in_del = c_in_p_f[34];
       6'h32 : c_in_del = c_in_p_f[35];
       6'h36 : c_in_del = c_in_p_f[36];
       6'h37 : c_in_del = c_in_p_f[37];
       6'h35 : c_in_del = c_in_p_f[38];
       6'h34 : c_in_del = c_in_p_f[39];
       6'h3C : c_in_del = c_in_p_f[40];
       6'h3D : c_in_del = c_in_p_f[41];
       6'h3F : c_in_del = c_in_p_f[42];
       6'h3E : c_in_del = c_in_p_f[43];
       6'h3A : c_in_del = c_in_p_f[44];
       6'h3B : c_in_del = c_in_p_f[45];
       6'h39 : c_in_del = c_in_p_f[46];
       6'h38 : c_in_del = c_in_p_f[47];
       default : c_in_del = c_in_p_f[48];
       endcase
    end
  else if (c_in_p == 1'b1)
    begin
      case (r_gray[5:0])
       6'h00 : c_in_del =   c_in_p_r[0];
       6'h01 : c_in_del =   c_in_p_r[1];
       6'h03 : c_in_del =   c_in_p_r[2];
       6'h02 : c_in_del =   c_in_p_r[3];
       6'h06 : c_in_del =   c_in_p_r[4];
       6'h07 : c_in_del =   c_in_p_r[5];
       6'h05 : c_in_del =   c_in_p_r[6];
       6'h04 : c_in_del =   c_in_p_r[7];
       6'h0C : c_in_del =   c_in_p_r[8];
       6'h0D : c_in_del =   c_in_p_r[9];
       6'h0F : c_in_del =   c_in_p_r[10];
       6'h0E : c_in_del =   c_in_p_r[11];
       6'h0A : c_in_del =   c_in_p_r[12];
       6'h0B : c_in_del =   c_in_p_r[13];
       6'h09 : c_in_del =   c_in_p_r[14];
       6'h08 : c_in_del =   c_in_p_r[15];
       6'h18 : c_in_del =   c_in_p_r[16];
       6'h19 : c_in_del =   c_in_p_r[17];
       6'h1B : c_in_del =   c_in_p_r[18];
       6'h1A : c_in_del =   c_in_p_r[19];
       6'h1E : c_in_del =   c_in_p_r[20];
       6'h1F : c_in_del =   c_in_p_r[21];
       6'h1D : c_in_del =   c_in_p_r[22];
       6'h1C : c_in_del =   c_in_p_r[23];
       6'h14 : c_in_del =   c_in_p_r[24];
       6'h15 : c_in_del =   c_in_p_r[25];
       6'h17 : c_in_del =   c_in_p_r[26];
       6'h16 : c_in_del =   c_in_p_r[27];
       6'h12 : c_in_del =   c_in_p_r[28];
       6'h13 : c_in_del =   c_in_p_r[29];
       6'h11 : c_in_del =   c_in_p_r[30];
       6'h10 : c_in_del =   c_in_p_r[31];
       6'h30 : c_in_del =   c_in_p_r[32];
       6'h31 : c_in_del =   c_in_p_r[33];
       6'h33 : c_in_del =   c_in_p_r[34];
       6'h32 : c_in_del =   c_in_p_r[35];
       6'h36 : c_in_del =   c_in_p_r[36];
       6'h37 : c_in_del =   c_in_p_r[37];
       6'h35 : c_in_del =   c_in_p_r[38];
       6'h34 : c_in_del =   c_in_p_r[39];
       6'h3C : c_in_del =   c_in_p_r[40];
       6'h3D : c_in_del =   c_in_p_r[41];
       6'h3F : c_in_del =   c_in_p_r[42];
       6'h3E : c_in_del =   c_in_p_r[43];
       6'h3A : c_in_del =   c_in_p_r[44];
       6'h3B : c_in_del =   c_in_p_r[45];
       6'h39 : c_in_del =   c_in_p_r[46];
       6'h38 : c_in_del =   c_in_p_r[47];
       default : c_in_del = c_in_p_r[48];
       endcase
    end

assign c_out_p =  c_in_del;
assign c_out_n = ~c_in_del;

endmodule