Question on index_id related to comparison

https://verificationacademy.com/cookbook/scoreboards#Reporting_and_Recording

This OOO comparator uses an index_id function(user written, correct?) to generate an index associated with every transaction and puts it in an associative array with index = 3 and data into the queue. If two transactions come from the same index_id we use the index(key) = 3 and push the 2nd transaction into the queue in FIFO order.

  1. What happens if on the opposite stream, the 2nd transaction of this queue, comes earlier than the 1st transaction in the queue?

When we pop data out of the queue after checking for index_id, we will pop out 1st transaction and report a mismatch?

2)Also, how do we know which index_id to compare to, when data comes from opposite stream? Since index_id is a locally written function and the stream of DUT side does not know anything about index_id?

Please correct me if I am missing something in the comparison logic?

Thanks

In reply to UVM_learner6:

The code in this example was written for more complex scenarios. I believe it assumes that transactions with different index_id’s can be received in any order, but transaction sent with the same index_id will be received in the same order sent. It will be much easier to understand if you assume that only one index_id gets used for each before/after pair. That way the
rcv_count.exists(idx) method tells you if opposite stream has already received a paired transaction with the same index_id().

index_id() returns some serial number that was encoded into the transaction when it got created. If no dedicated field for a serial number exists in the transaction already, there are ways of encoding that information into the random payload data, length, unused bits, or checksum. If there is no way of encoding this information and sending it through the DUT, you can’t use an OOO scoreboard.

In reply to dave_59:

Thanks - This clarifies my question on index_id usage.

Specifically these two points- " I believe it assumes that transactions with different index_id’s can be received in any order, but transaction sent with the same index_id will be received in the same order sent" and “index_id() returns some serial number that was encoded into the transaction when it got created.”.