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


Tutorials



OVM SEQUENCE 3


Body Callbacks:



Ovm 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 ovm_sequence #(instruction);

instruction req;

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

`ovm_sequence_utils(demo_pre_body_post_body, instruction_sequencer)

virtual task pre_body();
ovm_report_info(get_full_name()," pre_body() callback ",OVM_LOW);
endtask

virtual task post_body();
ovm_report_info(get_full_name()," post_body() callback ",OVM_LOW);
endtask

virtual task body();
ovm_report_info(get_full_name(),
"body() method: Before ovm_do macro ",OVM_LOW);
`ovm_do(req);
ovm_report_info(get_full_name(),
"body() method: After ovm_do macro ",OVM_LOW);
endtask

endclass


(S)Download the example


ovm_sequence_4.tar
Browse the code in ovm_sequence_4.tar


(S)Command to sun the simulation


Your_tool_simulation_command +incdir+path_to_ovm testcase.sv



(S)Log file report

OVM_INFO @ 0 [RNTST] Running test ...
OVM_INFO @ 0: reporter [***] pre_body() callback
OVM_INFO @ 0: reporter [***] body() method: Before ovm_do macro
0: Driving Instruction SUB
OVM_INFO @ 10: reporter [***] body() method: After ovm_do macro
OVM_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 ovm_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
`ovm_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
`ovm_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 ovm_sequence #(instruction);

seq_a s_a;
seq_b s_b;

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

`ovm_sequence_utils(sequential_sequence, instruction_sequencer)

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

endclass

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

(S)Download the example


ovm_sequence_5.tar
Browse the code in ovm_sequence_5.tar


(S)Command to sun the simulation


Your_tool_simulation_command +incdir+path_to_ovm testcase.sv



(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 ovm_sequence #(instruction);

seq_a s_a;
seq_b s_b;

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

`ovm_sequence_utils(parallel_sequence, instruction_sequencer)

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

endclass

(S)Download the example


ovm_sequence_6.tar
Browse the code in ovm_sequence_6.tar


(S)Command to sun the simulation


Your_tool_simulation_command +incdir+path_to_ovm testcase.sv



(S)Log file report

OVM_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
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 >>

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