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


Tutorials



OVM SEQUENCE 2



Pre Defined Sequences:



Every sequencer in ovm has 3 pre defined sequences. They are

1)Ovm_random_sequence
2)Ovm_exhaustive_sequence.
3)Ovm_simple_sequence
All the user defined sequences which are registered by user and the above three predefined sequences are stored in sequencer queue.





(S) Ovm_random_sequence :


This sequence randomly selects and executes a sequence from the sequencer sequence library, excluding ovm_random_sequence itself, and ovm_exhaustive_sequence. From the above image, from sequence id 2 to till the last sequence, all the sequences are executed randomly. If the "count" variable of the sequencer is set to 0, then non of the sequence is executed. If the "count" variable of the sequencer is set to -1, then some random number of sequences from 0 to "max_random_count" are executed. By default "mac_random_count" is set to 10. "Count" and "mac_random_count" can be changed using set_config_int().

The sequencer when automatically started executes the sequence which is point by default_sequence. By default default_sequence variable points to ovm_random_sequence.


(S)ovm_exaustive_sequence:


This sequence randomly selects and executes each sequence from the sequencers sequence library once in a randc style, excluding itself and ovm_random_sequence.


(S)ovm_simple_sequence:


This sequence simply executes a single sequence item.


In the previous example from OVM_SEQUENCE_1 section.

The print() method of the sequencer in that example printed the following



----------------------------------------------------------------------
Name                     Type                Size                Value
----------------------------------------------------------------------
sequencer                instruction_sequen+ -             sequencer@2
  rsp_export             ovm_analysis_export -            rsp_export@4
  seq_item_export        ovm_seq_item_pull_+ -      seq_item_export@28
  default_sequence       string              18     operation_addition
  count                  integral            32                     -1
  max_random_count       integral            32                   'd10
  sequences              array               4                       -
    [0]                  string              19    ovm_random_sequence
    [1]                  string              23   ovm_exhaustive_sequ+
    [2]                  string              19    ovm_simple_sequence
    [3]                  string              18     operation_addition
  max_random_depth       integral            32                    'd4
  num_last_reqs          integral            32                    'd1
  num_last_rsps          integral            32                    'd1
----------------------------------------------------------------------


Some observations from the above log:

The count is set to -1. The default sequencer is set to operations_addition. There are 3 predefined sequences and 1 user defined sequence.

Lets look at a example: In the attached example, in file sequence.sv file, there are 4 seuqneces, they are operation_addition, operation_subtraction, operation_multiplication.

In the testcase.sv file, the "default_seuence" is set to "ovm_exhaustive_sequence" using the set_config_string.

set_config_string("sequencer", "default_sequence", "ovm_exhaustive_sequence");



(S)Download the example


ovm_sequence_1.tar
Browse the code in ovm_sequence_1.tar


(S)Command to run the summation


Your_tool_simulation_command +incdir+path_to_ovm testcase.sv



(S)Log File

0: Driving Instruction PUSH_B

10: Driving Instruction PUSH_A
20: Driving Instruction PUSH_B
30: Driving Instruction SUB
40: Driving Instruction POP_C

50: Driving Instruction PUSH_A
60: Driving Instruction PUSH_B
70: Driving Instruction MUL
80: Driving Instruction POP_C

90: Driving Instruction PUSH_A
100: Driving Instruction PUSH_B
110: Driving Instruction ADD
120: Driving Instruction POP_C




From the above log , we can see that all the 3 user defined sequences and predefined ovm_simple_sequence are executed.





Sequence Action Macro:



In the previous sections, we have seen the implementation of body() method of sequence. The body() method implementation requires some steps. We have seen these steps as Creation of item, wait for grant, randomize the item, send the item.

All these steps have be automated using "sequence action macros". There are some more additional steps added in these macros. Following are the steps defined with the "sequence action macro".




Pre_do(), mid_do() and post_do() are callback methods which are in ovm sequence. If user is interested , he can use these methods. For example, in mid_do() method, user can print the transaction or the randomized transaction can be fined tuned. These methods should not be clled by user directly.


(S)Syntax:

virtual task pre_do(bit is_item)
virtual function void mid_do(ovm_sequence_item this_item)
virtual function void post_do(ovm_sequence_item this_item)



Pre_do() is a task , if the method consumes simulation cycles, the behavior may be unexpected.



Example Of Pre_do,Mid_do And Post_do



Lets look at a example: We will define a sequence using `ovm_do macro. This macro has all the above defined phases.

1)Define the body method using the `ovm_do() macro. Before and after this macro, just call messages.


virtual task body();
ovm_report_info(get_full_name(),
"Seuqnce Action Macro Phase : Before ovm_do macro ",OVM_LOW);
`ovm_do(req);
ovm_report_info(get_full_name(),
"Seuqnce Action Macro Phase : After ovm_do macro ",OVM_LOW);
endtask


2)Define pre_do() method. Lets just print a message from this method.


virtual task pre_do(bit is_item);
ovm_report_info(get_full_name(),
"Seuqnce Action Macro Phase : PRE_DO ",OVM_LOW);
endtask


3)Define mid_do() method. Lets just print a message from this method.


virtual function void mid_do(ovm_sequence_item this_item);
ovm_report_info(get_full_name(),
"Seuqnce Action Macro Phase : MID_DO ",OVM_LOW);
endfunction


4)Define post_do() method. Lets just print a message from this method.


virtual function void post_do(ovm_sequence_item this_item);
ovm_report_info(get_full_name(),
"Seuqnce Action Macro Phase : POST_DO ",OVM_LOW);
endfunction

(S)Complet sequence code:

class demo_ovm_do extends ovm_sequence #(instruction);

instruction req;

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

`ovm_sequence_utils(demo_ovm_do, instruction_sequencer)

virtual task pre_do(bit is_item);
ovm_report_info(get_full_name(),
"Seuqnce Action Macro Phase : PRE_DO ",OVM_LOW);
endtask

virtual function void mid_do(ovm_sequence_item this_item);
ovm_report_info(get_full_name(),
"Seuqnce Action Macro Phase : MID_DO ",OVM_LOW);
endfunction

virtual function void post_do(ovm_sequence_item this_item);
ovm_report_info(get_full_name(),
"Seuqnce Action Macro Phase : POST_DO ",OVM_LOW);
endfunction

virtual task body();
ovm_report_info(get_full_name(),
"Seuqnce Action Macro Phase : Before ovm_do macro ",OVM_LOW);
`ovm_do(req);
ovm_report_info(get_full_name(),
"Seuqnce Action Macro Phase : After ovm_do macro ",OVM_LOW);
endtask

endclass

(S)Download the example


ovm_sequence_2.tar
Browse the code in ovm_sequence_2.tar


(S)Command to run the simulation


Your_tool_simulation_command +incdir+path_to_ovm testcase.sv


(S)Log file report:

OVM_INFO@0:reporter[sequencer.demo_ovm_do]
Seuqnce Action Macro Phase : Before ovm_do macro
OVM_INFO@0:reporter[sequencer.demo_ovm_do]
Seuqnce Action Macro Phase : PRE_DO
OVM_INFO@0:reporter[sequencer.demo_ovm_do]
Seuqnce Action Macro Phase : MID_DO

0: Driving Instruction MUL

OVM_INFO@10:reporter[sequencer.demo_ovm_do]
Seuqnce Action Macro Phase : POST_DO
OVM_INFO@10:reporter[sequencer.demo_ovm_do]
Seuqnce Action Macro Phase : After ovm_do macro



The above log file shows the messages from pre_do,mid_do and post_do methods.



List Of Sequence Action Macros:



These macros are used to start sequences and sequence items that were either registered with a <`ovm-sequence_utils> macro or whose associated sequencer was already set using the <set_sequencer> method.


(S)`ovm_create(item/sequence)


This action creates the item or sequence using the factory. Only the create phase will be executed.


(S)`ovm_do(item/sequence)


This macro takes as an argument a ovm_sequence_item variable or sequence . All the above defined 7 phases will be executed.


(S)`ovm_do_with(item/sequence, Constraint block)


This is the same as `ovm_do except that the constraint block in the 2nd argument is applied to the item or sequence in a randomize with statement before execution.


(S)`ovm_send(item/sequence)


Create phase and randomize phases are skipped, rest all the phases will be executed. Using `ovm_create, create phase can be executed. Essentially, an `ovm_do without the create or randomization.


(S)`ovm_rand_send(item/sequence)


Only create phase is skipped. rest of all the phases will be executed. User should use `ovm_create to create the sequence or item.


(S)`ovm_rand_send_with(item/sequence , Constraint block)


Only create phase is skipped. rest of all the phases will be executed. User should use `ovm_create to create the sequence or item. Constraint block will be applied which randomization.


(S)`ovm_do_pri(item/sequence, priority )


This is the same as `ovm_do except that the sequence item or sequence is executed with the priority specified in the argument.


(S)`ovm_do_pri_with(item/sequence , constraint block , priority)


This is the same as `ovm_do_pri except that the given constraint block is applied to the item or sequence in a randomize with statement before execution.


(S)`ovm_send_pri(item/sequence,priority)


This is the same as `ovm_send except that the sequence item or sequence is executed with the priority specified in the argument.


(S)`ovm_rand_send_pri(item/sequence,priority)


This is the same as `ovm_rand_send except that the sequence item or sequence is executed with the priority specified in the argument.


(S)`ovm_rand_send_pri_with(item/sequence,priority,constraint block)


This is the same as `ovm_rand_send_pri except that the given constraint block is applied to the item or sequence in a randomize with statement before execution.


Following macros are used on sequence or sequence items on a different sequencer.



(S)`ovm_create_on(item/sequence,sequencer)


This is the same as `ovm_create except that it also sets the parent sequence to the sequence in which the macro is invoked, and it sets the sequencer to the specified sequencer argument.


(S)`ovm_do_on(item/sequence,sequencer)


This is the same as `ovm_do except that it also sets the parent sequence to the sequence in which the macro is invoked, and it sets the sequencer to the specified sequencer argument.


(S)`ovm_do_on_pri(item/sequence,sequencer, priority)


This is the same as `ovm_do_pri except that it also sets the parent sequence to the sequence in which the macro is invoked, and it sets the sequencer to the specified sequencer argument.


(S)`ovm_do_on_with(item/sequence,sequencer, constraint block)


This is the same as `ovm_do_with except that it also sets the parent sequence to the sequence in which the macro is invoked, and it sets the sequencer to the specified sequencer argument. The user must supply brackets around the constraints.


(S)`ovm_do_on_pri_with(item/sequence,sequencer,priority,constraint block)


This is the same as `ovm_do_pri_with except that it also sets the parent sequence to the sequence in which the macro is invoked, and it sets the sequencer to the specified sequencer argument.



Examples With Sequence Action Macros:



virtual task body();
ovm_report_info(get_full_name(),
"Executing Sequence Action Macro ovm_do",OVM_LOW);
`ovm_do(req)
endtask

virtual task body();
ovm_report_info(get_full_name(),
"Executing Sequence Action Macro ovm_do_with ",OVM_LOW);
`ovm_do_with(req,{ inst == ADD; })
endtask

virtual task body();
ovm_report_info(get_full_name(),
"Executing Sequence Action Macro ovm_create and ovm_send",OVM_LOW);
`ovm_create(req)
req.inst = instruction::PUSH_B;
`ovm_send(req)
endtask

virtual task body();
ovm_report_info(get_full_name(),
"Executing Sequence Action Macro ovm_create and ovm_rand_send",OVM_LOW);
`ovm_create(req)
`ovm_rand_send(req)
endtask



(S)Download the example


ovm_sequence_3.tar
Browse the code in ovm_sequence_3.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_B
OVM_INFO@10:reporter[***]Executing Sequence Action Macro ovm_do_with
10: Driving Instruction ADD
OVM_INFO@20:reporter[***]Executing Sequence Action Macro ovm_create and ovm_send
20: Driving Instruction PUSH_B
OVM_INFO@30:reporter[***]Executing Sequence Action Macro ovm_do
30: Driving Instruction DIV
OVM_INFO@40:reporter[***]Executing Sequence Action Macro ovm_create and ovm_rand_send
40: Driving Instruction MUL


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