In OOO scoreboard example and need_to_compare

In the OOO scoreboard example, "need_to_compare"is assigned from below code:


    need_to_compare = (rcv_count.exists(idx) &&
                         ((is_before && rcv_count[idx] > 0) ||
                         (!is_before && rcv_count[idx] < 0)));

Why it is need to compare if there is a transaction from _before port? I thought we only need to check if there is an transaction from _after port.

https://verificationacademy.com/cookbook/scoreboards#Comparing_transactions_out-of-order

In reply to wyc123:

The comparator is trying to be very symmetrical. It has two ports, “before” and “after”. It allows you to connect the predictor and DUT to “before, after” or “after, before”. The code works if the actual DUT transaction comes in on the before port or the after. Might be a little too clever.

Download the tar file - the code is slightly different than the cookbook page. The example runs the same no matter how you connect the ports in scoreboard_ooo_imps.svh

class scoreboard_ooo_imps extends analysis_group_base;

 function void connect_phase(uvm_phase phase);

  // connect up scoreboard analysis exports
//  mon_axp.connect(comp.after_axp );                 // Original
//  predictor.results_ap.connect(comp.before_axp);    // Original
  mon_axp.connect(comp.before_axp );                  // Swapped
  predictor.results_ap.connect(comp.after_axp);       // Swapped