Friday, 5 February 2016

How to change verbsity for particular component in UVM

There are two ways to set/control/change verbosity of particular component. 
  1. Using method call 
  2. Through Command line
Here I explained both using example.
Let's go through examples.

1. Using method call
-----------------------------------------------------------------------------------------------------
`include "uvm.svh"
import uvm_pkg::*;
class rpting extends uvm_component;
`uvm_component_utils(rpting)
function new(string name,uvm_component parent);
super.new(name, parent);
endfunction : new
task run();
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_NONE ",UVM_NONE)
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_LOW ",UVM_LOW)
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_MEDIUM",UVM_MEDIUM)
`uvm_warning(get_full_name(),"Warning Messgae from rpting")
`uvm_error(get_full_name(),"Error Message from rpting \n\n")
endtask : run
endclass : rpting
module top;
rpting rpt1;
rpting rpt2;
rpting rpt3;
initial begin
rpt1 = new("rpt1",null);
rpt2 = new("rpt2",null);
rpt3 = new("rpt3",null);
rpt1.set_report_verbosity_level(UVM_MEDIUM);
rpt2.set_report_verbosity_level(UVM_LOW);
rpt3.set_report_verbosity_level(UVM_NONE);
run_test();
end
endmodule : top
//Output:
// UVM_INFO @ 0: reporter [RNTST] Running test ...
// UVM_INFO top1.sv(19) @ 0: rpt1 [rpt1] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top1.sv(20) @ 0: rpt1 [rpt1] Info Message : Verbo lvl - UVM_LOW
// UVM_INFO top1.sv(21) @ 0: rpt1 [rpt1] Info Message : Verbo lvl - UVM_MEDIUM
// UVM_WARNING top1.sv(22) @ 0: rpt1 [rpt1] Warning Messgae from rpting
// UVM_ERROR top1.sv(23) @ 0: rpt1 [rpt1] Error Message from rpting
//
//
// UVM_INFO top1.sv(19) @ 0: rpt2 [rpt2] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top1.sv(20) @ 0: rpt2 [rpt2] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top1.sv(22) @ 0: rpt2 [rpt2] Warning Messgae from rpting
// UVM_ERROR top1.sv(23) @ 0: rpt2 [rpt2] Error Message from rpting
//
//
// UVM_INFO top1.sv(19) @ 0: rpt3 [rpt3] Info Message : Verbo lvl - UVM_NONE
// UVM_WARNING top1.sv(22) @ 0: rpt3 [rpt3] Warning Messgae from rpting
// UVM_ERROR top1.sv(23) @ 0: rpt3 [rpt3] Error Message from rpting

-----------------------------------------------------------------------------------------------------

2. Through Command line
-----------------------------------------------------------------------------------------------------
`include "uvm.svh"
import uvm_pkg::*;
class my_env extends uvm_env;
`uvm_component_utils(my_env)
function new(string name,uvm_component parent);
super.new(name, parent);
endfunction : new
task run();
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_NONE ",UVM_NONE)
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_LOW ",UVM_LOW)
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_MEDIUM",UVM_MEDIUM)
`uvm_warning(get_full_name(),"Warning Messgae from my_test")
`uvm_error(get_full_name(),"Error Message from my_test \n\n")
endtask : run
endclass : my_env
class my_test extends uvm_test;
`uvm_component_utils(my_test)
my_env env1, env2;
function new(string name,uvm_component parent);
super.new(name, parent);
endfunction : new
function void build_phase (uvm_phase phase);
super.build_phase (phase);
env1 = my_env :: type_id :: create ("env1", this);
env2 = my_env :: type_id :: create ("env2", this);
endfunction : build_phase
task run();
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_NONE ",UVM_NONE)
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_LOW ",UVM_LOW)
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_MEDIUM",UVM_MEDIUM)
`uvm_warning(get_full_name(),"Warning Messgae from my_test")
`uvm_error(get_full_name(),"Error Message from my_test \n\n")
endtask : run
endclass : my_test
module top;
initial begin
run_test("my_test");
end
endmodule : top
`include "uvm.svh"
import uvm_pkg::*;
class my_env extends uvm_env;
`uvm_component_utils(my_env)
function new(string name,uvm_component parent);
super.new(name, parent);
endfunction : new
task run();
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_NONE ",UVM_NONE)
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_LOW ",UVM_LOW)
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_MEDIUM",UVM_MEDIUM)
`uvm_warning(get_full_name(),"Warning Messgae from my_test")
`uvm_error(get_full_name(),"Error Message from my_test \n\n")
endtask : run
endclass : my_env
class my_test extends uvm_test;
`uvm_component_utils(my_test)
my_env env1, env2;
function new(string name,uvm_component parent);
super.new(name, parent);
endfunction : new
function void build_phase (uvm_phase phase);
super.build_phase (phase);
env1 = my_env :: type_id :: create ("env1", this);
env2 = my_env :: type_id :: create ("env2", this);
endfunction : build_phase
task run();
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_NONE ",UVM_NONE)
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_LOW ",UVM_LOW)
`uvm_info(get_full_name(),"Info Message : Verbo lvl - UVM_MEDIUM",UVM_MEDIUM)
`uvm_warning(get_full_name(),"Warning Messgae from my_test")
`uvm_error(get_full_name(),"Error Message from my_test \n\n")
endtask : run
endclass : my_test
module top;
initial begin
run_test("my_test");
end
endmodule : top

-----------------------------------------------------------------------------------------------------

Now run with 3 different simulation commands and see the difference.

+uvm_set_verbosity=component,id,verbosity,phase


-----------------------------------------------------------------------------------------------------

// Simulation Command:
// ./simv
//Output:
// UVM_INFO @ 0: reporter [RNTST] Running test my_test...
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(20) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_LOW
// UVM_INFO top2.sv(21) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_MEDIUM
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Error Message from my_test
//
//
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(20) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_LOW
// UVM_INFO top2.sv(21) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_MEDIUM
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Error Message from my_test
//
//
// UVM_INFO top2.sv(43) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(44) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_LOW
// UVM_INFO top2.sv(45) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_MEDIUM
// UVM_WARNING top2.sv(46) @ 0: uvm_test_top [uvm_test_top] Warning Messgae from my_test
// UVM_ERROR top2.sv(47) @ 0: uvm_test_top [uvm_test_top] Error Message from my_test
//-----------------------------------------------------------------------------------------------------
//Simulation Command:
// ./simv +uvm_set_verbosity=uvm_test_top,_ALL_,UVM_LOW,run +uvm_set_verbosity=uvm_test_top.env2,uvm_test_top.env2,UVM_NONE,run, +uvm_set_verbosity=uvm_test_top.env1,_ALL_,UVM_LOW,run
//Output:
// UVM_INFO @ 0: reporter [RNTST] Running test my_test...
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(20) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Error Message from my_test
//
//
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_NONE
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Error Message from my_test
//
//
// UVM_INFO top2.sv(43) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(44) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top2.sv(46) @ 0: uvm_test_top [uvm_test_top] Warning Messgae from my_test
// UVM_ERROR top2.sv(47) @ 0: uvm_test_top [uvm_test_top] Error Message from my_test
//-----------------------------------------------------------------------------------------------------
//Simulation Command:
// ./simv ./simv +uvm_set_verbosity=*,_ALL_,UVM_LOW,run
//Output:
// UVM_INFO @ 0: reporter [RNTST] Running test my_test...
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(20) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Error Message from my_test
//
//
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(20) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Error Message from my_test
//
//
// UVM_INFO top2.sv(43) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(44) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top2.sv(46) @ 0: uvm_test_top [uvm_test_top] Warning Messgae from my_test
// UVM_ERROR top2.sv(47) @ 0: uvm_test_top [uvm_test_top] Error Message from my_test
// _ALL_ is a "magic" name that can match either all severities or all IDs.
// Simulation Command:
// ./simv
//Output:
// UVM_INFO @ 0: reporter [RNTST] Running test my_test...
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(20) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_LOW
// UVM_INFO top2.sv(21) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_MEDIUM
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Error Message from my_test
//
//
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(20) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_LOW
// UVM_INFO top2.sv(21) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_MEDIUM
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Error Message from my_test
//
//
// UVM_INFO top2.sv(43) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(44) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_LOW
// UVM_INFO top2.sv(45) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_MEDIUM
// UVM_WARNING top2.sv(46) @ 0: uvm_test_top [uvm_test_top] Warning Messgae from my_test
// UVM_ERROR top2.sv(47) @ 0: uvm_test_top [uvm_test_top] Error Message from my_test
//-----------------------------------------------------------------------------------------------------
//Simulation Command:
// ./simv +uvm_set_verbosity=uvm_test_top,_ALL_,UVM_LOW,run +uvm_set_verbosity=uvm_test_top.env2,uvm_test_top.env2,UVM_NONE,run, +uvm_set_verbosity=uvm_test_top.env1,_ALL_,UVM_LOW,run
//Output:
// UVM_INFO @ 0: reporter [RNTST] Running test my_test...
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(20) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Error Message from my_test
//
//
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_NONE
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Error Message from my_test
//
//
// UVM_INFO top2.sv(43) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(44) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top2.sv(46) @ 0: uvm_test_top [uvm_test_top] Warning Messgae from my_test
// UVM_ERROR top2.sv(47) @ 0: uvm_test_top [uvm_test_top] Error Message from my_test
//-----------------------------------------------------------------------------------------------------
//Simulation Command:
// ./simv ./simv +uvm_set_verbosity=*,_ALL_,UVM_LOW,run
//Output:
// UVM_INFO @ 0: reporter [RNTST] Running test my_test...
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(20) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env1 [uvm_test_top.env1] Error Message from my_test
//
//
// UVM_INFO top2.sv(19) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(20) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top2.sv(22) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Warning Messgae from my_test
// UVM_ERROR top2.sv(23) @ 0: uvm_test_top.env2 [uvm_test_top.env2] Error Message from my_test
//
//
// UVM_INFO top2.sv(43) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_NONE
// UVM_INFO top2.sv(44) @ 0: uvm_test_top [uvm_test_top] Info Message : Verbo lvl - UVM_LOW
// UVM_WARNING top2.sv(46) @ 0: uvm_test_top [uvm_test_top] Warning Messgae from my_test
// UVM_ERROR top2.sv(47) @ 0: uvm_test_top [uvm_test_top] Error Message from my_test
// _ALL_ is a "magic" name that can match either all severities or all IDs.

-----------------------------------------------------------------------------------------------------

Reference:

2 comments: