Flush function of uvm_in_order_class_comparator not working

The flush function of the uvm_in_order_class_comparator is not working.

This is how I used it in my code when the scoreboard see a reset,


comp_cmd.flush();

But still the FIFO is not flushed.
What is the right way of using this function?

I believe this is a bug in the UVM Class reference. Looking at the source code, you need to call do_flush() instead of flush(). This is a method of uvm_component that calls the flush() method of itself, and all of its children components. I have filed 0005047

In reply to dave_59:

Hi dave,

I tried the do_flush() but still it is not flushing the FIFO.
It is setting the m_matches and m_mismatches to 0 but the FIFO is still not flushed.

In reply to Reuben:

Is it because I am creating a new item every time I’m pushing the item to the FIFO?

In reply to Reuben:

You need to call do_flush from the parent component that has the 2 FIFOs and the comparator as its children.

In reply to dave_59:

From the parent component?

I created a uvm_in_order_class_comparator in the build_phase of my scoreboard.
Then in the write function I’m calling the do_flush()


virtual function void build_phase(uvm_phase phase);
  comp_cmd = uvm_in_order_class_comparator#(packet)::type_id::create("comp_cmd", this);
endfunction

virtual function void write_exp_imp(packet tr);
  if(tr.reset) begin
    comp_cmd.do_flush();
  end
endfunction

What do you mean by calling it from the parent component?

In reply to Reuben:

This method sets m_matches and m_mismatches back to zero. The uvm_tlm_fifo::flush takes care of flushing the FIFOs.

In reply to lcf0451:

Okay, so you mean it is not the flush() that takes care the flushing of FIFO. It’s the uvm_tlm_fifo::flush() that takes care of it?
Is there a good website where I can see these codes together with their parents?

In reply to Reuben:

From UVM 1.1d
class uvm_in_order_comparator
#( type T = int ,
type comp_type = uvm_built_in_comp #( T ) ,
type convert = uvm_built_in_converter #( T ) ,
type pair_type = uvm_built_in_pair #( T ) )
extends uvm_component;

// Function: flush
//
// This method sets m_matches and m_mismatches back to zero. The
// <uvm_tlm_fifo::flush> takes care of flushing the FIFOs.

virtual function void flush();
m_matches = 0;
m_mismatches = 0;
endfunction

In reply to lcf0451:

Your scoreboard is the parent component of the comparator. Where are the FIFOs in relationship to your scoreboard? If they are also built by the scoreboard, then just calling this.do_flush() will take care of it. If they are outside the scoreboard, you will have to flush them explicitly (and might be a good case for moving them inside the scoreboard).

In reply to dave_59:

Hi dave,

The FIFOs are in the uvm_in_order_class_comparator.
The handle for that class is the comp_cmd.

The function flush() is inherited from uvm_in_order_comparator, while the do_flush() is inherited from uvm_component.

This is the class hierarchy from uvm_in_order_class_comparator up to its parents:

uvm_void
uvm_object extends uvm_void
uvm_report_object extends uvm_object
uvm_component extends uvm_report_object
uvm_in_order_comparator #( type T = int , type comp_type = uvm_built_in_comp , type convert = uvm_built_in_converter , type pair_type = uvm_built_in_pair ) extends uvm_component
uvm_in_order_class_comparator extends uvm_in_order_comparator

In reply to Reuben:

Yes, my mistake.

Actually the FIFOs are in the uvm_in_order_comparator, and uvm_in_order_comparator is extended from uvm_component. do_flush is defined as

2007 function void uvm_component::do_flush();
2008  foreach( m_children[s] )
2009     m_children[s].do_flush();
2010  flush();
2011 endfunc  tion

Since the fifos are children of uvm_in_order_comparator, their do_flush methods should have been called, which would eventually call the uvm_tlm_fifo::flush() method. So I don’t understand why you say your FIFOS are not getting flushed.

In reply to dave_59:

Thanks dave.
I think I should rather use a queue and uvm_compare than a comparator.

Hi Reuben/Dave,

I am also facing this issue.
I tried something like DATA_COMPARATOR.do_flush();

I also tried DATA_COMPARATOR.flush();

Its not working. I am doing this in my scoreboard which is extended from uvm_scoreboard.

What is the solution for this?

In reply to verif_buff:

The UVM committee seems to have abandoned uvm_*_comparators. Make your own.