Search code examples
uvm

uvm raise_objection and drop_objection


I am learning UVM and wondering how the objection is working. I thought that the following code (in my derived agent) executes seq.start(sequencer); and after the sequencer finishes, drop_objection is executed to finish the simulation. If it is true, even if I remove raise_objection and drop_objection, it should execute what the sequencer is programmed to do (sending 8 sequence items to DUT). But when I commented out raise_objection and drop_objection, the simulation finishes without sequencer doing anything even though seq.start should have been executed. Please help me to understand how objection works in UVM in this case. The full testbench environment can be found here: https://www.edaplayground.com/x/3_bM

task run_phase(uvm_phase phase);
      // We raise objection to keep the test from completing
      phase.raise_objection(this);
      begin
        my_sequence seq;
        seq = my_sequence::type_id::create("seq");
        seq.start(sequencer);      
      end
      // We drop objection to allow the test to complete
      phase.drop_objection(this);
    endtask

Solution

  • What you are seeing is exactly what you'd expect to happen, because that is exactly what objections are for - controlling when to stop the simulation. (Strictly speaking "controlling when to end the phase", but usually there is only one phase that consumes time - the run phase.)

    Basically, if there are no objections raised, the simulation stops. So, when you comment out your code that raises and drops objections, no objections are raised, so the simulation stops immediately (without doing anything).

    • You must always raise an objection in any UVM simulation, otherwise it will stop immediately;

    • you must always drop all objections at some point, otherwise your simulation will not ever stop.