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


Tutorials



UVM SEQUENCE 4


Sequencer Arbitration:



When sequences 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:
virtual task body();
repeat(3) begin
`uvm_do_with(req, { inst == MUL; });
end
endtask

(S)Sequence code 2:
virtual task body();
repeat(3) begin
`uvm_do_with(req, { inst == ADD; });
end
endtask

(S)Sequence code 3:
virtual task body();
repeat(3) begin
`uvm_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 uvm_sequence #(instruction);

seq_add add;
seq_sub sub;
seq_mul mul;

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

`uvm_sequence_utils(parallel_sequence, instruction_sequencer)

virtual task body();
m_sequencer.set_arbitration(SEQ_ARB_RANDOM);
fork
`uvm_do(add)
`uvm_do(sub)
`uvm_do(mul)
join
endtask

endclass


(S)Download the example


uvm_sequence_7.tar
Browse the code in uvm_sequence_7.tar


(S)Command to sun the simulation


VCS Users : make vcs
Questa Users: make questa




(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 (uvm_sequencer_base sequencer,
uvm_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 uvm_sequence #(instruction);

seq_add add;
seq_sub sub;
seq_mul mul;

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

`uvm_sequence_utils(parallel_sequence, instruction_sequencer)

virtual task body();
m_sequencer.set_arbitration(SEQ_ARB_WEIGHTED);
add = new("add");
sub = new("sub");
mul = new("mul");
fork
sub.start(m_sequencer,this,400);
add.start(m_sequencer,this,300);
mul.start(m_sequencer,this,200);
join
endtask

endclass

(S)Download the example


uvm_sequence_8.tar
Browse the code in uvm_sequence_8.tar


(S)Command to sun the simulation


VCS Users : make vcs
Questa Users: make questa




(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
Uvm Testbench
Uvm Reporting
Uvm Transaction
Uvm Configuration
Uvm Factory
Uvm Sequence 1
Uvm Sequence 2
Uvm Sequence 3
Uvm Sequence 4
Uvm Sequence 5
Uvm Sequence 6
Uvm Tlm 1
Uvm Tlm 2
Uvm Callback

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





<< PREVIOUS PAGE

TOP

NEXT PAGE >>

copyright 2007-2017 :: all rights reserved www.testbench.in::Disclaimer