anchor.diff:     rule sendup_init;
      endrule
   
  -   rule sendup_connect;
  -       sensor.align_BUSY_d(align_BUSY_d_wire);
  -       sensor.alignED_d(alignED_d_wire);
  -       sensor.sampleinFIRSTBIT(sampleinFIRSTBIT_wire);
  -       sensor.sampleinLASTBIT(sampleinLASTBIT_wire);
  -       sensor.sampleinOTHERBIT(sampleinOTHERBIT_wire);
  -       sensor.fifo_EMPTY_d(fifo_EMPTY_d_wire);
  -       sensor.raw_data(raw_data_wire);
  -   endrule
  -
      rule sendup;
  -   Bit#(5) emptyw = 0;
  -   Bit#(5) firstw = 0;
  -   Bit#(5) lastw = 0;
  -   //Bit#(5) otherw = 0;
  -   Bit#(5) alignedw = 0;
  -   Bit#(5) alignbusyw = 0;
  -   Bit#(50) rawdataw = 0;
  -   for (Bit#(8) i = 0; i < 5; i = i+1) begin
  -      serdes_v[i].control.align_start(serdes.align_start());
  -      alignbusyw[i] = serdes_v[i].control.align_busy();
  -      alignedw[i] = serdes_v[i].control.aligned();
  -      serdes_v[i].control.autoalign(serdes.auto_align());
  -      serdes_v[i].control.training(serdes.training());
  -      serdes_v[i].control.manual_tap(serdes.manual_tap());
  -      firstw[i] = serdes_v[i].control.sampleinfirstbit();
  -      lastw[i] = serdes_v[i].control.sampleinlastbit();
  -      //sampleinOTHERBIT_wire[i:i] <= serdes_v[i].control.sampleinotherbit();
  -      serdes_v[i].ibufdsOut.ibufds_out(sensor.ibufds_out_value()[i]);
  -      emptyw[i] = serdes_v[i].fifo.empty();
  -      rawdataw[(i+1)*10-1: i*10] = serdes_v[i].fifo.dataout();
  -      serdes_v[i].fifo.rden(host.decoder.enable());
  -/*
  -.clk(imageon_clk_tmp),
  -*/
  -   end
  -   fifo_EMPTY_d_wire <= emptyw;
  -   align_BUSY_d_wire <= alignbusyw;
  -   alignED_d_wire <= alignedw;
  -   sampleinFIRSTBIT_wire <= firstw;
  -   sampleinLASTBIT_wire <= lastw;
  -   //sampleinOTHERBIT_wire <= otherw;
  -   sampleinOTHERBIT_wire <= 
  -      { serdes_v[4].control.sampleinotherbit(),
  -      serdes_v[3].control.sampleinotherbit(),
  -      serdes_v[2].control.sampleinotherbit(),
  -      serdes_v[1].control.sampleinotherbit(),
  -      serdes_v[0].control.sampleinotherbit()};
  -   raw_data_wire <= rawdataw;
  +      Bit#(5) emptyw = 0;
  +      Bit#(5) firstw = 0;
  +      Bit#(5) lastw = 0;
  +      Bit#(5) otherw = 0;
  +      Bit#(5) alignedw = 0;
  +      Bit#(5) alignbusyw = 0;
  +      Bit#(50) rawdataw = 0;
  +      for (Bit#(8) i = 0; i < 5; i = i+1) begin
  +	 serdes_v[i].control.align_start(serdes.align_start());
  +	 alignbusyw[i] = serdes_v[i].control.align_busy();
  +	 alignedw[i] = serdes_v[i].control.aligned();
  +	 serdes_v[i].control.autoalign(serdes.auto_align());
  +	 serdes_v[i].control.training(serdes.training());
  +	 serdes_v[i].control.manual_tap(serdes.manual_tap());
  +	 firstw[i] = serdes_v[i].control.sampleinfirstbit();
  +	 lastw[i] = serdes_v[i].control.sampleinlastbit();
  +	 otherw[i] = serdes_v[i].control.sampleinotherbit();
  +	 //sampleinOTHERBIT_wire[i:i] <= serdes_v[i].control.sampleinotherbit();
  +	 serdes_v[i].ibufdsOut.ibufds_out(sensor.ibufds_out_value()[i]);
  +	 emptyw[i] = serdes_v[i].fifo.empty();
  +	 rawdataw[(i+1)*10-1: i*10] = serdes_v[i].fifo.dataout();
  +	 serdes_v[i].fifo.rden(host.decoder.enable());
  +	 /*
  +	 .clk(imageon_clk_tmp),
  +	 */
  +      end
  +      sensor.align_BUSY_d(alignbusyw);
  +      sensor.alignED_d(alignedw);
  +      sensor.sampleinFIRSTBIT(firstw);
  +      sensor.sampleinLASTBIT(lastw);
  +      sensor.sampleinOTHERBIT(otherw);
  +      sensor.fifo_EMPTY_d(emptyw);
  +      sensor.raw_data(rawdataw);
      endrule
      rule sendup2;
      for (Bit#(3) i = 0; i < 5; i = i+1) begin
  
positive.code:     
      rule serdes_calc;
          host.serdesind.clk_ready(1);
          host.serdesind.align_busy(pack(align_BUSY_d_wire != 0));
          host.serdesind.alignedbit(pack(alignED_d_wire == 5'b11111));
      endrule
  
      rule serdes_reset if (serdes.resets() == 1);
  
negative.code:     endinterface: out
  endmodule
  
  //(* always_ready, always_enabled *)
  interface SensorDiffData;
     //interface Vector#(5, IbufdsOut) in;
     //interface Vector#(5, IserdesControl) control;
  