`define otp_vldo    otp[41:40]
integer j;

initial begin
   #100_000;
   
   // Slew
   // ----------------------------------------------------------------
   vcore_vin_uvlo.VIN_SLEW  = 100;
   vddi2c_detect = 1'b1;             
   sel_in_reg =1'b1;
   #100_000;
   
   $display("\n VIN plug @ 10V");
   vcore_vin_uvlo.vin_lvl(10000);    
   @(posedge vin_uvlo);
   $display("\n enter Latch_otp");
   @(posedge en_clo_det);
   $display("\n CLO detection on going");      
   @(posedge en_cp);
   $display("\n enter precharge");
   @(posedge cp_div2);   
   $display("\n enter div2");
   
   #200_000;
// ----------------------------------------------------------------
// DIV2
// ----------------------------------------------------------------   
   $display("\n Check I2C VLDO settings ");
   $display("---------------------------------------------------\n");
   for (j=0;j<=3;j=j+1) begin
    i2c_vldo_fld = j;
    i2c_write_fields(fnGetAddr("i2c_vldo_fld"));      
    i2c_read_fields(fnGetAddr("i2c_vldo_fld"),8'hff);
    check_digital_net_id("prog_vldo",prog_vldo,i2c_vldo_fld);
    #10_000;       
   end
   i2c_vldo_fld = 0;
   i2c_write_fields(fnGetAddr("i2c_vldo_fld"));      
   
   $display("\n UVLO");
   vcore_vin_uvlo.VIN_SLEW  = 10;
   vcore_vin_uvlo.vin_lvl(0);    
   #500_000;
   
   $display("\n Check OTP VLDO default settings ");
   $display("---------------------------------------------------\n");
   for (j=0;j<=3;j=j+1) begin
    force `otp_vldo = j;
    
    $display("\n VIN plug @ 10V");
    vcore_vin_uvlo.VIN_SLEW  = 100;
    vcore_vin_uvlo.vin_lvl(10000);
    
    @(posedge vin_uvlo);
    $display("\n enter Latch_otp");
    @(posedge en_clo_det);
    $display("\n CLO detection on going");
    @(posedge en_cp);
    $display("\n enter precharge");
    @(posedge cp_div2);
    $display("\n enter div2");
    i2c_read_fields(fnGetAddr("i2c_vldo_fld"),8'hff);
    check_digital_net_id("prog_vldo",prog_vldo,i2c_vldo_fld);

    $display("\n UVLO");
    vcore_vin_uvlo.VIN_SLEW  = 10;
    vcore_vin_uvlo.vin_lvl(0);
    #500_000;
   end
      
   repeat (1) #1_000_000;
   // End
   // ----------------------------------------------------------------
   END_SIM;
   
end

always @(*) begin
   case ( `otp_vldo )
   2'b00: i2c_vldo_fld = 2'b10;
   2'b01: i2c_vldo_fld = 2'b00;
   2'b10: i2c_vldo_fld = 2'b01;
   2'b11 :i2c_vldo_fld = 2'b11;
   endcase
end     



