time start;
initial begin

   #100_000;
   sel_in_reg =1'b1;
   vddi2c_detect = 1'b1;   
   #100_000;

   $display("\n VIN plug @ 7V");
   $display("---------------------------------------------------\n");
   vcore_vin_uvlo.vin_lvl(7000);   
    
   @(posedge cp_pass_thru);
   $display("\n enter PT");    

   $display("\nDe-activate ADC auto conv");
   $display("---------------------------------------------------\n");
   i2c_adc_manual_fld = 1'b1;
   i2c_write_fields(`CMD3);
   
   #1_000;
   $display("\nValidate test_mode");
   $display("---------------------------------------------------\n");
   i2c_master.i2cWr(8'd126,8'h17);
   i2c_master.i2cWr(8'd126,8'h51);
   #1_000;
   i2c_test_mode_sns_fld = 1'b1;
   i2c_read_fields(`TEST_REGISTER0,i2c_test_mode_sns_mask);
   
   i2c_dig_mux_fld = 49;
   i2c_write_fields(`TEST_REGISTER7);
   #100_000;
   i2c_tb_digmux_clo_fld = 1;
   i2c_write_fields(`TEST_REGISTER7);
      
   $display("\nValidate test_mode");
   $display("---------------------------------------------------\n");
   i2c_master.i2cWr(8'd127,8'h17);
   i2c_master.i2cWr(8'd127,8'h51);
   #1_000;
   i2c_test_mode_sns_fld = 1'b0;
   i2c_read_fields(`TEST_REGISTER0,i2c_test_mode_sns_mask);
   
   sel_in_reg =1'b0;
   
   #100_000;
   @(negedge clk_115p2khz);            
   owi_rev_id_fld= 6'b000000;
   owi_read_revid_fields;
   #100_000;
   
   END_SIM;
end

always @ (negedge sel_in_reg) begin
   @ (posedge clo);
   start = $realtime;
   repeat (5) begin
      @ (posedge clo);
      check_time(start,$realtime,8000,9300);
      start = $realtime;
   end
   
end
