Default arguments for constructor

import uvm_pkg::*;
`include “uvm_macros.svh”

class pkt extends uvm_sequence_item;
`uvm_object_utils(pkt)

function new(string path);
super.new(path);
endfunction

endclass

The following code gives the error
MESSAGE_SP VCP2124 “Package uvm_pkg found in library uvm_1_2.”
ERROR VCP2890 “Unspecified argument is used for an argument that does not have a default value: path.” “testbench.sv” 5 413
ERROR VCP2890 “Unspecified argument is used for an argument that does not have a default value: path.” “/usr/share/Riviera-PRO/vlib/uvm-1.2/src/base/uvm_registry.svh” 207 30

It gets resolved if I change the new function as follows
function new(string path = “”);

Why do we need to have default args for the new constructor ?

It’s because of how factory registration works and backward compatibility. Older versions of UVM did not require uvm_object to have a name argument.

https://verificationacademy.com/verification-methodology-reference/uvm/docs_1.2/html/files/overviews/relnotes-txt.html#Mantis_4518(*)(+)

1 Like