time start;
initial begin
   #100_000;
   force vcore_vin_uvlo.VOUT_SLEW_W = 8;
   
   force otp[43:42] = 2'b01; // DIV2 delay = 75us

   $display("\n VIN @ 8V");
   $display("---------------------------------------------------\n");
   vcore_vin_uvlo.vin_lvl(8000);   
 
$display("\n// ----------------------------------------------------------------");
$display("// PASSTHROUGH");
$display("// ----------------------------------------------------------------   ");  
   @(posedge cp_pass_thru);
   #1_000;
   
   $display("\n Check passthru state");
   $display("---------------------------------------------------\n");
   check_digital_net_id("en_clk_12Mhz",   en_clk_12Mhz,  1);
   check_digital_net_id("en_vreg",        en_vreg,       1);
   check_digital_net_id("en_refs",        en_refs,       1);
   check_digital_net_id("en_vin_monitor", en_vin_monitor,1);
   check_digital_net_id("en_tsd",         en_tsd,        1);
   check_digital_net_id("en_clo_det",     en_clo_det,    0);
   check_digital_net_id("cp_clk_div2",    cp_clk_div2,   0);    


   check_digital_net_id("en_cp",          en_cp,         1);
   check_digital_net_id("cp_en_pmos",     cp_en_pmos,    1);
   check_digital_net_id("cp_pass_thru",   cp_pass_thru,  1);
   check_digital_net_id("cp_wait",        cp_wait,       0);
   check_digital_net_id("cp_div2",        cp_div2,       0);
   check_digital_net_id("cp_tsd",         cp_tsd,        0);

   check_digital_net_id("mode",           mode,          0);

   $display("\n VIN @ 18V");
   $display("---------------------------------------------------\n");
   vcore_vin_uvlo.vin_lvl(18000);   

$display("\n// ----------------------------------------------------------------");
$display("// WAIT");
$display("// ----------------------------------------------------------------");  
   @(posedge vin_vth);
   #700;
   $display("\n Check MODE pin");
   $display("---------------------------------------------------\n");
   check_digital_net_id("mode",           mode,          1);
   #2_000;
   
   $display("\n Check wait state");
   $display("---------------------------------------------------\n");
   check_digital_net_id("en_cp",          en_cp,         1);
   check_digital_net_id("cp_en_pmos",     cp_en_pmos,    0);
   check_digital_net_id("cp_pass_thru",   cp_pass_thru,  0);
   check_digital_net_id("cp_wait",        cp_wait,       1);
   check_digital_net_id("cp_div2",        cp_div2,       0);
   check_digital_net_id("cp_tsd",         cp_tsd,        0);

   #20_000;
   $display("\n VIN @ 8V");
   $display("---------------------------------------------------\n");
   vcore_vin_uvlo.vin_lvl(8000); 
   
   
   
   @(posedge vin_0p5);
   clock_generator_12mhz_slave.PERIOD = 70;
   
   @(negedge cp_wait);
   #20;
   $display("\n Check div2 state");
   $display("---------------------------------------------------\n");
   check_digital_net_id("en_cp",          en_cp,         1);
   check_digital_net_id("cp_en_pmos",     cp_en_pmos,    0);
   check_digital_net_id("cp_pass_thru",   cp_pass_thru,  0);
   check_digital_net_id("cp_wait",        cp_wait,       0);
   check_digital_net_id("cp_div2",        cp_div2,       1);
   check_digital_net_id("cp_tsd",         cp_tsd,        0);
   vcore_vin_uvlo.vin = 9700; 

   @(negedge vin_vth);
   start = $realtime;

   
   @(negedge slave.cp_wait);
   check_time(start,$realtime,0,1000);
   #20;
   $display("\n Check div2 state");
   $display("---------------------------------------------------\n");
   check_digital_net_id("en_cp",          slave.en_cp,         1);
   check_digital_net_id("cp_en_pmos",     slave.cp_en_pmos,    0);
   check_digital_net_id("cp_pass_thru",   slave.cp_pass_thru,  0);
   check_digital_net_id("cp_wait",        slave.cp_wait,       0);
   check_digital_net_id("cp_div2",        slave.cp_div2,       1);
   check_digital_net_id("cp_tsd",         slave.cp_tsd,        0);

   @(negedge cp_div2);
   check_time(start,$realtime,70000,80000);

   #20;
   $display("\n Check div2 state");
   $display("---------------------------------------------------\n");
   check_digital_net_id("en_cp",          en_cp,         1);
   check_digital_net_id("cp_en_pmos",     cp_en_pmos,    1);
   check_digital_net_id("cp_pass_thru",   cp_pass_thru,  1);
   check_digital_net_id("cp_wait",        cp_wait,       0);
   check_digital_net_id("cp_div2",        cp_div2,       0);
   check_digital_net_id("cp_tsd",         cp_tsd,        0);
   vcore_vin_uvlo.vin = 9700; 

   @(negedge slave.cp_div2);
   #20;
   $display("\n Check div2 state");
   $display("---------------------------------------------------\n");
   check_digital_net_id("en_cp",          slave.en_cp,         1);
   check_digital_net_id("cp_en_pmos",     slave.cp_en_pmos,    1);
   check_digital_net_id("cp_pass_thru",   slave.cp_pass_thru,  1);
   check_digital_net_id("cp_wait",        slave.cp_wait,       0);
   check_digital_net_id("cp_div2",        slave.cp_div2,       0);
   check_digital_net_id("cp_tsd",         slave.cp_tsd,        0);

   repeat (1) #100_000;

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