Uvm_algorithmic_comparator

There are multiple problems with your code - refer to the reference guide for uvm_algorithmic_comparator for the correct usage / see the corrected code below:

The type signature is uvm_algorithmic_comparator #(BEFORE,AFTER,TRANSFORMER) where TRANSFORMER should be a CLASS that contains a method with the signature ‘function AFTER transform (BEFORE b)’ i.e. which takes an object of type BEFORE and returns a transformed object of type AFTER. That class can be your scoreboard class, or some other class of your choosing.

class scoreboard extends uvm_algorithmic_comparator#(before_item, after_item, scoreboard);
`uvm_component_utils(scoreboard)

Your two fifos were the wrong way around:

  uvm_tlm_analysis_fifo #(after_item) after_fifo;
  uvm_tlm_analysis_fifo #(before_item) before_fifo;
  after_item hi;
  after_item hi1 = new;
  before_item pi;

Your constructor does NOT need a third argument, only the uvm_algorithmic_comparator constructor does (you call it with super.new()). In this example we are passing ‘this’ so that the base class can call OUR transform() method:

  function new(string name = "scoreboard", uvm_component parent=null);
    super.new(name, parent, this);
    before_fifo = new("before_fifo", this);
    after_fifo = new("after_fifo", this);
  endfunction

Note that your usage of the transform() is not strictly as intended, better to use its return value rather than have it update a class member variable. What you have does compile OK however.

  function after_item transform (before_item item);
    hi1.data = item.data;
  endfunction

  task run_phase(uvm_phase phase);
    forever
      begin
	before_fifo.get(pi);
	after_fifo.get(hi);
	transform(pi);
	if(!hi.compare(hi1))
	  $display("DATA MISMATCH");
	else
	  $display("DATA MATCHED");
      end
  endtask	

endclass

Note that this comparator is suitable only for simple scoreboarding requirements.