`timescale 1ns / 1ps
/*
   This file was generated automatically by Alchitry Labs version 1.2.0.
   Do not edit this file directly. Instead edit the original Lucid source.
   This is a temporary file and any changes made to it will be destroyed.
*/

/*
   Parameters:
     FACTOR = 5
*/
module serdes_n_to_1 (
    input ioclk,
    input strobe,
    input rst,
    input gclk,
    input [4:0] data,
    output reg iob_out
  );
  
  localparam FACTOR = 3'h5;
  
  
  reg [7:0] padded_data;
  
  integer i;
  
  wire [1-1:0] M_mserdes_OQ;
  wire [1-1:0] M_mserdes_TQ;
  wire [1-1:0] M_mserdes_SHIFTOUT1;
  wire [1-1:0] M_mserdes_SHIFTOUT2;
  wire [1-1:0] M_mserdes_SHIFTOUT3;
  wire [1-1:0] M_mserdes_SHIFTOUT4;
  reg [1-1:0] M_mserdes_IOCE;
  reg [1-1:0] M_mserdes_D1;
  reg [1-1:0] M_mserdes_D2;
  reg [1-1:0] M_mserdes_D3;
  reg [1-1:0] M_mserdes_D4;
  reg [1-1:0] M_mserdes_OCE;
  reg [1-1:0] M_mserdes_T1;
  reg [1-1:0] M_mserdes_T2;
  reg [1-1:0] M_mserdes_T3;
  reg [1-1:0] M_mserdes_T4;
  reg [1-1:0] M_mserdes_TCE;
  reg [1-1:0] M_mserdes_SHIFTIN1;
  reg [1-1:0] M_mserdes_SHIFTIN2;
  reg [1-1:0] M_mserdes_SHIFTIN3;
  reg [1-1:0] M_mserdes_SHIFTIN4;
  reg [1-1:0] M_mserdes_TRAIN;
  OSERDES2 #(.DATA_WIDTH(5), .DATA_RATE_OQ("SDR"), .DATA_RATE_OT("SDR"), .SERDES_MODE("MASTER"), .OUTPUT_MODE("DIFFERENTIAL")) mserdes (
    .CLK0(ioclk),
    .CLK1(1'h0),
    .RST(rst),
    .CLKDIV(gclk),
    .IOCE(M_mserdes_IOCE),
    .D1(M_mserdes_D1),
    .D2(M_mserdes_D2),
    .D3(M_mserdes_D3),
    .D4(M_mserdes_D4),
    .OCE(M_mserdes_OCE),
    .T1(M_mserdes_T1),
    .T2(M_mserdes_T2),
    .T3(M_mserdes_T3),
    .T4(M_mserdes_T4),
    .TCE(M_mserdes_TCE),
    .SHIFTIN1(M_mserdes_SHIFTIN1),
    .SHIFTIN2(M_mserdes_SHIFTIN2),
    .SHIFTIN3(M_mserdes_SHIFTIN3),
    .SHIFTIN4(M_mserdes_SHIFTIN4),
    .TRAIN(M_mserdes_TRAIN),
    .OQ(M_mserdes_OQ),
    .TQ(M_mserdes_TQ),
    .SHIFTOUT1(M_mserdes_SHIFTOUT1),
    .SHIFTOUT2(M_mserdes_SHIFTOUT2),
    .SHIFTOUT3(M_mserdes_SHIFTOUT3),
    .SHIFTOUT4(M_mserdes_SHIFTOUT4)
  );
  
  wire [1-1:0] M_sserdes_OQ;
  wire [1-1:0] M_sserdes_TQ;
  wire [1-1:0] M_sserdes_SHIFTOUT1;
  wire [1-1:0] M_sserdes_SHIFTOUT2;
  wire [1-1:0] M_sserdes_SHIFTOUT3;
  wire [1-1:0] M_sserdes_SHIFTOUT4;
  reg [1-1:0] M_sserdes_IOCE;
  reg [1-1:0] M_sserdes_D1;
  reg [1-1:0] M_sserdes_D2;
  reg [1-1:0] M_sserdes_D3;
  reg [1-1:0] M_sserdes_D4;
  reg [1-1:0] M_sserdes_OCE;
  reg [1-1:0] M_sserdes_T1;
  reg [1-1:0] M_sserdes_T2;
  reg [1-1:0] M_sserdes_T3;
  reg [1-1:0] M_sserdes_T4;
  reg [1-1:0] M_sserdes_TCE;
  reg [1-1:0] M_sserdes_SHIFTIN1;
  reg [1-1:0] M_sserdes_SHIFTIN2;
  reg [1-1:0] M_sserdes_SHIFTIN3;
  reg [1-1:0] M_sserdes_SHIFTIN4;
  reg [1-1:0] M_sserdes_TRAIN;
  OSERDES2 #(.DATA_WIDTH(5), .DATA_RATE_OQ("SDR"), .DATA_RATE_OT("SDR"), .SERDES_MODE("SLAVE"), .OUTPUT_MODE("DIFFERENTIAL")) sserdes (
    .CLK0(ioclk),
    .CLK1(1'h0),
    .RST(rst),
    .CLKDIV(gclk),
    .IOCE(M_sserdes_IOCE),
    .D1(M_sserdes_D1),
    .D2(M_sserdes_D2),
    .D3(M_sserdes_D3),
    .D4(M_sserdes_D4),
    .OCE(M_sserdes_OCE),
    .T1(M_sserdes_T1),
    .T2(M_sserdes_T2),
    .T3(M_sserdes_T3),
    .T4(M_sserdes_T4),
    .TCE(M_sserdes_TCE),
    .SHIFTIN1(M_sserdes_SHIFTIN1),
    .SHIFTIN2(M_sserdes_SHIFTIN2),
    .SHIFTIN3(M_sserdes_SHIFTIN3),
    .SHIFTIN4(M_sserdes_SHIFTIN4),
    .TRAIN(M_sserdes_TRAIN),
    .OQ(M_sserdes_OQ),
    .TQ(M_sserdes_TQ),
    .SHIFTOUT1(M_sserdes_SHIFTOUT1),
    .SHIFTOUT2(M_sserdes_SHIFTOUT2),
    .SHIFTOUT3(M_sserdes_SHIFTOUT3),
    .SHIFTOUT4(M_sserdes_SHIFTOUT4)
  );
  
  always @* begin
    padded_data = 8'h00;
    for (i = 1'h0; i < 3'h5; i = i + 1) begin
      padded_data[(i)*1+0-:1] = data[(i)*1+0-:1];
    end
    M_mserdes_OCE = 1'h1;
    M_mserdes_IOCE = strobe;
    M_mserdes_D4 = padded_data[7+0-:1];
    M_mserdes_D3 = padded_data[6+0-:1];
    M_mserdes_D2 = padded_data[5+0-:1];
    M_mserdes_D1 = padded_data[4+0-:1];
    M_mserdes_T1 = 1'h0;
    M_mserdes_T2 = 1'h0;
    M_mserdes_T3 = 1'h0;
    M_mserdes_T4 = 1'h0;
    M_mserdes_TRAIN = 1'h0;
    M_mserdes_TCE = 1'h1;
    M_mserdes_SHIFTIN1 = 1'h1;
    M_mserdes_SHIFTIN2 = 1'h1;
    M_mserdes_SHIFTIN3 = M_sserdes_SHIFTOUT3;
    M_mserdes_SHIFTIN4 = M_sserdes_SHIFTOUT4;
    M_sserdes_OCE = 1'h1;
    M_sserdes_IOCE = strobe;
    M_sserdes_D4 = padded_data[3+0-:1];
    M_sserdes_D3 = padded_data[2+0-:1];
    M_sserdes_D2 = padded_data[1+0-:1];
    M_sserdes_D1 = padded_data[0+0-:1];
    M_sserdes_T1 = 1'h0;
    M_sserdes_T2 = 1'h0;
    M_sserdes_T3 = 1'h0;
    M_sserdes_T4 = 1'h0;
    M_sserdes_TRAIN = 1'h0;
    M_sserdes_TCE = 1'h1;
    M_sserdes_SHIFTIN1 = M_mserdes_SHIFTOUT1;
    M_sserdes_SHIFTIN2 = M_mserdes_SHIFTOUT2;
    M_sserdes_SHIFTIN3 = 1'h1;
    M_sserdes_SHIFTIN4 = 1'h1;
    iob_out = M_mserdes_OQ;
  end
endmodule