Sequence Registration Macros does the following
1) Implements get_type_name method.
2) Implements create() method.
3) Registers with the factory.
4) Implements the static get_type() method.
5) Implements the virtual get_object_type() method.
6) Registers the sequence type with the sequencer type.
7) Defines p_sequencer variable. p_sequencer is a handle to its sequencer.
8) Implements m_set_p_sequencer() method.
If there are no local variables, then use following macro
`ovm_sequence_utils(TYPE_NAME,SQR_TYPE_NAME)
If there are local variables in sequence, then use macro
`ovm_sequence_utils_begin(TYPE_NAME,SQR_TYPE_NAME)
`ovm_field_* macro invocations here
`ovm_sequence_utils_end
Macros `ovm_field_* are used for define utility methods.
These `ovm_field_* macros are discussed in
OVM_TRANSACTION
Example to demonstrate the usage of the above macros:
class seq_mul extends ovm_sequence #(instruction);
OVM_INFO @ 0: reporter [RNTST] Running test ... OVM_INFO @ 0: reporter [sequencer.seq_mul] Num of transactions 5 0: Driving Instruction MUL 10: Driving Instruction MUL 20: Driving Instruction MUL 30: Driving Instruction MUL 40: Driving Instruction MUL
Setting Sequence Members:
set_config_* can be used only for the components not for the sequences.
By using configuration you can change the variables inside components only not in sequences.
But there is a workaround to this problem.
Sequence has handle name called p_sequencer which is pointing the Sequencer on which it is running.
Sequencer is a component , so get_config_* methods are implemented for it.
So from the sequence, using the sequencer get_config_* methods, sequence members can be updated if the variable is configured.
When using set_config_* , path to the variable should be sequencer name, as we are using the sequencer get_config_* method.
Following method demonstrates how this can be done:
(S)Sequence:
1) num_inst is a integer variables which can be updated.
2) In the body method, call the get_config_int() method to get the integer value if num_inst is configured from testcase.
class seq_mul extends ovm_sequence #(instruction);
ovm_report_info(get_full_name(),
$psprintf("Num of transactions %d",num_inst),OVM_LOW);
repeat(num_inst) begin `ovm_do_with(req, { inst == MUL; });
end endtask
endclass
(S)Testcase:
From the testcase, using the set_config_int() method, configure the num_inst to 3.
The instance path argument should be the sequencer path name.
driver.seq_item_port.connect(sequencer.seq_item_export);
sequencer.print();
fork begin run_test();
sequencer.start_default_sequence();
end #3000 global_stop_request();
join end
OVM_INFO @ 0: reporter [RNTST] Running test ... OVM_INFO @ 0: reporter [sequencer.seq_mul] Num of transactions 3 0: Driving Instruction MUL 10: Driving Instruction MUL 20: Driving Instruction MUL
From the above log we can see that seq_mul.num_inst value is 3.