Search form

Main menu

My Account Menu

uvm_comparer

ValhallaOne
ValhallaOne
Full Access
12 posts

I am attempting to compare uvm_sequence_item objects in my scoreboard, but I keep getting a NULL-Object reference error. I have do_compare implemented in my transaction class, and I wish to use the uvm_default_comparer.

static uvm_comparer comparer = uvm_default_comparer;

In run_phase...

comparer.sev = UVM_ERROR;
comparer.show_max = 100; //not sure what this value should be
comparer.init();

...

in_buff[compare_count].compare(out_buff[compare_count], comparer);

in_buff and out_buff are two dynamic arrays that are newed with the scoreboard.

	
function new(string name, uvm_component parent);
	super.new(name, parent);
	cg = new;
	out_buff = new[1];
	in_buff = new[1];
endfunction: new	

What is wrong with my initilization of the comparer?

Thanks in advance

Answers

dave_59
dave_59
Forum Moderator
1474 posts

You should never initialize a static variable with another static variable. This is called the static initialization order fiasco.

The immediate fix to your code is to call the static init() method:

static uvm_comparer comparer = uvm_comparer::init();

But I question why this needs to be a static variable in the first place. You should be able to make it a regular class member and initialize it in any phase before the run_phase().

Comments on this answer

Thanks for the tip about statically creating the comparer. I changed it up so it's no longer static. Problem solved.