Question

I have a UVM scoreboard that has multiple checks that cause `uvm_error. I would like to automatically intercept the uvm_error and dump the contents of my scoreboard. Other engineers will be adding checks to the scoreboard (and its children), so the callback should be as transparent as possible.

Simple example for what I'm trying to do:

  task run_phase(uvm_phase phase);
    phase.raise_objection(this);
    // How to do an automatic sb.dump_contents() callback?
    `uvm_error("ERROR", "scoreboard caught an error");
    phase.drop_objection(this);
  endtask

  function void dump_contents();
    $display("The queue contents of my scoreboard.");
  endfunction

You can simulate and modify the above example on EDA Playground: http://www.edaplayground.com/s/4/549

What is the UVM recommended way to do this? Can someone share working code?

Was it helpful?

Solution

You want to set up a report_catcher. this intercepts the report and you can either add the dump to the message string, or put it in a separate message. And to make the report easier to catch, you should use a unique Message ID like "SBERRDMP" to catch ScoreBoard ERRors that add a complete DuMP.

class sb_dump_catcher extends uvm_report_catcher;
  function new(string name="sb_dump_catcher");
    super.new(name);
  endfunction
  function action_e catch();
    if(get_severity() == UVM_ERROR && get_id() == "SBERRDMP")
      begin
         sb sb_h;
         if ( !$cast(sb_h, get_client()) ) `uvm_error("NOTASB", "The Message ID \"SBERRDMP\" is reserved for my scoreboard")
         set_message( {get_message, "/n", sb_h.dump_contents()} );
      end
    return THROW;
  endfunction
endclass

Then in some phase of your scoreboard, you add this catcher to the callback list

function void start_of_simulation_phase(uvm_phase phase);
  sb_dump_catcher h = new;
  uvm_report_cb::add(this, h);
endfunction
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top