Tricky operation (reordering) in a sequence body()


task foo::body()

forever begin

this.source_sequencer.get_next_item(tmp);
this.start_item(tmp);
this.finish_item(tmp);
this.source_sequencer.item_done();

end

endtask: body

In the above body(), I get only 1 item at a time.
The total number of items I can get is unknown a priori.
My goal is to reorder the items.
E.g. if the incoming items are A, B, C, the output should be (randomly) B, A, C.
How do I do this?
I am allowed to use a queue for storing “tmp”.
I am not allowed to change the behaviour of the upstream sequence.

Please let me know. Thank You!

Try having parallel sequencers for each data type and select from them randomly based on the order needed.

Good luck!!

In reply to new_to_uvm:

Storing in temporary queue and looking for the next required type may work. But assume a situation where you get a single type for quite some time. It will make the queue bigger and things will get out of control.

In reply to nsuresheee:

Thank You!

One potential issue is that you might not know how many upstream items will be generated which could lead to a potentially large queue. Plus, how would you know when you get all of the upstream items?

Why can’t you modify the upstream sequence? Anything that you have the source to can be modified.