      qdr_cq_p,     //QDR clock CQ
  input       [NUM_DEVICES-1:0]          qdr_cq_n,     //QDR clock CQ#
  input   [DATA_WIDTH-1 :0]              qdr_q,

  input [(HIGHEST_LANE*12)-1:0]          O,   // input coming from mc_phy to drive out qdr output signals
  output [(HIGHEST_LANE*12)-1:0]         I    // read data coming from memory provided out to hard phy
  );

  wire [DATA_WIDTH-1:0]    in_dq;
  wire [DATA_WIDTH-1:0]    in_q;
  wire [ADDR_WIDTH-1:0]    out_sa;
  wire [BW_WIDTH-1:0]      out_bw_n;
  wire                     out_w_n;
  wire                     out_r_n;
  wire [DATA_WIDTH-1:0]    out_dq;
  wire [DATA_WIDTH-1:0]    out_d;
  wire [DATA_WIDTH-1:0]    ts_dq;
  
  //want this to be an inout port (add later)
  wire [DATA_WIDTH-1:0]    qdr_dq;
  
  reg  [DATA_WIDTH-1:0]    q_dly_inc;
  reg  [DATA_WIDTH-1:0]    q_dly_ce;
  
  //These are for dealing with 2:1 or 4:1 widths
  localparam MAP0 = 320;
  localparam MAP1 = 80;
  localparam MAP2 = 8;
  
  localparam DIN_MAP0 = MAP0;
  localparam DIN_MAP1 = MAP1;
  localparam DIN_MAP2 = MAP2;

  // ratio of DQS per DQ  // rd data7 assignment
  localparam BYTE_WIDTH = (DATA_WIDTH/BW_WIDTH); //=9 for QDR
  // Localparam to have the byte lane information for each byte 
  localparam CALIB_BYTE_LANE ={Q7_MAP[5:4],Q6_MAP[5:4],
			      Q5_MAP[5:4],Q4_MAP[5:4],Q3_MAP[5:4],
			      Q2_MAP[5:4],Q1_MAP[5:4],Q0_MAP[5:4]};
  // localparam to have the bank information for each byte 
  localparam CALIB_BANK = {Q7_MAP[10:8],Q6_MAP[10:8],
			  Q5_MAP[10:8],Q4_MAP[10:8],Q3_MAP[10:8],
			  Q2_MAP[10:8],Q1_MAP[10:8],Q0_MAP[10:8]};      
			  
   localparam READ_DATA_MAP = {Q7_MAP, Q6_MAP, Q5_MAP, Q4_MAP,
                                 Q3_MAP, Q2_MAP, Q1_MAP, Q0_MAP};
                                 
   // number of data phases per internal clock
  localparam PHASE_PER_CLK = 2*nCK_PER_CLK;
  
  localparam FULL_D_MAP = {D7_MAP[12*BYTE_WIDTH-1:0],  
                           D6_MAP[12*BYTE_WIDTH-1:0],
                           D5_MAP[12*BYTE_WIDTH-1:0],  
                           D4_MAP[12*BYTE_WIDTH-1:0],  
                           D3_MAP[12*BYTE_WIDTH-1:0],  
                           D2_MAP[12*BYTE_WIDTH-1:0],  
                           D1_MAP[12*BYTE_WIDTH-1:0],  
                           D0_MAP[12*BYTE_WIDTH-1:0]};
   
	                  
   // In the phy_dout bus, output signals that need to be driven out of the fpga are arranged as follows and provided to the
   //      mc_phy: {signals within bank4, bank3, bank2, bank1, bank0}
   // & within a bank the assignment is as follows: {bytelane3, bytelane2, bytelane1, bytelane0}
   // and for each byte lane, the assignment is {bit 11, bit 10, bit9,.......bit1, bit0} to accommodate the 12 bits
   //  As the QDRII+ interface is used in the 2:1 mode, 4 bit data is provided for each IO signal.
   // The higher order 2 bits inside the byte group are driven for only the Address/control byte group.
   // Write byte groups drive out only the lower 10 bits inside the byte group   

  generate
    genvar m, n;
  // System Clock
!WuPA30	Τ6