real     bias_time1;
real     bias_time2;  

initial begin
   #100_000;
   bias_time1 = 0;
   bias_time2 = 0; 

   // Slew
   // ----------------------------------------------------------------
   vcore_vin_uvlo.VIN_SLEW  = 100;   
   vddi2c_detect = 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 precharge");
    
// ----------------------------------------------------------------
// DIV2
// ----------------------------------------------------------------  
   @(posedge cp_div2);
   $display("\n enter div2");
   
    
   $display("\n// read data VIT command");
   $display("// ----------------------------------------------------------------");   
   data1 = $random;
   data2 = $random;
   data3 = $random;
   data4 = $random;
   @(negedge clk_115p2khz);            
   owi_vin_msb_fld   = data1[9:8];    
   owi_vin_lsb_fld   = data1[7:2];   
   owi_iin_msb_fld   = data2[9:8];    
   owi_iin_lsb_fld   = data2[7:2];   
   owi_temp_msb_fld  = data3[9:8];    
   owi_temp_lsb_fld  = data3[7:2]; 
          
   fork
   owi_read_data_fields(6'b111111);
   begin
   @(posedge en_adc);
   bias_time1 = $realtime;
   #20;
   check_digital_net_id("en_adc",en_adc,1'b1);
   check_digital_net_id("en_iin_meter",en_iin_meter,1'b1);
   check_digital_net_id("en_vin_meter",en_vin_meter,1'b1);
   check_digital_net_id("adc_signed_conv",adc_signed_conv,1'b1);
   check_digital_net_id("adc_az_dis",adc_az_dis,1'b0);
   check_digital_net_id("adc_ext_vref",adc_ext_vref,1'b0);
 
   @(posedge adc_clk);
   bias_time2 = $realtime;
   check_time(bias_time1,bias_time2,30_000, 35_000);  
 
   @(posedge adc_enconv);  
   check_digital_net_id("adc_channel_mux_ctrl",adc_channel_mux_ctrl,0);    
   @(posedge adc_eoc);
   @(posedge adc_enconv);   
   check_digital_net_id("adc_channel_mux_ctrl",adc_channel_mux_ctrl,1);    
   @(posedge adc_eoc);
   @(posedge adc_enconv);   
   check_digital_net_id("adc_channel_mux_ctrl",adc_channel_mux_ctrl,2);    
   @(posedge adc_eoc);     
 
   #10_000;
   check_digital_net_id("en_adc",en_adc,1'b0);
   check_digital_net_id("en_iin_meter",en_iin_meter,1'b0);
   check_digital_net_id("en_vin_meter",en_vin_meter,1'b0);
   check_digital_net_id("adc_signed_conv",adc_signed_conv,1'b1);
   check_digital_net_id("adc_az_dis",adc_az_dis,1'b0);
   check_digital_net_id("adc_ext_vref",adc_ext_vref,1'b0);  
   end 
   join   
   repeat (1) #1_000_000;


   $display("\n// read data VI command");
   $display("// ----------------------------------------------------------------");   
   data1 = $random;
   data2 = $random;
   data3 = $random;
   data4 = $random;
   @(negedge clk_115p2khz);            
   owi_vin_msb_fld   = data1[9:8];    
   owi_vin_lsb_fld   = data1[7:2];   
   owi_iin_msb_fld   = data2[9:8];    
   owi_iin_lsb_fld   = data2[7:2];   
    
   fork
   owi_read_data_iv_fields;
   begin
   @(posedge en_adc);
   bias_time1 = $realtime;
   #20;
   check_digital_net_id("en_adc",en_adc,1'b1);
   check_digital_net_id("en_iin_meter",en_iin_meter,1'b1);
   check_digital_net_id("en_vin_meter",en_vin_meter,1'b1);
   check_digital_net_id("adc_signed_conv",adc_signed_conv,1'b1);
   check_digital_net_id("adc_az_dis",adc_az_dis,1'b0);
   check_digital_net_id("adc_ext_vref",adc_ext_vref,1'b0);
 
   @(posedge adc_clk);
   bias_time2 = $realtime;
   check_time(bias_time1,bias_time2,30_000, 35_000);  
 
   @(posedge adc_enconv);  
   check_digital_net_id("adc_channel_mux_ctrl",adc_channel_mux_ctrl,0);    
   @(posedge adc_eoc);
   @(posedge adc_enconv);   
   check_digital_net_id("adc_channel_mux_ctrl",adc_channel_mux_ctrl,1);    
   @(posedge adc_eoc);
  
   #10_000;
   check_digital_net_id("en_adc",en_adc,1'b0);
   check_digital_net_id("en_iin_meter",en_iin_meter,1'b0);
   check_digital_net_id("en_vin_meter",en_vin_meter,1'b0);
   check_digital_net_id("adc_signed_conv",adc_signed_conv,1'b1);
   check_digital_net_id("adc_az_dis",adc_az_dis,1'b0);
   check_digital_net_id("adc_ext_vref",adc_ext_vref,1'b0);  
   end 
   join      

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

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

