This is a short one about how UVM handle plusargs UVM UVM_CONFIG_DB_TRACE and UVM_OBJECTION_TRACE. The reason I here is I am tying to document some stuff while going though UVM 1.2.

UVM_CONFIG_DB_TRACE Link to heading

Starting with base/uvm_config_db.svh, command line parses UVM_CONFIG_DB_TRACE and sets tracing.

     clp = uvm_cmdline_processor::get_inst();

     if (clp.get_arg_matches("+UVM_CONFIG_DB_TRACE", trace_args)) begin
       tracing = 1;
     end

There is a getter function is_tracing to get that tracing.

  static function bit is_tracing();
    if (!ready) begin
      init();
    end

    return tracing;
  endfunction

Moving on to where it’s used in base/uvm_config_db_implementation.svh. Obvious it is checked in get and set. as shown below.

  virtual function bit get (uvm_component     cntxt,
                                  string            inst_name,
                                  string            field_name,
                                  inout T           value);
    uvm_resource#(T) r;
    uvm_resource_pool rp = uvm_resource_pool::get();
    uvm_resource_types::rsrc_q_t rq;
    uvm_coreservice_t cs = uvm_coreservice_t::get();
...
...
    if(uvm_config_db_options::is_tracing())
      begin
        show_msg("CFGDB/GET", "Configuration","read", inst_name, field_name, cntxt, r);
      end
  virtual function void set(string                              cntxt_name,
                                  string                              inst_name,
                                  string                              field_name,
                                  T                                   value,
                                  int                                 cntxt_depth,
                                  uvm_pool#(string, uvm_resource#(T)) pool,
                                  uvm_component                       cntxt);

    if(uvm_config_db_options::is_tracing())
      begin
        show_msg("CFGDB/SET", "Configuration","set", inst_name, field_name, cntxt, r);
      end

UVM_OBJECTION_TRACE Link to heading

Starting with base/uvm_objection.svh, where command line is processed and UVM_OBJECTION_TRACE is parsed.

  function new(string name="");
    // Get the command line trace mode setting
    clp = uvm_cmdline_processor::get_inst();
    if(clp.get_arg_matches("+UVM_OBJECTION_TRACE", trace_args)) 
      begin
        m_trace_mode=1;
      end
    m_objections.push_back(this);
  endfunction

In objection implementation functions m_drop and m_raise, m_trace_mode is checked and m_report is called when enabled.

    if (m_trace_mode)
      begin
        m_report(obj,source_obj,description,count,"raised");
      end
    if (m_trace_mode)
      begin
        m_report(obj,source_obj,description,count,"dropped");
      end

Let’s have a look at m_report just for kicks. Essentially, It just prints m_source_count and m_total_count from obj and source_obj. It does some mental gymnastics to shorten full_name strings.

  function void m_report(uvm_object obj, uvm_object source_obj, string description, int count, string action);
    int _count = m_source_count.exists(obj) ? m_source_count[obj] : 0;
    int _total = m_total_count.exists(obj) ? m_total_count[obj] : 0;
    if (!uvm_report_enabled(UVM_NONE,UVM_INFO,"OBJTN_TRC") || !m_trace_mode) 
      begin
        return;
      end


    if (source_obj == obj)

      begin
        uvm_report_info("OBJTN_TRC", 
        $sformatf("Object %0s %0s %0d %0s objection(s)%s: count=%0d  total=%0d",
           obj.get_full_name()==""?"uvm_top":obj.get_full_name(), action,
           count, get_full_name(), description != ""? {" (",description,")"}:"", _count, _total), UVM_NONE);
      end

    else 
      begin
        int cpath = 0, last_dot=0;
        string sname = source_obj.get_full_name(), nm = obj.get_full_name();
        int max = sname.len() > nm.len() ? nm.len() : sname.len();

        // For readability, only print the part of the source obj hierarchy underneath
        // the current object.
        while((sname[cpath] == nm[cpath]) && (cpath < max)) 
        begin
          if(sname[cpath] == ".") 
            begin
              last_dot = cpath;
            end

          cpath++;
        end 

        if(last_dot) 
          begin
            sname = sname.substr(last_dot+1, sname.len());
          end

        uvm_report_info("OBJTN_TRC",
        $sformatf("Object %0s %0s %0d %0s objection(s) %0s its total (%s from source object %s%s): count=%0d  total=%0d",
           obj.get_full_name()==""?"uvm_top":obj.get_full_name(), action=="raised"?"added":"subtracted",
            count, get_full_name(), action=="raised"?"to":"from", action, sname, 
            description != ""?{", ",description}:"", _count, _total), UVM_NONE);
      end
  endfunction