Igital Erification Low: Ahmoud Aeed Lbosily, Taff Erification Ngineer
Igital Erification Low: Ahmoud Aeed Lbosily, Taff Erification Ngineer
§ SystemVerilog Processes
§ SystemVerilog Class
§ System Verilog Constrained Randomization
§ SystemVerilog Funtional Coverage
§ fork-join:
Parallel Blocks fork-join:
▪ Object Oriented design is a common programming model “OOP”. Data and the means to manipulate are
described together in a formal structure called a class.
▪ A class is a datatype:
• Like a struct: Has data elements called properties
• Contains functions and tasks called methods, through which class properties may be manipulated
▪ An instance of a class is referred to as an object.
▪ SystemVerilog objects are dynamically created and destroyed.
▪ Memory allocation and deallocation are handled automatically by SystemVerilog.
▪ Pointers are a key in the flexibility of using classes, SystemVerilog implements them too and called handles.
▪ Code minimization and reuse is facilitated through inheritance, parameterization and polymorphism.
§ You must not give a return value type, as the constructor is a special function new( int a = 3 , b = 5);
function and automatically returns a handle to an object of the same A = a;
type as the class. B = b;
endfunction : new
§ Check the declaration of the handles of txn1 to txn4 and check the endclass
objects construction.
initial begin
§ Please keep in your mind we have two different statements: Transaction txn1, txn2, txn3, txn4;
txn1 = new();
• Declare the handle txn2 = new (4,7);
• Create the object txn3 = new (.a(10), .b(12));
txn4 = new[5];
§ You declare a handle and construct/create an object. end
txn1 1st
txn2 Object
2nd 1st
txn1 txn2
Object Object
▪ You can deallocate explicitly, by assign null value to txn1. Now the
1st and 2nd objects memory spaces are garbage. 2nd 1st
txn1
Object Object
§ Class methods can be normal SystemVerilog functions/task or both. extern function void add();
§ Defining class methods can be inside/outside the scope of the class. function void Calculator::add();
input_a = 20;
§ Please refer to the examples provided for more understanding. result = input_a + input_b;
$display("Result from add function: %d", result);
§ Methods can be defined inside the class scope or outside the class. endfunction : add
§ Please check the static variables and static function examples. static int unsigned input_a;
• Static variables and methods can be accessed directly by the data type Calculator::input_a ++;
“class name Calculator” using the scope operator “::” as shown.
• Static variables and methods can be accessed also by the class object extern static function void incr();
itself, and static variables can be modified inside a class method Calculator::incr();
regardless it’s defined as static or automatic as shown. Or at the c1.incr();
new() function.