When sequencers are executed parallel, sequencer will arbitrate among the parallel sequence. When all the parallel sequences are waiting for a grant from sequencer using wait_for_grant() method, then the sequencer, using the arbitration mechanism, sequencer grants to one of the sequencer.
There are 6 different arbitration algorithms, they are
To set the arbitaration, use the set_arbitration() method of the sequencer. By default , the arbitration algorithms is set to SEQ_ARB_FIFO.
functionvoid set_arbitration(SEQ_ARB_TYPE val)
Lets look at a example.
In this example, I have 3 child sequences seq_mul seq_add and seq_sub each of them generates 3 transactions.
(S)Sequence code 1: virtualtask body();
repeat(3) begin `ovm_do_with(req, { inst == MUL; });
end endtask
(S)Sequence code 2: virtualtask body();
repeat(3) begin `ovm_do_with(req, { inst == ADD; });
end endtask
(S)Sequence code 3: virtualtask body();
repeat(3) begin `ovm_do_with(req, { inst == SUB; });
end endtask
(S)Parallel sequence code:
In the body method, before starting child sequences, set the arbitration using set_arbitration(). In this code, im setting it to SEQ_ARB_RANDOM.
class parallel_sequence extends ovm_sequence #(instruction);
seq_add add;
seq_sub sub;
seq_mul mul;
function new(string name="parallel_sequence");
super.new(name);
endfunction
(S)Log file report for when SEQ_ARB_RANDOM is set.
0: Driving Instruction MUL 10: Driving Instruction SUB 20: Driving Instruction MUL 30: Driving Instruction SUB 40: Driving Instruction MUL 50: Driving Instruction ADD 60: Driving Instruction ADD 70: Driving Instruction SUB 80: Driving Instruction ADD
(S)Log file report for when SEQ_ARB_FIFO is set.
0: Driving Instruction ADD 10: Driving Instruction SUB 20: Driving Instruction MUL 30: Driving Instruction ADD 40: Driving Instruction SUB 50: Driving Instruction MUL 60: Driving Instruction ADD 70: Driving Instruction SUB 80: Driving Instruction MUL
If you observe the first log report, all the transaction of the sequences are generated in random order. In the second log file, the transactions are given equal priority and are in fifo order.
Setting The Sequence Priority:
There are two ways to set the priority of a sequence. One is using the start method of the sequence and other using the set_priority() method of the sequence. By default, the priority of a sequence is 100. Higher numbers indicate higher priority.