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


Tutorials



UVM SEQUENCE 3


Body Callbacks:



uvm sequences has two callback methods pre_body() and post_body(), which are executed before and after the sequence body() method execution. These callbacks are called only when start_sequence() of sequencer or start() method of the sequence is called. User should not call these methods.



virtual task pre_body()
virtual task post_body()

(S)Example


In this example, I just printed messages from pre_body() and post_body() methods. These methods can be used for initialization, synchronization with some events or cleanup.



class demo_pre_body_post_body extends uvm_sequence #(instruction);

instruction req;

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

`uvm_sequence_utils(demo_pre_body_post_body, instruction_sequencer)

virtual task pre_body();
uvm_report_info(get_full_name()," pre_body() callback ",UVM_LOW);
endtask

virtual task post_body();
uvm_report_info(get_full_name()," post_body() callback ",UVM_LOW);
endtask

virtual task body();
uvm_report_info(get_full_name(),
"body() method: Before uvm_do macro ",UVM_LOW);
`uvm_do(req);
uvm_report_info(get_full_name(),
"body() method: After uvm_do macro ",UVM_LOW);
endtask

endclass


(S)Download the example


uvm_sequence_4.tar
Browse the code in uvm_sequence_4.tar


(S)Command to sun the simulation


VCS Users : make vcs
Questa Users: make questa



(S)Log file report

UVM_INFO @ 0 [RNTST] Running test ...
UVM_INFO @ 0: reporter [***] pre_body() callback
UVM_INFO @ 0: reporter [***] body() method: Before uvm_do macro
0: Driving Instruction SUB
UVM_INFO @ 10: reporter [***] body() method: After uvm_do macro
UVM_INFO @ 10: reporter [***] post_body() callback



Hierarchical Sequences



One main advantage of sequences is smaller sequences can be used to create sequences to generate stimulus required for todays complex protocol.

To create a sequence using another sequence, following steps has to be done

1)Extend the uvm_sequence class and define a new class.
2)Declare instances of child sequences which will be used to create new sequence.
3)Start the child sequence using <instance>.start() method in body() method.



Sequential Sequences



To executes child sequences sequentially, child sequence start() method should be called sequentially in body method.
In the below example you can see all the 3 steps mentioned above.
In this example, I have defined 2 child sequences. These child sequences can be used as normal sequences.



(S)Sequence 1 code:


This sequence generates 4 PUSH_A instructions.


virtual task body();
repeat(4) begin
`uvm_do_with(req, { inst == PUSH_A; });
end
endtask

(S)Sequence 2 code:


This sequence generates 4 PUSH_B instructions.


virtual task body();
repeat(4) begin
`uvm_do_with(req, { inst == PUSH_B; });
end
endtask

(S)Sequential Sequence code:


This sequence first calls sequence 1 and then calls sequence 2.


class sequential_sequence extends uvm_sequence #(instruction);

seq_a s_a;
seq_b s_b;

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

`uvm_sequence_utils(sequential_sequence, instruction_sequencer)

virtual task body();
`uvm_do(s_a);
`uvm_do(s_b);
endtask

endclass

From the testcase, "sequential_sequence" is selected as "default_sequence".

(S)Download the example


uvm_sequence_5.tar
Browse the code in uvm_sequence_5.tar


(S)Command to sun the simulation


VCS Users : make vcs
Questa Users: make questa



(S)Log file report

0: Driving Instruction PUSH_A
10: Driving Instruction PUSH_A
20: Driving Instruction PUSH_A
30: Driving Instruction PUSH_A
40: Driving Instruction PUSH_B
50: Driving Instruction PUSH_B
60: Driving Instruction PUSH_B
70: Driving Instruction PUSH_B



If you observe the above log, you can see sequence seq_a is executed first and then sequene seq_b is executed.


Parallel Sequences



To executes child sequences Parallel, child sequence start() method should be called parallel using fork/join in body method.



(S)Parallel Sequence code:

class parallel_sequence extends uvm_sequence #(instruction);

seq_a s_a;
seq_b s_b;

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

`uvm_sequence_utils(parallel_sequence, instruction_sequencer)

virtual task body();
fork
`uvm_do(s_a)
`uvm_do(s_b)
join
endtask

endclass

(S)Download the example


uvm_sequence_6.tar
Browse the code in uvm_sequence_6.tar


(S)Command to sun the simulation


VCS Users : make vcs
Questa Users: make questa



(S)Log file report

UVM_INFO @ 0 [RNTST] Running test ...
0: Driving Instruction PUSH_A
10: Driving Instruction PUSH_B
20: Driving Instruction PUSH_A
30: Driving Instruction PUSH_B
40: Driving Instruction PUSH_A
50: Driving Instruction PUSH_B
60: Driving Instruction PUSH_A
70: Driving Instruction PUSH_B

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