|HOME |ABOUT |ARTICLES |ACK |FEEDBACK |TOC |LINKS |BLOG |JOBS |

Tutorials

OVM SEQUENCE 4

Sequencer Arbitration:

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.

function void 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:
repeat(3) begin
`ovm_do_with(req, { inst == MUL; });
end

(S)Sequence code 2:
repeat(3) begin
`ovm_do_with(req, { inst == ADD; });
end

(S)Sequence code 3:
repeat(3) begin
`ovm_do_with(req, { inst == SUB; });
end

(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_sub sub;
seq_mul mul;

function new(string name="parallel_sequence");
super.new(name);
endfunction

`ovm_sequence_utils(parallel_sequence, instruction_sequencer)

m_sequencer.set_arbitration(SEQ_ARB_RANDOM);
fork
`ovm_do(sub)
`ovm_do(mul)
join

endclass

ovm_sequence_7.tar
Browse the code in ovm_sequence_7.tar

(S)Command to sun the simulation

Your_tool_simulation_command +incdir+path_to_ovm testcase.sv

(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.

virtual task start (ovm_sequencer_base sequencer,
ovm_sequence_base parent_sequence = null,
integer this_priority = 100,
bit call_pre_post = 1)

function void set_priority (int value)

Lets look a example with SEQ_ARB_WEIGHTED.

For sequence seq_mul set the weight to 200.
For sequence seq_add set the weight to 300.
For sequence seq_sub set the weight to 400.

In the below example, start() method is used to override the default priority value.

(S)Code :

class parallel_sequence extends ovm_sequence #(instruction);

seq_sub sub;
seq_mul mul;

function new(string name="parallel_sequence");
super.new(name);
endfunction

`ovm_sequence_utils(parallel_sequence, instruction_sequencer)

m_sequencer.set_arbitration(SEQ_ARB_WEIGHTED);
sub = new("sub");
mul = new("mul");
fork
sub.start(m_sequencer,this,400);
mul.start(m_sequencer,this,200);
join

endclass

ovm_sequence_8.tar
Browse the code in ovm_sequence_8.tar

(S)Command to sun the simulation

Your_tool_simulation_command +incdir+path_to_ovm testcase.sv

(S)Log file report

0: Driving Instruction MUL
10: Driving Instruction ADD
20: Driving Instruction SUB
30: Driving Instruction SUB
40: Driving Instruction ADD
50: Driving Instruction ADD
60: Driving Instruction ADD
70: Driving Instruction MUL
80: Driving Instruction SUB

Index
Introduction
Ovm Testbench
Ovm Reporting
Ovm Transaction
Ovm Factory
Ovm Sequence 1
Ovm Sequence 2
Ovm Sequence 3
Ovm Sequence 4
Ovm Sequence 5
Ovm Sequence 6
Ovm Configuration

Report a Bug or Comment on This section - Your input is what keeps Testbench.in improving with time!

 << PREVIOUS PAGE TOP NEXT PAGE >>