
initial begin
   #100_000;

   // Slew
   // ----------------------------------------------------------------
   vcore_vin_uvlo.VIN_SLEW  = 100;
   
   sel_in_reg =1'b1;
   vddi2c_detect = 1'b1;           
   #100_000;

   $display("\n VIN plug @ 10V");
   $display("---------------------------------------------------\n");
   vcore_vin_uvlo.vin_lvl(10000);    
   @(posedge vin_uvlo);
   $display("\n enter precharge");   
   @(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_vth_stat_fld = 1'b1;
   i2c_vth_sns_fld = 1'b1;
   i2c_vth_int_fld = 1'b1;

   $display("\n// clear interrupts");
   $display("// ----------------------------------------------------------------");   
   i2c_read_fields(`INTERRUPTS,8'hff);
   #1_000;   
   i2c_vth_int_fld = 1'b0;
   i2c_vth_stat_fld = 1'b0;
   
   $display("\n// read status");
   $display("// ----------------------------------------------------------------");   
   i2c_read_fields(`STATUS,8'hff);
   #5_000;   
            
   $display(" chg_ok high by pwr_ok event: posedge interrupt");
   $display("// ----------------------------------------------------------------");          
   i2c_pwr_ok_fld = 1'b1;
   i2c_write_fields(fnGetAddr("i2c_pwr_ok_fld"));         
   i2c_chg_ok_stat_fld = 1'b1;
   i2c_chg_ok_int_fld  = 1'b1;
   i2c_chg_ok_sns_fld  = 1'b1;

   $display("Check int status high and sense high");
   i2c_read_fields(`SNS1,8'hff);  
   i2c_read_fields(`STATUS,8'hff);
   #1_000;   

   $display("Check interrupt high,clear interrupt");
   i2c_read_fields(`INTERRUPTS,8'hff);    
   i2c_chg_ok_int_fld  = 1'b0;
   i2c_chg_ok_stat_fld = 1'b0;
   i2c_vth_int_fld     = 1'b0;
   #1_000;     
   
   $display("Check int cleared");
   i2c_read_fields(`INTERRUPTS,8'hff);    
   #1_000;   

   $display("Check int status low");
   i2c_read_fields(`STATUS,8'hff);

   $display("Check sense still high");
   i2c_read_fields(`SNS1,8'hff);  
   
   #10_000;       
   $display("\n// chg_ok low by pwr_ok event: negedge interrupt");
   $display("// ----------------------------------------------------------------");      
   i2c_pwr_ok_fld = 1'b0;
   i2c_write_fields(fnGetAddr("i2c_pwr_ok_fld"));         
   i2c_chg_ok_stat_fld = 1'b1;
   i2c_chg_ok_int_fld  = 1'b1;
   i2c_chg_ok_sns_fld  = 1'b0;
   
   $display("Check int status and sense low");
   i2c_read_fields(`SNS1,8'hff);  
   i2c_read_fields(`STATUS,8'hff);
   #1_000;   
   
   $display("Check interrupt high,clear interrupt");
   i2c_read_fields(`INTERRUPTS,8'hff);    
   i2c_chg_ok_int_fld  = 1'b0;
   i2c_chg_ok_stat_fld = 1'b0;
   #1_000;   
   
   $display("Check int status low");
   i2c_read_fields(`STATUS,8'hff);
   #1_000;   

   $display("Check int cleared");
   i2c_read_fields(`INTERRUPTS,8'hff);    

   repeat (1) #1_000_000;
// ----------------------------------------------------------------

   // End
   // ----------------------------------------------------------------
   END_SIM;
   
end

