Facebook/LinkedIn login is now deprecated, please disconnect our access to your social profile.
User dashboard under chipverify.com/connect will be deprecated from Oct 1, 2020, Read More.
Let us contribute to a cleaner Earth, Go Green Updated: May 31, 2020
1 minute reading time (258 words)

how to pass a command line argument to UVM testbench ?

how to pass a command line argument to UVM testbench ?

At times we might need to accept values from the command line to make our testbench and testcases more flexible. UVM provides this support via the uvm_cmdline_processor singleton class. Generation of the data structures which hold the command line arguments happen during construction of the class object. A global variable called uvm_cmdline_proc is created at initialization time which can be used to access command line options. Let's see more on how this feature can be used.

class my_test extends uvm_test;
  uvm_cmdline_processor   opts;
  string           cmdline;
  virtual function void build_phase (uvm_phase phase);
    super.build_phase (phase);
    opts = uvm_cmdline_processor::get_inst ();
  virtual function void start_of_simulation_phase (uvm_phase phase);
    super.start_of_simulation_phase (phase);
    if (opts.get_arg_value ("+OPTION=", cmdline) begin
      // Pass to testbench, set as config db, or what its worth

Let's dig a bit more deeper and see how this is setup in the UVM class structure. A singleton class object of uvm_cmdline_processor exists within uvm_root and is used to collect and process all the commonly available command line options like uvm_set_verbosity, UVM_TIMEOUT, and UVM_MAX_QUIT_COUNT.

class uvm_root extends uvm_component;
	uvm_cmdline_processor clp;
	function new ();
		clp = uvm_cmdline_processor::get_inst();
A new instance of uvm_cmdline_processor will be created via get_inst() in uvm_root before rest of the class hierarchy is done, and all subsequent calls to get_inst() will return the handle of an already existing object within the UVM environment.

class uvm_cmdline_processor extends uvm_report_object;
  static local uvm_cmdline_processor  m_inst;
  static function uvm_cmdline_processor get_inst ();
    if (m_inst == null)
      m_inst = new ("uvm_cmdline_proc");
    return m_inst;
When an X on clock almost went unnoticed
$deposit - Put a value onto any net/register

By accepting you will be accessing a service provided by a third-party external to https://www.chipverify.com/

You consent to our cookies if you continue to use our website. To know more about cookies, see our privacy policy. I accept cookies from this site.