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.