Professional Documents
Culture Documents
UVM_OBJECTION
UVM_OBJECTION
UVM_OBJECTION
UVM OBJECTION
1) Concept used by UVM based testbenches to figure out when specific components
functionality is completed.
2) Simulation is completed when all objections raised or dropped.
3) If a TB does not have any objections raised,simulation completed at 0 time.
4) A component raise_objection to indicate that component functionality has started.
Phase.raise_objection(this);
5) A component drops objection to indicate that functionality has completed
Phase.drop_objection(this);
6) Phase is coming from uvm_root,hence uvm_root keeps track of all objections raised
and dropped.
--------------------------------------------------------------------------------------------------------------------------
//OBJECTIONS
--------------------
1) IN COMPONENTS
Phase.raise_objection(this);
This method tells the UVM that a test is running,UVM will stay in the
run_phase() until the test drops the objection
Phase.drop_objection(this);
This method tells the UVM that the test has finished & that the run phase can
end
1|Page
@shraddha_pawankar Date:31/03/2024
2) IN OBJECT
Starting_phase.raise_objection(this);
Staring .phase.drop_objection(this);
Drain time:
The amount of wait time between all objection has been dropped and calling all_dropped()
called drain time.
Set drain time :
Phase.phase_done.set_drain_time(100,1);
Even after all objections are dropped,we wait for 100 ns for simulation to finish.
Example:
2|Page
@shraddha_pawankar Date:31/03/2024
Objections make sure that all the phases of UVM TB complete,only then
$finish get called,Hence user will see the extract ,check,report phase also
getting executed,even though drop objection is happening in run_phase.
3|Page
@shraddha_pawankar Date:31/03/2024
UVM_OBJECTION USAGE:
1. UVM phasing mechanism uses objections to coordinate with each other and
the phase should be ended when all objections are dropped. They can be
used in all UVM phases.
CALLBACK HOOKS:
The callback methods are defined in the uvm_objection_callback class which is derived from
the uvm_callback class.
Callback
Description
Hooks
Called when all objections are dropped for this component and its derived
all_dropped
classes.
4|Page
@shraddha_pawankar Date:31/03/2024
task body();
req = seq_item::type_id::create("req");
// send to the driver
#20;
...
endtask
task post_body();
if(starting_phase != null) starting_phase.drop_objection(this);
endtask
endclass
The objection mechanism in the sequence can be used with the below two approaches.
1. With set_starting_phase and get_starting_phase methods
2. With set_automatic_phase_objection method
With set_starting_phase and get_starting_phase methods
As the name implies set_starting_phase and get_starting_phase are used to set and
retrieve the phase.
Note: If get_starting_phase returns null, then the sequence will not raise and drop
objection.
Code:
5|Page
@shraddha_pawankar Date:31/03/2024
endclass
task pre_body();
`uvm_info(get_type_name(), "Inside pre_body", UVM_LOW);
phase = get_starting_phase; // Retrieve phase information
if (phase != null) phase.raise_objection(this);
endtask
task body();
`uvm_info(get_type_name(), "Base seq: Body started", UVM_LOW);
req = seq_item::type_id::create("req");
// send to the driver
#20;
`uvm_info(get_type_name(), "Base seq: Body completed", UVM_LOW);
endtask
task post_body();
`uvm_info(get_type_name(), "Inside post_body", UVM_LOW);
if (phase != null) phase.drop_objection(this);
endtask
endclass
`uvm_component_utils(base_test)
6|Page
@shraddha_pawankar Date:31/03/2024
endfunction
module tb_top;
initial begin
run_test("base_test");
end
endmodule
Output :
UVM_INFO testbench.sv(18) @ 0: reporter@@bseq [base_seq] Inside pre_body
UVM_INFO testbench.sv(24) @ 0: reporter@@bseq [base_seq] Base seq: Body started
UVM_INFO testbench.sv(28) @ 20: reporter@@bseq [base_seq] Base seq: Body completed
UVM_INFO testbench.sv(32) @ 20: reporter@@bseq [base_seq] Inside post_body
Que) if you have multiple objections and for one drop objection you left how will you
rectify the situation?
1) If we have multiple objection in the UVM and and multiple objection undropped.
It could lead synchronization problem,unintended simulation results.
2) We can handle this situation:
7|Page
@shraddha_pawankar Date:31/03/2024
-----------------------------------------------------------------------------------------------------------------
----------
//two objection are raised @0 time unit and one drop objection @10 time unit another
drop objection @100 time unit
//simulator will remains in the run phase till the objections dropped
//hence,the objection mechanism helps the simulator to decide at what point of time it
can proceed to extract phase from run phase
`include "uvm_macros.svh"
import uvm_pkg::*;
8|Page
@shraddha_pawankar Date:31/03/2024
endclass
endclass
Transmitter Tx;
9|Page
@shraddha_pawankar Date:31/03/2024
Receiver Rx;
env env_h;
function new(string name="",uvm_component parent);
super.new(name,parent);
endfunction
module tb;
initial
begin
run_test("test");
end
endmodule
10 | P a g e
@shraddha_pawankar Date:31/03/2024
OUTPUT :
11 | P a g e
@shraddha_pawankar Date:31/03/2024
objection(s) from its total (dropped from source object uvm_test_top.env_h.Rx): count=0
total=0
# KERNEL: UVM_INFO @ 100: run [OBJTN_TRC] Object uvm_test_top subtracted 1
objection(s) from its total (all_dropped from source object uvm_test_top.env_h.Rx):
count=0 total=0
# KERNEL: UVM_INFO @ 100: run [OBJTN_TRC] Object uvm_top subtracted 1 objection(s)
from its total (dropped from source object uvm_test_top.env_h.Rx): count=0 total=0
# KERNEL: UVM_INFO @ 100: run [OBJTN_TRC] Object uvm_top subtracted 1 objection(s)
from its total (all_dropped from source object uvm_test_top.env_h.Rx): count=0 total=0
# KERNEL: UVM_INFO /home/build/vlib1/vlib/uvm-1.2/src/base/uvm_objection.svh(1271)
@ 100: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
# KERNEL: UVM_INFO /home/build/vlib1/vlib/uvm-
1.2/src/base/uvm_report_server.svh(869) @ 100: reporter [UVM/REPORT/SERVER]
Output : https://www.edaplayground.com/x/JAFw
12 | P a g e