anchor.diff:      Bit#(10) video_data;
   } XsviData deriving (Bits);
   
  -(* always_enabled *)
  +//(* always_ready *)
   interface ImageonSensorControl;
       method Bit#(32) get_debugind();
       method Action raw_data(Bit#(50) v);
  
positive.code:    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;
     endrule
     rule sendup2;
     for (Bit#(3) i = 0; i < 5; i = i+1) begin
  
negative.code:    Reset defaultReset <- exposeCurrentReset();
  
     Vector#(5, IserdesDatadeser) serdes_v <- replicateM(mkIserdesDatadeser(clkdiv));
     //ReadOnly#(Bit#(1)) reset_wire <- mkNullCrossingWire(defaultClock, serdes.reset());
     //Reg#(Bit#(1)) reset_wire <- mkReg(0);
     //rule sendup_reset;
  