title: How to use uvm_test_done objection in test sequence?
body: <p>I am doing following in my UVM testbench to create seq and start test.</p>
  
  <ol>
  <li>I've some sequences. I'm copying a code snippet from one of the sequences bellow.</li>
  </ol>
  
  <p>Inside body():</p>
  
  <pre><code>`uvm_create_on(my_seq, p_sequencer.my_sequencer)
  my_seq.randomize();
  `uvm_send(my_seq)
  </code></pre>
  
  <p>2.In my test, I'm doing following to start a sequence:</p>
  
  <pre><code>   task run_phase(uvm_phase phase);
       ..... 
       phase.raise_objection(this);
       seq.start(env.virtual_sequencer);
       phase.drop_objection(this);
      endtask
  </code></pre>
  
  <p>Now, if I do this, the test is starts and ends at zero time. What I mean is, the DUT is not being driven by my sequence. If I make following change then it seems to work fine:</p>
  
  <p>Option1:changing run_phase in test- </p>
  
  <pre><code>   task run_phase(uvm_phase phase);
       ..... 
       phase.raise_objection(this);
       seq.start(env.virtual_sequencer);
       #100000;   // Adding delay here. 
       phase.drop_objection(this);
      endtask
  </code></pre>
  
  <p>If I do this then test starts and I can see that DUT is being driven and everything is working as expected. However, test always ends at time 1000000- even though the sequence is not done sending all the transactions to DUT. It's not good as I don't know how long my DUT will take to complete a test. So, I rather tried something like this:</p>
  
  <p>Option 2: Keeping the default code in test (not adding delay in run_phase). Making following change inside body of my_seq:</p>
  
  <p>Inside body():</p>
  
  <pre><code> uvm_test_done.raise_objection(this);
  `uvm_create_on(my_seq, p_sequencer.my_sequencer)
   my_seq.randomize();
  `uvm_send(my_seq)
   uvm_test_done.drop_objection(this);
  </code></pre>
  
  <p>If I do this then it works fine. Is it the proper way of handling objection ? Going back to my original implementation, I assumed that my sequence is blocking. So, whenever I start a sequence in run_phase of test using start(...), it'll be considered as blocking and will wait at that line until sequence is done sending all the transaction. So, I didn't add any delay in my original code. </p>
  
  <p>I think I'm missing something here. Any help will be greatly appreciated. </p>