IMPORTANT NOTICE: Please be advised that the Verification Academy Forums will be offline for scheduled maintenance on Sunday, April 6th at 2:00 US/Pacific.
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.
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.
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.