UVM Scoreboard

 UVM Scoreboard 


User-defined scoreboard is extended from uvm_scoreboard, uvm_scoreboard is inherited by uvm_component.

 Writing Scoreboard : 

1. Scoreboard is written by extending the UVM_SCOREBOARD.

class mem_scoreboard extends uvm_scoreboard;

  `uvm_component_utils(mem_scoreboard)

  // new - constructor
  function new (string name, uvm_component parent);
    super.new(name, parent);
  endfunction : new

endclass : mem_scoreboard


Socreboard will check the correctness of the DUT by comparing the DUT output with the expected values. scoreboard will receive the transactions from the Monitors implemented inside agents.
Monitor and scoreboard will communicate via TLM ports and exports.

Scoreboard shall compare the DUT output values with,
1.The golden reference values.
2.The values Generated from reference model.


*click on image for better view


2. Declare and Create TLM Analysis port, ( to receive transaction pkt from Monitor).

//Declaring port
uvm_analysis_imp#(mem_seq_item, mem_scoreboard) item_collected_export;

//creating port
item_collected_export = new("item_collected_export", this);

3. analysis export of Scoreboard is connected to Monitor port.

monitor.item_collected_port.connect(scoreboard.item_collected_export);

4. Adding Write Method:
write method of scoreboard will receive the transaction packet from monitor, on calling write method from monitor.


 
  //calling write method from monitor
  item_collected_port.write(pkt);
 
  //scoreboard write function
  virtual function void write(mem_seq_item pkt);
    pkt.print();
  endfunction : write

 Complete scoreboard code 

class mem_scoreboard extends uvm_scoreboard;

  `uvm_component_utils(mem_scoreboard)
  uvm_analysis_imp#(mem_seq_item, mem_scoreboard) item_collected_export;

  // new - constructor
  function new (string name, uvm_component parent);
    super.new(name, parent);
  endfunction : new

  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    item_collected_export = new("item_collected_export", this);
  endfunction: build_phase
  
  // write
  virtual function void write(mem_seq_item pkt);
    $display("SCB:: Pkt recived");
    pkt.print();
  endfunction : write

endclass : mem_scoreboard