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


Tutorials



OVM SEQUENCE 5

Sequencer Registration Macros


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);

  rand integer num_inst ;
  instruction req;

  constraint num_c { num_inst inside { 3,5,7 }; };

    `ovm_sequence_utils_begin(seq_mul,instruction_sequencer)    
    `ovm_field_int(num_inst, OVM_ALL_ON)
    `ovm_sequence_utils_end
  
  function new(string name="seq_mul");
    super.new(name);
  endfunction
  

  virtual task body();
      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 

Download the example

ovm_sequence_9.tar
Browse the code in ovm_sequence_9.tar

Command to sun the simulation

Your_tool_simulation_command +incdir+path_to_ovm testcase.sv


Log

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:

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);

  integer num_inst = 4;
  instruction req;

    `ovm_sequence_utils_begin(seq_mul,instruction_sequencer)    
    `ovm_field_int(num_inst, OVM_ALL_ON)
    `ovm_sequence_utils_end
  
  function new(string name="seq_mul");
    super.new(name);
  endfunction
  

  virtual task body();

       void'(p_sequencer.get_config_int("num_inst",num_inst));

       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 


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.


module test;


  instruction_sequencer sequencer;
  instruction_driver driver;

  initial begin
    set_config_string("sequencer", "default_sequence", "seq_mul");
    set_config_int("sequencer", "num_inst",3);
    sequencer = new("sequencer", null); 
    sequencer.build();
    driver = new("driver", null); 
    driver.build();

    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

endmodule
 

Download the example

ovm_sequence_10.tar
Browse the code in ovm_sequence_10.tar

Command to sun the simulation

Your_tool_simulation_command +incdir+path_to_ovm testcase.sv


Log

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.




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