UVM notes32
UVM notes32
➢ UVM Sequencer
➢ UVM Driver
➢ UVM Monitor
➢ UVM Agent
➢ Environment
➢ Test
➢ Top
UVM Sequencer
• The uvm_sequencer act as a routing component
between sequence and driver
• User sequencer is extended from uvm_sequencer
bass class
• It is parametrized with REQ, RSP
▪ REQ
▪ RSP
are the handles of uvm sequence item
EXAMPLE
class ram_sequencer extends uvm_sequencer #(write_xtn)
Sequencer Driver Connection
• Seq_item_port ,Seq_item_export are the builtin tlm
interface in uvm_sequencer and uvm_driver .
• It gets inherit to ram_sequencer and ram_driver.
• seq_item_port is the handle of
uvm_seq_item_pull_port present in uvm driver class
• seq_item_export is the handle of
uvm_seq_item_pull_imp present in uvm sequencer
class
• Both seq_item_port and seq_item_export are used for a
bidirectional communication .
• Driver get the data through seq_item_port
• Sequencer provide a data through seq_item_export.
• Driver seq_item_port connected to a
sequencer seq_item_export.
• seq_item_port, seq_item_export are comes under
TLM 2.0.
• put_port , put_imp, get_port, get_imp are comes under
TLM 1.0
UVM Driver
• Fetches data repeatedly from a sequencer
• Declare a virtual interface in a driver to connect the
driver to dut.
• Driver can be derived from a uvm_driver base class
• It is parametrized with REQ and RSP
get_next_item()
It is blocking method .
It going to call item_done explicitly.
Try_next_item()
It is a non blocking method.
It is used inside a if else condition
Get()
It is a blocking method.
It going to call item_done implicitly so it is not
recommended.
Example
class my_driver extends uvm_driver #(my_data);
`uvm_component_utils (my_driver)
virtual dut_if vif;
forever begin
`uvm_info (get_type_name (), $sformatf ("Waiting for
data from sequencer"), UVM_MEDIUM)
seq_item_port.get_next_item (data_obj);
drive_item (data_obj);
seq_item_port.item_done ();
end
endtask
virtual task drive_item (my_data data_obj);
// Drive based on bus protocol
endtask
endclass
seq_item_port.item_done()
seq_item_port.put_response(rsp)
rsp_port.write(rsp)
are used in driver send a response back to the sequencer
UVM MONITOR
▪ It samples a data through Virtual Interface.
▪ It is not a parametrized class.
▪ Monitor is connected to other components such as
scoreboard, coverage checker, etc via Standard tlm
interfaces Analysis ports and exports.
To create a monitor
➢ Monitor is extends from a uvm_monitor .
➢ Derive a virtual interface in the monitor to the
connect a monitor to DUT .
➢ Declare a analysis port
➢ Obtain a data item from the interface and send
it to the score board.
Example
class my_monitor extends uvm_monitor ;
`uvm_component_utils(my_monitor)
virtual ram_if vif;
ram_config m_tb_cfg;
wr_xtn data;
uvm_analysis_port#(write_xtn) monitor_port;
function new(string name ,uvm_component parent);
super.new(name,parent);
monitor_port=new(“monitor_port ”,this);
endfunction
function build_phase (uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db #(ram_config)::get
(“this”, “”, “ram_config”, m_tb_cfg));
`uvm_fatal(“get_type_name()”, “cannot get from the
ram_config”)
endfunction
function connect_phase(uvm_phase phase);
super.connect_phase(phase);
vif=m_tb_cfg.vif;
endfunction
task run_phase(uvm_phase phase );
data= write_xtn::type_id::create(“data”);
forever
collect_data();
endtask
task collect_data();
………………….
endtask
endclass
UVM_AGENT
▪ Agent is extends from a uvm_agent.
▪ An agent encapsulates
a Sequencer, Driver and Monitor into a single entity by
instantiating and connecting the components together via
TLM interfaces.
▪ Since UVM is all about configurability, an agent can also
have configuration options like the type of UVM agent
(active/passive), knobs to turn on features such as
functional coverage, and other similar parameters.
Types of Agents
Active
➢ Instantiates all three components [Sequencer,
Driver, Monitor].
Passive
➢ Instantiates only monitor.
Creating Agents
➢ Write_agent is extends from uvm_agent.
➢ Instance a driver, monitor, sequencer inside a agent
class.
➢ In build phase create a object for a monitor . If
is_active flag is set to UVM_ACTIVE ,construct the
driver and sequencer.
➢ If is_active is set to uvm_active in connect_phase()
method connect a driver and sequencer .
Example
Class my_agent extends uvm_agent;
ram_driver driver;
ram_monitor monitor;
ram_sequencer sequencer ;
ram_config m_tb_cfg;
Creating Environment
▪ my_env extends from a uvm_env.
▪ Declare a instances of all the agents inside a class .
▪ build phase() method in the environment class construct
all the agents .
Example
Class my_env extends uvm_env;
Ram_write_agent write_agent;
Ram_read_agent read_agent ;
Ram_config m_tb_cfg;
Function void build_phase (uvm_phase phase );
Super.build_phase(phase);
if(!uvm_config_db #(ram_config)::get(this, “”,
“ram_config”,m_tb_cfg))
`uvm_fatal(“get_type_name”, “cannot get()
from the uvm_config ”)
if(m_tb_cfg.has_write_agent)
write_agent=ram_write_agent::type_id::create
(“write_agent”,this)
if(m_tb_cfg.has_read_agent)
read_agent=ram_read_agent::type_id::create(“
read_agent”,this)
endfunction
UVM_TEST
A testcase is a pattern to check and verify specific
features and functionalities of a design.
A verification plan lists all the features and other
functional items that needs to be verified, and the tests neeeded
to cover each of them.
Creating test
▪ The user-defined test is derived from uvm_test.
▪ Declare a instances of env /agent inside a class.
▪ In build_phase construct all the environment.
▪ In build_phase configure all the parameters.
Example
Class my_test extends uvm_test;
Ram_env env_h;
Ram_config m_tb_cfg;