I have a question about virtual sequencer in UVM. Let's think that I have N equal interfaces driven by N equal drivers, each one connected to its own sequencer. What I want to do is to have a transaction like:
class my_transaction extends uvm_sequence_item;
logic data;
int num_if;
endclass
that when executed with `uvm_do() is sent to the driver number num_if. My idea is that for this kind of work I need a virtual sequencer that "forward" the transaction to the right sequencer (the number num_if). Is this right? If yes, how it could be done? Thanks.
While Tudor's answer will work technically, conceptually the decision on which of the interfaces to run on (num_if) is a value that should not belong to the transaction, but to the sequence that calls it (which of course should also be randomized). Transactions should contain only a representation of the value that travels from A to B and the way in which it travels for that protocol. The specification of which A and B is normally outside of the responsibility of a transaction.
In which case, a variation on your transaction and Tudor's sequence would look like this:
..and..
..running on the virtual sequencer as Tudor says:
The above approach also lets the randomization happen in the correct place: after start_item() returns and immediately prior to calling finish_item() which completes the sequence item.