Professional Documents
Culture Documents
obj o;
o.set_report_verbosity_level(UVM_NONE);
int level = o.get_report_verbosity_level;
set/get verbosity
code
UVM – Chapter 4 content
endclass end
endmodule
UVM – Why Object-Oriented Programming?
The functions and tasks inside a class are called class methods.
Properties of a class can be accesses using the object handler.
module tb;
class dummy;
dummy d; // Class handler
bit [7:0] A; // class property
initial begin // procedural block
function void print(string s);
d = new(); // allocate memory for d object
$display(s);
d.A = 8'h3B;
endfunction
d.print(“Hola”); // calling print method
endclass
end
endmodule
UVM – Why Object-Oriented Programming?
Lab: This lab presents how structures can be used with SystemVerilog.
UVM – Why Object-Oriented Programming?
Lab: This lab presents how classes can be used with SystemVerilog.
UVM – Why Object-Oriented Programming?
Assignment. This assignment consists of generating random stimulus for the input ports
of the following module using class-based coding. Use a class method to print the values
in hex. Hint: use randomize() class method.
bit A [15:0]
bit B [15:0] Z [15:0]
Z = f(A,B,En)
bit En
UVM – Why Object-Oriented Programming?
Assignment. This assignment consists of generating random stimulus for the input ports
of the following module using class-based coding. And print the values in hex.
UVM – Why Object-Oriented Programming?
Class methods can also have input arguments, just as conventional programming
functions.
this keyword
distinguishes
class member
from method
local variable
UVM – Why Object-Oriented Programming?
Lab: This Lab shows how class inheritance can be used to extend an existing class, by
adding new features, this feature is widely used in UVM testbench, thus, it is important
to understand its behavior and advantages.
Class inheritance
code
UVM – Why Object-Oriented Programming?
Class methods can be overridden in a child class. This can be only done with methods
declared as virtual in parent class.
endfunction endtask
UVM – Why Object-Oriented Programming?
Lab: This Labs shows how methods of parent class, can be redefined within a child
class by declaring methods in parent class as virtual. Virtual methods are used to apply
polymorphism dynamically (i.e. at run-time). NOTE: Constructor function must always
be non-virtual function.
Class inheritance
code
Class inheritance
Code 2