UVM Interview Questions Part 2 1705926241
UVM Interview Questions Part 2 1705926241
1. Immediate Assertions – are executed like a statement in a procedural block & follow
simulation event semantics. These are used to verify immediate property during simulation
2. Concurrent Assertions – are based on clock semantics. Properties get evaluated everytime
on given clock.
2. What is functional coverage? How is it different from code coverage?
• Functional coverage is a measure of how functionalities/features of the design have been
exercised by the tests. This is useful in constrained random verification (CRV) to know
what features have been covered by a set of tests in regression.
Code coverage measures how much of the design code is exercised. This includes the execution
of design blocks, Number of Lines, Conditions, FSM, Toggle and Path.
• In a verification context, a register model (or register abstraction layer) is a set of classes
that model the memory mapped behavior of registers and memories in the DUT in order
to facilitate stimulus generation and functional checking (and optionally some aspects of
functional coverage). The UVM provides a set of base classes that can be extended to
implement comprehensive register modeling capabilities.
• We all know about new () method that is use to allocate memory to an object instance. In
UVM (and OVM), the create () method causes an object instance to be created from the
factory. This allows you to use factory overrides to replace the desired object with an
object of a different type without having to recode.
• uvm_analysis_port
Broadcasts a value to all subscribers implementing a uvm_analysis_imp.
• uvm_analysis_imp
Receives all transactions broadcasted by a uvm_analysis_port.
• uvm_analysis_export
Exports a lower-level uvm_analysis_imp to its parent.
• In simpler words TLM FIFO is a FIFO between two UVM components, preferably between
Monitor and Scoreboard. Monitor keep on sending the DATA, which will be stored in TLM
FIFO, and Scoreboard can get data from TLM FIFO whenever needed.
8. What is the difference between UVM RAL model backdoor write/read and front door
write/read?
• Fontdoor access means using the standard access mechanism external to the DUT to read
or write to a register. This usually involves sequences of time-consuming transactions on
a bus interface.
• Backdoor access means accessing a register directly via hierarchical reference or outside
the language via the PLI. A backdoor reference usually in 0 simulation time.
9. What is objection?
• There is a built-in objection for each in-built phase, which provides a way for components
and objects to synchronize their testing activity and indicate when it is safe to end the phase
and, ultimately, the test end.
• The component or sequence will raise a phase objection at the beginning of an activity that
must be completed before the phase stops, so the objection will be dropped at the end of
that activity. Once all of the raised objections are dropped, the phase terminates.
• m_sequencer is the default handle for uvm_vitual_sequencer and p_sequencer is the hook
up for child sequencer.
• m_sequencer is the generic uvm_sequencer pointer. It will always exist for the
uvm_sequence and is initialized when the sequence is started.
• The drawback of p_sequencer is that once the p_sequencer is defined, one cannot run the
sequence on any other sequencer type.
11. What is the difference between Active mode and Passive mode with respect to agent?
• In active mode, the sequencer and the driver are constructed and stimulus is generated by
sequences sending sequence items to the driver through the sequencer. At the same time
the monitor assembles pin level activity into analysis transactions.
• In passive mode, only the monitor is constructed and it performs the same function as in
an active agent. Therefore, your passive agent has no need for a sequencer. You can set up
the monitor using a configuration object.
• The built-in copy () method executes the __m_uvm_field_automation() method with the
required copy code as defined by the field macros (if used) and then calls the built-
in do_copy() virtual function. The built-in do_copy() virtual function, as defined in the
uvm_object base class, is also an empty method, so if field macros are used to define the
fields of the transaction, the built-in copy () method will be populated with the proper code
to copy the transaction fields from the field macro definitions and then it will execute the
empty do_copy() method, which will perform no additional activity.
• The copy () method can be used as needed in the UVM testbench. One common place
where the copy () method is used is to copy the sampled transaction and pass it into a
sb_calc_exp() (scoreboard calculate expected) external function that is frequently used by
the scoreboard predictor.
• The clone () method calls the create () method (constructs an object of the same type) and
then calls the copy () method. It is a one-step command to create and copy an existing
object to a new object handle.
• UVM Factory is used to manufacture (create) UVM objects and components. Apart from
creating the UVM objects and components the factory concept essentially means that you
can modify or substitute the nature of the components created by the factory without
making changes to the testbench.
• For example, if you have written two driver classes, and the environment uses only one of
them. By registering both the drivers with the factory, you can ask the factory to substitute
the existing driver in environment with the other type. The code needed to achieve this is
minimal, and can be written in the test.
14. What are the types of sequencers? Explain each?
• A virtual sequencer is a sequencer that is not connected to a driver itself, but contains
handles for sequencers in the testbench hierarchy. It is an optional component for running
of virtual sequences - optional because they need no driver hookup, instead calling other
sequences which run on real sequencers.
• A sequence which controls stimulus generation across more than one sequencer, coordinate
the stimulus across different interfaces and the interactions between them. Usually, the top
level of the sequence hierarchy i.e., 'master sequence' or 'coordinator sequence'. Virtual
sequences do not need their own sequencer, as they do not link directly to drivers. When
they have one it is called a virtual sequencer.
• This mechanism can be used only with components. Sequences and transactions cannot be
configured using this mechanism. When set_config_* method is called, the data is stored
w.r.t strings in a table. There is also a global configuration table.
• Higher level component can set the configuration data in level component table. It is the
responsibility of the lower-level component to get the data from the component table and
update the appropriate table.
• following are the method to configure integer, string and object of uvm_object based class
respectively.
function void set_config_object (string inst_name, string field_name, uvm_object value, bit
clone = 1)
• The RAL (register abstraction layer) provides accesses to DUT and also keeps a track of
register content of DUT.
• UVM RAL can be used to automate the creation of high-level, object-oriented abstraction
model of registers and memory in DUT.
• Register layer makes the register abstraction and access of its contents independent of the
bus protocol which is used to transfer data in and out of registers inside the design.
• Hierarchical model provided by RAL makes the reusability of test bench components very
easy.
• The changes in initial configuration of registers or specifications can be easily
communicated in the entire environment. RAL layer supports both front door and backdoor
access. The backdoor access does not use the bus interface rather it uses the HDL defined
paths for direct communication with the device. Thus, in zero simulation time the registers
of device can be reconfigured using the backdoor access and verification can be started.
• One more advantage of backdoor access is that it can be used for verify if the access
through front door is happening correctly. To achieve this the front door, write is verified
using backdoor read.
Weighted distribution weight will be specified to the values inside the constraint
block. Value with the more weight will get allocated more often to a random variable.
constraint addr_range {addr1 dist {2: = 5, 7: = 8, 10: = 12};}
constraint addr_range {addr2 dist {[ 100: 200]: / 200};}
• Conditional constraint
Implication constraints
constraint address_range { (addr_range >= 3'd7) -> (addr < 8);}
If else constraints
constraint address_range {if(addr_range >= 3'd7)
addr < 8;
else
addr > 8;}
• Inline constraint
Inline constraint allows the user to add extra constraints to existing constraints written
inside the class. inline constraints will be written outside the class i.e along with the randomize
method call.
initial
begin
packet pkt;
pkt = new ();
pkt.randomize() with { addr == 8;};
$display ("addr = %0d", pkt.addr);
end
• Soft constraint
A soft constraint is a constraint on a random variable, which allows overriding the
constraint.
constraint addr_range {soft addr > 6;}
• Like class members, constraints also will get inherited from parent class to child class.
• Constraint blocks can be overridden by writing constraint block with the same name as in
parent class.
7. What is Randomization
• Randomization is the process of generating random values to a variable.
• Verilog – Randomization of the variables alone ($random, $urandom).
• System Verilog –Randomization of variables and dynamic class
objects(rand,randc,randomize()).
• rand
Variables declared with the rand keyword are standard random variables. Their values
are uniformly distributed over their range.
Eg : rand bit [3:0] addr;
• randc
Variables declared with the randc keyword, on randomization variable values don’t
repeat a random value until every possible value has been assigned.
Eg : randc bit [3:0] addr;
• pre_randomize
The pre_randomize function can be used to set pre-conditions before the object
randomization.
For example, Users can implement randomization control logic in pre_randomize
function. i.e randomization enable or disable by using rand_mode() method.
• post_randomize
The post_randomization function can be used to check and perform post-conditions
after the object randomization.
For example, Users can override the randomized values or can print the randomized
values of variables.
Property delay_p;
@ (posedge clk) a ## 2 b;
endproperty
These are the operational steps from a Sequence which we want to execute using a
Sequencer that is connected to a Driver inside an “Agent”.
Sequence Code:
`uvm_object_utils(my_seq)
// Constructor
super.new(name);
endfunction: new
// Body Task
task body;
repeat(n)
begin
my_txn txn;
// Step 1
start_item(txn);
// Step 2
// Step 3
// Step 4
finish_item(txn);
end
endtask: body
endclass: my_seq
`uvm_component_utils(my_driver)
………
………
// Run Task
// Step 1
my_txn txn;
forever begin
// Step 2
seq_item_port.get_next_item(txn);
// Step 3
@ (posedge vif.clk)
begin
vif.addr = txn.addr;
vif.data = txn.data;
vif.we = txn.we;
end
// Step 4
seq_item_port.item_done();
end
endtask: run_phase
………
endclass: my_driver
Fork-Join will start all the processes inside it parallel and wait for the completion of all the
processes.Using “begin end” inside fork join we can execute threads sequentially.
a) TOP
TestBench top is the module, it connects the DUT and Verification environment components.
Typical Testbench_top contains
• DUT instance
• interface instance
• run_test() method
• virtual interface set config_db
• clock and reset generation logic
b)UVM test
c)UVM Environment
Env or environment: The environment is a container component for grouping higher level
components like agent’s and scoreboard.
d)UVM Agent
The sequence-item defines the pin level activity generated by agent (to drive to DUT through the
driver).
f) UVM DRIVER
Responsible for driving the packet level data inside sequence_item into pin level (to DUT).
g) UVM SEQUENCE
Defines the sequence in which the data items need to be generated and sent/received to/from the
driver.
h) UVM SEQUENCER
Responsible for routing the data packet’s(sequence_item) generated in sequence to the driver or
vice-verse.
i)UVM MONITOR
Observes pin level activity on interface signals and converts into packet level which is sent to
components such as scoreboards.
j) UVM Scoreboard
Receives data items from monitor’s and compares with expected values. expected values can be
either golden reference values or generated from the reference model.
15.Task and function
Tasks and Functions provide a means of splitting code into small parts.
A Task can contain a declaration of parameters, input arguments, output arguments, in-out
arguments, registers, events, and zero or more behavioral statements.
• static
• automatic
i)Static tasks
Static tasks share the same storage space for all task calls.
ii)Automatic tasks
Automatic tasks allocate unique, stacked storage for each task call.
SystemVerilog allows,
A Function can contain declarations of range, returned type, parameters, input arguments,
registers, and events.
• static
• automatic
i)Static Function
Static functions share the same storage space for all function calls.
ii)Automatic Function
Automatic functions allocate unique, stacked storage for each function call.
SystemVerilog allows,
A Task can contain a declaration of parameters, input arguments, output arguments, in-out
arguments, registers, events, and zero or more behavioral statements.
• static
• automatic
i)Static tasks
Static tasks share the same storage space for all task calls.
ii)Automatic tasks
Automatic tasks allocate unique, stacked storage for each task call.
`uvm_object_utils(mem_sequence)
//Constructor
function new (string name = "mem_sequence");
super.new(name);
endfunction
endtask
endclass
• UVM_test code
class mem_model_test extends uvm_test;
`uvm_component_utils(mem_model_test)
mem_model_env env;
mem_sequence seq;
endclass : mem_model_test
mem_agent mem_agnt;
`uvm_component_utils(mem_model_env)
// new - constructor
function new (string name, uvm_component parent);
super.new(name, parent);
endfunction : new
// build_phase
function void build_phase(uvm_phase phase);
super.build_phase(phase);
mem_agnt = mem_agent::type_id::create ("mem_agnt", this);
endfunction : build_phase
endclass : mem_model_env
• The clock event that provides a synchronization reference for DUT and
testbench
• The set of signals that will be sampled and driven by the testbench
• The timing, relative to the clock event, that the testbench uses to drive and
sample those signals
i)Clocking event
The event specification used to synchronize the clocking block, @ (posedge clk) is the clocking
event.
ii)Clocking signal
Signals sampled and driven by the clocking block, from DUT and to DUT are the clocking
signals,
iii)Clocking skew
Clocking skew specifies the moment (w.r.t clock edge) at which input and output clocking
signals are to be sampled or driven respectively. A skew must be a constant expression and can
be specified as a parameter.
Input (or inout) signals are sampled at the designated clock event. If an input skew is specified
then the signal is sampled at skew time units before the clock event. Similarly, output (or inout)
signals are driven skew simulation time units after the corresponding clock event. A skew must
be a constant expression and can be specified as a parameter. In case if the skew does not specify
a time unit, the current time unit is used.
Modport
SystemVerilog Modport. The Modport groups and specifies the port directions to the
wires/signals declared within the interface. modports are declared inside the interface with the
keyword modport.
19. RAL
• In a verification context, a register model (or register abstraction layer) is a set of classes
that model the memory mapped behavior of registers and memories in the DUT in order
to facilitate stimulus generation and functional checking (and optionally some aspects of
functional coverage). The UVM provides a set of base classes that can be extended to
implement comprehensive register modeling capabilities.
• The RAL (register abstraction layer) provides accesses to DUT and also keeps a track of
register content of DUT.
• UVM RAL can be used to automate the creation of high-level, object-oriented abstraction
model of registers and memory in DUT.
• Register layer makes the register abstraction and access of its contents independent of the
bus protocol which is used to transfer data in and out of registers inside the design.
• Hierarchical model provided by RAL makes the reusability of test bench components very
easy.
• The changes in initial configuration of registers or specifications can be easily
communicated in the entire environment. RAL layer supports both front door and backdoor
access. The backdoor access does not use the bus interface rather it uses the HDL defined
paths for direct communication with the device. Thus, in zero simulation time the registers
of device can be reconfigured using the backdoor access and verification can be started.
• One more advantage of backdoor access is that it can be used for verify if the access
through front door is happening correctly. To achieve this the front door, write is verified
using backdoor read.
21. Write a packed array and unpacked array and initialise value and then assign packed
array values to unpacked array?
module top;
packed_array pa = 4’b1010;
unpacked_array upa;
initial
begin
upa = unpacked_array’(pa);
end
endmodule