OVM Reference

Preview:

Citation preview

OVM Class Reference

Version 1.0.1February 2008

© 2008 Cadence Design Systems, Inc. (Cadence). All rights reserved.Cadence Design Systems, Inc., 2655 Seely Ave., San Jose, CA 95134, USA.

© 2008 Mentor Graphics, Inc. (Mentor). All rights reserved.Mentor Graphics, Inc., 8005 SW Boeckman Rd., Wilsonville, OR 97070, USA

This product is licensed under the Apache Software Foundation’s Apache License, Version 2.0, January2004. The full license is available at: http://www.apache.org/licenses/

Trademarks: Trademarks and service marks of Cadence Design Systems, Inc. and Mentor Graphics, Inc.contained in this document are attributed to Cadence and Mentor with the appropriate symbol. For queriesregarding Cadence’s or Mentor’s trademarks, contact the corporate legal department at the address shownabove. All other trademarks are the property of their respective holders.

Restricted Permission: This publication is protected by copyright law. Cadence and Mentor grantpermission to print hard copy of this publication subject to the following conditions:

1. The publication may not be modified in any way.2. Any authorized copy of the publication or portion thereof must include all original copyright,

trademark, and other proprietary notices and this permission statement.

Disclaimer: Information in this publication is provided as is and subject to change without notice and doesnot represent a commitment on the part of Cadence or Mentor. Cadence and Mentor do not make, andexpressly disclaim, any representations or warranties as to the completeness, accuracy, or usefulness ofthe information contained in this document. Cadence and Mentor do not warrant that use of such informationwill not infringe any third party rights, nor does Cadence or Mentor assume any liability for damages or costsof any kind that may result from use of such information.

Restricted Rights: Use, duplication, or disclosure by the Government is subject to restrictions as set forthin FAR52.227-14 and DFAR252.227-7013 et seq. or its successor.

1

OVM Class Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Class Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

ovm_void . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10ovm_object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11ovm_transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Component Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30ovm_component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30ovm_threaded_component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54ovm_env . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58ovm_phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67ovm_report_object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68ovm_reporter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76ovm_report_handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77ovm_report_server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

Factory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88ovm_object_wrapper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88ovm_component_registry #(type T, string Tname) . . . . . . . . . . . . . . . . . . . . . . . . . . . 90ovm_object_registry #(type T, string Tname) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92ovm_factory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98ovm_event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98ovm_event_pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103ovm_event_callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106ovm_barrier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108ovm_barrier_pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

Policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114ovm_comparer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114ovm_packer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119ovm_recorder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125ovm_printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

Contents

2

Policy Knobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138ovm_printer_knobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138Printer Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

TLM Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145tlm_if_base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146Classes for Connectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149Uni-Directional interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151Bi-Directional Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Ports and Exports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153ovm_uni-if_export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153ovm_bi-if_export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155ovm_uni-if_port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157ovm_bi-if_port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159ovm_uni-if_imp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161ovm_bi-if_imp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163ovm_port_base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

Built-In TLM Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168tlm_analysis_fifo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169tlm_fifo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171tlm_req_rsp_channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175tlm_transport_channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180ovm_random_stimulus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181ovm_test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183ovm_agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185ovm_driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187ovm_sequencer_base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189ovm_sequencer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193ovm_monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198ovm_scoreboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200ovm_virtual_sequencer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202ovm_subscriber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205ovm_req_rsp_driver#(REQ, RSP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

Comparators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209ovm_in_order_built_in_comparator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210ovm_in_order_class_comparator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

3

ovm_algorithmic_comparator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212ovm_in_order_comparator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218ovm_sequence_item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218ovm_sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222ovm_req_rsp_sequence#(REQ, RSP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230ovm_random_sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232ovm_exhaustive_sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234ovm_simple_sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

Sequence Interface Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238ovm_seq_item_prod_if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238ovm_seq_item_cons_if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241ovm_seq_prod_if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243ovm_seq_cons_if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

Layered Stimulus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249ovm_scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250ovm_scenario_controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255ovm_scenario_driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

OVM Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259Utility Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259Fields Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261Factory Registration Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264Array Printing Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265Sequence Action Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271ovm_built_in_clone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271ovm_built_in_comp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272ovm_built_in_converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273ovm_built_in_pair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274ovm_class_clone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276ovm_class_comp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277ovm_class_converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278ovm_class_pair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

4

5

OVM Class Definitions

The OVM Reference documents all public classes in the OVM library. The classes areorganized into related groups and a logical hierarchy. Each class includes a description andhow it is used.

Table 1-1 on page 5 is an alphabetized list of all of the classes. To use the Class Index, lookup a class name to find the page that has the description. You can also browse the groups tounderstand how the classes work together.

Class Index

Table 1-1 Class Index

ovm_agent on page 185

ovm_algorithmic_comparator on page 212

ovm_barrier on page 108

ovm_barrier_pool on page 111

ovm_bi-if_export on page 155

ovm_bi-if_imp on page 163

ovm_bi-if_port on page 159

ovm_built_in_clone on page 271

ovm_built_in_comp on page 272

ovm_built_in_converter on page 273

ovm_built_in_pair on page 274

ovm_class_clone on page 276

ovm_class_comp on page 277

ovm_class_converter on page 278

ovm_class_pair on page 279

ovm_comparer on page 114

6

ovm_component on page 30

ovm_component_registry #(type T, string Tname) on page 90

ovm_default_line_printer on page 131

ovm_default_printer on page 131

ovm_default_table_printer on page 131

ovm_default_tree_printer on page 131

ovm_driver on page 187

ovm_env on page 58

ovm_event on page 98

ovm_event_callback on page 106

ovm_event_pool on page 103

ovm_exhaustive_sequence on page 234

ovm_factory on page 94

ovm_hier_printer_knobs on page 142

ovm_in_order_built_in_comparator on page 210

ovm_in_order_class_comparator on page 211

ovm_in_order_comparator on page 215

ovm_monitor on page 198

ovm_object on page 11

ovm_object_registry #(type T, string Tname) on page 92

ovm_object_wrapper on page 88

ovm_packer on page 119

ovm_phase on page 61

ovm_port_base on page 165

ovm_printer on page 128

ovm_printer_knobs on page 138

ovm_random_sequence on page 232

ovm_random_stimulus on page 181

ovm_recorder on page 125

7

ovm_report_handler on page 77

ovm_report_object on page 68

ovm_report_server on page 83

ovm_reporter on page 76

ovm_req_rsp_driver#(REQ, RSP) on page 207

ovm_req_rsp_sequence#(REQ, RSP) on page 230

ovm_scenario on page 250

ovm_scenario_controller on page 255

ovm_scenario_driver on page 257

ovm_scoreboard on page 200

ovm_seq_cons_if on page 245

ovm_seq_item_cons_if on page 241

ovm_seq_item_prod_if on page 238

ovm_seq_prod_if on page 243

ovm_sequence on page 222

ovm_sequence_item on page 218

ovm_sequencer on page 193

ovm_sequencer_base on page 189

ovm_simple_sequence on page 236

ovm_subscriber on page 205

ovm_table_printer_knobs on page 142

ovm_test on page 183

ovm_threaded_component on page 54

ovm_transaction on page 23

ovm_tree_printer_knobs on page 143

ovm_uni-if_export on page 153

ovm_uni-if_imp on page 161

ovm_uni-if_port on page 157

ovm_virtual_sequencer on page 202

8

ovm_void on page 10

tlm_analysis_fifo on page 169

tlm_fifo on page 171

tlm_if_base on page 146

tlm_req_rsp_channel on page 175

tlm_transport_channel on page 178

Macros

`ovm_component_registry(TYPE, STR) on page 265

`ovm_object_registry(TYPE, STR) on page 265

`ovm_component_utils on page 260

`ovm_component_utils_begin and `ovm_component_utils_end on page 260

`ovm_create on page 268

`ovm_create_seq on page 270

`ovm_do on page 268

`ovm_do_seq on page 269

`ovm_do_seq_with on page 270

`ovm_do_with on page 268

`ovm_field_aa_int_<key_type> on page 264

`ovm_field_aa_int_string on page 263

`ovm_field_aa_object_int on page 264

`ovm_field_aa_object_string on page 264

`ovm_field_aa_string_int on page 264

`ovm_field_aa_string_string on page 264

`ovm_field_array_int on page 263

`ovm_field_array_object on page 263

`ovm_field_array_string on page 263

`ovm_field_enum on page 262

`ovm_field_int on page 262

`ovm_field_object on page 262

9

`ovm_field_queue_int on page 263

`ovm_field_queue_object on page 263

`ovm_field_queue_string on page 263

`ovm_field_string on page 262

`ovm_field_utils_begin and `ovm_field_utils_end on page 260

`ovm_object_utils on page 260

`ovm_object_utils_begin and `ovm_object_utils_end on page 260

`ovm_rand_send on page 269

`ovm_rand_send_with on page 269

`ovm_send on page 269

`print_aa_int_key4 on page 265

`print_aa_int_object2 on page 265

`print_aa_string_int3 on page 266

`print_aa_string_object2 on page 266

`print_aa_string_string2 on page 266

`print_object_qda3 on page 266

`print_qda_int4 on page 267

`print_string_qda3 on page 267

10

Base

ovm_void

The ovm_void class is the base class for all OVM classes.

The ovm_void class is an abstract class with no data members or functions. It allows forgeneric containers of objects to be created, similar to a void pointer in the C programminglanguage. User classes derived directly from ovm_void inherit none of the OVM functionality,but such classes may be placed in containers with ovm type objects.

Summaryvirtual class ovm_void;endclass

File

base/ovm_misc.svh

Virtual

Yes

Members

None

Methods

None

ovm_void

11

ovm_object

The ovm_object class is the base class for all OVM data and hierarchical classes. Itsprimary role is to define a set of methods for such common operations as create, copy,compare, print, and record. Classes deriving from ovm_object must implement the purevirtual such as create and get_type_name. Additionally, it is strongly recommended thatderived classes override the virtual methods prefixed with do_.

The ovm_object class provides data access methods and control bits.It contains only a namevariable whose default value is an empty string.

Summaryvirtual class ovm_object extends ovm_void;

function new (string name="");

static bit use_ovm_seeding = 1;

pure virtual function ovm_object create (string name="");

pure virtual function string get_type_name ();

function void copy (ovm_object rhs);

function bit compare (ovm_object rhs, ovm_comparer comparer=null);

function void record (ovm_recorder recorder=null);

function int pack (ref bit bitstream[], input ovm_packer packer=null);

function int unpack (ref bit bitstream[], input ovm_packer packer=null);

function int pack_bytes (ref byte bitstream[], input ovm_packer packer=null);

function int unpack_bytes (ref byte bitstream[],input ovm_packerpacker=null);

function int pack_inits (ref int intstream[], input ovm_packer packer=null);

function int unpack_ints (ref int intstream[],input ovm_packer packer=null);

function void print (ovm_printer printer=null);

function string sprint (ovm_printer printer=null);

function string get_name ();

function void reseed ();

ovm_void

ovm_object

12

virtual function ovm_object clone ();

virtual function void do_print (ovm_printer printer);

virtual function void do_record (ovm_recorder recorder);

virtual function void do_copy (ovm_object rhs);

virtual function bit do_compare (ovm_object rhs, ovm_comparer comparer);

virtual function void do_pack (ovm_packer packer);

virtual function void do_unpack (ovm_packer packer);

virtual function void set_name (string name);

virtual function string get_full_name ();

virtual function void set_int_local (string field_name,

ovm_bitstream_t value);

virtual function void set_object_local (string field_name,

ovm_object value, bit clone=1);

virtual function void set_string_local (string field_name,

string value);

endclass

File

base/ovm_object.svh

Virtual

Yes

Membersstatic bit use_ovm_seeding = 1;

This bit enables or disables the OVM seeding mechanism. It globally affects theoperation of the reseed method.

When enabled, OVM-based objects are seeded based on their type and full hierarchicalname rather than allocation order. This improves random stability for objects whoseinstance names are unique across each type. The ovm_component class is an exampleof a type that has a unique instance name.

Note: This is the only OVM library type which is automatically seeded using OVMseeding during construction. All other objects must be manually re-seeded, ifappropriate.

13

Methods

newfunction new (string name="")

The name is the instance name of the object. If not supplied, the object is unnamed.

clonevirtual function ovm_object clone ()

The clone method creates and returns an exact copy of this object.

The default implementation calls create() followed by copy(). As clone is virtual,derived classes may override this implementation if desired.

comparefunction bit compare (ovm_object rhs,

ovm_comparer comparer=null)

The compare method deep compares this data object with the object provided in therhs (right-hand side) argument..

The compare method is not virtual and should not be overloaded in derived classes. Tocompare the fields of a derived class, that class should override the do_comparemethod. See do_compare on page 14 for more details.

The optional comparer argument specifies the comparison policy. It allows you tocontrol some aspects of the comparison operation. It also stores the results of thecomparison, such as field-by-field miscompare information and the total number ofmiscompares. If a compare policy is not provided, the global default_comparerpolicy is used. See ovm_comparer on page 114 for more information.

copyfunction ovm_object copy (ovm_object rhs)

The copy method returns a deep copy of this object.

The copymethod is not virtual and should not be overloaded in derived classes. To copythe fields of a derived class, that class should override the do_copy method. Seedo_copy on page 15 for more details.

14

createpure virtual function ovm_object create (string name="")

The create method allocates a new object of the same type as this object and returnsit via a base ovm_object handle. Every class deriving from ovm_object, directly orindirectly, must implement the create method.

A typical implementation is as follows:

class mytype extends ovm_object;

...

virtual function ovm_object create(string name="");

mytype t = new(name);

return t;

endfunction

do_comparevirtual function void do_compare (ovm_object rhs,

ovm_comparer comparer)

The do_compare method is user-definable hook called by the compare method onpage 13. A derived class should override this method to include its fields in a compareoperation.

A typical implementation is as follows:

class mytype extends ovm_object;

...

int f1;

virtual function void do_compare (ovm_object rhs, ovm_comparer comparer);

mytype rhs_;

super.do_compare(rhs,comparer);

$cast(rhs_,rhs);

comparer.compare_field_int(“f1", f1, rhs_.f1);

endfunction

A derived class implementation must call super.do_compare to ensure its base class’properties, if any, are included in the comparison. Also, the rhs argument is provided asa generic ovm_object. Thus, you must $cast it to the type of this object beforecomparing.

The actual comparison should be implemented using the ovm_comparer object ratherthan direct field-by-field comparison. This enables users of your class to customize howcomparisons are performed and how much miscompare information is collected. Seeovm_comparer on page 114 for more details.

15

do_copyvirtual function void do_copy (ovm_object rhs)

The do_copymethod is the user-definable hook called by the copymethod on page 13.A derived class should override this method to include its fields in a copy operation.

A typical implementation is as follows:

class mytype extends ovm_object;

...

int f1;

function void do_copy (ovm_object rhs);

mytype rhs_;

super.do_copy(rhs);

$cast(rhs_,rhs);

field_1 = rhs_.field_1;

endfunction

The implementation must call super.do_copy, and it must $cast the rhs argument tothe derived type before copying.

do_packvirtual function void do_pack (ovm_packer packer)

The do_packmethod is the user-definable hook called by the packmethod on page 18.A derived class should override this method to include its fields in a pack operation.

The packer argument is the policy object for packing. The policy object should be usedto pack objects.

A typical example of an object packing itself is as follows:

class mysubtype extends mysupertype;...

shortint myshort;

obj_type myobj;

byte myarray[];

...

function void do_pack (ovm_packer packer);

super.do_pack(packer); // pack mysupertype properties

packer.pack_field_int(myarray.size(), 32);

foreach (myarray)

packer.pack_field_int(myarray[index], 8);

packer.pack_field_int(myshort, $bits(myshort));

packer.pack_object(myobj);

16

endfunction

The implementation must call super.do_pack so that base class properties arepacked as well.

For dynamic array properties (queues, dynamic arrays, and associative arrays) , youmust pack the number of elements in the 32 bits immediately before packing individualelements. This is needed to facilitate reconstruction of the object during an unpackoperation.

Packing order does not need to match declaration order. However, unpacking order mustmatch packing order.

do_printvirtual function void do_print (ovm_printer printer)

The do_print method is the user-definable hook called by the print method onpage 19. A derived class should override this method to include its fields in a printoperation.

The printer argument is the policy object that governs the format and content of theoutput. A do_printmethod implementation should not call $display directly. It shouldmerely call the appropriate printer methods for each of its fields. See ovm_printer onpage 128 for more information.

A typical implementation is as follows:

class mytype extends ovm_object;

data_obj data;

int f1;

function void do_print (ovm_printer printer);

super.do_print(printer);

printer.print_field_int("f1", f1, $bits(f1), DEC);

printer.print_object("data", data);

endfunction

do_recordvirtual function void do_record (ovm_recorder recorder)

The do_record method is the user-definable hook called by the record method onpage 19. A derived class should override this method to include its fields in a recordoperation.

The recorder argument is policy object for recording this object. A do_recordimplementation should call the appropriate recorder methods for each of its fields.

17

Vendor-specific recording implementations are encapsulated in the recorder policy,thereby insulating user-code from vendor-specific behavior. See ovm_recorder onpage 125 for information.

A typical implementation is as follows:

class mytype extends ovm_object;

data_obj data;

int f1;

function void do_record (ovm_recorder recorder);

recorder.record_field_int("f1", f1, $bits(f1), DEC);

recorder.record_object("data", data);

endfunction

do_unpackvirtual function void do_pack (ovm_packer packer)

The do_unpack method is the user-definable hook called by the unpack method onpage 22. A derived class should override this method to include its fields in an unpackoperation.

The packer argument is the policy object for both packing and unpacking. Thedo_unpack implementation must use the same packer policy, and it must unpack fieldsin the same order in which they were packed. See ovm_packer on page 119 for moreinformation.

The following implementation corresponds to the example given in do_pack on page 15:

function void do_unpack (ovm_packer packer);

int sz;

super.do_unpack(packer); // unpack super’s properties

sz = packer.unpack_field_int(myarray.size(), 32);

for(int index=0; index<sz; index++)

myarray[index] = packer.unpack_field_int(8);

myshort = packer.unpack_field_int($bits(myshort));

packer.unpack_object(myobj);

endfunction

For dynamic array properties (queues, dynamic arrays, and associative arrays) , youmust pack the number of elements in the 32 bits immediately before packing individualelements.

get_namefunction string get_name ()

18

Returns the name of the object, as provided by the name argument in the new function,or as set by way of the set_name method.

get_full_namevirtual function string get_full_name ()

Returns the full hierarchical name of this object. The default implementationcontatenates the hierarchical name of the parent, if any, with the short name of thisobject, as given by get_name.

It may be desirable to override the default implementation. For example, some dataelements have an anchor in the OVM hierarchy, and for these types of elements it isuseful to provide the hierarchical context as part of the name. An example of this is theovm_sequence type.

get_type_namepure virtual function string get_type_name()

This function returns the type name of the object, which is typically the type identifierenclosed in quotes. It is used for various debugging functions in the library and it is usedby the factory for creating objects.

This function must be defined in every derived class.

A typical implementation is as follows:

class mytype extends ovm_object;

...

virtual function string get_type_name();

return "mytype";

endfunction

pack

pack_bytes

pack_initsfunction int pack (ref bit bitstream[],

ovm_packer packer=null)

function int pack_bytes (ref byte bytestream[],

ovm_packer packer=null)

19

function int pack_ints (ref byte intstream[],

ovm_packer packer=null)

The pack methods bitwise-concatenate this object’s properties into an array of bits,bytes, or ints. The methods are not virtual and must not be overloaded. To includeadditional fields in the pack operation, derived classes should override the do_packmethod on page 15.

The optional packer argument specifies the packing policy, which governs the packingoperation. If a packer policy is not provided, the global default_packer policy isused. See ovm_packer on page 119 for more information.

The return value is the number of bits, bytes, or ints placed into the supplied array. Thecontents of the array are overwritten. Thus, the total size of the array after the operationis its initial size plus the return value.

printfunction void print (ovm_printer printer=null)

The print method deep-prints this object’s properties according to an optionalprinter policy. The method is not virtual and must not be overloaded. To includeadditional fields in the print operation, derived classes should override the do_printmethod on page 16.

The optional printer argument specifies the printer policy, which governs the formatand content of the output. If a printer policy is not provided explicitly, the globaldefault_printer policy is used. See ovm_printer on page 128 for moreinformation.

Note: The OVM library provides four pre-defined printers: ovm_printer,ovm_line_printer, ovm_tree_printer, ovm_table_printer. The defaultprinter is the table printer.

recordfunction void record (ovm_recorder recorder=null)

The record method deep-records this object’s properties according to an optionalrecorder policy. The method is not virtual and must not be overloaded. To includeadditional fields in the record operation, derived classes should override the do_recordmethod on page 16.

The optional recorder argument specifies the recording policy, which governs howrecording takes place. If a recorder policy is not provided explicitly, the globaldefault_recorder policy is used. See ovm_recorder on page 125 for information.

20

Note: A simulator’s recording recording mechanism is vendor-specific. By providingaccess via a common interface, the ovm_recorder policy provides vendor-independentacess to a simulator’s recording capabilities.

reseedfunction void reseed ()

Calls srandom on the object to reseed the object using the OVM seeding mechanism toset the seed based on type name and instance name instead of based on instanceposition in a thread.

If the use_ovm_seeding static variable is set to 0, then reseed() does not performany function.

set_int_local

set_string_local

set_object_localvirtual function void set_int_local (string field_name,

ovm_bitstream_t value)

virtual function void set_string_local (string field_name,

string value)

virtual function void set_object_local (string field_name,

ovm_object value,

bit clone=1)

These methods provide write access to integral, string, and ovm_object-basedproperties indexed by a field_name string. The object designer choose which, if any,properties will be accessible, and overrides the appropriate methods depending on theproperties’ types. For objects, the optional clone argument specifies whether to clonethe value argument before assignment.

An example implementation of all three methods is as follows. The globalovm_is_match function is used so that the field_name may contain wildcards.

class mytype extends ovm_object;

local int myint;

local byte mybyte;

local shortint myshort; // no access

local string mystring;

local obj_type myobj;

21

// provide access to integral properties

function void set_int_local(string field_name, ovm_bitstream_t value);

if (ovm_is_match (field_name, "myint"))

myint = value;

else if (ovm_is_match (field_name, "mybyte"))

mybyte = value;

endfunction

// provide access to string properties

function void set_string_local(string field_name, string value);

if (ovm_is_match (field_name, "mystring"))

mystring = value;

endfunction

// provide access to sub-objects

function void set_object_local(string field_name, ovm_object value,

bit clone=1);

if (ovm_is_match (field_name, "myobj")) begin

if (value != null) begin

obj_type tmp;

// if provided value is not correct type, produce error

if (!$cast(tmp, value)

/* error */

else

myobj = clone ? tmp.clone() : tmp;

end

else

myobj = null; // value is null, so simply assign null to myobj

end

endfunction

...

Note: Although the object designer implements these methods to provide outsideaccess to one or more properties, they are intended for internal use (e.g. forcommand-line debugging and auto-configuration) and should not be called directly bythe user.

set_namefunction void set_name (string name)

Sets the instance name of this object; overwriting any previously given name.

22

sprintfunction string sprint (ovm_printer printer=null)

The sprint method deep-prints this object’s properties just like the print method onpage 19, except the output is to the return string. The method is not virtual and must notbe overloaded. To include additional fields in the print operation, derived classes shouldoverride the do_print method on page 16.

The optional printer argument specifies the printer policy, which governs the formatand content of the output. If a printer policy is not provided explicitly, the globaldefault_printer policy is used. See ovm_printer on page 128 for details.

Note: The OVM library provides four pre-defined printers: ovm_printer,ovm_line_printer, ovm_tree_printer, ovm_table_printer. The defaultprinter is the table printer.

unpack

unpack_bytes

unpack_intsfunction int unpack (ref bit bitstream[], ovm_packer packer=null)

function int unpack_bytes (ref byte bytestream[],ovm_packer packer=null)

function int unpack_ints (ref byte intstream[], ovm_packer packer=null)

The unpack methods extract property values from an array of bits, bytes, or ints. Themethod of unpacking must exactly correspond to the method of packing. This is assuredif (a) the same packer policy is used to pack and unpack, and (b) the order of unpackingis the same as the order of packing used to create the input array.

The unpack methods are fixed (non-virtual) entry points that are called directly by theuser. To include additional fields in the unpack operation, derived classes should overridethe do_unpack method on page 17.

The optional packer argument specifies the packing policy, which governs both thepack and unpack operation. If a packer policy is not provided, the globaldefault_packer policy is used. See ovm_packer on page 119 for more information.

The return value is the number of bits, bytes, or ints extracted from the supplied array.

23

ovm_transaction

The ovm_transaction class is the root base class for OVM transactions. Inheriting all themethods of ovm_object, ovm_transaction adds a timing and recording interface fortracking transaction duration.

Summaryvirtual class ovm_transaction extends ovm_object;

function new (string name="");

virtual function string convert2string();

function void set_initiator (ovm_component initiator);

function ovm_component get_initiator ();

// Transaction recording interface

function void accept_tr (time accept_time=0);

function integer begin_tr (time begin_time=0);

function integer begin_child_tr (time begin_time=0, integer parent_handle=0);

function void end_tr (time end_time=0, bit free_handle=1);

function integer get_tr_handle ();

function void disable_recording ();

function void enable_recording (string stream);

function bit is_recording_enabled();

function bit is_active ();

// Methods to add action during transaction recording

virtual protected function void do_accept_tr ();

ovm_void

ovm_object

ovm_transaction

24

virtual protected function void do_begin_tr ();

virtual protected function void do_end_tr ();

// Access methods

function ovm_event_pool get_event_pool ();

function time get_begin_time ();

function time get_end_time ();

function time get_accept_time ();

endclass

File

base/ovm_transaction.svh

Virtual

Yes

Members

None

Methods

newfunction new (string name="")

Creates a new transaction object. The name is the instance name of the transaction. Ifnot supplied, the object is unnamed.

accept_trfunction void accept_tr (time accept_time=0)

Calling accept_tr indicates that the transaction has been accepted for processing bya consumer component, such as an ovm_driver. With some protocols, the transactionmay not be started immediately after it is accepted. For example, a bus driver may haveto wait for a bus grant before starting the transaction.

This function performs the following actions:

25

❑ The transaction’s internal accept time is set to the current simulation time, or toaccept_time if provided and non-zero. The accept_time may be any time,past or future.

❑ The transaction’s internal accept event is triggered. Any processes waiting on thethis event will resume in the next delta cycle.

❑ The do_accept_trmethod on page 26 is called to allow for any post-accept actionin derived classes.

begin_child_trfunction integer begin_child_tr (time begin_time=0, integer parent_handle)

This function indicates that the transaction has been started as a child of a parenttransaction given by parent_handle. Generally, a consumer component beginsexecution of the transactions it receives.

The parent handle is obtained by a previous call to begin_tr or begin_child_tr. Ifthe parent_handle is invalid (=0) this function behaves the same as begin_tr.

This function performs the following actions:

❑ The transaction’s internal start time is set to the current simulation time, or tobegin_time if provided and non-zero. The begin_time may be any time, pastor future, but should not be less than the accept time.

❑ If recording is enabled, a new database-transaction is started with the same begintime as above. The record method inherited from ovm_object is then called,which records the current property values to this new transaction. Finally, the newlystarted transaction is linked to the parent transaction given by parent_handle.

❑ The do_begin_tr method on page 26 is called to allow for any post-begin actionin derived classes.

❑ The transaction’s internal begin event is triggered. Any processes waiting on thisevent will resume in the next delta cycle.

The return value is a transaction handle, which is valid (non-zero) only if recording isenabled. The meaning of the handle is implementation specific.

begin_trfunction integer begin_tr (time begin_time=0)

This function indicates that the transaction has been started and is not the child ofanother transaction. Generally, a consumer component begins execution of thetransactions it receives.

26

This function performs the following actions:

❑ The transaction’s internal start time is set to the current simulation time, or tobegin_time if provided and non-zero. The begin_time may be any time, pastor future, but should not be less than the accept time.

❑ If recording is enabled, a new database-transaction is started with the same begintime as above. The record method inherited from ovm_object is then called,which records the current property values to this new transaction.

❑ The do_begin_tr method on page 26 is called to allow for any post-begin actionin derived classes.

❑ The transaction’s internal begin event is triggered. Any processes waiting on thisevent will resume in the next delta cycle.

The return value is a transaction handle, which is valid (non-zero) only if recording isenabled. The meaning of the handle is implementation specific.

disable_recordingfunction void disable_recording ()

Turns off recording for the transaction.

do_accept_trfunction void do_accept_tr ()

This user-definable callback is called by accept_tr just before the accept event istriggered. Implementations should call super.do_accept_tr to ensure correctoperation.

do_begin_trfunction void do_begin_tr ()

This user-definable callback is called by begin_tr and begin_child_tr just beforethe begin event is triggered. Implementations should call super.do_begin_tr toensure correct operation.

do_end_trfunction void do_end_tr ()

This user-definable callback is called by end_tr just before the end event is triggered.Implementations should call super.do_end_tr to ensure correct operation.

27

convert2stringvirtual function string convert2string ()

This function converts a transaction to a string.

The default implementation calls ovm_object::sprint using the default printer.

This method can be overloaded in derived classes to provide an alternate stringrepresentation of the transaction object.

enable_recordingfunction void enable_recording (string stream)

Turns on recording to the stream specified by stream, whose interpretation isimplementation specific.

If transaction recording is on, a call to record is made when the transaction is startedand when it is ended.

end_trfunction void end_tr (time end_time=0. bit free_handle=1)

This function indicates that the transaction execution has ended. Generally, a consumercomponent ends execution of the transactions it receives.

This function performs the following actions:

❑ The transaction’s internal end time is set to the current simulation time, or toend_time if provided and non-zero. The end_time may be any time, past orfuture, but should not be less than the begin time.

❑ If recording is enabled and a database-transaction is currently active, the recordmethod inherited from ovm_object is called, which records the final propertyvalues. The transaction is then ended. If free_handle is set, the transaction isreleased and can no longer be linked to (if supported by the implementation).

❑ The do_end_tr method on page 26 is called to allow for any post-end action inderived classes.

❑ The transaction’s internal end event is triggered. Any processes waiting on thisevent will resume in the next delta cycle.

get_accept_timefunction time get_accept_time ()

28

Returns the accept time for this transaction, as set by a previous call to accept_tr.

get_begin_timefunction time get_begin_time ()

Returns the begin time for this transaction, as set by a previous call tobegin_child_tr or begin_tr.

get_end_timefunction time get_end_time ()

Returns the end time for this transaction, as set by a previous call to end_tr.

get_event_poolfunction ovm_event_pool get_event_pool ()

Returns the event pool associated with this transaction.

By default, the event pool contains the events: begin, accept, and end. Events can alsobe added by derivative objects. See ovm_event_pool on page 103 for more information.

get_initiatorfunction ovm_component get_initiator ()

Returns the component that produced or started the transaction, as set by a previous callto set_initiator.

get_tr_handlefunction integer get_tr_handle ()

Returns the handle associated with the transaction, as set by a previous call tobegin_child_tr or begin_tr with transaction recording enabled.

is_activefunction bit is_active ()

Returns 1 if the transaction has been started but has not yet been ended.

Returns 0 if the transaction has not been started.

29

is_recording_enabledfunction bit is_recording_enabled ()

Returns 1 if recording is currently on.

Returns 0 if recording is currently off.

set_initiatorfunction void set_initiator (ovm_component initiator)

Sets initiator as the initiator of this transaction.

The initiator can be the component that produces the transaction. It can also be thecomponent that started the transaction. This or any other usage is up to the transactiondesigner.

30

Component Hierarchy

ovm_component

The ovm_component class is the root base class for OVM components. In addition to thefeatures inherited from ovm_object and ovm_report_object, ovm_componentprovides the following interfaces:

■ Hierarchy — provides methods for searching and traversing the component hierarchy.

■ Configuration — provides methods for configuring component topology and otherparameters ahead of and during component construction.

■ Phasing — defines a phased test flow that all components follow. Methods include thephase callbacks, such as post_new and report, which derived classes override.During simulation, these callbacks are executed in precise order.

■ Factory — provides a convenience interface to the ovm_factory on page 94. The factoryis used to create new components and other objects based on type-wide andinstance-specific configuration.

■ Reporting — provides a convenience interface to the ovm_report_handler on page 77.All messages, warnings, and errors are processed through this interface.

■ Transaction recording — provides methods for recording the transactions produced orconsumed by the component to a transaction database (vendor specific).

ovm_void

ovm_object

ovm_report_object

ovm_component

31

Summaryvirtual class ovm_component extends ovm_report_object;

function new (string name, ovm_component parent);

// Hierarchy information and setting

static function ovm_component find_component (string comp_match);

static function void find_components (string comp_match,

ref ovm_component comps[$]);

static function ovm_component get_component (int ele);

static function int get_num_components ();

function ovm_component absolute_lookup(string name );

function ovm_component relative_lookup(string name );

virtual function ovm_component get_parent ();

function int get_num_children ();

function ovm_component get_child (int index);

bit print_enabled = 1;

// Configuration interface

virtual function void set_config_int (string inst_name,

string field_name,

ovm_bitstream_t value);

virtual function void set_config_object (string inst_name,

string field_name,

ovm_object value, bit clone=1);

virtual function void set_config_string (string inst_name,

string field_name,

string value);

virtual function bit get_config_int (string field_name,

inout ovm_bitstream_t value);

virtual function bit get_config_object (string field_name,

inout ovm_object value);

virtual function bit get_config_string (string field_name,

inout string value);

virtual function void apply_config_settings (bit verbose=0);

function void print_config_settings (string field="",

ovm_component comp=null,

bit recurse=0);

static bit print_config_matches = 0;

32

// Phasing interface

virtual function void post_new ();

virtual function void extract ();

virtual function void check ();

virtual function void report ();

virtual function void build ();

static function void set_global_timeout (time timeout);

static function string get_current_global_phase ();

function string get_current _phase ();

task do_phase (string ph_name, bit block=1, bit no_error=0);

protected function void push_back_phase (ovm_phase phase);

protected function void insert_phase (string exist_ph_name,

ovm_phase phase);

static function void resolve_all_bindings();

static task global_stop_request ();

task stop_request (stop_enum who=STOP_ALL);

static function void set_global_stop_timeout (time timeout);

virtual task stop (string ph_name);

protected int enable_stop_interrupt = 0;

// Factory interface

function void print_override_info (string type_name,

string inst_name="");

function ovm_component create_component (string type_name,

string inst_name);

function ovm_object create_object (string type_name,

string name="");

static function void set_type_override (string override_type,

string type_name,

bit replace=1);

function void set_inst_override (string inst_path,

string override_type,

string type_name);

// Reporting interface

function void set_report_severity_action_hier (ovm_severity s,

ovm_action a);

33

function void set_report_id_action_hier (string id,

ovm_action a);

function void set_report_severity_id_file_hier (ovm_severity s,

string id,

ovm_action a);

function void set_report_severity_file_hier (ovm_severity s,

FILE f);

function void set_report_default_file_hier (FILE f);

function void set_report_id_file_hier (string id,

FILE f);

function void set_report_severity_id_file_hier (ovm_severity s,

string id,

FILE f);

function void set_report_verbosity_level_hier(int v);

// Transaction interface

function void accept_tr (ovm_transaction tr,

time accept_time=0);

function integer begin_tr (ovm_transaction tr,

string stream_name="main",

string label="",

string desc="",

time begin_time=0);

function integer begin_child_tr (ovm_transaction tr,

integer parent_handle=0,

string stream_name="main",

string label="",

string desc="",

time begin_time=0);

function void do_accept_tr (ovm_transaction tr,

time end_time=0,

bit free_handle=1);

function integer record_error_tr (string stream_name="main",

ovm_object info=null,

string label="error_tr",

string desc="",

time error_time=0,

bit keep_active=0);

function integer record_event_tr (string stream_name="main",

ovm_object info=null,

string label="event_tr",

34

string desc="",

time event_time=0,

bit keep_active=0);

virtual protected

function void do_accept_tr (ovm_transaction tr);

virtual protected

function void do_begin_tr (ovm_transaction tr,

string stream_name,

integer tr_handle);

virtual protected

function void do_end_tr (ovm_transaction tr,

integer tr_handle);

endclass

File

base/ovm_component.svh

Virtual

Yes

Membersbit print_enabled = 1

This bit determines if this component should automatically be printed as a child of itsparent object.

By default, all children are printed. However, this bit allows a parent component to disablethe printing of specific children.

static bit print_config_matches = 0

This static bit sets up the printing of configuration matches for debug purposes.

When a get_config_* call is used, or when the automatic configuration mechanismfinds a match, the match is printed when print_config_matches is 1.

bit enable_stop_interrupt = 0

This bit allows a component to raise an objection to the stopping of the current phase. Itaffects only time consuming phases (such as the run phase inovm_threaded_component).

35

When this bit is set, the stop task in the component is called when aglobal_stop_request is issued.

Methods

newfunction new (string name, ovm_component parent)

All components must specify an instance name and a parent component.

The component will be inserted as a child of the parent object. If the parent is null, thenthe component will be a top level component.

All classes derived from ovm_component must call super.new() with appropriatename and parent arguments.

absolute_lookupfunction ovm_component absolute_lookup (string name)

This function searches for a component in the enclosing environment.

If there is no enclosing environment, then absolute_lookup starts its search fromthe root component.

If name is not found in the enclosing topology then a null object is returned, otherwise ahandle to name is returned.

accept_trfunction void accept_tr (ovm_transaction tr, time accept_time=0)

This function marks the acceptance of a transaction,tr, by this component. Specifically,it performs the following actions:

❑ Calls the transaction’s accept_tr method, passing to it the accept_timeargument. See accept_tr on page 24 for details.

❑ Calls the component’s do_accept_tr method on page 39 to allow for anypost-begin action in derived classes.

❑ Triggers the component’s internal accept_tr event. Any processes waiting on thisevent will resume in the next delta cycle.

36

apply_config_settingsvirtual function void apply_config_settings (bit verbose=0)

This is an automation function called by ovm_component::build() that finds allconfiguration overrides matching this component’s full instance name.

The overrides are applied in reverse order by calling the appropriate set_*_localmethod (e.g. for an object override, set_object_local is called). By making the callsin reverse order, the same semantics associated with the get_config* calls areachieved.

Because apply_config_settings uses the set_*_local methods to apply theconfiguration settings, these methods must be overloaded for the component.

Note: The automation macros (`ovm_field_*) are also in effect whenapply_config_settings is called, regardless of whether set_*_local isoverloaded.

If you do not want apply_config_settings to be called for a component, thebuild()method should be overloaded and you should not call super.build(). If thisis done, you must also set the m_build_done bit.

Likewise, apply_config_settings() can be overloaded, and the meaning of theautomated configuration can be changed (for instance, replaced with get_config*calls).

When the verbose bit is set, all overrides are printed as they are applied. If the static bitprint_config_settings is set, then apply_config_settings is automaticallycalled with verbose=1.

begin_trfunction integer begin_tr (ovm_transaction tr,

string stream_name="main",

string label="",

string desc="",

time begin_time=0)

This function marks the start of a transaction,tr, by this component. Specifically, itperforms the following actions:

❑ Calls the transaction’s begin_tr method. The begin_time should be greaterthan or equal to the accept time. By default, when begin_time=0, the currentsimulation time is used. See begin_tr on page 25 for details.

37

❑ If recording is enabled (recording_detail != OVM_OFF), a newdatabase-transaction is started on the component’s transaction stream given by thestream argument. No transaction properties are recorded at this time.

❑ Calls the component’s do_begin_tr method on page 39 to allow for anypost-begin action in derived classes.

❑ Triggers the component’s internal begin_tr event. Any processes waiting on thisevent will resume in the next delta cycle.

A handle to the transaction is returned. The meaning of this handle, as well as theinterpretation of the arguments stream_name, label, and desc are vendor specific.

begin_child_trfunction integer begin_child_tr (ovm_transaction tr,

integer parent=0,

string stream_name="main",

string label="",

string desc="",

time begin_time=0)

This function marks the start of a child transaction,tr, by this component. Its operationis identical to that of begin_tr, except that an association is made between thistransaction and the provided parent transaction. This association is vendor-specific.

buildvirtual function void build()

This method is a hook to use for building components.

Component hierarchies are created in the build()method instead of in the constructorin order to support a configurable topology creation.

The build method must be called explicitly after a component has been constructed. Thisis not a phase callback because you must control when build is called. For example,for a random topology, build is called after the object is constructed and randomized.

If build() is not called explicitly, then it is called implicitly during the post_new()phase.

checkvirtual function void check()

38

The check phase callback is one of several methods automatically called during thecourse of simulation.

The check phase starts after the extract phase has completed. The following occursduring execution of the check phase:

❑ The global begin_check event is triggered.

❑ All components’ check methods are called recursively in depth-first, bottom-uporder, i.e. children are executed before their parents.

❑ The global end_check event is triggered.

Generally, derived classes should override this method to perform component specific,end-of-test checks. Any override should call super.check.

This method should never be called directly.

See ovm_phase on page 61 for more information on phases.

create_componentfunction ovm_component create_component (string type_name,

string inst_name)

This method creates a new child component using the ovm_factory on page 94.

Depending on the factory configuration, the type of the component created may bedifferent than the requested type. This happens when the factory determines, based onthis component’s full path, type_name, and inst_name, that a type or instanceoverride exists. See ovm_factory on page 94 for details on factory operation.

create_objectfunction ovm_object create_object (string type_name,

string name="")

This method creates a non-component object using the ovm_factory on page 94.

Depending on the factory configuration, the type of object created may be different thanthe requested type. This happens when the factory determines, based on thiscomponent’s full path, type_name, and optional name, that a type or instance overrideexists. See ovm_factory on page 94 for details on factory operation.

do_phasefunction void do_phase(string ph_name)

39

Executes the phase, ph_name, on this component and its sub-components.

If ph_name is not the next phase to be executed, then all previous phases are run tobring the sub-hierachy of components up through the ph_name phase.

In general, this function should not be called directly. Use run_test on page 60 anddo_test on page 59 to initiate a phased simulation.

do_accept_trvirtual protected function void do_accept_tr (ovm_transaction tr)

The accept_tr method calls this function to accommodate any user-definedpost-accept action. Implementations should call super.do_accept_tr to ensurecorrect operation.

do_begin_trvirtual protected function void do_begin_tr (ovm_transaction tr,

string stream_name,

integer tr_handle)

The begin_tr and begin_child_tr methods call this function to accommodate anyuser-defined post-begin action. Implementations should call super.do_begin_tr toensure correct operation.

do_end_trvirtual protected function void end_tr (ovm_transaction tr,

integer tr_handle)

The do_accept_tr method calls this function to accommodate any user-definedpost-end action. Implementations should call super.do_begin_tr to ensure correctoperation.

end_trfunction void end_tr (ovm_transaction tr,

time accept_time=0,

bit free_handle=1)

This function marks the end of a transaction,tr, by this component. Specifically, itperforms the following actions:

40

❑ Calls the transaction’s end_tr method. The end_time must at least be greaterthan the begin time. By default, when end_time=0, the current simulation time isused. See end_tr on page 27 for details.

❑ The transaction’s properties are recorded to the database-transaction on which itwas started, and then the transaction is ended. Only those properties handled bythe transaction’s record method are recorded.

❑ Calls the component’s do_end_tr method on page 39 to accommodate anypost-end action in derived classes.

❑ Triggers the component’s internal end_tr event. Any processes waiting on thisevent will resume in the next delta cycle.

The free_handle bit indicates that this transaction is no longer needed. Theimplementation of free_handle is vendor specific.

extractvirtual function void extract()

The extract phase callback is one of several methods automatically called during thecourse of simulation.

The extract phase starts after the run phase has completed. The following occursduring execution of the extract phase:

❑ The global begin_extract event is triggered.

❑ All components’ extract methods are called recursively in depth-first, bottom-uporder, i.e. children are executed before their parents.

❑ The global end_extract event is triggered.

Generally, derived classes should override this method to collect information for thesubsequent check phase when such information needs to be collected in a hierarchical,bottom-up manner. Any override should call super.extract.

This method should never be called directly.

See ovm_phase on page 61 for more information on phases.

find_componentstatic function ovm_component find_component (string comp_match)

This function searches for a component in the global registry of components.

41

The comp_match argument is a search string that is matched against the full names ofthe all the component in the testbench hierarchy. It may contain wildcards.

If no match is found, a null object is returned, otherwise the handle to first matchingcomponent is returned.

find_componentsstatic function void find_components (string comp_match,

ref ovm_component comps[$])

This function searches for components in the global registry of components.

The comp_match argument is a search string that is matched against the full names ofthe all the component in the testbench hierarchy. It may contain wildcards.

The comps list is emptied prior to the search.

All matching components are added to the list.

get_childfunction ovm_component get_child (int ele)

Returns the component handle of the child at index ele. Returns null if ele is out ofrange.

Use this function with get_num_children on page 43 to iterate through this component’schildren.

get_componentstatic function ovm_component get_component (int ele)

Returns the handle of the component at index ele in the global component registry.

Use this function with get_num_components on page 43 to scan the the global registryof components.

No assumptions can be made about which components are at which element number.

42

get_config_int

get_config_string

get_config_objectvirtual function bit get_config_int (string field_name,

inout ovm_bitstream_t value)

virtual function bit get_config_string (string field_name,

inout ovm_bitstream_t value)

virtual function bit get_config_object (string field_name,

inout ovm_object value)

These methods retrieve configuration settings made by previous calls toset_config_int, set_config_string, and set_config_object. As themethods’ names imply, there is direct support for integral types, strings, and objects.Settings of other types can be indirectly supported by defining an object to contain them.

Configuration settings are stored in a global table and in each component instance. Witheach call to a get_config_* method, a top-down search is made for a setting thatmatches this component’s full name and the given field_name . For example, if thiscomponent’s full instance name is top.u1.u2, the global configuration table issearched first. If that fails, it searches the configuration table in component top, followedby top.u1.

The first instance/field match causes value to be written with the value of theconfiguration setting and the return value is 1. If no match is found, then value isunchanged and the return value is 0.

Calling the get_config_object method requires special handling. Because value isan output of type ovm_object, you must provide an ovm_object handle to assign to(not a derived class handle). After the call, you can then $cast to the actual type.

For example, the following code illustrates how a component designer might call uponthe configuration mechanism to assign its data object property. Note that we areoverriding the apply_config_settings.

class mycomponent extends ovm_component;

local myobj_t data;

function void apply_config_settings();

ovm_object tmp;

if(get_config_object("data", tmp))

if (!$cast(data, tmp))

$display("error! config setting for ‘data’ not of type myobj_t");

endfunction

...

43

The above example overrides the apply_config_settings method, whichautomatically configures this component’s properties via the set_*_local methods, ifimplemented. See set_object_local method on page 20 andapply_config_settings method on page 36 for details on the automaticconfiguration mechanism.

See Global set_config Functions on page 52 for information on setting the globalconfiguration table.

get_current _phasefunction string get_current_phase ()

Returns the name of the current phase that this component is running.

get_current_global_phasestatic function string get_current_global_phase ()

Returns the name of the current phase in the global phase queue.

Individual components may be out of phase with the global phase queue. For example,ovm_env::do_test() phases a single environment instead of synchronizing phasesacross environments.

get_num_childrenfunction int get_num_children ()

Returns the number of children of this component.

Use this function with get_child on page 41 to iterate through this component’s children.

get_num_componentsstatic function int get_num_components ()

This method returns the total number of components in the global registry.

Use this function with get_component on page 41 to scan the the global registry ofcomponents.

get_parentvirtual function ovm_component get_parent ()

Returns a handle to this component’s parent, or null if it has no parent.

44

global_stop_requeststatic function void global_stop_request ()

Globally aborts the currently running task-based phase (e.g. the run phase). Beforedoing so, it calls the stop method on page 51 for all components whoseenable_stop_interrupt bits have been set prior to this stop request. Suchcomponents may need extra time to shut down cleanly. They may implement stop tofinish the currently executing transaction, flush the queue, or perform other cleanup.Upon return from its stop, a component signals it is ready to be stopped. A componentsignals it can be stopped at any time if it does not set its enable_stop_interrupt bit.

When all stop tasks return or the stop timeout expires, whichever occurs first, allprocesses that were forked in the currently running phase are killed, and the next phasestarted. See set_global_stop_timeout on page 49 to learn how to set the stop timeout.

insert_phaseprotected function void insert_phase(string exist_ph_name,

ovm_phase phase)

Inserts the user-defined phase object before the existing phase namedexist_ph_name in the component’s phase list, and inserts the phase in the globalphase list (if not already added).

See ovm_phase on page 61 for more information.

post_newvirtual function void post_new()

The post_new phase callback is the first of several methods automatically called duringthe course of simulation.

The post_new phase executes after the initial hierarchy has been constructed. Thefollowing occurs during execution of the post_new phase:

❑ The global begin_post_new event is triggered.

❑ All components’ post_new methods are called recursively in depth-first, bottom-uporder, i.e. children are executed before their parents.

❑ The global end_post_new event is triggered.

Generally, derived classes should override this method to create new components andconnect their ports. Any override should call super.post_new.

This method should never be called directly.

45

See ovm_phase on page 61 for more information on phases.

print_config_settingsfunction void print_config_settings(string field="",

ovm_component comp=null,

bit recurse=0)

Called without arguments, print_config_settings prints all configurationinformation for this component, as set by previous calls to set_config_*.

If field is specified an non-empty, then only the configuration matching the field areprinted. The field can not contain wildcards.

If comp is specified and non-null, then the configuration for that component is printed,not this component.

If recurse is set, then configuration information for all children and below are printedas well.

print_override_infofunction void print_override_info(string type_name,

string inst_name="")

This factory debug method performs the same lookup process as create_object andcreate_component, but instead of creating an object, it prints information about whattype of object would be created given the provided arguments.

push_back_phaseprotected function void push_back_phase(ovm_phase phase)

Adds a user defined phase object to the end of the list of phases for this component andadds the phase to the global phase list (if it has not already been added). Seeovm_phase on page 61 for more information.

relative_lookupfunction ovm_component relative_lookup(string name)

This function searches for a component that lives hierarchically beneath this componentand has the relative, hierarchical name.

The handle to the matching component is returned if found, other returns null.

46

reportvirtual function void report()

The report phase callback is the last of several methods automatically called duringthe course of simulation.

The report phase starts after the check phase has completed. The following occursduring execution of the report phase:

❑ The global begin_report event is triggered.

❑ All components’ report methods are called recursively in depth-first, bottom-uporder, i.e. children are executed before their parents.

❑ The global end_report event is triggered.

Generally, derived classes should override this method to perform component-specificreporting of test results. Any override should call super.report.

This method should never be called directly.

See ovm_phase on page 61 for more information on phases.

record_error_trfunction integer record_error_tr (string stream_name="main",

ovm_object info=null,

string label="",

string desc="",

time error_time=0,

bit keep_active=0)

This function marks an error transaction by a component. Properties of the givenovm_object, info, as implemented in its do_record method on page 16, arerecorded to the transaction database.

An error_time of 0 indicates to use the current simulation time.

The keep_active bit determines if the handle should remain active. Ifkeep_active is 0, a zero-length error transaction is recorded.

A handle to the database-transaction is returned.

Interpretation of this handle, as well as the strings stream_name, label, and desc, arevendor specific.

47

record_event_trfunction integer record_event_tr (string stream_name="main",

ovm_object info=null,

string label="",

string desc="",

time event_time=0,

bit keep_active=0)

This function marks an event transaction by a component.

An event_time of 0 indicates to use the current simulation time.

A handle to the transaction is returned. The keep_active bit determines if the handlemay be used for other vendor specific purposes.

The strings for stream_name, label, and desc are vendor specific identifiers for thetransaction.

resolve_all_bindingsstatic function void resolve_all_bindings()

Performs elaboration of ports, exports and implementations.

This method is called automatically after the post_new phase, but can be calledmanually if needed.

set_config_int

set_config_string

set_config_objectvirtual function void set_config_int (string inst_name,

string field_name,

ovm_bitstream_t value)

virtual function void set_config_string (string inst_name,

string field_name,

string value)

virtual function void set_config_object (string inst_name,

string field_name,

ovm_object value,

bit clone=1)

48

These methods work in conjunction with the get_config_* methods to provide aconfiguration setting mechanism for integral, string, and ovm_object-based types.Settings of other types, such as virtual interfaces and arrays, can be indirectly supportedby defining an object to contain them.

Calling any of set_config_* causes a configuration setting to created and placed ina table internal to this component. The configuration setting stores the suppliedinst_name, field_name, andvalue for later use by descendent componentsduring their construction.

When a descendant component calls a get_config_* method, the inst_name andfield_name provided in the get call are matched against all the configuration settingsstored in the global table and then in each component in the parent hierarchy, top-down.Upon the first match, the value stored in the configuration setting is returned. Thus,precedence is global, following by the top-level component, and so on down to thedescendent component’s parent.

Both inst_name and field_name may contain wildcards.

For set_config_int, value is an integral value that can be anything from 1 bit to4096 bits.

For set_config_string, value is a string.

For set_config_object, value must be an ovm_object-based object or null. Itsclone argument specifies whether the object should be cloned. If set, the object iscloned both going into the table (during the set) and coming out of the table (during theget), so that multiple components matched to the same setting (by way of wildcards) donot end up sharing the same object.

See get_config_int, get_config_string, and get_config_object on page 42 formore information on getting and applying configuration settings. See Global set_configFunctions on page 52 for information on setting the global configuration table.

set_global_timeoutstatic function void set_global_timeout (time timeout)

Sets a timeout for task-based phases. If the timeout elapses before the phase completes,an error is generated and the phase terminated. All processes forked during the phasewill be killed.

Currently, the only built-in time-consuming phase is the run phase forovm_threaded_component.

A timeout of 0 (the default) indicates that there is no timeout.

49

set_global_stop_timeoutstatic function void set_global_stop_timeout (time timeout)

Sets a timeout for stop tasks. If the timeout elapses before all stop tasks havecompleted, a warning is generated, all stop tasks are terminated, and stop request isfulfilled.

The default timeout is arbitrarily set to 10000 time units. If it is expected that somecomponents will need more time, then the stop timeout can be extended.

See global_stop_request on page 44 for details on the stop mechanism.

set_inst_overridefunction void set_inst_override (string inst_path,

string override_type,

string type_name)

Sets an instance override in the ovm_factory for components created at this level ofhierarchy or below. The inst_path is relative to this component and may includewildcards.

When a child component calls upon the factory to create a new object or component, e.g.with create_component or create_object, it provides an instance path and adesired type name. The factory compares these with thevariousinst_paths-type_name pairs registered by this method. If a match is found,then the factory creates and returns an object of the override_type in place of therequested type.

This is a convenience function for ovm_factory::set_inst_override.

set_report_default_file_hier

set_report_id_file_hier

set_report_severity_file_hier

set_report_severity_id_file_hierfunction void set_report_default_file_hier (FILE file)

function void set_report_id_file_hier (string id, FILE file)

function void set_report_severity_file_hier (ovm_severity sev, FILE file)

function void set_report_severity_id_file_hier (ovm_severity sev,

string id, FILE file)

50

These methods recursively configure the report handers in this component and all itschildren to direct some or all of its output to the given file descriptor. The fileargument must be a multi-channel descriptor (mcd) or file id compatible with$fdisplay.

❑ set_report_default_file_hier hierarchically sets a default file descriptor. It is usedwhen no other setting applies.

❑ set_report_severity_file_hier hierarchically sets the file descriptor for reportsmatching the given severity. This setting takes precedence over the default setting.

❑ set_report_id_file_hier hierarchically sets the file descriptor for reports matchingthe given id. This setting takes precedence over the default and any severitysettings from set_report_severity_file_hier.

❑ set_report_severity_id_file_hier hierarchically sets the file descriptor for reportsmatching both the given severity and id. This setting takes highest precedence.

For a list of severities and other information related to the report mechanism, refer toovm_report_handler on page 77.

set_report_severity_action_hier

set_report_severity_file_hier

set_report_severity_id_action_hierfunction void set_report_severity_action_hier (ovm_severity sev,

ovm_action action)

function void set_report_id_action_hier (string id,

ovm_action action)

function void set_report_severity_id_action_hier (ovm_severity sev,

string id,

ovm_action action)

These methods recursively configure the report handers in this component and all itschildren to perform the given action when issuing reports matching the givenseverity, id, or both severity and id.

❑ set_report_severity_action_hier hierarchically sets the action for reportsmatching the given sev. This setting takes precedence over the default setting.

❑ set_report_id_action_hier hierarchically sets the action for reports matchingthe given id. This setting takes precedence over the default and any severitysettings from set_report_severity_action_hier.

51

❑ set_report_severity_id_action_hier hierarchically sets the action for reportsmatching both the given sev and id. This setting takes highest precedence.

For a list of severities and their default actions, refer to ovm_report_handler on page 77.

set_report_verbosity_level_hierfunction void set_report_verbosity_level_hier (int verbosity)

This method recursively configures the report handers in this component and all itschildren to output messages at the given verbosity level and below.

To be displayed, messages must have a verbosity setting equal to or less thanverbosity. To display all messages, set verbosity to a large number (such as'hfffffff).

See ovm_report_handler on page 77 for a list of pre-defined message verbosity levelsand their meaning.

set_type_overridestatic function void set_type_override (string override_type,

string type_name,

bit replace=1)

This is a convenience function for set_type_override in ovm_factory. It configuresthe factory to create an object of type override_type whenever an object oftypetype_name is requested.

When a component calls upon the factory to create a new object or component, e.g. withcreate_component or create_object, it provides an instance path and a desiredtype name. If the requested type name matches type_name, and there is no matchinginstance override, then the factory creates the given override_type in place of therequested type.

When replace is 1, a previous override on type_name is replaced, otherwise theprevious override remains intact.

This is a wrapper function for ovm_factory::set_type_override.

stopvirtual task stop()

This component’s stop task is called when a global_stop_request is issued duringa task-based phase (e.g.run) and its enable_stop_interrupt bit is set.

52

Before a phase is abruptly ended, e.g. when a test deems the simulation complete, somecomponents may need extra time to shut down cleanly. Such components mayimplement stop to finish the currently executing transaction, flush the queue, or performother cleanup. Upon return from its stop, a component signals it is ready to be stopped.

The stop method will not be called if enable_stop_interrupt=0.

The default implementation of stop is empty, i.e. to return immediately.

The stop method should never be called directly.

stop_requestfunction void stop_request (stop_enum who=STOP_ALL)

Issues a request to abort the current task-based phase (e.g. run) for this component andits children.

The stop_enum variable has the following definitions:

❑ STOP_ALL stops this component and recursively stops its descendants.

❑ STOP_CHILDREN recursively stops the descendants.

❑ STOP_SELF stops only this component and does not affect its descendants.

Normally, the stop control should be done globally using the global_stop_requestmethod on page 44.

Global set_config Functions

set_config_int

set_config_string

set_config_objectfunction void set_config_int (string inst_name,

string field_name,

ovm_bitstream_t value)

function void set_config_string (string inst_name,

string field_name,

string value)

function void set_config_object (string inst_name,

string field_name,

53

ovm_object value,

bit clone=1)

These are the global versions of the set_config_int, set_config_string, andset_config_object. They place the configuration settings in the global overridetable, which has highest precedence over any component-level setting.

54

ovm_threaded_component

The ovm_threaded_component class is a base class for active components with runningprocesses. In addition to the features inherited from ovm_component, it adds the pre_runand run phase callbacks. The run phase is the only built-in phase that is allowed to consumesimulation time. The pre_run and run phases are inserted between theend_of_elaboration and extract phases.

Summaryvirtual class ovm_threaded_component extends ovm_component;

function new (string name,

ovm_component parent);

// Run phase interface

virtual function void pre_run ();

virtual task run ();

//Run process control interface

virtual function void kill ();

endclass

ovm_void

ovm_object

ovm_report_object

ovm_component

ovm_threaded_component

55

File

base/ovm_threaded_component.svh

Virtual

Yes

Members

None

Methods

newfunction new (string name,

ovm_component parent)

All components must specify an instance name and a parent component.

Note: Threaded components may have a non-threaded component as a parent, so theconstructor of a derived class should have an ovm_component parent as an argument.

killvirtual function void kill ()

Kills the run process executing on this component.

Killing the run processes calls all sub-processes that were initiated by this component’srun phase to be terminated as well.

An alternative mechanism for stopping the run phase is the stop request. Callingglobal_stop_request on page 44 causes all components’ run processes to be killed, butonly after all components have had the opportunity to complete in progress transactionsand shutdown cleanly.

pre_runvirtual function void pre_run ()

The pre_run phase starts after the end_of_elaboration phase has completed andbefore the run phase. The following occurs during execution of the pre_run phase:

56

❑ The global begin_pre_run event is triggered.

❑ All components’ pre_run methods are called recursively in depth-first, bottom-uporder, i.e. children are executed before their parents.

❑ The global end_pre_run event is triggered.

Generally, derived classes should override this method to perform component-specificpre-run operations, such as discovery of the elaborated hierarchy, printing banners, etc.Any override should call super.pre_run.

This method should never be called directly.

See ovm_phase on page 61 for more information on phases.

runvirtual task run ()

The run phase callback is the only time-consuming, task-based phase.

The run phase executes after test environment has been fully constructed andelaborated. Derived classes should override this method to perform the bulk of itsfunctionality, forking off additional processes if needed.

The following occurs during execution of the run phase:

❑ The global begin_run event is triggered.

❑ All components’ run tasks are forked as independent processes. Returning fromthe run task signals a component’s completion of the run phase. If additionalprocesses have been forked, a wait fork must be called to prevent exitingprematurely. Once all components’ run tasks have completed, or a stop request hasbeen honored, the run phase is ended.

Keep in mind other ways of exiting the run phase.

❍ global_stop_request — this static method of ovm_component can becalled by anyone. See global_stop_request on page 44 for more information.

❍ global timeout expired — the set_global_timeout method can be used toset a timeout for task-based phase execution.

❍ kill — calling this method kills this components’ run task and any processesit has forked. Other components, including any children, are not affected.

❍ do_test completion — the top-level ovm_env::do_test task recursivelykills all the run tasks in the entire component hierarchy just before it returns.

57

❑ After all component’s run tasks are completed or killed, the global end_run eventis triggered.

This method should never be called directly.

See ovm_phase on page 61 for more information on phases.

58

ovm_env

The ovm_env class is a top-level container component that provides phasing control for ahierarchy of components.

Summaryvirtual class ovm_env extends ovm_threaded_component

function new (string name=env, ovm_component parent=null);

static task run_test (string test_name="");

static task do_global_phase (string ph_name);

// methods used when in do_test mode

virtual task run();

virtual task do_test(); // DEPRECATED

endclass

ovm_void

ovm_object

ovm_report_object

ovm_component

ovm_threaded_component

ovm_env

59

File

base/ovm_env.svh

Virtual

Yes

Membersstatic bit finish_on_completion = 1

Sets whether or not the run_test method should invoke $finish when it completes.By default, run_testwill exit in the delta cycle after it has completed running. When setto 0, you must explicitly end the simulation.

Methods

newfunction new (string name="env", ovm_component parent=null)

Creates and initializes an instance of the ovm_env class.

If parent is null, then this instance is a top-level component having special semanticswhen running in do_test mode (deprecated). First, simulation test flow is started with acall to do_test, not run_test. Second, the run task of this env controls the durationof the run phase for all components. See run method on page 60 for more information.

do_global_phasestatic function void do_global_phase(string ph_name)

Executes the phase, ph_name, on all components in the test environment.

If ph_name is not the next phase to be executed, then all previous phases are run tobring all components up through the ph_name phase.

In general, this function should not be called directly. Use run_test or do_test toinitiate a phased simulation.

do_testvirtual task do_test () - DEPRECATED

60

The do_test calls report_header, run_test, and report_summarize. Callingthis method requires this ovm_env instance be the only top-level (parent=null) in thetest environment. The run phase completes once this instance’s run task completes.

Note: The do_test method may be depreciated in favor of the run_test method,affording users more control of the simulation test flow.

run_teststatic task run_test (string test_name="")

The run_test task governs phasing for all components in the test environment.

If a command-line plus argument, +OVM_TESTNAME=test_type, is present,run_test calls upon the ovm_factory to create an instance of the given type beforestarting the phasing of all components. If the plus argument is absent, then iftest_name is specified and non empty, run_test calls upon the factory to create thatinstance before phasing. Otherwise, run_test starts phasing immediately withoutcreating any new components.

The component created by run_test, if any, is given the instance nameovm_test_top.

runvirtual task run (string)

When in do_test mode (parent=null), this ovm_env object is considered the singletop-level, and the run task in the deriving class takes on special semantics:

❑ The OVM ensures this run task is started last, after all descendant components runtasks have started.

❑ When this run task ends, a call to global_stop_request is issued for the env,thus ending the run phase once all component’s stop tasks have completed.

Global Functions

run_testtask run_test (string test_name="")

This global task simply calls ovm_env::run_test(test_name), which eliminatesthe need for the ovm_env:: scope specifier.

61

ovm_phase

The ovm_phase class is used for defining phase objects.

Phases are a synchronizing mechanism for the environment. Depending on the phase,components in the environment are phased in top-down or bottom-up order. Phase callbacksmay be either functions or tasks.

Table 1-2 on page 61 shows the predefined phases that are part of OVM.

Table 1-2 Predefined Phases

Phase PhaseType Object defining the phase Description

post_new function ovm_component First phase called. Children maybe instantiated during this phase.

elaborate function ovm_component Implicit phase used by portbinding.

pre_run function ovm_threaded_component Called before the run phase onthreaded components.

run task ovm_threaded_component The main process phase. Thisphase process (as with all taskprocesses) may be killed.

extract function ovm_component This phase is for organizinginformation from the run.

check function ovm_component This phase is for doing end ofsimulation checking.

report function ovm_component This phase is for reporting results.

ovm_phase

62

Summaryvirtual class ovm_phase;

function new (string name, bit is_top_down, bit is_task);

function string get_name();

virtual function string get_type_name();

function bit is_task();

function bit is_top_down();

virtual task call_task();

virtual function void call_func();

virtual task execute(ovm_component parent);

endclass

File

base/ovm_phases.sv

Virtual

Yes

Members

None

Methods

newfunction new (string name, bit is_top_down, bit is_task);

Creates a phase object.

The name is the name of the phase. When is_top_down is set, the parent is phasedbefore its children. is_task indicates whether the phase callbacks consume time.

get_namefunction string get_name ();

63

Returns the name of the phase object as supplied in the constructor.

get_type_namevirtual function string get_type_name ();

Returns the name of the type name phase object.

is_taskfunction bit is_task ();

Returns 1 if the phase is time consuming and 0 if not.

is_top_downfunction bit is_top_down ();

Returns 1 if the phase executes top down (executes the parent’s phase callback beforeexecuting the children’s callback) and 0 otherwise.

call_taskvirtual task call_task ();

This task is overridden by a derived class that defines a task phase. In typical usage, thefunction calls the phase task of its parent component.

call_funcvirtual void function call_func ();

This function is overridden by a derived class that defines a function phase. In typicalusage, the function calls the phase task of its parent component.

executevirtual task execute (ovm_component parent);

This task is called by the OVM controller during the phasing operation. Implementationsmust $cast the parent argument to the component type whose queue contains thisphase object. It must then invoke call_task or call_func which calls the actualphase method in the parent component.

64

Usage

In general, it is not necessary to know the details of phases in order to use them. However,in order to create a user defined phase, it is necessary to inherit from the ovm_phase classin a specific way. The following section explains how to do this.

Phase objects are created in the global space, one phase object per phase.

The phase objects are added to each component’s phase queue in the constructor of theobject that defines the phase.

Inheriting from the ovm_phase Class

When creating a user defined phase, you must do the following:

1. Define a derived class definition for the phase, inheriting from ovm_phase. The derivedclass must have knowledge of the type of component in which it is to be used. This canbe accomplished with a type-parameter.

2. Create a single instance of the phase in the same scope for each component class thatwill use that phase.

3. In the constructor of the component class, add the phase object to the component’sphase queue. Also, be sure to declare the phase callback in the component class.

For example, to create a phase called mytask that is run by object of type mycomponent (orderivatives), do the following:

// step 1: define a top-dwn task phase, mytask (see convenience macros, below)

`ovm_phase_task_decl(mytask,1)

// step 2: create an instance of the phase object

typedef class mycomponent; // forward declare the parent type

mytask_phase #(mycomponent) mytask_ph = new();

// step 3: insert phase object in component’s phase queue

class mycomponent extends ovm_threaded_component;

...

function new(string name, ovm_component parent);

super.new(name,parent);

insert_phase("run", mytask_ph); //insert before existing run phase

...

endfunction

65

...

task mytask(); // this task is now a phase callback

...

endtask

endclass

Optional Macros

The following macros simplify the process of creating a user defined phase. They create aphase type that is parameterized to the component class that uses the phase.

The PHASE_NAME argument is used to define the name of the phase, the name of thecomponent method that is called back during phase execution, and the type-name of thephase class itself.

TheTOP_DOWN argument is passed to the constructor of the ovm_phase base class.

`ovm_phase_func_decl`ovm_phase_func_decl (PHASE_NAME, TOP_DOWN)

This macro creates the following class definition.

class PHASE_NAME``_phase #(type PARENT=int) extends ovm_phase;

PARENT m_parent;

function new();

super.new(`"NAME`",TOP_DOWN,1);

endfunction

virtual function void call_func();

m_parent.NAME(); // call the component’s phase callback

endtask

virtual task execute(ovm_component parent);

assert($cast(m_parent,parent));

call_func();

endtask

endclass

`ovm_phase_task_decl`ovm_phase_task_decl (PHASE_NAME, TOP_DOWN)

This macro creates the following class definition:

class PHASE_NAME``_phase #(type PARENT=int) extends ovm_phase;

PARENT m_parent;

66

function new();

super.new(`"NAME`",TOP_DOWN,1);

endfunction

virtual task call_task();

m_parent.NAME(); // call the component’s phase callback

endtask

virtual task execute(ovm_component parent);

assert($cast(m_parent,parent));

call_task();

endtask

endclass

67

Reporting

The reporting classes provide a facility for issuing reports with different severities and IDs,and to different files. The primary interface to the reporting facility is ovm_report_object,which is inherited by ovm_component.

ovm_object

ovm_void

ovm_report_object

ovm_report_server

ovm_report_handler

ovm_componentovm_reporter

68

ovm_report_object

The ovm_report_object provides an interface to the OVM reporting facility. Through thisinterface, components issue the various messages that occur during simulation. They canalso configure what actions are taken and what file(s) are output for individual messages orfor all messages.

Most methods in ovm_report_object are delegated to an instance of anovm_report_handler, which stores its component’s reporting configuration anddetermines whether an issued message should be displayed based on the configuration. Todisplay a message, the report handler delegates the actual formatting and production ofmessages to a central ovm_report_server.

Summaryvirtual class ovm_report_object extends ovm_object;

function new(string name="");

function void ovm_report_fatal(string id, string message,

int verbosity_level=100,

tring filename="", int line=0);

function void ovm_report_fatal(string id, string message,

int verbosity_level=0,

string filename="", int line=0);

function void ovm_report_fatal(string id, string message,

int verbosity_level=300,

tring filename="", int line=0);

function void ovm_report_warning(string id, string message,

int verbosity_level=200,

string filename="", int line=0);

function ovm_report_handler get_report_handler();

ovm_void

ovm_object

ovm_report_object

69

function string get_report_name();

virtual function void report_header(FILE f=0);

virtual function bit report_hook(string id, string message,

int verbosity,

string filename, int line);

virtual function bit report_fatal_hook(string id,

string message,

int verbosity,

string filename, int line);

virtual function bit report_fatal_hook(string id,

string message,

int verbosity,

string filename, int line);

virtual function bit report_info_hook(string id,

string message,

int verbosity,

string filename, int line);

function void report_summarize(FILE f=0);

virtual function bit report_warning_hook (string id,

string message,

int verbosity,

string filename, int line);

function void reset_report_handler();

function void set_report_handler(ovm_report_handler hndlr);

function void set_report_max_quit_count(int m);

function void set_report_name(string s);

function void set_report_severity_action (ovm_severity s,

ovm_action a);

function void set_report_verbosity_level(int verbosity_level);

function void set_report_severity_action (string id, ovm_action a);

function void set_report_severity_id_action (ovm_severity s,

string id,

ovm_action a);

function void set_report_default_file (input FILE f);

function void set_report_severity_file (ovm_severity s,

FILE f);

function void set_report_id_file (input string id, input FILE f);

function void set_report_severity_file (ovm_severity s,

string id,

FILE f);

function void set_report_verbosity_level();

70

virtual function void die();

end class

File

base/ovm_report_object.svh

Virtual

Yes

Membersprotected ovm_report_handler m_rh

Handle to a report handler, which stores message configuration. It may be unique to thiscomponent or shared with several components.

Methods

newfunction new(string name="")

Creates a new report object with the given name. This method also creates a newovm_report_handler object, which this object delegates most tasks to.

ovm_report_fatal

ovm_report_error

ovm_report_warning

ovm_report_infofunction void ovm_report_fatal(string id, string message,

int verbosity_level=0,

string filename="", int line=0)

function void ovm_report_error(string id, string message,

int verbosity_level=100,

71

string filename="", int line=0)

function void ovm_report_warning(string id, string message,

int verbosity_level=200,

string filenamee="", int line=0)

function void ovm_report_info(string id, string message,

int verbosity_level=300,

string filename="", int line=0)

These methods produce reports of severity OVM_FATAL, OVM_ERROR, OVM_WARNING,and OVM_INFO. All message output should come from calls to these four methods.

The id argument is a unique identifer for a message. You can configure an individualreport’s actions and output file descriptor using its id string.

The message argument is main body of the message you want displayed.

The verbosity argument specifies the message’s relative importance. If theverbosity argument is higher than the maximum verbosity setting in the reporthandler, this report is simply ignored. The default verbosity levels by severity are:OVM_FATAL=0, OVM_ERROR=100, warning=200, and info=300. The maximumverbosity can be set using the set_report_verbosity_level method on page 75or set_report_verbosity_level_hier method on page 51.

The filename and line arguments allow you to provide the location of the call to thereport methods. If specified, they are displayed in the output.

get_report_handlerfunction ovm_report_handler get_report_handler()

Provides public access to the report handler, which stores all of the state information.

get_report_namefunction string get_report_name()

Provides public access to the report name.

report_headervirtual function void report_header(FILE file=0)

Prints version and copyright information. This information is sent to the command line iff is 0, or to the file descriptor f if it is not 0.

This method is called by ovm_env immediately after the construction phase and beforethe connect phase.

72

report_hook

report_info_hook

report_warning_hook

report_error_hook

report_fatal_hookvirtual function bit report_hook (string id, string message,

int verbosity,

string filename, int line)

virtual function bit report_info_hook (string id, string message,

int verbosity,

string filename, int line)

virtual function bit report_warning_hook(string id, string message,

int verbosity,

string filename, int line)

virtual function bit report_error_hook(string id, string message,

int verbosity,

string filename, int line)virtual function bit report_fatal_hook(string id, string message,

int verbosity,

string filename, int line)

These hook methods can be defined in derived classes to perform additional actionswhen reports are issued. They are called only if the OVM_CALL_HOOK bit is specified inthe action associated with the report. The default implementations return 1, which allowsthe report to be processed. If an override returns 0, the report is not processed.

report_summarizefunction void report_summarize(FILE f=0)

Produces statistical information on the reports issued by the central report server. Thisinformation will be sent to the command line if f is 0, or to the file descriptor f if it is not 0.

reset_report_handlerfunction void reset_report_handler()

73

Re-initializes the component’s report handler to the default settings.

set_report_handlerfunction void set_report_handler(ovm_report_handler hndlr)

Sets the report handler, thus allowing more than one component to share the samereport handler.

set_report_max_quit_countfunction void set_report_max_quit_count(int m)

Sets the value of the max_quit_count in the report handler to m. When the number ofOVM_COUNT actions reaches m, the die method on page 75 is called.

The default value of 0 indicates that there is no upper limit to the number of OVM_COUNTreports.

set_report_namefunction void set_report_name(string s)

Sets the report name.

set_report_default_file

set_report_severity_file

set_report_id_file

set_report_severity_id_filefunction void set_report_default_file (FILE file)

function void set_report_severity_file (ovm_severity sev,

FILE file)function void set_report_id_file (string id, FILE file)

function void set_report_severity_id_file (ovm_severity sev,

string id, FILE file)

These methods configure the report hander to direct some or all of its output to the givenfile descriptor. The file argument must be a multi-channel descriptor (mcd) or fileid compatible with $fdisplay.

74

❑ set_report_default_file sets a default file descriptor for all reports issued by thisreport hander. The initial descriptor is set to 0, which means that even if the actionincludes a OVM_LOG attribute, the report is not sent to a file.

❑ set_report_severity_file sets the file descriptor for reports matching the givenseverity. This setting takes precedence over the default file descriptor.

❑ set_report_id_file sets the file descriptor for reports matching the given id. Thissetting takes precedence over the default and any severity settings fromset_report_severity_file.

❑ set_report_severity_id_file sets the file descriptor for reports matching both thegiven severity and id. This setting takes highest precedence.

See ovm_report_handler on page 77 for more information.

set_report_severity_action

set_report_id_action

set_report_severity_id_action

function void set_report_severity_action (ovm_severity sev,

ovm_action action)

function void set_report_id_action (string id,

ovm_action action)

function void set_report_severity_id_action (ovm_severity sev,

string id,

ovm_action action)

These methods configure the report hander in this component to perform the givenaction when issuing reports matching the given severity, id, or severity -idpair.

❑ set_report_severity_action sets the action for reports matching the given sev.This setting takes precedence over the default setting.

❑ set_report_id_action sets the action for reports matching the given id. Thissetting takes precedence over settings from set_report_severity_action.

❑ set_report_severity_id_action sets the action for reports matching both thegiven sev and id. An action associated with a (severity, id) pair takes priorityover an action associated with either the severity or the id alone.

75

The action argument can take the value OVM_NO_ACTION (5'b00000), or it can bea bitwise OR of any combination of OVM_DISPLAY, OVM_LOG, OVM_COUNT, OVM_EXIT,and OVM_CALL_HOOK.

For a list of severities and their default actions, refer to ovm_report_handler on page 77.

set_report_verbosity_levelfunction void set_report_verbosity_level(int verbosity_level)

Sets the maximum verbosity level for the report handler. Any report whose verbosityexceeds this maximum is ignored.

dump_report_statefunction void dump_report_state()

This method dumps the internal state of the report handler. This includes informationabout the maximum quit count, the maximum verbosity, and the action and filesassociated with severities, ids, and (severity, id) pairs.

dievirtual function void die()

This method is called by the report server if a report reaches the maximum quit count orhas an OVM_EXIT action associated with it, e.g. fatal errors.

If die is called in a report object that is an ovm_component contained in an ovm_env,the ovm_env ends the run phase by killing all its children’s run tasks. The extract,check, and report phases are then executed, followed by a call toreport_summarize. In this case, any other ovm_env’s in the environment will not beaffected.

If die is called in a report object that is not an ovm_component, or in anovm_component defined outside of an ovm_env, then report_summarize is calledand the simulation terminates with $finish.

76

ovm_reporter

The ovm_reporter extends ovm_report_object and is used as a standalone reporter.Objects that are not ovm_components may use this to issue reports that leverage the sameconfiguration and formatting features as components.

Summaryclass ovm_reporter extends ovm_report_object;

function new(string name="reporter");

end class

File

base/ovm_report_object.svh

Virtual

No

Methods

newfunction new(string name="reporter")

The constructor has the default name of reporter.

ovm_void

ovm_object

ovm_report_object

77

ovm_report_handler

ovm_report_handler is the class to which many of the methods in ovm_report_objectare delegated. It stores the maximum verbosity, actions, and files that affect the way reportsare handled.

Note: The report handler is not intended for direct use. See ovm_report_object for infomationon the OVM reporting mechanism.

The relationship between ovm_report_object (a base class for ovm_component) andovm_report_handler is usually one to one, but it can, in theory, be many to one. When areport needs processing, the report handler passes it to the central report server. Therelationship between ovm_report_handler and ovm_report_server is many to one.

Summaryclass ovm_report_handler;

function new();

function void set_max_quit_count(int m);

function void summarize(FILE f=0);

function void report_header(FILE f=0);

function void initialize();

virtual function bit run_hooks(ovm_report_object client,

vm_severity s, string id,

string message, int verbosity,

string filename, int line);

function void set_verbosity_level(int verbosity_level);

function action get_action(ovm_severity s, string id);

function FILE get_file_handle(ovm_severity s, string id);

function void report(ovm_severity s, string name, string id,

string mess,

int verbosity_level=0,

ovm_report_object client=null);

function string format_action(ovm_action a);

ovm_report_handler

ovm_reporter

78

function void set_severity_action(ovm_severity s, ovm_action a);

function void set_id_action(string id, ovm_action a);

function void set_severity_id_action(ovm_severity s, string id,

ovm_action a);

function void set_default_file(FILE f);

function void set_severity_file(ovm_severity s, FILE f);

function void set_id_file(string id, FILE f);

function void set_severity_id_file(ovm_severity s, string id,

FILE f);

function void dump_state();

end class

File

base/ovm_report_handler.svh

Virtual

No

Membersovm_report_server m_srvr

This is the central report server that actually processes the reports.

int m_max_verbosity_level

This is the maximum verbosity of reports that this report handler forwards to the reportserver. The default value is 10000.

action severity_actions[severity]

This is the array that contains the actions associated with each severity. The defaultvalues are given by the table below.

Severity Actions

OVM_INFO OVM_DISPLAY

OVM_WARNING OVM_DISPLAY

79

id_actions_array id_actions

This is the array of actions associated with each string id. By default, there are noentries in this array.

id_actions_array severity_id_actions[severity]

This is an associative array of associative arrays. If it exists, thenseverity_id_actions[s][i] contains the actions associated with the (severity,id) pair (s,i). By default, there are no entries in this array.

FILE default_file_handle

This is the default file handle for this report handler. By default, it is set to 0, which meansthat reports are not sent to a file even if an OVM_LOG attribute is set in the actionassociated with the report.

FILE severity_file_handles[severity]

This array contains the file handle associated with each severity.

id_file_array id_file_handles

This array contains the file handle associated with each string id.

id_file_array severity_id_file_handles[severity]

This associative array of associative arrays contains the file descriptor associated witheach (severity, id) pair, if there are any.

Methods

newfunction new()

The constructor.

set_max_quit_countfunction void set_max_quit_count(int m)

OVM_ERROR OVM_DISPLAY |OVM_COUNT

OVM_FATAL OVM_DISPLAY |OVM_EXIT

Severity Actions

80

See ovm_report_object::set_report_max_quit_count.

summarizefunction void summarize(FILE f=0)

See ovm_report_object::report_summarize.

report_headerfunction void report_header(FILE f=0)

See ovm_report_object::report_header.

initializefunction void initialize()

This method is called by the constructor to initialize the arrays and other variablesdescribed above to their default values.

run_hooksvirtual function bit run_hooks(ovm_report_object client,

ovm_severity s, string id,

string message, int verbosity,

string filename, int line)

run_hooks is called if the OVM_CALL_HOOK action is set for this report. It calls theclient’s report_hook and then the severity-specific hook method. If either returns 0, thereport is not processed.

set_verbosity_levelfunction void set_verbosity_level(int verbosity_level)

See ovm_report_object::set_report_verbosity_level.

get_actionfunction action get_action(ovm_severity s, string id)

This method looks up the action associated with this severity and id.

81

get_file_handlefunction FILE get_file_handle(ovm_severity s, string id)

This method returns the file descriptor associated with the given severity and id.

reportfunction void report(ovm_severity s, string name, string id,

string mess, int verbosity_level=0,

ovm_report_object client=null)

This is the common method called by the four core reporting methods inovm_report_object: ovm_report_fatal, ovm_report_warning,ovm_report_fatal, and ovm_report_fatal.

See the descriptions of these methods for their detailed behavior.

format_actionfunction string format_action(ovm_action a)

This method returns a string that describes the action.

set_severity_actionfunction void set_severity_action(ovm_severity s, ovm_action a)

See ovm_report_object::set_report_severity_action.

set_id_actionfunction void set_id_action(string id, ovm_action a)

See ovm_report_object::set_report_severity_action.

set_severity_id_actionfunction void set_severity_id_action(ovm_severity s, string id,

ovm_action a)

See ovm_report_object::set_report_severity_id_action.

set_default_filefunction void set_default_file(FILE f)

See ovm_report_object::set_report_default_file.

82

set_severity_filefunction void set_severity_file(ovm_severity s, FILE f)

See ovm_report_object::set_report_severity_file.

set_id_filefunction void set_id_file(string id, FILE f)

See ovm_report_object::set_report_id_file.

set_severity_id_filefunction void set_severity_id_file(ovm_severity s, string id,

FILE f)

See ovm_report_object::set_report_severity_file.

dump_statefunction void dump_state()

See ovm_report_object::set_report_verbosity_level.

83

ovm_report_server

ovm_report_server is a global server that processes all of the reports generated by anovm_report_handler. None of its methods are intended to be called by normal testbenchcode, although in some circumstances the virtual methods process_report and/orcompose_ovm_info may be overloaded in a subclass.

Summaryclass ovm_report_server;

protected function new();

static function ovm_report_server get_server();

function int get_max_quit_count();

function void set_max_quit_count(int m);

function void reset_quit_count();

function void incr_quit_count();

function int get_quit_count();

function bit is_quit_count_reached();

function void reset_severity_counts();

function int get_severity_count(ovm_severity s);

function void incr_severity_count(ovm_severity s);

function void set_id_count(string id, int n);

function int get_id_count(string id);

function void incr_id_count(string id);

function void summarize(FILE f=0);

function void f_ovm_display(FILE f, string s);

function void dump_server_state();

virtual function void process_report(ovm_severity s, string name,

string id, string message,

ovm_action a,

FILE f,

string filename, int line,

ovm_report_object client );

virtual function string compose_ovm_info(ovm_severity s, string name,

string id, string message);

end class

ovm_report_server

84

File

base/ovm_report_server.svh

Virtual

No

Members

none

Methods

newprotected function new()

Creates the central report server, if not already created. Else, does nothing. Theconstructor is protected to enforce a singleton.

get_serverstatic function ovm_report_server get_server()

Returns a handle to the central report server.

get_max_quit_countfunction int get_max_quit_count()

Returns the maximum number of COUNT actions that can be tolerated before anOVM_EXIT action is taken. The default value is 0, which specifies no maximum.

set_max_quit_countfunction void set_max_quit_count(int m)

Sets the maximum number of COUNT actions that can be tolerated before an OVM_EXITaction is taken.

85

reset_quit_countfunction void reset_quit_count()

This method resets the value of quit_count to 0.

incr_quit_countfunction void incr_quit_count()

Increments the number of COUNT actions issued.

get_quit_countfunction int get_quit_count()

Returns the number of COUNT actions issued.

is_quit_count_reachedfunction bit is_quit_count_reached()

Returns 1 if the number of COUNT actions has reached the maximum, if set.

reset_severity_countsfunction void reset_severity_counts()

This method resets the severity counters to 0.

get_severity_countfunction int get_severity_count(ovm_severity s)

Returns the number of issued reports of severity s since the last reset.

incr_severity_countfunction void incr_severity_count(ovm_severity s)

Increments the counter for reports of severity s.

set_id_countfunction void set_id_count(string id, int n)

Sets the counter for reports with the given id to n.

86

get_id_countfunction int get_id_count(string id)

Returns the number of issued reports that had the given identifier.

incr_id_countfunction void incr_id_count(string id)

Increments the number of reports with this id.

summarizefunction void summarize(FILE f=0)

See ovm_report_object::report_summarize.

f_ovm_displayfunction void f_ovm_display(FILE f, string s)

This method sends string s to the command line if f is 0 and to the file(s) specified by fif it is not 0.

dump_server_statefunction void dump_server_state()

See ovm_report_object::set_report_verbosity_level.

process_reportvirtual function void process_report(ovm_severity s, string name,

string id, string message,

ovm_action a,

FILE f,

string filename, int line,

ovm_report_object client )

This method calls compose_ovm_info to construct the actual message to be output. Itthen takes the appropriate action according to the value of action a and file f.

This method can be overloaded by expert users so that the report system processes theactions different from the way described in ovm_report_object andovm_report_handler.

87

compose_ovm_infovirtual function string compose_ovm_info(ovm_severity s, string name,

string id, string message)

This method constructs the actual string sent to the file or command line from theseverity, component name, report ID, and the message itself.

Expert users can overload this method to change the formatting of the reports generatedby ovm_report_object.

88

Factory

ovm_object_wrapper

The ovm_object_wrapper is an abstract class which provides the interface used forregistering proxy objects with the factory for creating object types.

The ovm_registry types provide templated types which implement type-specific wrappers.

Summary

virtual class ovm_object_wrapper;

virtual function ovm_object create_object (string name="");

virtual function ovm_component create_component (string name,

ovm_component parent);

pure virtual function string get_type_name();

endclass

File

base/ovm_factory.svh

Virtual

Yes

Members

None

ovm_object_wrapper

89

Methods

create_componentfunction ovm_component create_component(string name,

ovm_component parent)

Implementation of create_component.

A wrapper must either implement create_object or create_component. The nameand parent arguments should be passed to the constructor of the component objectthat is being created.

create_objectfunction ovm_object create_object(string name="")

Implementation of create_object.

A wrapper must either implement create_object or create_component. The nameargument is the name to which the object should be set, using set_name() and afterthe object has been created.

get_type_namefunction string get_type_name()

This is the method used by the factory to determine the type of object the wrappercreates. This method must be implemented.

90

ovm_component_registry #(type T, string Tname)

The ovm_component_registry provides a templatized wrapper. In order to register anobject with the factory, it is sufficient to declare a specialization of this type with the type T,which the wrapper creates, and the string Tname, which is the name the factory uses for thelookup. By convention, Tname should be an actual type name.

Summary

class ovm_component_registry#(type T, string Tname) extends ovm_object_wrapper;

function ovm_component create_component (string name,

ovm_component parent);

virtual function string get_type_name();

endclass

File

base/ovm_registry.svh

Virtual

No

Members

None

ovm_object_wrapper

ovm_component_registry #(type T, string Tname)

91

Methods

create_componentfunction ovm_component create_component (string name,

ovm_component parent)

Creates a component of type T.

get_type_namefunction string get_type_name()

Returns the value Tname.

92

ovm_object_registry #(type T, string Tname)

The ovm_object_registry provides a templatized wrapper.

In order to register an object with the factory, it is sufficient to declare a specialization of thistype with the type T, which the wrapper creates, and the string Tname, which is the name thefactory uses for the lookup.

By convention, Tname should be an actual type name.

Summaryclass ovm_object_registry#(type T, string Tname) extends ovm_object_wrapper;

function ovm_object create_object (string name="");

virtual function string get_type_name();

endclass

File

base/ovm_registry.svh

Virtual

No

Members

None

ovm_object_wrapper

ovm_object_registry #(type T, string Tname)

93

Methods

create_objectfunction ovm_object create_object(string name="")

Creates an object of type T.

get_type_namefunction string get_type_name()

Returns the value Tname.

94

ovm_factory

The ovm_factory is a class which implements a factory pattern.

A singleton factory instance is created for a given simulation run. Class types are registeredwith the factory using the ovm_object_wrapper.

Summaryclass ovm_factory extends ovm_object;

static function void auto_register (ovm_object_wrapper obj);

static function ovm_object create_object (string create_type,

string inst_path="",

string name="");

static function ovm_component create_component (string lookup_str,

string inst_path="",

string name,

ovm_component parent);

static function void set_type_override (string create_type,

string type_name, bit replace=1);

static function void set_inst_override (string inst_path,

string lookup_str, string type_name);

static function void print_all_overrides (bit all_types=0);

static function void print_override_info (string create_type,

string inst_path="",

string inst_name="");

endclass

ovm_void

ovm_object

ovm_factory

95

File

base/ovm_factory.svh

Virtual

No

Members

None

Methods

auto_registerstatic function void auto_register(ovm_object_wrapper obj)

Registers a proxy object with the factory.

The type of object that the wrapper is able to create is defined by theget_type_name() method.

The object can either create a component, or it can create a data object.

create_componentstatic function ovm_component create_component(string create_type,

string inst_path="",

string name="",

ovm_component parent)

Uses the factory to generate a component of type create_type.

The generated component will be create_type, or a derivative type if an override is ineffect. A null object will be returned if the factory does not have a component registeredwith the string identifier create_type.

inst_path is an optional hierarchical anchor for the object being created. This path isused in conjunction with name to search for instance overrides.

name is an optional leaf name for the object. The full name of the object is{inst_path, “.”, name}.

96

The factory uses instance overrides first, if name and inst_path are not empty.

If no instance override exists for the full name of the object, then the factory searches fora type override on create_type.

Note: A simplified version of create_component is available in ovm_componentwhen a child component is being created.

create_objectstatic function ovm_object create_object(string create_type,

string inst_path="",

string name="")

Uses the factory to generate an object of type create_type.

The generated object will be create_type, or a derivative type if an override is in effect.A null object will be returned if the factory does not have an object registered with thestring identifier create_type.

inst_path is an optional hierarchical anchor for the object being created. This path isused in conjunction with name to search for instance overrides.

name is an optional leaf name for the object. The full name of the object is {inst_path,“.”, name}.

The factory uses instances overrides first, if name and inst_path are not empty.

If no instance override exists for the full name of the object then the factory searches fora type override on create_type.

Note: A simplified version of create_object is available in ovm_componentwhen anobject is being created inside of a component.

print_all_overridesstatic function void print_all_overrrides(bit all_types=0)

This debug method prints all of the overrides that the factory knows about.

By default, it prints only information on types which have overrides.

If the all_types bit is set, the method will print all types that are registered with thefactory, whether or not an override exists.

print_override_infostatic function void print_override_info (string create_type,

97

string inst_path="",

string name="")

This debug method takes the same set of arguments as create_object orcreate_component (except the parent argument which does not effect the override).However, instead of generating a component, it provides information about what type ofcomponent it would create.

All overrides which apply to the input arguments are listed in their order of precedence.

set_inst_overridestatic function void set_type_override (string inst_path,

string create_type,

string type_name)

Places an instance specific override in the instance override queue.

inst_path is the instance name to override and create_type is the type of objectexpected to be created at that instance.

type_name is the actual type that is created when the factory is asked to create anobject or component at inst_path of type create_type.

The instance path may include wildcards (* and ?).

When the factory processes instance overrides, the instance queue is processed in orderof the override call. Thus, more specific overrides should be set in place first, followed bymore general overrides. This way, the general override will not override the specificoverride.

set_type_overridestatic function void set_type_override(string create_type,

string type_name,

bit replace=1)

Places a type-wide override into the factory.

When a type override is put in place, the factory will generate the type given bytype_name when you attempt to create and object or component of typecreate_type.

If a type override already exists, the new override will take effect if the replace bit is set;otherwise the previous override will remain in place.

98

Synchronization

ovm_event

The ovm_event class is a wrapper class around a traditional Verilog event.

The ovm_event provides some services on top of a traditional verilog event, such as settingcallbacks on the event.

Note: Because of the extra overhead associated with an ovm_event object, these objectsshould be used sparingly, and should be used only in those places where traditional Verilogevents are not sufficient.

Summaryclass ovm_event extends ovm_object;

function new (string name="");

// waiting

virtual task wait_on (bit delta=0);

virtual task wait_off (bit delta=0);

virtual task wait_trigger ();

virtual task wait_ptrigger ();

virtual task wait_trigger_data (output ovm_object data);

extern virtual task wait_ptrigger_data(output ovm_object data);

// triggering

virtual function void trigger (ovm_object data=null);

virtual function ovm_object get_trigger_data ();

virtual function time get_trigger_time ();

// state

virtual function bit is_on ();

ovm_object

ovm_event

99

virtual function bit is_off ();

virtual function void reset (bit wakeup=0);

// callbacks

virtual function void add_callback (ovm_event_callback cb,

bit append=1);

virtual function void delete_callback (ovm_event_callback cb);

// waiters list

virtual function void cancel ();

virtual function int get_num_waiters ();

endclass

File

base/ovm_event.svh

Virtual

No

Members

None

Methods

newfunction new (name)

Creates a new event object.

add_callbackvirtual function void add_callback (ovm_event_callback cb, bit append=1)

Adds a callback to the event. Callbacks have a pre_trigger() and post_trigger()function.

If append is set to 1, which is the default, then the callback is added to the back of thecallback list. Otherwise the callback is put in the front of the callback list.

100

cancelvirtual function void cancel ()

Decrements the number of waiters on the event.

This is used if a process that is waiting on an event is disabled or activated by some othermeans.

delete_callbackvirtual function void delete_callback (ovm_event_callback cb)

Removes a callback from the event.

get_num_waitersvirtual function int get_num_waiters ()

Returns the number of processes waiting on the event.

get_trigger_datavirtual function ovm_object get_trigger_data ()

Gets the data, if any, associated with the last trigger event.

get_trigger_timevirtual function time get_trigger_time ()

Gets the time that this event was last triggered. If the event has not been triggered, orthe event has been reset, the trigger time will be 0.

is_onvirtual function bit is_on ()

Indicates whether the event has been triggered since it was last reset.

A return of 1 indicates that the event has triggered.

is_offvirtual function bit is_off ()

Indicates whether the event has been triggered since it was last reset.

A return of 1 indicates that the event has not been triggered.

101

resetvirtual function void reset (bit wakeup=0)

Resets the event to its off state. If wake-up is set, then all processes waiting for the eventat the time of the reset are activated before the event is reset.

No callbacks are called during a reset.

triggervirtual function void trigger (ovm_object data=null)

Triggers the event.

This causes all processes waiting on the event to be enabled.

An optional data argument can be supplied with the enable to provide trigger-specificinformation.

wait_onvirtual task wait_on (bit delta=0)

Waits for the event to be activated for the first time.

If the event has already been triggered, then this task immediately returns (if the delta bitis set, it will cause a #0 delay to be consumed before returning).

Once an event has been triggered, this task will always return immediately unless theevent is reset.

wait_offvirtual task wait_off (bit delta=0)

Waits for the event to be reset if it has already triggered.

If the event has not already been triggered, then this task immediately returns (the deltabit will cause a #0 delay to be consumed before returning).

wait_ptriggervirtual task wait_ptrigger ()

Waits for the event to be triggered. Unlike wait_trigger, wait_ptrigger() viewsthe event as persistent within a time-slice. Thus, if the waiter happens after the trigger,the waiter will still see the event trigger during the current time-slice.

102

wait_ptrigger_datavirtual task wait_ptrigger_data (output ovm_object data)

This method is a wrapper for calling wait_ptrigger immediately followed byget_trigger_data.

wait_triggervirtual task wait_trigger ()

Waits for the event to be triggered.

If one process calls wait_trigger() and another process calls trigger() in thesame delta cycle, a race condition occurs and there is no guarantee whether or not thewaiter will see the trigger.

wait_trigger_datavirtual task wait_trigger_data (output ovm_object data)

This method is a wrapper for calling wait_trigger immediately followed byget_trigger_data.

103

ovm_event_pool

The ovm_event_pool is essentially an associative array of ovm_event objects which isindexed by the string name of the event.

Summaryclass ovm_event_pool extends ovm_object;

function new (string name="");

// Pool and event access

static function ovm_event_pool get_global_pool ();

virtual function ovm_event get (string name);

// Iterators

virtual function int num ();

virtual function void delete (string name);

virtual function int exists (string name);

virtual function int first (ref string name);

virtual function int last (ref string name);

virtual function int next (ref string name);

virtual function int prev (ref string name);

endclass

File

base/ovm_event.svh

Virtual

No

ovm_object

ovm_event_pool

104

Members

None

Methods

newfunction new (name)

Creates a new event pool.

deletevirtual function void delete (string name)

Removes the event name from the pool.

existsvirtual function bit exists (ref string name)

Checks if the event name exists in the pool.

A return of 1 indicates that name is in the pool and 0 indicates that name is not in the pool.

firstvirtual function int first (ref string name)

Places the first event name from the pool into the variable name.

If the pool is empty, then name is unchanged and 0 is returned.

If the pool is not empty, then name gets the value of the first element and 1 is returned.

getvirtual function ovm_event get (string name)

Returns the event with the name specified by name.

If no events exist with the given name, then a new event is created and returned.

get_global_poolstatic function ovm_event_pool get_global_pool ()

105

Accesses the singleton global event pool.

This allows events to be shared amongst components throughout the verificationenvironment.

lastvirtual function int last (ref string name)

Returns the name of the last event in the pool.

If the pool is empty, then 0 is returned and name is unchanged.

the pool is not empty, then name is set to the last name in the pool and 1 is returned.

numvirtual function int num ()

Returns the number of events in the pool.

nextvirtual function int next (ref string name)

Uses the current value of name to find the next event name in the pool.

If the input name is the last name in the pool, then name is unchanged and 0 is returned.

If a next name is found, then name is replaced with the next name and 1 is returned.

prevvirtual function int prev (ref string name)

Uses the current value of name to find the previous event name in the pool.

If the input name is the first name in the pool, then name is unchanged and 0 is returned.

If a previous name is found, then name is replaced with the previous name and 1 isreturned.

106

ovm_event_callback

The ovm_event_callback class is an abstract class that is used to create callback objectswhich may be attached to events.

Callbacks are an alternative to using processes to wait on events. When a callback isattached to an event, that callback object’s callback function is called each time the event istriggered.

Summaryvirtual class ovm_event_callback extends ovm_object;

function new (string name="");

virtual function bit pre_trigger (ovm_event e,

ovm_object data=null);

virtual function void post_trigger (ovm_event e,

ovm_object data=null);

endclass

File

base/ovm_event.svh

Virtual

Yes

Members

None

ovm_object

ovm_event_callback

107

Methods

newfunction new (name)

Creates a new callback object.

pre_triggervirtual function bit pre_trigger (ovm_event e,

ovm_object data=null)

This function implements the pre_trigger functionality.

If a callback return 1 then the event will not trigger its waiters. This provides a way for acallback to override an event action.

In the function, e is the ovm_event that is being triggered, and data is the data, if any,associated with the event trigger.

post_triggervirtual function void post_trigger (ovm_event e,

ovm_object data=null)

This function implements the post_trigger functionality.

In the function, e is the ovm_event that is being triggered, and data is the data, if any,associated with the event trigger.

108

ovm_barrier

The ovm_barrier class provides a multi process synchronization mechanism.

The ovm_barrier class enables a set of processes to block until the desired number ofprocesses get to the synchronization point, at which time all of the processes are released.

Summaryclass ovm_barrier extends ovm_object;

function new (string name="");

// waiting

virtual task wait_for ();

virtual function void reset (bit wakeup=1);

virtual function void set_auto_reset (bit value=1);

virtual function void set_threshold (int threshold);

virtual function int get_threshold ();

virtual function int get_num_waiters ();

virtual function void cancel ();

endclass

File

base/ovm_event.svh

Virtual

No

ovm_object

ovm_barrier

109

Members

None

Methods

newfunction new (name)

Creates a new barrier object.

cancelvirtual function void cancel ()

Decrements the waiter count by one. This is used when a process that is waiting on thebarrier is killed or activated using some other means.

get_num_waitersvirtual function int get_num_waiters ()

Returns the number of processes currently waiting at the barrier.

get_thresholdvirtual function int get_threshold ()

Gets the current threshold setting for the barrier.

resetvirtual function void reset (bit wakeup=1)

Resets the barrier. This sets the waiter count back to zero.

The threshold is unchanged. After reset, the barrier will force processes to wait for thethreshold again.

If the wake-up bit is set, then currently waiting processes will be activated.

set_auto_resetvirtual function void set_auto_reset (bit value=1)

110

Determines if the barrier should reset itself when the threshold is reached.

The default is on, so when a barrier hits its threshold it will reset, and new processes willblock until the threshold is reached again.

If auto reset is off, then once the threshold is achieved, new processes pass throughwithout being blocked, until the barrier is reset.

set_thresholdvirtual function void set_threshold (int threshold)

Sets the process threshold.

This determines how many processes must be waiting on the barrier before theprocesses may proceed.

Once the threshold is reached, all waiting processes are activated.

If the threshold is set to a value less than the number of waiting processes, then thebarrier is reset and waiting processes are activated.

wait_forvirtual task wait_for ()

Waits for enough processes to reach the barrier before continuing.

The number of processes to wait for is set by the set_threshold() method.

111

ovm_barrier_pool

The ovm_barrier_pool is essentially an associative array of ovm_barrier objects whichis indexed by the string name of the barrier.

Summaryclass ovm_barrier_pool extends ovm_object;

function new (string name="");

// Pool and barrier access

static function ovm_barrier_pool get_global_pool ();

virtual function ovm_barrier get (string name);

// Iterators

virtual function int num ();

virtual function void delete (string name);

virtual function int exists (string name);

virtual function int first (ref string name);

virtual function int last (ref string name);

virtual function int next (ref string name);

virtual function int prev (ref string name);

endclass

File

base/ovm_event.svh

ovm_object

ovm_barrier_pool

112

Virtual

No

Members

None

Methods

newfunction new (name)

Creates a new barrier pool.

deletevirtual function void delete (string name)

Removes the barrier name from the pool.

existsvirtual function bit exists (ref string name)

Checks if the barrier name exists in the pool.

A return of 1 indicates that name is in the pool and 0 indicates that name is not in the pool.

firstvirtual function int first (ref string name)

Places the first barrier name from the pool into the variable name.

If the pool is empty, then name is unchanged and 0 is returned.

If the pool is not empty, then name gets the value of the first element and 1 is returned.

getvirtual function ovm_barrier get (string name)

Returns the barrier with the name specified by name.

113

If no barriers exist with the given name, then a new barrier is created and returned.

get_global_poolstatic function ovm_barrier_pool get_global_pool ()

Accesses the singleton global barrier pool.

This allows events to be shared amongst components throughout the verificationenvironment.

lastvirtual function int last (ref string name)

Returns the name of the last barrier in the pool.

If the pool is empty, then 0 is returned and name is unchanged.

Otherwise, name is set to the last name in the pool and 1 is returned.

numvirtual function int num ()

Returns the number of barriers in the pool.

nextvirtual function int next (ref string name)

Uses the current value of name to find the next barrier name in the pool.

If the input name is the last name in the pool, then name is unchanged and 0 is returned.

If a next name is found, then name is replaced with the next name and 1 is returned.

prevvirtual function int prev (ref string name)

Uses the current value of name to find the previous barrier name in the pool.

If the input name is the first name in the pool, then name is unchanged and 0 is returned.

If a previous name is found, then name is replaced with the previous name and 1 isreturned.

114

Policies

ovm_comparer

The ovm_comparer class provides a policy object for doing comparisons.

The policies determine how miscompares are treated and how they are counted.

Results of a comparison are stored in the comparer object.

Summaryclass ovm_comparer;

// Comparison message settings

int unsigned show_max = 1;

int unsigned verbosity = 500;

severity sev = OVM_INFO;

string miscompares = "";

// Comparison settings

bit physical = 1;

bit abstract = 1;

bit check_type = 1;

recursion_policy_enum policy = OVM_DEFAULT_POLICY;

// Result of comparison

int unsigned result = 0;

// Methods used checking for printing information

virtual function bit compare_field (string name,

ovm_bitstream_t lhs,

ovm_bitstream_t rhs,

int size,

radix_enum radix=OVM_NORADIX);

virtual function bit compare_field_int (string name,

logic[63:0] lhs,

ovm_comparer

115

logic[63:0] rhs,

int size,

radix_enum radix=OVM_NORADIX);

virtual function bit compare_object (string name,

ovm_void lhs,

ovm_void rhs);

virtual function bit compare_string (string name,

string lhs,

string rhs);

function void print_msg (string msg);

endclass

File

base/ovm_object.svh

Virtual

No

Membersbit abstract = 1

This bit provides a filtering mechanism for fields.

The abstract and physical settings allow an object to distinguish between two differentclasses of fields.

It is up to you, in the ovm_object::do_compare() routine, to test the setting of thisfield if they want to use it as a filter.

bit check_type = 1

This bit determines whether the type, given by ovm_object::get_type_name(), isused to verify that the types of two objects are the same.

This bit is used by the compare_object() method. In some cases it is useful to setthis to 0 when it is legitimate for one side, for example the rhs, to contain a derivative ofthe other side (the lhs).

int unsigned result = 0;

This bit stores the number of miscompares for a given compare operation. You can usethe result to determine the number of miscompares that were found.

string miscompares = “”

116

This string is reset to an empty string when a comparison is started.

The string holds the last set of miscompares that occurred during a comparison.

bit physical = 1

This bit provides a filtering mechanism for fields.

The abstract and physical settings allow an object to distinguish between two differentclasses of fields.

It is up to you, in the ovm_object::do_compare() routine, to test the setting of thisfield if they want to use it as a filter.

severity sev = OVM_INFO

Sets the severity for printed messages.

The severity setting is used by the messaging mechanism for printing and filteringmessages.

int unsigned show_max = 1

Sets the maximum number of messages to send to the messager for miscompares ofan object.

All miscompares are stored into the miscompares string.

int verbosity = 500

Sets the verbosity for printed messages.

The verbosity setting is used by the messaging mechanism to determine whethermessages should be suppressed or shown.

Methods

compare_fieldvirtual function bit compare_field (string name,

ovm_bitstream_t lhs,

ovm_bitstream_t rhs,

int size,

radix_enum radix=OVM_NORADIX)

Compares two integral values.

The name input is used for purposes of storing and printing a mis-compare.

The left-hand-side (lhs) and right-hand-side (rhs) objects are the two objects used forcomparison.

117

The size variable indicates the number of bits to compare; size must be less than orequal to 4096.

The radix is used for reporting purposes, the default radix is hex.

compare_field_intvirtual function bit compare_field (string name,

logic [31:0] lhs,

logic [31:0] rhs,

int size,

radix_enum radix=OVM_NORADIX)

This method is the same as compare_field except that the arguments are smallintegers, less than or equal to 64 bits.

compare_objectvirtual function bit compare_object (string name,

ovm_void lhs,

ovm_void rhs)

Compares two class objects using the policy value to determine whether the comparisonshould be deep, shallow, or reference.

The name input is used for purposes of storing and printing a mis-compare.

The lhs and rhs objects are the two objects used for comparison.

The check_type bit is used to determine whether or not to verify the object types match(the return from lhs.get_type_name() matches rhs.get_type_name()).

compare_stringvirtual function bit compare_string (string name,

string lhs,

string rhs)

Compares two string variables.

The name input is used for purposes of storing and printing a mis-compare.

The lhs and rhs objects are the two objects used for comparison.

118

print_msgfunction void print_msg (string msg)

Causes the error count to be incremented and the message, msg, to be appended to themiscompares string (a newline is used to separate messages).

If the message count is less than the show_max setting, then the message is printed tostandard-out using the current verbosity and severity settings. See the verbosity andseverity variables for more information.

119

ovm_packer

The ovm_packer class provides a policy object for packing and unpacking ovm_objects.The policies determine how packing and unpacking should be done. Packing an objectcauses the object to be placed into a bit (byte or int) array. By default, no metadatainformation is stored for the packing of dynamic objects (strings, arrays, class objects).Therefore, and in general, it is not possible to automatically unpack into an object whichcontains dynamic data (Note that this is only a concern when using the field macros toautomate packing and unpacking).

Summaryclass ovm_packer;

bit use_metadata = 0;

bit big_endian = 1;

bit physical = 1;

bit abstract = 0;

recursion_policy_enum policy = OVM_DEFAULT_POLICY;

virtual function void pack_field_int (logic[63:0] value,

int size);

virtual function void pack_field (ovm_bitstream_t value,

int size);

virtual function void pack_string (string value);

virtual function void pack_time (time value);

virtual function void pack_real (real value);

virtual function void pack_object (ovm_void value);

virtual function bit is_null ();

virtual function logic[63:0] unpack_field_int (int size);

virtual function ovm_bitstream_t unpack_field (int size);

virtual function string unpack_string (int num_chars=-1);

virtual function time unpack_time ();

virtual function real unpack_real ();

virtual function void unpack_object (ovm_void value);

virtual function int get_packed_size();

endclass

ovm_packer

120

File

base/ovm_packer.svh

Virtual

No

Membersbit abstract = 1

This bit provides a filtering mechanism for fields.

The abstract and physical settings allow an object to distinguish between two differentclasses of fields. It is up to you, in the ovm_object::do_pack() andovm_object::do_unpack() routines, to test the setting of this field if you want to useit as a filter.

bit big_endian = 1

This bit determines the order that integral data is packed (using pack_field,pack_field_int, pack_time, or pack_real) and how the data is unpacked fromthe pack array (using unpack_field, unpack_field_int, unpack_time, orunpack_real). When the bit is set, data is associated msb to lsb; otherwise it is asso-ciated lsb to msb.

The following code illustrates how data can be associated msb to lsb and lsb to msb:

class mydata extends ovm_object;

logic[15:0] value = ‘h1234;

function void do_pack (ovm_packer packer);

packer.pack_field_int(value, 16);

endfunction

function void do_unpack (ovm_packer packer);

value = packer.unpack_field_int(16);

endfunction

endclass

mydata d = new;

bit bits[];

initial begin

d.pack(bits); // results in ‘b0001001000110100

ovm_default_packer.big_endian = 0;

d.pack(bits); // results in `b0010110001001000

end

121

bit physical = 1

This bit provides a filtering mechanism for fields.

The abstract and physical settings allow an object to distinguish between two differentclasses of fields. It is up to you, in the ovm_object::do_pack() andovm_object::do_unpack() routines, to test the setting of this field if you want to useit as a filter.

bit use_metadata = 0

This flag is used to encode metadata into a packed stream, or to use metadata whenunpacking a stream. Metadata affects dynamic objects in the following ways:

❑ Strings encode a null byte after the string is packed.

❑ Objects encode a four bit value to indicate the existence of object information (where0 indicates that a null object was packed).

❑ Queues and dynamic arrays encode the number of elements in the array when usingthe `ovm_field_array macros to automatic packing and unpacking of the array.

By default, metadata is not used. It is necessary for automated extraction (unpacking) ofdata which contain dynamic fields. However, the use of metadata makes many packinguse models difficult (when packing is used to serialize an object onto a bus, for exam-ple).

Methods

get_packed_sizevirtual function int get_packed_size ()

This method returns an int value that represents the number of bits that were packed.

is_nullvirtual function bit is_null ()

This method is used during unpack operations to peek at the next 4-bit chunk of the packdata and determine if it is 0.

If the next four bits are all 0, then the return value is a 1; otherwise it is 0.

This is useful when unpacking objects, to decide whether a new object needs to beallocated or not.

122

pack_fieldvirtual function void pack_field (ovm_bitstream_t value,

int size)

Packs an integral field (less than or equal to 4096 bits) into the pack array.

value is the value of the field to pack. size is the number of bits to pack.

pack_field_intvirtual function void pack_field_int (logic[63:0] value,

int size)

Packs an integral field (less than or equal to 64 bits) into the pack array.

value is the value of the field to pack. size is the number of bits to pack.

This specialized version of pack_field() provides a higher performance mechanismfor packing small vectors.

pack_stringvirtual function void pack_string (string value)

Packs a string field into the pack array.

value is the value of the field to pack.

A 32-bit header is inserted ahead of the string to indicate the size of the string that waspacked.

This is useful for mixed language communication where unpacking may occur outside ofSystemVerilog OVM.

pack_objectvirtual function void pack_object (ovm_object value)

Packs an object field into the pack array.

value is the value of the field to pack.

A 4-bit header is inserted ahead of the string to indicate the number of bits that waspacked. If a null object was packed, then this header will be 0.

This is useful for mixed language communication where unpacking may occur outside ofSystemVerilog OVM.

123

pack_realvirtual function void pack_real (real value)

Packs a real value as 64 bits into the pack array.

value is the value of the field to pack.

The real value is converted to a 6-bit scalar value using the function $real2bitsbefore it is packed into the array.

pack_timevirtual function void pack_time (time value)

Packs a time value as 64 bits into the pack array. value is the value of the field to pack.

unpack_fieldvirtual function ovm_bitstream_t unpack_field (int size)

Unpacks bits from the pack array and returns the bit-stream that was unpacked. size isthe number of bits to unpack; the maximum is 4096 bits.

unpack_field_intvirtual function logic[63:0] unpack_field_int (int size)

Unpacks bits from the pack array and returns the bit-stream that was unpacked.

size is the number of bits to unpack; the maximum is 64 bits.

This is a more efficient variant than unpack_field when unpacking into smallervectors.

unpack_stringvirtual function string unpack_string ()

Unpacks a string.

The first 32 bits are used to determine the number of characters that the packed stringcontains.

If the first 32 bits are 0, then an empty string is returned.

unpack_objectvirtual function void unpack_object (ovm_void value)

124

Unpacks an object and stores the result into value.

value must be an allocated object that has enough space for the data being unpacked.The first four bits of packed data are used to determine if a null object was packed intothe array.

The is_null() function can be used by you to peek at the next four bits in the packarray before calling unpack_object.

unpack_realvirtual function real unpack_real ()

Unpacks the next 64 bits of the pack array and places them into a real variable.

The 64 bits of packed data are converted to a real using the $bits2real systemfunction.

unpack_timevirtual function value unpack_time ()

Unpacks the next 64 bits of the pack array and places them into a time variable.

125

ovm_recorder

The ovm_recorder class provides a policy object for recording ovm_objects. The policiesdetermine how recording should be done.

A default recorder instance, default_recorder, is provided so theovm_object::record() may be called without specifying a recorder.

Summaryclass ovm_recorder;

integer tr_handle = 0;

radix_enum default_radix = OVM_HEX;

bit physical = 1;

bit abstract = 1;

bit identifier = 1;

recursion_policy_enum policy = OVM_DEFAULT_POLICY;

virtual function void record_field (string name,

ovm_bitstream_t value,

int size,

radix_enum radix=OVM_NORADIX);

virtual function void record_object (string name,

ovm_void value);

virtual function void record_string (string name,

string value);

virtual function void record_time (string name,

time value);

endclass

File

base/ovm_object.svh

Virtual

No

ovm_recorder

126

Membersbit abstract = 1

This bit provides a filtering mechanism for fields.

The abstract and physical settings allow an object to distinguish between two differentclasses of fields.

It is up to you, in the ovm_object::do_pack() and ovm_object::do_unpack()routines, to test the setting of this field if they want to use it as a filter.

radix_enum default_radix = OVM_HEX

This is the default radix setting if record_field() is called without a radix.

bit identifier = 1

This bit is used to specify whether or not an object’s reference should be recorded whenthe object is recorded.

bit physical = 1

This bit provides a filtering mechanism for fields.

The abstract and physical settings allow an object to distinguish between two differentclasses of fields.

It is up to you, in the ovm_object::do_pack() and ovm_object::do_unpack()routines, to test the setting of this field if you want to use it as a filter.

recursion_policy_enum policy = OVM_DEFAULT_POLICY

Sets the recursion policy for recording objects.

The default policy is deep (which means to recurse an object).

integer tr_handle = 0

This is an integral handle to a transaction object. Its use is vendor specific.

A handle of 0 indicates there is no active transaction object.

Methods

new

record_fieldvirtual function void record_field (string name,

ovm_bitstream_t value,

int size,

127

radix_enum radix=OVM_NORADIX)

Records an integral field (less than or equal to 4096 bits). name is the name of the field.

value is the value of the field to record.

size is the number of bits of the field which apply. radix is the radix to use forrecording.

record_stringvirtual function void record_string (string name,

string value)

Records a string. value is the value of the field to record.

record_objectvirtual function void record_object (string name,

ovm_void value)

Record an object field. name is the name of the field.

This method uses the recursion policy to determine whether or not to recurse into theobject when it records.

record_timevirtual function void record_time (string name,

time value)

Records a time value. name is the name of the field.

128

ovm_printer

The ovm_printer class provides a policy object for printing ovm_objects in variousformats.

A user defined printer format can be created, or one of the following four built in printers canbe used:

■ The generic ovm_printer provides a raw, essentially un-formatted, dump of the object.

■ The table printer prints the object in a tabular form.

■ The tree printer prints the object in a tree form.

■ The line printer prints the information on a single line, but uses the same objectseparators as the tree printer.

Printers have knobs that you use to control the various settings. These knobs are containedin separate knob classes.

The following set of default printers are instantiated at time 0:

■ ovm_default_printer (set to the default_table_printer)

■ ovm_default_tree_printer

■ ovm_default_line_printer

■ ovm_default_table_printer

ovm_printer

ovm_table_printer ovm_tree_printer

ovm_line_printer

129

Summaryclass ovm_printer;

ovm_printer_knobs knobs = new;

// Primary user level functions called from ovm_object::do_print()

virtual function void print_field (string name,

ovm_bitstream_t value,

int size,

radix_enum radix=OVM_NORADIX,

byte scope_separator=".",

string type_name="");

virtual function void print_object_header (string name,

ovm_object value,

byte scope_separator=".");

virtual function void print_object (string name,

ovm_object value,

byte scope_separator=".");

virtual function void print_string (string name,

string value,

byte scope_separator=".");

virtual function void print_time (string name,

time value,

byte scope_separator=".");

virtual function void print_generic (string name,

string type_name,

int size,

string value,

byte scope_separator=".");

virtual function void print_array_header (string name,

int size,

string arraytype="array",

byte scope_separator=".");

virtual function void print_array_range (int min,

int max);

virtual function void print_array_footer (int size=0);

// Primary derived class overrides for creating new printers.

virtual function void print_header ();

virtual function void print_footer ();

130

virtual protected function void print_id (string id,

byte scope_separator=".");

virtual protected function void print_type_name (string name,

bit is_object=0);

virtual protected function void print_size (int size=-1);

virtual protected function void print_newline (bit do_global_indent=1);

virtual protected function void print_value (ovm_bitstream_t value,

int size,

radix_enum radix=OVM_NORADIX);

virtual protected function void print_value_object (ovm_object value);

virtual protected function void print_value_string (string value);

virtual protected function void print_value_array (string value="",

int size=0);

endclass

Note: The derived printer classes (ovm_tree_printer, ovm_line_printer, andovm_table_printer) do not add any new user level APIs. However, they do add newknobs, but the visible API of printing is the same for all printers.

File

base/ovm_printer.svh

Virtual

No

Membersovm_printer_knobs knobs = new

The knob object provides access to the variety of knobs associated with a specificprinter instance.

Each derivative printer class overloads the knobs variable with the specific knob classthat applies to that printer. In this way, you always have direct access to the knobs by wayof the knobs variable.

131

Global Variables

ovm_default_line_printerovm_line_printer default_line_printer = new

The line printer is a singleton object that can be used with ovm_object::do_print()to get single-line style printing.

ovm_default_tree_printerovm_tree_printer default_tree_printer = new

The tree printer is a singleton object that can be used with ovm_object::do_print()to get multi-line tree style printing.

ovm_default_table_printerovm_table_printer default_table_printer = new

The table printer is a singleton object that can be used withovm_object::do_print() to get tabular style printing.

ovm_default_printerovm_printer default_printer = default_table_printer

The default printer is a singleton object that is used by ovm_object::print() orovm_object::sprint() when no specific printer is set.

The default printer may be set to any legal ovm_printer derived type.

Methods

print_array_headervirtual function void print_array_header (string name,

int size,

string arraytype="array",

byte scope_separator=".")

Prints the header of an array. This function is called before each individual element isprinted. print_array_footer() is called to mark the completion of array printing.

132

print_array_footervirtual function void print_array_footer (int size=0)

Prints the header of a footer. This function marks the end of an array print. Generally,there is no output associated with the array footer, but this method lets the printer knowthat the array printing is complete.

print_array_rangevirtual function void print_array_range (int min,

int max)

Prints a range using ellipses for values. This method is used when honoring the arrayknobs for partial printing of large arrays.

This function should be called after the start elements have been printed and before theend elements have been printed.

print_fieldvirtual function void print_field (string name,

ovm_bitstream_t value,

int size,

radix_enum radix=OVM_NORADIX,

byte scope_separator=".",

string typename="")

Prints an integral field. name is the name of the field.

value is the value of the field. size is the number of bits of the field (maximum is 4096).

radix is the radix to use for printing—the printer knob for radix is used if no radix isspecified.

scope_separator is used to find the leaf name since many printers only print the leafname of a field.

Typical values for the separator are . (dot) or [ (open bracket).

print_genericvirtual function void print_generic (string name,

string type_name,

int size,

string value,

byte scope_separator=".")

133

Prints a generic value.

The value is specified as a string and the type name is supplied.

print_footervirtual protected function void print_footer ()

When creating a new printer type, this method is used to print footer information.

The method is called when the current depth is 0, after all fields have been printed.

print_headervirtual protected function void print_header ()

When creating a new printer type, this method is used to print header information.

The method is called when the current depth is 0, before any fields have been printed.

print_idvirtual protected function void print_id (string name,

byte separator=".")

When creating a new printer type, this method is used to print a field’s name.

The intent of the separator is to mark where the leaf name starts if the printer only printsthe leaf name of the identifier.

This function is called with a fully qualified name for the field.

print_newlinevirtual protected function void print_newline (bit do_global_indent=1)

When creating a new printer type, this method is used to indicate a new line. It is up tothe printer to determine how to display new lines.

The do_global_indent bit indicates whether or not the call to print_newline()should honor the indent knob.

print_objectvirtual function void print_object (string name,

ovm_object value,

byte scope_separator=".")

134

Prints an object. Whether the object is recursed depends on a variety of knobs, such asthe depth knob; if the current depth is at or below the depth setting then the object is notrecursed.

Note: By default, the children of ovm_components are printed. To turn this behavior off,you must set the ovm_component::print_enabled bit to 0 for the specific childrenyou do not want automatically printed.

print_object_headervirtual function void print_object_header (string name,

ovm_object value,

byte scope_separator=".")

Prints the header of an object.

This function is called when an object is printed by reference.

For this function, the object will not be recursed.

print_sizevirtual protected function void print_size (int size=-1)

When creating a new printer type, this method is used to print a field’s size.

A size value of -1 indicates that no size is available.

print_stringvirtual function void print_string (string name,

string value,

byte scope_separator=".")

Prints a string field.

print_timevirtual function void print_time (string name,

time value,

byte scope_separator=".")

Prints a time value. name is the name of the field and value is the value to print.

The print is subject to the $timeformat system task for formatting time values.

135

print_type_namevirtual protected function void print_type_name (string name,

bit is_object=0)

When creating a new printer type, this method is used to print a field’s type.

The is_object bit indicates that the item being printed is a ovm_object derived type.

print_valuevirtual protected function void print_value (ovm_bitstream_t value,

int size,

radix_enum radix=OVM_NORADIX)

When creating a new printer type, this method is used to print an integral field’s value.

The value vector is up to 4096 bits, so the size input indicates the number of bits toactually print.

The radix input is the radix that should be used for printing the value.

print_value_arrayvirtual protected function void print_value_array (string value,

int size)

When creating a new printer type, this method is used to print an array’s value.

This only prints the header value of the array, which means that it implements the printerspecific print_array_header().

value is the value to be printed for the array. value is generally the stringrepresentation of size, but it may be any string. size is the number of elements in thearray.

print_value_objectvirtual protected function void print_value_object (ovm_object value)

When creating a new printer type, this method is used to print a unique identifierassociated with an object.

print_value_stringvirtual protected function void print_value_string (string value)

When creating a new printer type, this method is used to print a string field’s value.

136

Optional Macros

`print_aa_int_object2`print_aa_int_object2 (field, printer)

This macro implements array printing for an associative array of ovm_object types withan int key.

field is the field to print and is also used as the name of the field.

printer is the printer to use.

`print_aa_int_key4`print_aa_int_key (key_type, field, radix, printer)

This macro implements array printing for an associative array of integral types with anarbitrary key type.

key_type is the type of the indexing variable for the array.

field is the field to print and is also used as the name of the field.

radix is the radix to use for each element. printer is the printer to use.

`print_aa_string_int3`print_aa_string_int3 (field, radix, printer)

This macro implements array printing for an associative array of integral types with astring key.

field is the field to print and is also used as the name of the field.

radix is the radix to use for the elements. printer is the printer to use.

`print_aa_string_object2`print_aa_string_object2 (field, printer)

This macro implements array printing for an associative array of ovm_object types witha string key.

field is the field to print and is also used as the name of the field.

printer is the printer to use.

137

`print_aa_string_string2`print_aa_string_string2 (field, printer)

This macro implements array printing for an associative array of string types with a stringkey.

field is the field to print and is also used as the name of the field.

printer is the printer to use.

`print_object_qda3`print_string_qda3 (field, printer, arraytype)

This macro implements array printing for an ovm_object array type.

field is the field to print and is also used as the name of the field.

printer is the printer to use.

arraytype is the type name to use when printing the array (no quotes are used).

`print_qda_int4`print_qda_int4 (field, radix, printer, arraytype)

This macro implements array printing for an integral array type.

field is the field to print and is also used as the name of the field.

radix is the radix to use for the elements. printer is the printer to use.

arraytype is the type name to use when printing the array (no quotes are used).

`print_string_qda3`print_string_qda3 (field, printer, arraytype)

This macro implements array printing for a string array type.

field is the field to print and is also used as the name of the field.

printer is the printer to use.

arraytype is the type name to use when printing the array (no quotes are used).

138

Policy Knobs

ovm_printer_knobs

The ovm_printer_knobs classes provide you with formatting control over the variousprinters. Each printer has a knob object that can be set to modify how the printer formatsinformation.

All of the knobs are variables. Most of the knobs exist in the ovm_printer_knobs baseclass. The derivative classes provide extra controls that apply only to those printer types.

Summaryclass ovm_printer_knobs;

int column = 0;

int max_width = 999;

string truncation = "+";

bit header = 1;

bit footer = 1;

int global_indent = 0;

bit full_name = 1;

bit identifier = 1;

int depth = -1;

bit reference = 1;

bit type_name = 1;

bit size = 1;

radix_enum default_radix = OVM_HEX;

ovm_printer_knobs

ovm_hier_printer_knobs

ovm_table_printer_knobs ovm_tree_printer_knobs

139

int begin_elements = 5;

int end_elements = 5;

bit show_radix = 1;

int mcd = OVM_STDOUT;

string bin_radix = "'b";

string oct_radix = "'o";

string dec_radix = "'d";

string unsigned_radix = "'d";

string hex_radix = "'h";

function string get_radix_str(radix_enum radix);

endclass

class ovm_hier_printer_knobs extends ovm_printer_knobs; string indent_str = "";

bit show_root = 0;

endclass

class ovm_table_printer_knobs extends ovm_hier_printer_knobs;

int name_width = 25;

int type_width = 20;

int size_width = 5;

int value_width = 20;

endclass

class ovm_tree_printer_knobs extends ovm_hier_printer_knobs;

string separator = “{}”;

endclass

File

base/ovm_printer.svh

Virtual

No

140

Members

ovm_printer_knobsint begin_elements = 5;

This defines the number of elements at the head of a list that should be printed.

string bin_radix = “'b"

This string should be prepended to the value of an integral type when a radix of OVM_BINis used for the radix of the integral object.

int column = 0

This is the column pointer, which is the current column that the printer is pointing to.

This is useful for derivative printers where column information is important, such as theovm_table_printer.

string dec_radix = “'d"

This string should be prepended to the value of an integral type when a radix of OVM_DECis used for the radix of the integral object.

Note: When a negative number is printed, the radix is not printed since only signeddecimal values can print as negative.

radix_enum default_radix = OVM_HEX

This knob sets the default radix to use for integral values when a radix of OVM_NORADIXis supplied to the print_field() method.

int depth = -1

This knob indicates how deep to recurse when printing objects.

A depth of -1 means to print everything.

int end_elements = 5;

This defines the number of elements at the end of a list that should be printed.

bit footer = 1

This bit indicates whether the print_footer() function should be called when anobject is printed.

If it is desired for a footer to be suppressed, then this bit should be set to 0.

bit full_name = 1

This bit indicates whether the printer should print the full name of an identifier or just theleaf name when print_id() is called.

The line, table, and, tree printers ignore this bit and always print only the leaf name.

141

int global_indent = 0

This is the number of columns of indentation to add whenever a newline is printed.

bit header = 1

This bit indicates whether the print_header() function should be called when anobject is printed.

If it is desired for a header to be suppressed, then this bit should be set to 0.

string hex_radix = “'b"

This string should be prepended to the value of an integral type when a radix of OVM_HEXis used for the radix of the integral object.

bit identifier = 1

This bit indicates whether the printer should print an identifier when print_id() iscalled.

This is useful in cases where you just want the values of an object, but no identifiers.

int max_width = 999

This is the maximum column width to use for a printer. If the current column reaches themaximum width, nothing is printed until a newline is printed.

integer mcd = OVM_STDOUT

This is a file descriptor, or multi-channel descriptor, that specifies where the print outputshould be directed.

By default, the output goes to the standard output of the simulator.

string oct_radix = “'o"

This string should be prepended to the value of an integral type when a radix of OVM_OCTis used for the radix of the integral object.

bit reference = 1

This bit indicates whether the printer should print a unique reference ID for anovm_object type.

The behavior of this knob is simulator dependent.

bit show_radix = 1;

Indicates whether the radix string ('h, and so on) should be pre-pended to an integralvalue when one is printed.

bit size = 1

This bit indicates whether the printer should print the size of the fields that it is printing.

142

In some cases, printing the size obscures important aspects of the data being printed,so this information can be turned off.

string truncation = “+"

Used to define the truncation character when a field is too large for the output.

For example, the table printer uses this character to truncate fields so that columns donot overflow.

bit type_name = 1

This bit indicates whether the printer should print the type name of the fields that it isprinting.

In some cases, printing of the type_name obscures the important aspects of the databeing printed, so this information can be turned off.

string unsigned_radix = “'d"

This is the string which should be prepended to the value of an integral type when a radixof OVM_UNSIGNED is used for the radix of the integral object.

ovm_hier_printer_knobsstring indent_str = “"

This knob specifies the string to use for indentations.

By default, two spaces are used to indent each depth level.

The string can be set to any string and the string will be replicated for the current depthwhen indentation is done.

bit show_root = 0

This setting indicates whether or not the initial object that is printed (when current depthis 0) prints the full path name. By default, the first object is treated like all other objectsand only the leaf name is printed.

ovm_table_printer_knobsint name_width = 25

This knob sets the width of the name column in the table. If this knob is set to 0, thenthe name column will not be printed.

int size_width = 5

This knob sets the width of the size column in the table. If this knob is set to 0, then thesize column will not be printed.

int type_width = 20

143

This knob sets the width of the type column in the table. If this knob is set to 0, then thetype column will not be printed.

int value_width = 20

This knob sets the width of the value column in the table. If this knob is set to 0, then thevalue column will not be printed.

ovm_tree_printer_knobsstring separator = “{}"

The separator string is a two character string. The first character is printed when anobject is traversed; it represents the start of the object value.

The second character is printed after the last field in the object has been printed; itrepresents the end of the object value.

Methods

get_radix_strfunction string get_radix_str (radix_enum radix)

Converts the radix from an enumerated to a printable radix according to the radixprinting knobs (bin_radix, and so on).

Printer Examples

The following examples show the output of a simple data object using the four styles ofprinter:

■ Generic

■ Line

■ Tree

■ Table

Example 1-1 on page 143 shows the output from a generic printer.

Example 1-1 Generic Printer, ovm_printerc1 (container)(@1013)

c1.d1 (mydata)(@1022)

144

c1.d1.v1 (integral) (32) 'hcb8f1c97

c1.d1.e1 (enum) (32) THREE

c1.d1.str (string) (2) hi

c1.value (integral) (12) 'h2d

Example 1-2 on page 144 shows the output from a line printer.

Example 1-2 Line Printer, ovm_line_printerc1: (container@1013) { d1: (mydata@1022) { v1: 'hcb8f1c97 e1: THREE str: hi }value: 'h2d }

Example 1-3 on page 144 shows the output from a tree printer.

Example 1-3 Tree Printer, ovm_tree_printerc1: (container@1013) {

d1: (mydata@1022) {

v1: 'hcb8f1c97

e1: THREE

str: hi

value: 'h2d

}

Example 1-4 on page 144 shows the output from a table printer.

Example 1-4 Table Printer, ovm_table_printer----------------------------------------------------------------------

Name Type Size Value

----------------------------------------------------------------------

c1 container - @1013

d1 mydata - @1022

v1 integral 32 'hcb8f1c97

e1 enum 32 THREE

str string 2 hi

value integral 12 'h2d

----------------------------------------------------------------------

145

TLM Interfaces

Figure 1-1 TLM Communication

The OVM TLM library defines several abstract, transaction-level interfaces. Each TLMinterface consists of one or more methods used to transport data. TLM specifies the requiredbehavior (semantic) of each method, but does not define their implementation. Classesinheriting a TLM interface must provide an implementation that meets the specified semantic.

ovm_*_export ovm_*_port

ovm_port_base ovm_connector_base

ovm_component

1

<<interface>>

ovm_*_imp

tlm_if_base

IF

1

IFIF

IFIF

146

tlm_if_base#(type T1=int, type T2=int) extends ovm_report_object

Summaryvirtual class tlm_if_base #(type T1=int, type T2=int) extends ovm_report_object;

virtual task put( input T t );

virtual task get( output T t );

virtual task peek( output T t );

virtual function bit try_put( input T t );

virtual function bit can_put();

virtual function bit try_get( output T t );

virtual function bit can_get();

virtual function bit try_peek( output T t );

virtual function bit can_peek();

virtual task transport( input REQ req , output RSP rsp );

virtual function bit nb_transport(input REQ req,output RSP rsp);

virtual function void write( input T t );

endclass

Virtual

Yes

Members

None

Methods

putvirtual task put (T t)

Sends a user-defined transaction of type T.

Components implementing the interface will block the calling thread if it cannotimmediately accept delivery of the transaction.

147

getvirtual task get (output T t)

Provides a new transaction of type T.

The calling thread is blocked if the requested transaction cannot be providedimmediately. The new transaction is returned in the provided output argument.

The implementation of get must regard the transaction as consumed. Subsequent callsto get must return a different transaction instance.

peekvirtual task peek (output T t)

Obtain a new transaction without consuming it.

If a transaction is available, then it is written to the provided output argument. If atransaction is not available, then the calling thread is blocked until one is available.

The returned transaction is not consumed. A subsequent peek or get will return thesame transaction.

try_putvirtual function bit try_put (T t)

Sends a transaction of type T, if possible.

If the component is ready to accept the transaction argument, then it does so and returns1, otherwise it returns 0.

can_putvirtual function bit can_put()

Returns 1 if the component is ready to accept the transaction; 0 otherwise.

try_getvirtual function bit try_get(output T t)

Provides a new transaction of type T. If a transaction is immediately available, then it iswritten to the provided output argument and 1 is returned. Otherwise, the outputargument is not modified and 0 is returned.

148

can_getvirtual function bit can_get()

Returns 1 if a new transaction can be provided immediately upon request, 0 otherwise.

try_peekvirtual function bit try_peek(output T t)

Provides a new transaction without consuming it.

If available, a transaction is written to the output argument and 1 is returned. Asubsequent peek or getwill return the same transaction. If a transaction is not available,then the argument is unmodified and 0 is returned.

can_peekvirtual function bit can_peek()

Returns 1 if a new transaction is available; 0 otherwise.

transportvirtual task transport (input REQ request, output RSP response)

Sends a transaction request for immediate execution.

A response is provided in the output argument upon return. The calling thread mayblock until the response is provided.

nb_transportvirtual function bit nb_transport (input REQ request, output REQ response);

Sends a transaction request for immediate execution.

Execution must occur without blocking—for example, no waits and no simulation timepasses. The response is provided in the output argument. If for any reason therequest could not be delivered immediately, then a 0 must be returned; otherwise 1.

writevirtual function write (T t)

Broadcasts a user-defined transaction of type T to any number of listeners. The callingthread must not be blocked.

149

Classes for Connectors

These methods are grouped into a basic set of connection interfaces that either require(ports) or provide (exports) a subset of those methods.

Connectors are the ports and exports used to form transaction-level connections betweencomponents or between components and channels. A set of combined interfaces made fromthe basic interfaces allow you to express different levels of abstraction.

The various forms of the put, get, and peek interfaces are used at one end of auni-directional channel. They may be paired to form either a master or slave end of abi-directional channel.

The transport interface is used for a bi-directional channel where requests and responses arelinked together in a non-pipelined fashion.

An analysis interface is used by a component such as a monitor to publish a transaction tozero, one, or more subscribers. Typically, it will be used inside a monitor to publish atransaction observed on a bus to scoreboards and coverage objects.

150

151

Uni-Directional interfacesclass ovm_uni-if_export #( type T = int )

extends ovm_port_base #( tlm_if_base #(T,T) );

class ovm_uni-if_port #( type T = int )

extends ovm_port_base #( tlm_if_base #(T,T) );

class ovm_uni-if_imp #( type T = int )

extends ovm_port_base #( tlm_if_base #(T,T) );

Table 1-3 uni-ifblocking_put

nonblocking_put

put

blocking_get

nonblocking_get

get

blocking_peek

nonblocking_peek

peek

blocking_get_peek

nonblocking_get_peek

get_peek

analysis

152

Bi-Directional Interfacesclass ovm_bi-if_export #( type REQ = int , type RSP = int )

extends ovm_port_base #( tlm_if_base #(REQ, RSP) );

class ovm_bi-if_port #( type REQ = int , type RSP = int )

extends ovm_port_base #( tlm_if_base #(REQ, RSP) );

class ovm_bi-if_imp #( type REQ = int , type RSP = int )

extends ovm_port_base #( tlm_if_base #(REQ, RSP) );

Table 1-4 bi-if

The name and parent are the standard ovm_component constructor arguments. Themin_size and max_size specify the minimum and maximum number of interfaces thatmust have been supplied to this port by the end of elaboration.

blocking_master

nonblocking_master

master

blocking_slave

nonblocking_slave

slave

blocking_transport

nonblocking_transport

transport

153

Ports and Exports

ovm_uni-if_export#(type T=int)

extends ovm_port_base #(tlm_if_base #(T,T))

An ovm_uni-if_export is a uni-directional connector that provides interfaces to othercomponents. It provides these interfaces by connecting to an ovm_uni-if_export orovm_uni-if_imp in a child component. There is one export class for each uni-directionalinterface.

ovm_uni-if_export inherits all the connectivity methods (e.g., the connect() method)from its base class ovm_port_base.

Summaryclass ovm_uni-if_export #(type T=int) extends ovm_port_base

#(tlm_if_base #(T,T));

function new(string name,

ovm_component parent,

int min_size=1,

int max_size=1);

end class

File

tlm/ovm_exports.svh

Parameterstype T = int

The type of transaction to be communicated across the export.

Members

None

154

Methods

newfunction new(string name,

ovm_component parent,

int min_size=1,

int max_size=1)

The name and parent are the standard ovm_component constructor arguments. Themin_size and max_size specify the minimum and maximum number of interfacesthat must have been supplied to this port by the end of elaboration.

155

ovm_bi-if_export#(type REQ=int, RSP=int) extends ovm_port_base #(tlm_if_base #(REQ,RSP))

An ovm_bi-if_export is a bi-directional connector that provides interfaces to othercomponents. It provides these interfaces by connecting to an ovm_bi-if_export orovm_bi-if_imp in a child component. There is one port class for each bi-directionalinterface.

ovm_bi-if_export inherits all connectivity methods (the connect() method) from itsbase class ovm_port_base.

Summaryclass ovm_bi-if_export#(type REQ=int, RSP=int) extends ovm_port_base

#(tlm_if_base #(REQ,RSP));

function new(string name,

ovm_component parent,

int min_size=1,

int max_size=1);

end class

File

tlm/ovm_exports.svh

Parameterstype REQ = int

The type of request transaction to be communicated across the export.

type RSP = int

The type of response transaction to be communicated across the export.

Members

None

156

Methods

newfunction new(string name,

ovm_component parent,

int min_size=1,

int max_size=1)

The name and parent are the standard ovm_component constructor arguments. Themin_size and max_size specify the minimum and maximum number of interfacesthat must have been supplied to this port by the end of elaboration.

157

ovm_uni-if_port(type T=int) extends ovm_port_base #(tlm_if_base #(T,T))

An ovm_uni-if_port is a uni-directional connector that requires interfaces from othercomponents. It gets these interfaces by connecting to an ovm_uni-if_port in a parentcomponent or an ovm_uni-if_imp in a sibling component. There is one export class foreach uni-directional interface.

ovm_uni-if_port inherits all connectivity methods (e.g., the connect() method) fromits base class ovm_port_base.

Summaryclass ovm_uni-if_port (type T=int) extends ovm_port_base

#(tlm_if_base #(T,T));

function new(string name,

ovm_component parent,

int min_size=1,

int max_size=1);

end class

File

tlm/ovm_ports.svh

Parameterstype T = int

The type of transaction to be communicated across the export.

Members

None

Methods

newfunction new(string name,

ovm_component parent,

158

int min_size=1,

int max_size=1)

The name and parent are the standard ovm_component constructor arguments. Themin_size and max_size specify the minimum and maximum number of interfacesthat must have been supplied to this port by the end of elaboration.

159

ovm_bi-if_port#(type T=int) extends ovm_port_base #(tlm_if_base #(T,T))

An ovm_bi-if_port is a bi-directional connector that requires interfaces from othercomponents. It gets these interfaces by connecting to an ovm_bi-if_port in a parentcomponent or an ovm_bi-if_imp in a sibling component. There is one export class foreach bi-directional interface.

ovm_bi-if_port inherits all connectivity methods (e.g., the connect()method) from itsbase class ovm_port_base.

Summaryclass ovm_bi-if_port #(type T=int) extends ovm_port_base

#(tlm_if_base #(T,T));

function new(string name,

ovm_component parent,

int min_size=1,

int max_size=1);

end class

File

tlm/ovm_ports.svh

Parameterstype REQ = int

The type of request transaction to be communicated across the export.

type RSP = int

The type of response transaction to be communicated across the export.

Members

None

160

Methods

newfunction new(string name,

ovm_component parent,

int min_size=1,

int max_size=1)

The name and parent are the standard ovm_component constructor arguments. Themin_size and max_size specify the minimum and maximum number of interfacesthat must have been supplied to this port by the end of elaboration.

161

ovm_uni-if_imp#(type T=int, type IMP=int)

extends ovm_port_base #(tlm_if_base #(T))

ovm_uni-if_imp provides the implementations of the methods in tlm_if_base toports and exports that require it. The actual implementation of the methods that comprisetlm_if_base are defined in an object of type IMP (tlm_fifo #(T)) which is passedin to the constructor.

Summaryclass ovm_uni-if_imp #(type T=int, type IMP=int) extends ovm_port_base

#(tlm_if_base #(T));

function new(string name, IMP imp);

end class

File

tlm/ovm_imps.svh

Parameterstype T = int

Type of transactions to be communicated across the underlying interface.

type IMP = int

Type of the parent of this implementation.

Memberslocal IMP m_imp

Handle to the component that implements the methods conveyed in the tlm_if_basedescription.

Methods

newfunction new(string name, IMP imp)

162

The name is the normal first argument to an ovm_component constructor. The imp isa slightly different form for the second argument to the ovm_component constructor,which is of type IMP and defines the type of the parent.

Since it is the purpose of an imp class to provide an implementation of a set of interfacetasks and functions, the particular set of tasks and functions available for eachovm_uni-if_imp class is dependent on the type of the interface it implements, whichis the particular TLM interface it extends.

163

ovm_bi-if_imp(type REQ=int, type RSP=int,

type IMP=int,

type REQ_IMP=IMP, type RSP_IMP=IMP)

extends ovm_port_base #(tlm_blocking_master_if #(REQ, RSP))

ovm_bi-if_imp provides the implementations of the methods in tlm_if_base to portsand exports that require it. The actual implementation of the methods that comprisetlm_if_base are defined in an object of type IMP (tlm_transport #(T1,T2))which is passed in to the constructor.

Summaryclass ovm_bi-if_imp (type REQ=int, type RSP=int,

type IMP=int,

type REQ_IMP=IMP, type RSP_IMP=IMP)

extends ovm_port_base #(tlm_blocking_master_if #(REQ, RSP));

function new(string name, IMP imp,REQ_IMP req_imp=imp, RSP_IMP rsp_imp=imp);

end class

File

tlm/ovm_imps.svh

Parameterstype REQ = int

Type of transactions to be sent by the master or received by the slave.

type RSP = int

Type of transactions to be received by the master or sent by the slave.

type IMP = int

Type of the parent of this implementation.

type REQ_IMP = IMP

Type of the object that implements the request side of the interface.

type RSP_IMP = IMP

Type of the object that implements the response side of the interface.

164

Methods

newfunction new(string name,

IMP imp,

REQ_IMP req_imp=imp,

RSP_IMP rsp_imp=imp)

The name is the normal first argument to an ovm_component constructor. The imp isa slightly different form for the second argument to the ovm_component constructor,which is of type IMP and defines the type of the parent. The req_imp and rsp_impare optional. If they are specified, then they must point to the underlying implementationof the request and response methods; tlm_req_rsp_channel, req_imp andrsp_imp are the request and response FIFOs.

165

ovm_port_base#(type IF=ovm_object) extends ovm_port_base_baseIF

ovm_port_base is the base class for all ports, exports, and implementations(ovm_*_port, ovm_*_export, and ovm_*_imp). The ovm_port_base extends IF,which is the type of the interface required and/or provided by the port, export, orimplementation.

In many senses, ovm_port_base is a facade class. It has a handle to anovm_connector_base and delegates much of the functionality to it.

Summaryclass ovm_port_base #(type IF=ovm_object) extends ovm_port_base_baseIF;

function new(string name,

ovm_component parent,

ovm_port_type_e port_type,

int min_size=1,

int max_size=1,

bit check_parent=1);

function void connect(this_type provider);

function IF lookup_indexed_if(int i=0);

function void remove();

function int size();

end class

File

base/ovm_port_base.svh

Virtual

Yes

Parameterstype IF = ovm_void

A placeholder for the type of interface supported by this connector.

typedef ovm_connector_base #(IF) connector_type

typedef ovm_port_base #(IF) this_type

166

ovm_connector_base #(IF) m_connector

The place where most of the hard work related to checking the validity of the connection,making the connection, and providing debugging information is done. Many of themethods below are delegated to m_connector.

Methods

newfunction new(string name, ovm_component parent,

ovm_port_type_e port_type,

int min_size=1,

int max_size=1,

bit check_parent=1)

The first two arguments are the normal ovm_component constructor arguments. Theport_type is port, export, or implementation. The min_size and max_sizespecify the minimum and maximum number of interfaces that must be supplied to thisport base by the end of elaboration. The parent is usually non null, in which case,check_parent should take its default value of 1. The rare exception to this (usually,analysis ports defined outside of an ovm_env) should set the value of parent to nulland check_parent to 0.

connectfunction void connect(this_type provider)

Connects a port or export that requires interfaces of type IF to a port, export, orimplementation that provides interfaces of type IF.

lookup_indexed_iffunction IF lookup_indexed_if(int i=0)

Gets the ith interface that has been provided to this port base, by delegating the call tom_connector.

removefunction void remove()

Delegates the method call to m_connector.

167

sizefunction int size()

Gets the number of interfaces that have been provided to this port base by delegatingthe call to m_connector.

168

Built-In TLM Channels

The OVM supplies a FIFO channel and a variety of interfaces to access it. The interfaces haveboth blocking and non-blocking forms. Because SystemVerilog does not support multipleinheritance, the FIFO has a collection of imps implementations of abstract interfaces that areused to access the FIFO. The FIFO is a named component and thus has a name and alocation in the component hierarchy.

Figure 1-2 UML Diagram for Channels

tlm_analysis_f tlm_transport_ch

tlm_fifo tlm_req_rsp_channe

ovm_component

1

<<interface>>

ovm_*_imp

tlm_if_base

T

2

REQ, RSPT, imp_type

REQ, RSP

wrapper

implementation

169

tlm_analysis_fifo #(type T=int) extends tlm_fifo #(T)

An analysis_fifo is a tlm_fifo with an unbounded size and a write() interface. Itcan be used any place an ovm_subscriber is used. Typical usage is as a buffer betweenan analysis_port in a monitor and an analysis component (a component derived fromovm_subscriber).

Summaryclass tlm_analysis_fifo #(type T=int) extends tlm_fifo #(T);

function new(string name, ovm_component parent=null);

function void write(input T t);

end class

File

tlm/tlm_fifos.svh

Virtual

No

Parameterstype T = int

Type of transactions to be stored in the FIFO.

Membersovm_analysis_imp #(T, analysis_fifo #(T)) analysis_export

analysis_export provides the write method to other components. Callingap.write(t) on a port bound to this export is the normal mechanism for writing to ananalysis FIFO.

Methods

newfunction new(string name, ovm_component parent=null)

170

This is the standard ovm_component constructor. The name is the local name of thiscomponent. The parent should be left unspecified when this component is instantiatedin statically elaborated constructs and must be specified when this component is a childof another OVM component.

writefunction void write(input T t)

Transfers transaction t into the unbounded FIFO, which is guaranteed to succeed.

171

tlm_fifo#(type T=int) extends ovm_component

tlm_fifo is a FIFO that implements all the uni-directional TLM interfaces.

Summaryclass tlm_fifo #(type T=int) extends ovm_component;

function new(string name, ovm_component parent=null, int size=1);

function bit can_get();

function bit can_peek();

function bit can_put();

function void flush();

task get(output T t);

task peek(output T t);

task put(input T t);

function int size();

function bit try_get(output T t);

function bit try_peek(output T t);

function bit try_put(input T t);

end class

File

tlm/tlm_fifos.svh

Virtual

No

Parameterstype T = int

Type of transactions to be stored in the FIFO.

Memberstypedef tlm_fifo #(T) this_type

ovm_blocking_get_imp #(T, this_type) blocking_get_export

172

ovm_blocking_get_peek_imp #(T, this_type) blocking_get_peek_export

ovm_blocking_peek_imp #(T, this_type) blocking_peek_export

ovm_blocking_put_imp #(T, this_type) blocking_put_export

ovm_get_imp #(T, this_type) get_export

ovm_get_peek_imp #(T, this_type) get_peek_export

ovm_nonblocking_get_imp #(T, this_type) nonblocking_get_export

ovm_nonblocking_get_peek_imp #(T, this_type) nonblocking_get_peek_export

ovm_nonblocking_peek_imp #(T, this_type) nonblocking_peek_export

ovm_nonblocking_put_imp #(T, this_type) nonblocking_put_export

ovm_peek_imp #(T, this_type) peek_export

ovm_put_imp #(T, this_type) put_export

The implementations above export the relevant TLM interface. Every uni-directionalTLM interface is implemented in tlm_fifo and exported using an appropriatelynamed export.

ovm_analysis_port #(T) put_ap

Analysis port to which the transaction is published whenever put() or try_put()succeeds.

ovm_analysis_port #(T) get_ap

Analysis port to which the transaction is published whenever get(), try_get(),peek(), or try_peek() succeeds.

local mailbox #(T) m

The internal mailbox used to implement the basic FIFO functionality.

local int m_size

m_size is the maximum size of the FIFO. A value of zero indicates no upper bound.

Methods

newfunction new(string name, ovm_component parent=null, int size=1)

The name and parent are the normal ovm_component constructor arguments. Theparent should be null if the tlm_fifo is going to be used in a statically elaboratedconstruct. If it is defined within an ovm_env, then parent must be specified. The sizeindicates the maximum size of the FIFO; a value of zero indicates no upper bound.

can_getfunction bit can_get()

173

can_get() returns 1 if try_get() will be successful, and it returns 0 otherwise.

can_peekfunction bit can_peek()

can_peek() returns 1 if try_peek() will be successful, and it returns 0 otherwise.

can_putfunction bit can_put()

can_put() returns 1 if try_put() will be successful, and it returns 0 otherwise.

flushfunction void flush()

flush() flushes the FIFO.

gettask get(output T t)

Does a blocking get and then publishes the gotten transaction using get_ap. Succeedswhen there is something in the FIFO available to be gotten. A get() is consuming.When it succeeds, t is no longer in the FIFO.

peektask peek(output T t)

Does a blocking peek() and then publishes the peeked transaction using get_ap.Succeeds when there is something in the FIFO available to be peeked. A peek() is notconsuming. When it succeeds, t is still in the FIFO.

puttask put(input T t)

Inserts transaction t to the internal mailbox and publishes the transaction to the put_apwhen it is successful. Succeeds when there is room in the FIFO.

sizefunction int size()

174

This returns m_size.

try_getfunction bit try_get(output T t)

Will get a transaction from the FIFO. If the FIFO contains a transaction, then it publishesthe transaction across get_ap and returns 1. Otherwise, it returns 0. A try_get() isconsuming. When it succeeds, t is no longer in the FIFO.

try_peekfunction bit try_peek(output T t)

Will get a transaction from the FIFO if it contains a transaction, then it publishes thetransaction across get_ap and returns 1. Otherwise, it returns 0. A peek() is notconsuming. When it succeeds, t is still in the FIFO.

try_putfunction bit try_put(input T t)

Will put t into the FIFO if there is room, then publish the transaction across put_ap andreturn 1. Otherwise, it returns 0.

175

tlm_req_rsp_channel#(type REQ=int, type RSP=int) extends ovm_component

tlm_req_rsp_channel contains a request FIFO of type REQ and a response FIFO of typeRSP. These FIFOs can be of any size. This channel is particularly useful for dealing withpipelined protocols where the request and response are not tightly coupled.

Summaryclass tlm_req_rsp_channel #(type REQ=int, type RSP=int) extends ovm_component;

function new(string name, ovm_component parent=null,

int request_fifo_size=1,

int response_fifo_size = 1);

end class

File

tlm/tlm_req_rsp.svh

Virtual

No

Parameterstype REQ = int

Type of transactions to be passed to/from the request FIFO.

type RSP = int

Type of transactions to be passed to/from the response FIFO.

Memberstypedef tlm_req_rsp_channel #(REQ, RSP) this_type

protected tlm_fifo #(REQ) m_request_fifo

The internal FIFO that stores the REQs.

protected tlm_fifo #(RSP) m_response_fifo

The internal FIFO that stores the RSPs.

ovm_blocking_put_export #(REQ) blocking_put_request_export

ovm_nonblocking_put_export #(REQ) nonblocking_put_request_export

176

ovm_put_export #(REQ) put_request_export

The exports make the put, blocking put, and non-blocking put interfaces of the requestFIFO externally visible. Through these interfaces, a master can put requests into therequest FIFO.

ovm_blocking_get_peek_export #(REQ) blocking_get_peek_request_export

ovm_blocking_get_export #(REQ) blocking_get_request_export

ovm_blocking_peek_export #(REQ) blocking_peek_request_export

ovm_get_peek_export #(REQ) get_peek_request_export

ovm_get_export #(REQ) get_request_export

ovm_nonblocking_get_peek_export #(REQ) nonblocking_get_peek_request_export

ovm_nonblocking_get_export #(REQ) nonblocking_get_request_export

ovm_nonblocking_peek_export #(REQ) nonblocking_peek_request_export

ovm_peek_export #(REQ) peek_request_export

These nine request get exports export the blocking, non-blocking, and combined get,peek, and get_peek interfaces of the request FIFO. These allow slaves to get or peekrequests from the request FIFO.

ovm_blocking_put_export #(RSP) blocking_put_response_export

ovm_nonblocking_put_export #(RSP) nonblocking_put_response_export

ovm_put_export #(RSP) put_response_export

These three response put exports export the put, blocking put, and non-blocking putinterfaces of the response FIFO. These allow a slave to put responses into the responseFIFO.

ovm_blocking_get_peek_export #(RSP) blocking_get_peek_response_export

ovm_blocking_get_export #(RSP) blocking_get_response_export

ovm_blocking_peek_export #(RSP) blocking_peek_response_export

ovm_get_peek_export #(RSP) get_peek_response_export

ovm_get_export #(RSP) get_response_export

ovm_nonblocking_get_peek_export #(RSP) nonblocking_get_peek_response_export

ovm_nonblocking_get_export #(RSP) nonblocking_get_response_export

ovm_nonblocking_peek_export #(RSP) nonblocking_peek_response_export

ovm_peek_export #(RSP) peek_response_export

These nine response get exports export the blocking, non-blocking, and combinedget, peek, and get_peek interfaces of the request FIFO. These allow masters to getor peek responses from the response FIFO.

ovm_analysis_port #(RSP) response_ap

response_ap publishes an RSP whenever a put() or try_put() to the responseFIFO succeeds.

ovm_analysis_port #(REQ) request_ap

177

Publishes a REQ whenever a put() or try_put() to the request FIFO succeeds.

ovm_master_imp #(REQ, RSP, this_type, tlm_fifo #(REQ), tlm_fifo #(RSP))master_export

Exports a single interface that allows a master to put requests and get or peekresponses.

ovm_slave_imp #(REQ, RSP, this_type tlm_fifo #(REQ), tlm_fifo #(RSP)) slave_export

Exports a single interface that allows a slave to get or peek requests and to putresponses.

ovm_blocking_master_imp #(REQ, RSP, this_type, tlm_fifo #(REQ), tlm_fifo #(RSP))blocking_master_export

Exports a single blocking interface that allows a master to put requests and get orpeek responses.

ovm_blocking_slave_imp #(REQ, RSP, this_type, tlm_fifo #(REQ), tlm_fifo #(RSP))blocking_slave_export

Exports a single blocking interface that allows a slave to get or peek requests and toput responses.

ovm_nonblocking_master_imp #(REQ, RSP, this_type, tlm_fifo #(REQ), tlm_fifo#(RSP)) nonblocking_master_export

Exports a single non-blocking interface that allows a master to put requests and getor peek responses.

ovm_nonblocking_slave_imp #(REQ, RSP, this_type, tlm_fifo #(REQ), tlm_fifo #(RSP))nonblocking_slave_export

Exports a single non-blocking interface that allows a slave to get or peek requests andto put responses.

Methods

newfunction new(string name, ovm_component parent=null,

int request_fifo_size=1,

int response_fifo_size = 1)

The name and parent are the standard ovm_component constructor arguments.The parent must be null if this component is defined within a static component suchas a module, program block, or interface, and it must take a non-value if it is definedinside an ovm_env. The last two arguments specify the request and response FIFOsizes, which have default values of 1.

178

tlm_transport_channel#(type REQ=int, type RSP=int) extends tlm_req_rsp_channel #(REQ, RSP)

A tlm_transport_channel is a tlm_req_rsp_channel that implements thetransport interface. It is useful when modeling a non-pipelined bus at the transactionlevel. Because the requests and responses have a tightly coupled one-to-one relationship,the request and response FIFO sizes must be one.

Summaryclass tlm_transport_channel #(type REQ=int, type RSP=int) extendstlm_req_rsp_channel #(REQ, RSP);

function new (string name, ovm_component parent=null);

task transport(input REQ request, output RSP response);

end class

File

tlm/tlm_req_rsp.svh

Parameterstype REQ = int

Type of transactions to be passed to/from the request FIFO.

type RSP = int

Type of transactions to be passed to/from the response FIFO.

Memberstypedef tlm_transport_channel #(REQ, RSP) this_type

ovm_transport_imp #(REQ, RSP, this_type) transport_export

The mechanism by which external components gain access to the transport() task.

Methods

newfunction new(string name, ovm_component parent=null)

The name and parent are the standard ovm_component constructor arguments.The parent must be null if this component is defined within a statically elaborated

179

construct such as a module, program block, or interface, and it must take a non-null valueif it is defined inside an ovm_env.

transporttask transport(input REQ request, output RSP response)

Calls put(request) followed by get(response).

180

Components

Components form the foundation of the OVM. Components encapsulate behavior oftransactors, scoreboards, and other objects in a testbench. The ovm_component is the baseclass from which all component classes are derived.

Figure 1-3 UML Diagram for Components

ovm_subscriber

ovm_connector_base ovm_env

ovm_component

1

ovm_threaded_componentIF

parent

children

ovm_component

1

0..1

0..*

ovm_random_stimul

181

ovm_random_stimulus#(type trans_type=ovm_transaction) extends ovm_component

This is a general purpose uni-directional random stimulus generator. It is a very usefulcomponent in its own right, but can also be used as a template to define other stimulusgenerators, or it can be extended to add additional stimulus generation methods to simplifytest writing.

The ovm_random_stimulus class generates streams of trans_type transactions. Thesestreams may be generated by the randomize() method of trans_type, or therandomize() method of one of its subclasses, depending on the type of the argumentpassed into the generate_stimulus() method. The stream may go indefinitely, untilterminated by a call to stop_stimulus_generation(), or you may specify the maximumnumber of transactions to be generated.

By using inheritance, we can add directed initialization or tidy up sequences to the randomstimulus generation.

Summaryclass ovm_random_stimulus #(type trans_type=ovm_transaction) extendsovm_component;

function new(string name, ovm_component parent);

virtual task generate_stimulus(trans_type t=null, int max_count=0);

virtual function void stop_stimulus_generation();

end class

File

base/ovm_random_stimulus.svh

Parameterstype trans_type=ovm_transaction

Specifies the type of transaction to be generated.

Membersovm_blocking_put_port #(trans_type) blocking_put_port

The port through which transactions come out of the stimulus generator.

local bit m_stop=0

182

Indicates whether the stimulus generator should stop before issuing the next transaction.

Methods

newfunction new(string name, ovm_component parent)

This is the standard OVM constructor.

The constructor displays the string obtained from get_randstate() duringconstruction. The set_randstate() can then be used to regenerate precisely thesame sequence of transactions for debugging purposes.

generate_stimulusvirtual task generate_stimulus(trans_type t=null, int max_count=0)

The main user-visible method. If t is not specified, then it will generate randomtransactions of type trans_type. If t is specified, then it will use the randomize()method in t to generate transactions—so t must be a subclass of trans_type. Themax_count is the maximum number of transactions to be generated. A value of zeroindicates no maximum—in this case, generate_stimulus() will go on indefinitelyunless stopped by some other process. The transactions are cloned before they are sentout over the blocking_put_port.

stop_stimulus_generationvirtual function void stop_stimulus_generation()

Stops the generation of stimulus.

183

ovm_test

The ovm_test virtual class should be used as the base class for the user-defined tests.Doing so provides the ability to select which test to execute by using the OVM_TESTNAMEcommand line argument when used in conjunction with the run_test() task. For example:

> ‘simulator command and switches’ +OVM_TESTNAME=test_bus_retry

The run_test() task should be specified inside an initial block such as:

initial begin

run_test();

end

This allows multiple tests to be compiled in and then selected for execution from thecommand line with random seeding—preventing the need for a re-compilation.

If run_test() is used and +OVM_TESTNAME=test_name is specified, the specifiedtest_name is created by factory and executed. If the specified test_name cannot becreated by the factory, a fatal error occurs. If run_test() is used and OVM_TESTNAME is notspecified, all constructed components will be cycled through their simulation phases.

Deriving from ovm_test will allow you to distinguish tests from other component types usingits inheritance. Also, tests will automatically inherit any new test-specific features that areadded to ovm_test.

Summaryvirtual class ovm_test extends ovm_threaded_component;

// Constructor

function new (input string name,

ovm_component parent);

endclass

ovm_threaded_component

ovm_test

184

File

methodology/ovm_test.svh

Virtual

Yes

Members

None

Methods

newnew (input string name,

ovm_component parent)

The constructor of the ovm_test specifies two arguments: the name and parentcomponent.

The name, which has no default, is the instance name of the ovm_test.

The parent is the enclosing hierarchical component.

185

ovm_agent

The ovm_agent virtual class should be used as the base class for the user-defined agents.

Deriving from ovm_agent will allow you to distinguish agents from other component typesalso using its inheritance. Also, agents will automatically inherit any new agent-specificfeatures that are added to ovm_agent.

While an agent’s build() function, which is inherited from ovm_component, can beimplemented to define any agent topology, an agent typically contains three sub-components:the driver, the sequencer and the monitor.

If the agent is active (typically signified by the added is_active control field), the agentcontains all three sub-components. If the agent is passive, it contains only the monitor.

Summaryvirtual class ovm_agent extends ovm_threaded_component;

// Constructor

function new (input string name,

ovm_component parent);

endclass

File

methodology/ovm_agent.svh

Virtual

Yes

ovm_threaded_component

ovm_agent

186

Members

None

Methods

newnew (input string name, ovm_component parent)

The constructor of the ovm_agent specifies two arguments: the name and parentcomponent.

The name, which has no default, is the instance name of the ovm_agent.

The parent is the enclosing hierarchical component.

187

ovm_driver

The ovm_driver class provides a base class that contains the interface component(ovm_seq_item_prod_if) necessary in order to communicate with a sequence itemproducer (a sequencer).

Summaryclass ovm_driver extends ovm_driver;

// Constructor

function new (input string name,

ovm_component parent);

// Sequence Item Producer Interface

ovm_seq_item_prod_if seq_item_prod_if;

endclass

File

methodology/ovm_driver.svh

Virtual

No

Membersovm_seq_item_prod_if seq_item_prod_if

The ovm_driver contains an instance of the ovm_seq_item_prod_if class suchthat you do not need to add this component in the user-defined driver.

ovm_threaded_component

ovm_driver

188

Methods

newnew (input string name,

ovm_component parent)

The constructor of the ovm_driver specifies two arguments: the name and parentcomponent.

The name, which has no default, is the instance name of the ovm_driver.

The parent is the enclosing hierarchical component.

189

ovm_sequencer_base

The ovm_sequencer_base virtual class provides the interfaces that are common betweenthe ovm_sequencer and the ovm_virtual_sequencer. You should derive fromovm_sequencer or ovm_virtual_sequencer appropriately.

Summaryvirtual class ovm_sequencer_base extends ovm_threaded_component;

// Constructor

function new (input string name,

ovm_component parent = null);

// Sequence execution interface

task start_sequence(ovm_sequence this_seq,

ovm_sequencer_base this_seqr = null);

// Random Sequence Selection Interface

protected rand int unsigned seq_kind;

function int unsigned get_seq_kind(string type_name);

function ovm_sequence get_sequence(int unsigned req_kind);

// Sequence producer interface

ovm_seq_prod_if seq_prod_if;

// Sequence queue

string sequences[$];

// default sequence variable

protected string default_sequence = “ovm_random_sequence”;

// User control properties

int count = -1;

int unsigned max_random_count = 10;

endclass

ovm_threaded_component

ovm_sequencer_base

190

File

sequences/ovm_sequencer_base.svh

Virtual

Yes

Membersprotected rand int seq_kind

Utility property that can be used to return the constrained value of randomly selectedsequences. This is typically used with the get_seq_kind() function.

ovm_seq_prod_if seq_prod_if

The ovm_sequencer_base contains an instance of the ovm_seq_prod_if classsuch that you do not need to add this component in the user-defined sequencer (orvirtual_sequencer).

This instance allows the ovm_sequencer_base derivative to be connected to aovm_seq_cons_if class.

string sequences[$]

This queue stores the type names of the sequences that are available for execution bythis sequencer.

protected string default_sequence = “ovm_random_sequence”

This string variable which sequence is started automatically by the sequencer at timezero, given that count does not equal 0.

int count = -1

This integer property is used by the ovm_random_sequence to determine how manyrandom sequences to execute.

If the value of count is set to -1 (the default value), then a random number between 1and the max_random_count variable is used by the ovm_random_sequence.

If the value of count is 0, the default_sequence will not be started by the sequencerregardless of the default_sequence variable setting.

If the value of count is greater than 0, then count random sequences will be executedregardless of the setting to max_random_count as long as the default_sequenceis set to ovm_random_sequence.

int unsigned max_random_count = 10

191

This integer property provides the upper bound for when the count property israndomized.

Methods

newnew (input string name="",

ovm_component parent = null)

The constructor of the ovm_sequencer_base specifies two arguments: the name andparent component.

The name, which defaults to an empty string, is the instance name of theovm_sequencer_base.

The parent is the enclosing hierarchical component.

start_sequencetask start_sequence(ovm_sequence this_seq, ovm_sequencer_base this_seqr =null)

This task is used to start a root sequence on the given sequencer. start_sequence()triggers the this_seq start event, executes the pre_body(), body() andpost_body() tasks, and then triggers the this_seq end event.

If this_seqr is not supplied, the library code assumes that the SystemVerilog keywordthis can be used.

this_seq must be allocated and randomized before calling this task.

get_seq_kindfunction int unsigned get_seq_kind(string type_name)

This function is used to find the integer mapping of a sequence type name in order tocreate constraints such that sequences can be picked randomly from a sequence librarybased on type_name. A fatal error occurs if the type_name is not found.

get_sequencefunction ovm_sequence get_sequence(int unsigned req_kind)

This function creates a sequence of the type located at the respective integer of thesequence kind map.

192

Use get_seq_kind() to find the integer location.

Optional Macros

`ovm_declare_sequence_lib

This macro provides the infrastructure necessary in order to use the`ovm_register_sequence and `ovm_sequence_utils* macros to build thesequencer’s sequence library. Using these macros allows you to utilize the RandomSequence Selection Interfaces.

This macro should be used in conjunction with the `ovm_update* macros.

`ovm_sequencer_utils(SEQUENCER)

This macro is simply the combination of:

`ovm_declare_sequence_lib

`ovm_component_utils(SEQUENCER)

Such that you can supply one line of code and get both of the functions.

`ovm_sequencer_utils_begin(SEQUENCER)`ovm_sequencer_utils_end

This macro is simply the combination of:

`ovm_declare_sequence_lib

`ovm_component_utils_begin(SEQUENCER)

`ovm_component_utils_end

Such that you can add any desired `ovm_field_* macros, for example:

`ovm_sequencer_utils_begin(simple_sequencer)

`ovm_field_int(status, OVM_ALL_ON)

`ovm_sequencer_utils_end

193

ovm_sequencer

The ovm_sequencer class provides the interfaces that are specific to a sequencer thatprocesses items.

Summaryclass ovm_sequencer extends ovm_sequencer_base;

// Constructor

function new (input string name,

ovm_component parent);

// Sequence Item Consumer Interface

ovm_seq_item_cons_if seq_item_cons_if;

// Last Item Queue Interfaces

function ovm_sequence_item last(int unsigned n);

function void set_num_last_items (int unsigned max);

// Grab Interfaces

task grab(ovm_sequence_seq seq);

function void ungrab(ovm_sequence_seq seq);

function ovm_sequence current_grabber();

function bit is_grabbed();

// Direct Execution Interface

task execute_item(input ovm_sequence_item item);

ovm_threaded_component

ovm_sequencer_base

ovm_sequencer

194

// Item Readiness Interface

function bit has_do_available();

// Delta Delay Interface

virtual task wait_for_sequences();

// User Configuration Settings

protected bit pull_mode = 1;

endclass

File

sequences/ovm_sequencer.svh

Virtual

No

Membersovm_seq_item_cons_if seq_item_cons_if

The ovm_sequencer contains an instance of the ovm_seq_item_cons_if classsuch that you do not need to add this component in the user-defined sequencer.

This instance allows the ovm_sequencer to be connected to anovm_seq_item_prod_if class (inside a driver).

protected bit pull_mode = 1

This configuration property defines the driver/sequencer interaction mode. Currently,only pull_mode = 1 is supported (get/try_next_item()).

Methods

newnew (input string name="",

ovm_component parent = null)

The constructor of the ovm_sequencer_base specifies two arguments: the name andparent components.

195

The name, which defaults to an empty string, is the instance name of theovm_sequencer_base.

The parent is the enclosing hierarchical component.

lastfunction ovm_sequence_item last(int unsigned n)

This function returns the item, as an ovm_sequence_item type at the nth location ofthe last item queue.

If n is greater than the depth of the last item queue, a null object is returned.

The most recent item is located at n = 0.

set_num_last_itemsfunction void set_num_last_items(int unsigned max)

This function is used to set the depth of the last item queue.

grabtask grab(ovm_sequence_seq seq)

This task requests exclusive access to the sequencer’s action queue.

When this task returns, seq has been granted exclusive access. In this case, items doneby seq and its sub-sequences will have priority for processing in the action queue overitems done by other sequences.

Other sequences attempting to grab will be blocked until exclusive access can begranted.

Sub-sequences of the current grabbing sequence can further be granted exclusiveaccess by performing another grab.

ungrabfunction void ungrab(ovm_sequence_seq seq)

This task removes exclusive access to the sequencer’s action queue that has beengranted to seq.

An error occurs if a sequence that does not hold the exclusive access performs anungrab().

196

current_grabberfunction ovm_sequence current_grabber()

This function returns a reference of type ovm_sequence to the current grabbingsequence. If there is no grabbing sequence, a null object is returned.

is_grabbedfunction bit is_grabbed()

This function returns a bit indicating whether or not the sequencer is grabbed. A 1indicates that a sequence is currently grabbing. A 0 indicates that no sequence iscurrently grabbing.

execute_itemtask execute_item(input ovm_sequence_item)

This task provides an interface to allow you to directly execute activity on a givensequencer.

This task blocks until the item provided, either a sequence item or a sequence, iscompleted. The item must be allocated and randomized before calling this task.

The parent sequence of the item defaults to a null behavior, and the sequencer isassumed to be the sequencer on which the task is executed.

has_do_availablefunction bit has_do_available()

This function indicates whether the sequencer has an item available for immediateprocessing. A return value of 1 indicates an item is available. A return value of 0 indicatesthat an item is not available.

wait_for_sequencesvirtual task wait_for_sequences()

This task can be called to introduce delta delay cycles (by default 100) in advanced usemodels.

The delta delay cycles allow processes that are attempting to place an item in the actionqueue of a sequencer to complete before the sequence item producer interface retrievesthat item by way of a try_next_item() call.

197

You can override this task if the existing implementation does not satisfy the currentneed.

Optional Macros`ovm_update_sequence_lib_and_item(USER_ITEM_TYPE)

This macro populates the sequences[$] queue and effectively builds the sequencer’ssequence library.

The argument to this macro is your item type such that a factory override can beregistered for the ovm_simple_sequence.

This macro, which should be used only in sequencers, should be placed in theconstructor of your sequencer, as follows:

function sequencer::new(…

super.new(name, parent);

`ovm_update_sequence_lib_and_item(simple_item)

Endfunction

This macro adds the ovm_random_sequence, ovm_exhaustive_sequence andovm_simple_sequence to the sequences[$] queue.

198

ovm_monitor

The ovm_monitor virtual class should be used as the base class for the user-definedmonitors.

Deriving from ovm_monitor allows you to distinguish monitors from other component typesalso using its inheritance. Also, monitors will automatically inherit any new monitor-specificfeatures that are added to ovm_monitor.

Summaryvirtual class ovm_monitor extends ovm_threaded_component;

// Constructor

function new (input string name,

ovm_component parent);

File

methodology/ovm_monitor.svh

Virtual

Yes

Members

None

ovm_threaded_component

ovm_monitor

199

Methods

newnew (input string name,

ovm_component parent)

The constructor of the ovm_monitor specifies two arguments: the name and parentcomponents.

The name, which has no default, is the instance name of the ovm_monitor.

The parent is the enclosing hierarchical component.

200

ovm_scoreboard

The ovm_scoreboard virtual class should be used as the base class for the user-definedscoreboards.

Deriving from ovm_scoreboard will allow you to distinguish scoreboards from othercomponent types using its inheritance. Also, scoreboards will automatically inherit any newscoreboard-specific features that are added to ovm_scoreboard.

Summaryvirtual class ovm_scoreboard extends ovm_threaded_component;

// Constructor

function new (input string name,

ovm_component parent);

endclass

File

methodology/ovm_scoreboard.svh

Virtual

Yes

Members

None

ovm_threaded_component

ovm_scoreboard

201

Methods

newnew (input string name,

ovm_component parent)

The constructor of the ovm_scoreboard specifies two arguments: the name andparent components.

The name, which has no default, is the instance name of the ovm_scoreboard.

The parent is the enclosing hierarchical component.

202

ovm_virtual_sequencer

The ovm_virtual_sequencer virtual class provides the interfaces that are specific to thevirtual sequencer.

Summaryvirtual class ovm_virtual_sequencer extends ovm_sequencer_base;

// Constructor

function new (input string name="",

ovm_component parent = null);

// Sequence Consumer Interface Array

ovm_seq_cons_if seq_cons_if[string];

// Sequence Consumer Interface Creation

virtual function void add_seq_cons_if(string if_name);

endclass

File

sequences/ovm_virtual_sequencer.svh

Virtual

Yes

ovm_threaded_component

ovm_sequencer_base

ovm_virtual_sequencer

203

Membersovm_seq_cons_if seq_cons_if[string]

Associative array of ovm_seq_cons_if objects with a string key that holds thesequence consumer interfaces.

These sequence consumer interfaces should be connected to the sequencers andvirtual sequencers that are to be controlled from the virtual sequences.

Methods

newnew (input string name,

ovm_component parent)

The constructor of the ovm_virtual_sequencer specifies two arguments: the nameand parent components.

The name, which defaults to an empty string, is the instance name of theovm_virtual_sequencer.

The parent is the enclosing hierarchical component.

add_seq_cons_ifvirtual function void add_seq_cons_if(string if_name)

This function should be used to make entries into the seq_cons_if associative arrayinstead of doing a new for an entry. This allows the add_seq_cons_if function toensure proper printing of the sequence consumer interfaces.

Optional Macros

`ovm_update_sequence_lib

This macro populates the sequences[$] queue of a virtual sequencer and effectivelybuilds the virtual sequencer’s sequence library.

This macro, which should be used only in virtual sequencers, should be placed in theconstructor of your virtual sequencer as follows:

function virtual_sequencer::new(…

super.new(name, parent);

`ovm_update_sequence_lib

204

Endfunction

This macro adds the ovm_random_sequence and ovm_exhaustive_sequence tothe sequences[$] queue.

Note: The ovm_simple_sequence is not added since that sequence acts on items.

205

ovm_subscriber#(type T=int) extends ovm_component

A subclass of ovm_subscriber can be used to connect to an ovm_analysis_port thatwrites transactions of type T.

ovm_subscriber has a single pure virtual method, write(), which is made available tothe outside by way of an analysis_export. This is particularly useful when writing acoverage object that needs to be attached to a monitor.

Summaryvirtual class ovm_subscriber #(type T=int) extends ovm_component;

function new(string name, ovm_component p);

pure virtual function void write(T t);

end class

File

utils/ovm_subscriber.svh

Parameterstype T = int

Specifies the type of transaction to be received.

Memberstypedef ovm_subscriber #(T) this_type

ovm_analysis_imp #(T, this_type) analysis_export

The export through which the write method is made available.

Methods

newfunction new(string name, ovm_component p)

This is the standard ovm_component constructor.

206

writepure virtual function void write(T t)

A pure virtual method that needs to be defined in a subclass.

207

ovm_req_rsp_driver#(REQ, RSP)

The ovm_req_rsp_driver class provides parameterization such that theget_next_item returns the user-specific type.

This class also provides a put() interface, which requires that you provide the appropriatelytyped response.

Summaryclass ovm_req_rsp_driver #(type REQ = ovm_sequence_item, type RSP =ovm_sequence_item) extends ovm_driver;

// Constructor

function new (input string name,

ovm_component parent);

// get_next_item

task get_next_item(output REQ this_req);

// put

task put(input RSP this_rsp)

endclass

File

methodology/ovm_req_rsp_driver.svh

ovm_threaded_component

ovm_driver

ovm_req_rsp_driver#(REQ, RSP)

208

Virtual

No

Members

None

Methods

newnew (input string name,

ovm_component parent)

The constructor of the ovm_driver specifies two arguments: the name and parentcomponent.

The name, which has no default, is the instance name of the ovm_driver.

The parent is the enclosing hierarchical component.

get_next_itemtask get_next_item(output REQ this_req)

This task allows you to make a local task call in order to retrieve the next item from thesequencer. The seq_item_prod_ifmust still be connected, but this task can be calledwithout accessing the seq_item_prod_if.

The output argument type is of the REQ parameterization type.

puttask put(input RSP this_rsp)

This task allows you to make a local task call in order to return the response item to thesequencer. The seq_item_prod_ifmust still be connected, but this task can be calledwithout accessing the seq_item_prod_if.

The input argument type is of the RSP parameterization type.

209

Comparators

A common function of testbenches is to compare streams of transactions for equivalence. Forexample, a testbench may compare a stream of transactions from a DUT with expectedresults. The OVM library provides a base class called ovm_in_order_comparator andtwo derived classes, which are ovm_in_order_built_in_comparator for comparingstreams of built-in types and ovm_in_order_class_comparator for comparing streamsof class objects. The ovm_algorithmic_comparator also compares two streams oftransactions; however, the transaction streams might be of different type objects. This devicewill use a user-written transformation function to convert one type to another beforeperforming a comparison.

Figure 1-4 UML Diagram for Comparator Classes

ovm_component

ovm_threaded_componentovm_algorithmic_comparato

ovm_in_order_class_compara ComparatorsT T

ovm_in_order_comparator

BEFORE, AFTER, TRANSFORM

T, comp, convert, pair_type

210

ovm_in_order_built_in_comparator#(type T=int) extends ovm_in_order_comparator #(T)

A subclass of ovm_in_order_comparator that is used to compare two streams of built-intypes.

Summaryclass ovm_in_order_built_in_comparator #(type T=int) extendsovm_in_order_comparator #(T);

function new(string name,ovm_component parent);

end class

File

methodology/ovm_in_order_comparator.svh

Parameterstype T = int

Specifies the type of transactions to be compared.

Members

None

Methods

newfunction new(string name,ovm_component parent)

This is the normal ovm_component constructor.

211

ovm_in_order_class_comparator#(type T=int) extends ovm_in_order_comparator #(T)

A subclass of ovm_in_order_comparator that is used to compare two streams of built-intypes.

Summaryclass ovm_in_order_built_in_comparator #(type T=int) extendsovm_in_order_comparator #(T);

function new(string name,ovm_component parent);

end class

File

methodology/ovm_in_order_comparator.svh

Parameterstype T = int

Specifies the type of transactions to be compared.

Members

None

Methods

newfunction new(string name,ovm_component parent)

This is the normal ovm_component constructor.

212

ovm_algorithmic_comparator#(type BEFORE=int, type AFTER=int, type TRANSFORMER=int_transform)

extends ovm_component

The algorithmic comparator is a wrapper around ovm_in_order_class_comparator.Like the in-order comparator, the algorithmic comparator compares two streams oftransactions, the “before” stream and the “after” stream. It is often the case when two streamsof transactions need to be compared that the two streams are in different forms. That is, thetype of the before transaction stream is different than the type of the after transaction stream.

The ovm_algorithmic_comparator provides a transformer that transforms beforetransactions into after transactions. The transformer is supplied to the algorithmic comparatoras a policy class via the class parameter TRANSFORMER. The transformer policy mustprovide a transform() method with the following prototype:

AFTER transform (BEFORE b);

Summaryclass ovm_algorithmic_comparator #(type BEFORE=int,

type AFTER=int,

type TRANSFORMER=int_transform)

extends ovm_component;

function new(TRANSFORMER transformer, string name, ovm_component parent);

function void export_connections();

function void write(BEFORE b);

end class

File

methodology/ovm_algorithmic_comparator.svh

Virtual

no

Parameterstype AFTER = int

The type of the transaction against which the transformed BEFORE transactions will becompared.

type BEFORE = int

213

The type of incoming transaction to be transformed prior to comparing against the AFTERtransactions.

type TRANSFORMER = int_transform

The type of the class that contains the transform() method.

Memberstypedef ovm_algorithmic_comparator #(BEFORE, AFTER, TRANSFORMER) this_type

ovm_analysis_export #(AFTER) after_export

Provides a write(AFTER t) method so that publishers (monitors) can send in anordered stream of transactions against which the transformed BEFORE transactions willbe compared.

ovm_analysis_imp #(BEFORE, this_type) before_export

Provides a write(BEFORE t) method so that publishers (monitors) can send in anordered stream of transactions to be transformed and compared to the AFTERtransactions.

internal memberslocal ovm_in_order_class_comparator #(AFTER) comp

comp is the comparator used to compare the transformed BEFORE stream with theAFTER stream.

local TRANSFORMER m_transformer

m_transformer encapsulates the algorithm that transforms BEFOREs into AFTERs.

Methods

newfunction new(TRANSFORMER transformer, string name, ovm_component parent)

The constructor takes a handle to an externally constructed transformer, a name,and a parent. The last two arguments are the normal arguments for anovm_component constructor.

We create an instance of the transformer (rather than making it a genuine policy classwith a static transform method) because we might need to do reset and configuration onthe transformer itself.

214

export_connectionsfunction void export_connections()

This is the standard OVM method for making exports and implementations ofsubcomponents visible externally.

writefunction void write(BEFORE b)

This method handles incoming BEFORE transactions. It is usually accessed via thebefore_export, and it transforms the BEFORE transaction into an AFTER transactionbefore passing it to the in_order_class_comparator.

215

ovm_in_order_comparator#(type T=int, type comp=ovm_built_in_comp #(T),

type convert=ovm_built_in_converter #(T),

type pair_type=ovm_built_in_pair #(T))

extends ovm_threaded_component

Compares two streams of transactions. These transactions may either be classes or built-intypes. To be successfully compared, the two streams of data must be in the same order. Apartfrom that, there are no assumptions made about the relative timing of the two streams of data.

Summaryclass ovm_in_order_comparator #(type T=int, type comp=ovm_built_in_comp #(T),

type convert=ovm_built_in_converter #(T),

type pair_type=ovm_built_in_pair #(T))

extends ovm_threaded_component;

function new(string name, ovm_component parent);

function void export_connections();

function void flush();

task run();

end class

File

methodology/ovm_in_order_comparator.svh

Parameterstype T = int

Specifies the type of transactions to be compared.

type comp = ovm_built_in_comp #(T)

The type of the comparator to be used to compare the two transaction streams.

type convert = ovm_built_in_converter #(T)

A policy class to allow convert2string() to be called on the transactions beingcompared. If T is an extension of ovm_transaction, then it usesT::convert2string(). If T is a built-in type, then the policy provides aconvert2string() method for the comparator to call.

type pair_type = ovm_built_in_pair #(T)

216

A policy class to allow pairs of transactions to be handled as a singleovm_transaction type.

Membersovm_analysis_export #(T) before_export

The export to which one stream of data is written.

ovm_analysis_export #(T) after_export

The export to which the other stream of data is written.

ovm_analysis_port #(pair_type) pair_ap

The comparator sends out pairs of transactions across this analysis port. Both matchedand unmatched pairs are published.

int m_matches

The number of successfully paired transactions.

int m_mismatches

The number of unsuccessfully paired transactions.

local analysis_fifo #(T) before_fifo

The local storage for the stream of data coming in through before_export.

local analysis_fifo #( T ) after_fifo

The local storage for the stream of data coming in through after_export.

Methods

newfunction new(string name, ovm_component parent)

The normal ovm_component constructor.

export_connectionsfunction void export_connections()

Connects the before_export and after_export to their respective FIFOs.

flushfunction void flush()

217

This method sets m_matches and m_mismatches back to zero. Thetlm_fifo::flush takes care of flushing the FIFOs.

runtask run()

Takes pairs of before and after transactions and compares them. Status informationis updated according to the results of the comparison and pairs are published using theanalysis port.

218

Sequences

ovm_sequence_item

The ovm_sequence_item class is the base class for user-defined sequence items and alsothe base class for the ovm_sequence.

The ovm_sequence_item class provides the basic functionality for objects, both sequenceitems and sequences, to operate in the sequence mechanism.

Summaryclass ovm_sequence_item extends ovm_transaction;

function new (input string name="ovm_sequence_item",

ovm_sequencer_base sequencer=null,

ovm_sequence parent_seq=null);

bit print_sequence_info = 0;

function void set_sequencer(ovm_sequencer_base sequencer);

function ovm_sequencer_base get_sequencer();

function void set_parent_seq(ovm_sequence parent);

function ovm_sequence get_parent_seq();

virtual function int is_item();

function int get_depth();

endclass

ovm_transaction

ovm_sequence_item

219

File

sequences/ovm_sequence_item.svh

Virtual

No

Membersbit print_sequence_info = 0

This bit controls whether the sequence mechanism specific information (parentsequence, root sequence, or sequencer) is printed when the sequence item’s print()method is called.

This bit is automatically set when sequence items are created by the sequencemechanism.

If you manually create a sequence item using new(), then if you want to see thisinformation, you should set this bit appropriately.

Methods

new function new (input string name="ovm_sequence_item",

ovm_sequencer_base sequencer=null,

ovm_sequence parent_seq=null)

The constructor of the ovm_sequence_item specifies three arguments: the name,sequencer, and parent sequence.

The name, which defaults to ovm_sequence_item, is the instance name of thesequence item.

The sequencer is the target sequencer for this item.

The parent_seq is the parent sequence of this item.

set_sequencerfunction void set_sequencer(ovm_sequencer_base sequencer)

This function can be used to set the sequencer for an ovm_sequence_item.

220

This function is useful when performing an allocation of a sequence item using theconstructor.

If the sequence action macros are used, this function is not necessary.

get_sequencerfunction ovm_sequencer_base get_sequencer()

This function returns the sequencer of the sequence item as an ovm_sequencer_basetype. Once created, an ovm_sequence_item can identify on which sequencer the itemwill be processed.

set_parent_seqfunction void set_parent_seq(ovm_sequence parent)

This function can be used to set the parent sequence for an ovm_sequence_item.

This function is useful when performing an allocation of a sequence item using theconstructor.

If the sequence action macros are used, this function is not necessary.

get_parent_seqfunction ovm_sequence get_parent_seq()

This function returns the parent sequence of the sequence item as an ovm_sequencetype.

An ovm_sequence_item can identify what parent sequence initiated the item.

is_itemfunction int is_item()

This function returns a 1 if the object is a sequence item.

If the object is a sequence, this function returns a 0.

Although virtual for polymorphism, this method is not meant to be overridden by you.

get_depthfunction int get_depth()

This function returns the depth from the sequencer.

221

A root sequence item has a depth of one.

A child sequence item of a root sequence has a depth of two.

A grandchild sequence item of a root sequence has a depth of three, and so on.

222

ovm_sequence

The ovm_sequence class provides the interfaces necessary in order to create streams ofsequence items and/or other sequences.

Summaryclass ovm_sequence extends ovm_sequence_item;

// Constructor

function new (input string name="ovm_sequence",

ovm_sequencer_base sequencer = null,

ovm_sequence parent_seq = null);

function int unsigned num_sequences;

// User Hook Interface

event started;

event ended;

constraint pick_sequence {

(num_sequences() <= 2) || (seq_kind >= 2);

(seq_kind < num_sequences()) || (seq_kind == 0);}

virtual task body();

virtual task post_body();

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

task apply(ovm_sequence_item req,

output ovm_sequence_rsp rsp);

ovm_transaction

ovm_sequence_item

ovm_sequence

223

virtual task pre_apply();

virtual task mid_apply();

virtual task post_apply();

task start(ovm_sequencer_base sequencer, ovm_sequence parent_seq = null);

function void stop();

virtual function bit is_relevant();

virtual task wait_for_relevant();

// Random Sequence Selection Interface

rand int unsigned seq_kind;

function int unsigned get_seq_kind(string type_name);

function ovm_sequence get_sequence(int unsigned req_kind);

task do_sequence_kind(int unsigned req_kind);

// Status Interface

function bit is_blocked();

function int get_id();

endclass

File

sequences/ovm_sequence.svh

Virtual

No

Membersconstraint pick_sequence

This constraint causes the seq_kindmember to be a legal value in the sequence libraryof the attached sequencer. The seq_kind member can then be used in a sequenceusing the do_seq_kind() method.

If the sequence is not attached to a sequencer, then seq_kind is constrained to 0.

event started

Event to indicate that the body() of the sequence is being started.

event ended

Event to indicate that the body() of the sequence has completed.

224

rand int unsigned seq_kind

Utility property that can be used to return the constrained value of randomly selectedsequences.

Methods

newfunction new (input string name="ovm_sequence",

ovm_sequencer_base sequencer=null,

ovm_sequence parent_seq=null)

The constructor of the ovm_sequence specifies three arguments: the name,sequencer, and parent sequence.

The name, which defaults to ovm_sequence, is the instance name of the sequence.

The sequencer is the target sequencer for this item.

The parent_seq is the parent sequence of this item.

num_sequencesfunction int unsigned num_sequences;

This function returns the number of sequences available in the attached sequencer'ssequence library. If no sequencer is attached to the sequence, the function returns 0.

pre_bodyvirtual task pre_body()

This task is a user hook method of the sequence.

The pre_body() callback is only executed when a sequence is started as a rootsequence on the sequencer using the p_sequencer.start_sequence(sequence)task.

The pre_body() occurs immediately before the body() is executed.

Note: You should not call this task directly.

bodyvirtual task body()

225

This task is the main method of the sequence.

The body() callback is executed regardless of how a sequence is executed.

Note: You should not call this task directly.

post_bodyvirtual task post_body()

This task is a user hook method of the sequence.

The post_body() callback is only executed when a sequence is started as a rootsequence on the sequencer using the p_sequencer.start_sequence(sequence)task. The post_body() occurs immediately after the body() is executed.

Note: You should not call this task directly.

pre_dovirtual task pre_do(bit is_item)

This task is a user hook method of the sequence.

The pre_do() is called at the start of a do action performed by the sequence.

The pre_do() is executed once the sequencer has selected a do action for execution.

is_item indicates whether an item or sequence is being done.

This method is called automatically with the appropriate is_item setting.

mid_dovirtual function void mid_do(ovm_sequence_item this_item)

This function is a user hook method of the sequence.

The mid_do() is called during a do action just after this_item is randomized andbefore one of the following:

a. It is delivered to the item consumer, in the case of an item.

b. The body() of the sequence is executed, in the case of sequence.

post_dovirtual function void post_do(ovm_sequence_item this_item)

226

This function is a user hook method of the sequence.

The post_do() is called just after one of the following:

a. The consumer indicates the item is done, in the case of an item.

b. The body() of the sequence is completed, in the case of sequence.

applytask apply(ovm_sequence_item req, output ovm_sequence_item rsp)

This task allows you to execute a sequence item without using the do actions.

The sequence item req must exist prior to calling this task.

This task blocks until the item is completed, and the response is provided to you as thesecond argument, rsp.

pre_applytask pre_apply()

This task is a user hook method of the sequence.

The pre_apply() is called during the apply() task.

The pre_apply() is executed once the sequencer has selected the item forapplication.

mid_applytask mid_task()

This function is a user hook method of the sequence. mid_apply() is called during theapply() task just after pre_apply().

post_applytask post_apply()

This function is a user hook method of the sequence.

The post_apply() is called during the apply() task just after the consumer indicatesthe item is done.

227

starttask start(ovm_sequencer_base sequencer, ovm_sequence parent_seq = null);

This task provides the capability to start a sequence on a sequencer manually. Youshould provide the sequencer on which the sequence will be started as the firstargument.

If the sequence is being started inside another sequence and requires that the startedsequence to a sub-sequence of the current sequence, then you should provide this asthe second argument. Otherwise, the sequence will be started as a root sequence on thesequencer.

stopfunction void stop()

This function disables the body() task of the sequence.

is_relevantvirtual function bit is_relevant()

This function is a user hook method of the sequence. It is used to define conditions forperforming do item actions, such that the do action will not be selected for executionunless is_relevant() returns 1'b1.

The default implementation of this method returns 1'b1.

is_relevant() only affects items—it is not checked when doing a sub-sequence.

You can redefine this function to set specific conditions for when sequence items arerelevant.

wait_for_relevantvirtual task wait_for_relevant()

This function is a user hook method of the sequence.

It is used to define conditions to trigger a re-evaluation of the sequencer’s action queuewhen a sequence doing an item is not relevant.

This task is executed by the sequencer and if this task finishes, the re-evaluation occurs.

The default implementation of this task is to never return. You should implement this taskas follows:

virtual task wait_for_relevant();

228

while(!is_relevant())

@(is_relevant_condition_variables)

endtask

get_seq_kindfunction int unsigned get_seq_kind(string type_name)

This function is used to find the integer location in the sequence kind map of thesequence type_name. This allows you to create constraints such that sequences canbe picked randomly from a sequence library based on type_name.

A fatal error occurs if type_name is not registered with the sequencer on which thissequence is operating.

get_sequencefunction ovm_sequence get_sequence(int unsigned req_kind)

This function creates a sequence of the type located at the respective integer location ofthe sequence kind map.

Use get_seq_kind() to find the integer location.

do_sequence_kindtask do_sequence_kind(int unsigned req_kind)

This task is used to invoke a specific sequence using an unsigned integer as an identifier.

The unsigned integer can be retrieved by invoking the get_seq_kind() function withthe type name string as the argument.

is_blockedfunction bit is_blocked()

Method to query if a sequence is blocked from sending items by another grabbingsequence that is not an ancestor.

A return value of 1 indicates the sequence is blocked.

229

Optional Macros

`ovm_register_sequence(TYPE_NAME, SEQUENCER)

This macro does the following operations:

1. Registers the TYPE_NAME sequence on the SEQUENCER type argument such that theRandom Sequence Selection Interfaces can be used.

An example of the usage follows:

class simple_seq extends ovm_sequence;

`ovm_register_sequence(simple_seq, simple_sequencer)

Endclass

In the example, the simple_seq is register in the sequence library of thesimple_sequencer type.

2. Declares and initializes a p_sequencer variable that is of the SEQUENCER argumenttype. You can then access the SEQUENCER argument type specific variables using thep_sequencer.

`ovm_sequence_utils(TYPE_NAME, SEQUENCER)

This macro is simply the combination of:

`ovm_register_sequence(TYPE_NAME, SEQUENCER)

`ovm_object_utils(TYPE_NAME)

such that you can supply one line of code and get both of the functions.

`ovm_sequence_utils_begin(TYPE_NAME, SEQUENCER)`ovm_sequence_utils_end

This macro is simply the combination of:

`ovm_register_sequence(TYPE_NAME, SEQUENCER)

`ovm_object_utils_begin(TYPE_NAME)

`ovm_object_utils_end

such that you can add any desired `ovm_field_* macros, for example:

`ovm_sequence_utils_begin(simple_seq, simple_sequencer)

`ovm_field_int(status, OVM_ALL_ON)

`ovm_sequence_utils_end

230

ovm_req_rsp_sequence#(REQ, RSP)

The ovm_req_rsp_sequence class provides parameterized interfaces that allow compiletime checking of argument value types and also remove the need to cast return variable.

Summaryclass ovm_req_rsp_sequence #(type REQ = ovm_sequence_item, type RSP =ovm_sequence_item) extends ovm_sequence;

// Constructor

function new (input string name="ovm_req_rsp_sequence",

ovm_sequencer_base sequencer = null,

ovm_sequence parent_seq = null);

// Apply

task apply(input REQ this_req, output RSP this_rsp);

endclass

File

sequences/ovm_req_rsp_sequence.svh

Virtual

No

ovm_transaction

ovm_sequence_item

ovm_sequence

ovm_req_rsp_sequence#(REQ, RSP)

231

Members

None

Methods

newfunction new (input string name="ovm_sequence",

ovm_sequencer_base sequencer=null,

ovm_sequence parent_seq=null)

The constructor of the ovm_sequence specifies three arguments: the name,sequencer, and parent sequence.

The name, which defaults to ovm_sequence, is the instance name of the sequence.

The sequencer is the target sequencer for this item.

The parent_seq is the parent sequence of this item.

applytask apply(input REQ this_req, output RSP this_rsp)

This task utilizes the super.apply() but requires the appropriate argument asparameterized by the REQ and RSP types.

232

ovm_random_sequence

The ovm_random_sequence class is a built-in sequence that is preloaded into everysequencer’s and virtual sequencer’s sequence library.

This sequence is registered in the sequence library as ovm_random_sequence. Thissequence randomly selects and executes a sequence from the sequencer’s sequence library,excluding ovm_random_sequence itself, and ovm_exhaustive_sequence.

The number of selections and executions is determined by the count property of thesequencer (or virtual sequencer) on which ovm_random_sequence is operating. Seeovm_sequencer_base on page 189 for more information.

Summaryclass ovm_random_sequence extends ovm_sequence;

// Constructor

function new (input string name="ovm_random_sequence",

ovm_sequencer_base sequencer = null,

ovm_sequence parent_seq = null);

endclass

File

sequences/ovm_sequence_builtin.svh

ovm_transaction

ovm_sequence_item

ovm_sequence

ovm_random_sequence

233

Virtual

No

Members

None

Methods

None

234

ovm_exhaustive_sequence

The ovm_exhaustive_sequence class is a built-in sequence that is preloaded into everysequencer’s and virtual sequencer’s sequence library.

This sequence is registered in the sequence library as ovm_exhaustive_sequence. Thissequence randomly selects and executes each sequence from the sequencer’s sequencelibrary once, excluding ovm_exhaustive_sequence itself, and ovm_random_sequence.

Summaryclass ovm_exhaustive_sequence extends ovm_sequence;

// Constructor

function new (input string name="ovm_exhaustive_sequence",

ovm_sequencer_base sequencer = null,

ovm_sequence parent_seq = null);

endclass

File

sequences/ovm_sequence_builtin.svh

ovm_transaction

ovm_sequence_item

ovm_sequence

ovm_exhaustive_sequence

235

Virtual

No

Members

None

Methods

None

236

ovm_simple_sequence

The ovm_simple_sequence class is a built-in sequence that is preloaded into everysequencer’s (but not virtual sequencer’s) sequence library.

This sequence is registered in the sequence library as ovm_simple_sequence. Thissequence simply executes a single sequence item.

The item parameterization of the sequencer that the ovm_simple_sequence is executedon defines the actual type of the item executed. See ovm_sequencer on page 193 for moreinformation.

Summaryclass ovm_simple_sequence extends ovm_sequence;

// Constructor

function new (input string name="ovm_simple_sequence",

ovm_sequencer_base sequencer = null,

ovm_sequence parent_seq = null);

endclass

File

sequences/ovm_sequence_builtin.svh

ovm_transaction

ovm_sequence_item

ovm_sequence

ovm_simple_sequence

237

Virtual

No

Members

None

Methods

None

238

Sequence Interface Classes

ovm_seq_item_prod_if

The ovm_seq_item_prod_if class provides the interfaces necessary to communicate witha sequence item producer (a sequencer).

Summaryclass ovm_seq_item_prod_if extends ovm_component;

// Constructor

function new (input string name="",

ovm_component parent = null);

// Connection method

function void connect_if(ovm_seq_item_cons_if seqr_if);

// Producer interfaces

task wait_for_sequences();

task get_next_item(output ovm_sequence_item item);

task try_next_item(output ovm_sequence_item item);

function void item_done(ovm_sequence_item item = null);

function bit has_do_available();

endclass

File

methodology/ovm_driver.svh

ovm_component

ovm_seq_item_prod_if

239

Virtual

No

Members

None

Methods

newnew (input string name="",

ovm_component parent = null)

The constructor of the ovm_seq_item_prod_if specifies two arguments: the nameand the parent component.

The name, which defaults to an empty string, is the instance name of theovm_seq_item_prod_if.

The parent is the enclosing hierarchical component.

connect_iffunction void connect_if(ovm_seq_item_cons_if seqr_if)

This function is used to connect the ovm_seq_item_prod_if to anovm_seq_item_cons_if object.

get_next_itemtask get_next_item(output ovm_sequence_item item)

This task should be called only when communicating with a sequencer that is set tooperate in pull mode.

When called, this task blocks indefinitely until an item is provided.

The output argument of this task is of the ovm_sequence_item type.

try_next_itemtask try_next_item(output ovm_sequence_item item)

240

This task should be called only when communicating with a sequencer that is set tooperate in pull mode.

When called, this task returns in the current simulation cycle whether an item or isprovided or not.

If no item can be provided, the output of this task is null.

The output argument of this task is of the ovm_sequence_item type.

Note: try_next_item() returns in the same simulation cycle if there is no pending doaction in the connected sequencer.

When calling try_next_item(), if the sequencer does not succeed in choosing a doaction before the time specified by the sequencer’s wait_for_sequences() taskexpires, then try_next_item() returns with the output set to null. The caller can usethis output to determine what action to take.

However, if a do action started execution during the current simulation cycle, thentry_next_item() may take longer than a simulation cycle (for example, if you extendthe pre_do() task to take longer than a simulation cycle).

item_donefunction void item_done(ovm_sequence_item item = null)

This function indicates to the producer that the consumer is done processing the item.

The call can optionally take the item that has been processed as an argument.

has_do_availablefunction bit has_do_available()

This function indicates whether the item producer connected to this interface has an itemavailable for immediate processing.

A return value of 1 indicates an item is available.

A return value of 0 indicates that an item is not available.

wait_for_sequencestask wait_for_sequences()

This task results in the wait_for_sequences() task of the sequencer which isconnected to this ovm_seq_item_prod_if being called.

241

ovm_seq_item_cons_if

The ovm_seq_item_cons_if class provides the interfaces necessary in order tocommunicate with a sequence item consumer (a driver or another sequencer).

The only user interface necessary from the sequence item consumer interface classperspective is the ability to connect this interface class to a sequence item producer interfaceclass.

Summaryclass ovm_seq_item_cons_if extends ovm_component;

// Constructor

function new (input string name="",

ovm_component parent = null);

// Connection method

function void connect_if(ovm_seq_item_prod_if item_prod_if);

endclass

File

sequences/ovm_sequencer.svh

Virtual

No

Members

None

ovm_component

ovm_seq_item_cons_if_base

242

Methods

newnew (input string name="",

ovm_component parent = null)

The constructor of the ovm_seq_item_cons_if specifies two arguments: the nameand parent components.

The name, which defaults to an empty string, is the instance name of theovm_seq_item_cons_if.

The parent is the enclosing hierarchical component.

connect_iffunction void connect_if(ovm_seq_item_prod_if item_prod_if)

This function is used to connect an ovm_seq_item_cons_if to anovm_seq_item_prod_if.

243

ovm_seq_prod_if

The ovm_seq_prod_if class provides the interfaces necessary in order to communicate witha sequence producer (i.e. a virtual sequencer). The only user interface necessary from thesequence producer interface class perspective is the ability to connect this interface class toa sequence consumer interface class.

Summaryclass ovm_seq_prod_if extends ovm_component;

// Constructor

function new (input string name="",

ovm_component parent = null);

// Connection method

function void connect_if(ovm_seq_cons_if vseq_if);

endclass

File

sequences/ovm_sequencer_base.svh

Virtual

No

Members

None

ovm_component

ovm_seq_prod_if

244

Methods

newnew (input string name="",

ovm_component parent = null)

The constructor of the ovm_seq_prod_if specifies two arguments: the name andparent components.

The name, which defaults to an empty string, is the instance name of theovm_seq_prod_if.

The parent is the enclosing hierarchical component.

connect_iffunction void connect_if(ovm_seq_cons_if vseq_if)

This function is used to connect ovm_seq_prod_if to ovm_seq_cons_if.

245

ovm_seq_cons_if

The ovm_seq_cons_if class provides the interfaces necessary in order to communicatewith a sequence consumer (for example, a sequencer).

Summaryclass ovm_seq_cons_if extends ovm_component;

// Constructor

function new (input string name="",

ovm_component parent = null);

// Connection method

function void connect_if(ovm_seq_prod_if seqr_if);

// Status Interfaces

function bit is_connected();

function bit is_virtual_sequencer();

function string get_sequencer_type_name();

// Root Sequence Execution Interface

task start_sequence(ovm_sequence this_seq);

// Grab Interfaces

task grab(ovm_sequence this_seq);

function void ungrab(ovm_sequence this_seq);

function ovm_sequence current_grabber();

function bit is_grabbed();

endclass

ovm_component

ovm_seq_cons_if

246

File

sequences/ovm_virtual_sequencer.svh

Virtual

No

Members

None

Methods

newnew (input string name="",

ovm_component parent = null)

The constructor of the ovm_seq_cons_if specifies two arguments: the name andparent components.

The name, which defaults to an empty string, is the instance name of theovm_seq_cons_if.

The parent is the enclosing hierarchical component.

connect_iffunction void connect_if(ovm_seq_prod_if vseq_if)

This function is used to connect ovm_seq_cons_if to ovm_seq_prod_if.

is_connectedfunction bit is_connected()

This function indicates whether this interface is connected.

A 1 return value means the interface is connected.

is_virtual_sequencerfunction bit is_virtual_sequencer()

247

This function indicates whether the interface is connected to a sequencer or a virtualsequencer.

A 1 return value means the interface is connected to a virtual sequencer. If this functionis called and the interface is not connected, a fatal error occurs. Consequently, youshould use is_connected() before calling this function.

get_sequencer_type_namefunction string get_sequencer_type_name()

This function returns the type name of the connected sequencer or virtual sequencer.

If this interface is not connected, this function returns NOT_CONNECTED.

start_sequencetask start_sequence(ovm_sequence this_seq)

This task starts this_seq as a root sequence on the sequencer (or virtual sequencer)connected to this interface.

start_sequence() triggers the this_seq start event, executes the pre_body(),body() and post_body() tasks, and then triggers the this_seq end event.

this_seq must be allocated and randomized before calling this task.

grabtask grab(ovm_sequence this_seq)

This task requests exclusive access to the connected sequencer’s action queue.

When this task returns, this_seq has been granted exclusive access and items doneby this_seq and its sub-sequences will have priority for processing in the action queueover items done by other sequences.

Other sequences attempting to grab will be blocked until exclusive access can begranted.

Sub-sequences of the current grabbing sequence can further be granted exclusiveaccess by performing another grab.

If this task is called on an ovm_seq_cons_if that is connected to a virtual sequencer,a fatal error occurs since virtual sequencer cannot be grabbed (grab only affectsscheduling of items and virtual sequencer do not do items—only sequences).

248

ungrabfunction void ungrab(ovm_sequence this_seq)

This task removes exclusive access to the connected sequencer’s action queue that hasbeen granted to seq.

An error occurs if a sequence that does not hold the exclusive access performs anungrab().

If this task is called on an ovm_seq_cons_if that is connected to a virtual sequencer,a fatal error occurs since virtual sequencer cannot be grabbed (grab only affectsscheduling of items and virtual sequencer do not do items—only sequences).

current_grabberfunction ovm_sequence current_grabber()

This function returns a reference of type ovm_sequence to the current grabbingsequence on the connected sequencer.

If there is no grabbing sequence, a null object is returned.

If this task is called on an ovm_seq_cons_if that is connected to a virtual sequencer,a fatal error occurs since virtual sequencer cannot be grabbed (grab only affectsscheduling of items and virtual sequencer do not do items—only sequences).

is_grabbedfunction bit is_grabbed()

This function returns a bit indicating whether or not the connected sequencer is grabbed.A 1 indicates that a sequence is currently grabbing.

A 0 indicates that no sequence is currently grabbing.

If this task is called on an ovm_seq_cons_if that is connected to a virtual sequencer,a fatal error occurs since virtual sequencer cannot be grabbed (grab only affectsscheduling of items and virtual sequencer do not do items—only sequences).

249

Layered Stimulus

Figure 1-5 UML Diagram for Layered Stimulus Classes

ovm_scenario_driver_base

ovm_scenario_driver

ovm_threaded_component

250

ovm_scenario#(REQ = ovm_sequence_item, RSP = ovm_sequence_item)

The ovm_scenario class provides the interfaces necessary to create and control streamsof sequence_items and other scenarios.

Summaryclass ovm_scenario #(REQ = ovm_sequence_item, RSP = ovm_sequence_item);

//Constructor

Function new (input string name);

virtual task apply_request(input REQ data_req);

virtual task apply_send(input REQ data_req);

virtual task apply(input REQ data_req, output RSP data_rsp);

virtual function void grant(ovm_scenario_driver_base driver_ptr);

function int get_id();

function ovm_scenario_base get_parent_scenario();

function int get_depth();

function string get_scenario_path_name();

task lock();

function void unlock();

function bit is_blocked();

virtual task start(ovm_scenario_controller_base scenario_controller,

ovm_scenario_base parent_seq = null);

virtual task pre_apply();

virtual task mid_apply();

virtual task post_apply();

virtual task pre_body();

virtual task body();

virtual task post_body();

end class

Virtual

No

251

Methods

newfunction new (input string name);

The constructor of ovm_scenario specifies the name of the sequence.

pre_bodyvirtual task pre_body()

The pre_body called back is executed when a scenario is started. The pre_body calloccurs immediately before the body() is executed.

Note: You should not call this task directly

bodyvirtual task body()

The body task is the main method of the scenario. The body callback is where ascenario is expected to communicate with the sequence_controller to issuerequests.

Note: You should not call this task directly

post_bodyvirtual task post_body()

The post_body task is called immediately after the body() task completes.

Note: You should not call this task directly

pre_applyvirtual task pre_apply()

The pre_apply task is called when a scenario has requested to send an item, and thescenario_controller has granted this sequence. This task is called immediatelyafter the grant, but before the item is randomized

Note: You should not call this task directly

252

mid_applyvirtual task mid_apply()

The mid_apply task is called when a scenario has requested to send an item, and afterthe item has been randomized. This task is called just before the item is to be sent to thedriver.

Note: You should not call this task directly

applyvirtual task apply(input ovm_sequence_item REQ, output ovm_sequence_item RSP);

The apply task should be called from inside the body of the scenario. The applyargument executes a sequence item. It will issue a request, randomize the REQsequence item send it to the driver, and wait for the RSP sequence_item to be returnedfrom the driver. The pre_apply, mid_apply, and post_apply tasks will be called atthe appropriate times.

apply_requestvirtual task apply_request(input REQ data_req);

This task is called by both the apply and apply_send methods. It issues the requestto the scenario_controller, and waits for the grant to be issued. Pre_apply,randomization, and mid_apply are called by this task.

apply_sendvirtual task apply_send(input REQ data_req);

This task is called by the apply method, and may be called directly by the body if youwant to break up the apply() method. For example if a driver does not send aresponse back to the scenario, then this call should be used. Be aware that this task willresult in pre_apply and mid_apply being called, but not post_apply.

grantvirtual function void grant(ovm_scenario_driver_base driver_ptr);

The grant function is called by the scenario_controller when a previously issuedrequest is granted. The scenario_controller returns a pointer to the driver that thescenario is being granted access to. The pointer is provided so that a scenario and drivermay start direct arbitrary communication with each other if necessary. In general, if asingle ovm_sequence_item is not sufficient, then a ovm_scenario_noparam shouldbe used.

253

post_applyvirtual task post_apply()

The post_apply task is called after the response has been received from the driver. Itis the last callback called before the apply task returns control to the scenario body.

Note: You should not call this task directly.

startvirtual task start(ovm_scenario_controller_base scenario_controller,

ovm_scenario_base parent_seq = null);

Used to start the execution of a scenario on a scenario_controller. Start will causethe pre_body, body, and post_body tasks to be called, and the scenario tocommunicate with the scenario_controller indicated in the first argument.

The first argument specifies the scenario_controller that this scenario is tocommunicate with.

The second argument specifies the parent scenario. If the parent_scenario is null,then this is a parent scenario. If non-null, then this is a child scenario.

Be aware that the scenario hierarchy is import for locks.

is_relevantvirtual function bit is_relevant()

This function is a hook to indicate to the scenario controller if the scenario is currentlyready to provide a sequence_item, after the scenario has already issued a requestthrough the apply() method.

The default implementation returns a 1'b1, which indicates that the scenario is ready.

If for some reason the scenario has requested to send an item, and then the item is notready for some period of time, then is_relevant must return a 1'b0 until thesequence_item is ready.

locktask lock();

The lock task will request that this scenario and all of its children receive a lock from thescenario_controller. This task will return after the scenario_controllergrants the lock. The scenario_controller will arbitrate the lock along with anyrequests received from other scenarios.

254

Once the lock has been granted, the scenario_controller will grant requests onlyfrom the owner of the lock, or any children scenarios of the locking scenario.

Children of a locked scenario may also request a lock. When that lock is granted, onlythe child or children of the child will be granted access to a driver by thescenario_controller.

unlockfunction void unlock();

The unlock function will release a lock owned by a particular scenario. Only thescenario that issued the lock will successfully unlock.

is_blockedfunction bit is_blocked();

This function will return a bit indicating if any existing locks will prevent this scenario frombeing granted access by the scenario_controller. A return value of 0'b0 indicatesthat there are currently no locks preventing this scenario from being granted access.

255

ovm_scenario_controller#(ovm_sequence_item REQ, ovm_sequence_item GNT):

The ovm_scenario_controller provides the arbitration and interconnect between one ormore ovm_scenario and an ovm_scenario_driver.

Summaryclass ovm_scenario_controller #(ovm_sequence_item REQ, ovm_sequence_item GNT):

function new (string name,

ovm_component parent,

ovm_scenario_controller_base push_if = null);

function void request(ovm_scenario_base scenario_ptr);

task driver_request (input ovm_scenario_driver_base driver_ptr,

output ovm_scenario_base chosen_scen );

// For driver ports to connect to the request_driver

ovm_blocking_get_export #(REQ) get_req_export;

ovm_blocking_put_export #(RSP) put_rsp_export;

// For stimulus generators to connect to the stimulus scenario

ovm_blocking_put_export #(REQ) put_req_export;

end class

Virtual

No

Methods

newfunction new (string name,

ovm_component parent,

ovm_scenario_controller_base push_if = null);

The constructor of ovm_scenario_controller takes two arguments, plus anoptional third argument.

The name and parent component are the required first two arguments.

The third argument defaults to null, which is the normal case. If the push_if is non-null,then the scenario_controller will forward all scenario requests to a downstreamscenario_controller.

256

All arbitration will be done by the downstream scenario_controller.

requestfunction void request(ovm_scenario_base scenario_ptr);

request is called by one or more scenarios to request access to a driver. Thescenario_controller will arbitrate requests, and call grant for a selected scenarioeach time the driver indicates it is ready to start a new operation.

driver_requesttask driver_request (input ovm_scenario_driver_base driver_ptr, output

driver_request is called by a driver to indicate to the scenario_controller thatit is ready to start a new operation. driver_request causes thescenario_controller to choose a scenario and issue a grant.

ports

The scenario_controller provides ports for both the driver and the scenarios tocommunicate. The driver and scenarios must both be written to either use thescenario_controller ports, or to communicate directly.

driver portsovm_blocking_get_export #(REQ) get_req_export;

ovm_blocking_put_export #(RSP) put_rsp_export;

A driver may directly access items through TLM connections to these ports, or throughthe get_next_item() function call in the ovm_scenario_driver_base.

stimulus generator portovm_blocking_put_export #(REQ) put_req_export;

A stimulus generator may be connected directly through a tlm connect call to thescenario_controller by connecting the put_req_export of thescenario_generator. When an item is put on this port, the scenario_controllerwill arbitrate this request in parallel with all other sequence requests.

257

ovm_scenario_driver#(ovm_sequence_item REQ, ovm_sequence_item RSP)

The ovm_scenario_driver accepts sequence_items from thescenario_controller for driving into the DUT. A typical ovm_scenario_drivercontains a BFM for driving pin-level signals along with some logic to convert thetransaction-level ovm_sequence_item to an RTL-level operation.

The ovm_scenario_drivermay also respond back to the ovm_scenario_controllerwith a response ovm_sequence_item either to indicate to the selected scenario that theoperation is complete, or to provide response data back to the scenario.

Summaryvirtual class ovm_scenario_driver #(type REQ = ovm_sequence_item, type RSP =ovm_sequence_item);

function new (string name, ovm_component parent);

function void set_scenario_controller(ovm_scenario_controller_basescenario_controller_ptr);

virtual task get_next_item(output REQ req_item);

end class

Virtual

No

Methods

newfunction new (string name, ovm_component parent);

The constructor of ovm_scenario_driver requires the name and parentcomponents.

set_scenario_controllerfunction void set_scenario_controller(ovm_scenario_controller_basescenario_controller_ptr);

The set_scenario_controller function provides a pointer to thescenario_controller that will supply sequence_items for thescenario_driver. When using pointer-based TLM communication, this function must

258

be called before the scenario_driver can issue requests for items from thescenario_controller.

get_next_itemvirtual task get_next_item(output REQ req_item);

The scenario_driver can call get_next_item to issue a driver_request to thescenario_controller and return a sequence_item. Each call to get_next_itemwill return a sequence_item from a scenario selected by thescenario_controller.

259

OVM Macros

OVM provides a number of macros to make common code easier to write. It is nevernecessary to use the macros, but in many cases the macros can save a substantial amountof user written code.

The OVM macros include:

■ Utility Macros

■ Fields Macros

■ Factory Registration Macros

■ Array Printing Macros

■ Sequence Action Macros.

Utility Macros

The utility macros provide overrides for the create() method, which is needed for cloning,and the get_type_name() method, which is needed for a number of debugging features.These macros also perform the factory registration of the class type.

Below is an example usage of the utility macros with the field macros. By using the macros,you do not have to implement any of the data methods to get all of the capabilities of anovm_object.

class mydata extends ovm_object;

string str;

mydata subdata;

int field;

myenum e1;

int queue[$];

`ovm_object_utils_begin(mydata) //requires ctor with default args

`ovm_field_string(str, OVM_DEFAULT)

`ovm_field_object(subdata, OVM_DEFAULT)

`ovm_field_int(field, OVM_DEC) //use decimal radix

`ovm_field_enum(e1, OVM_DEFAULT)

`ovm_field_queue_int(queue, OVM_DEFAULT)

`ovm_object_utils_end

endclass

260

`ovm_object_utils`ovm_object_utils (TYPE)

This macro implements get_type_name(), returning a value of TYPE and implementscreate() by instantiating an object of TYPE using the default constructor (noarguments).

This method also registers TYPEwith the factory as an object type, using the string TYPEas the factory lookup string for the type.

`ovm_object_utils_begin and `ovm_object_utils_end`ovm_object_utils_begin (TYPE)

`ovm_object_utils_end

These macros form a block in which `ovm_field_* macros can be placed.

The ovm_object_utils_begin macro does all of the same overrides thatovm_object_utils does, and also starts the block necessary for the ovm_field_*macros to be placed.

`ovm_component_utils`ovm_component_utils (TYPE)

This macro implements get_type_name(), returning a value of TYPE and implementscreate() by instantiating an object of TYPE using a two argument constructor (theconstructor must have a name and a parent argument).

This method also registers TYPE with the factory as a component type, using the stringTYPE as the factory lookup string for the type.

`ovm_component_utils_begin and `ovm_component_utils_end`ovm_component_utils_begin (TYPE)

`ovm_component_utils_end

These macros form a block in which `ovm_field_* macros can be placed.

The ovm_component_utils_begin macro does all of the same overrides thatovm_component_utils does, and also starts the block necessary for theovm_field_* macros to be placed.

`ovm_field_utils_begin and `ovm_field_utils_end`ovm_field_utils_begin (TYPE)

261

`ovm_field_utils_end

These macros form a block in which `ovm_field_* macros can be placed.

These macros do NOT perform factory registration, set get_type_name(), or overridethe create method.

These macros are used when you want to use the field macros, but you also want toexplicitly implement the required overrides. This macro set is also useful when you aresetting up field macros for an abstract class.

Fields Macros

The field macros can be placed inside of the `ovm_*_utils_begin and'ovm_*_utils_end macro blocks to set up automation of fields. The automation of thefields means that the fields automatically get an implementation for all of the data methods:copy, compare, pack, unpack, record, print, sprint. A flag argument is specified toindicate which, if any, of the data methods NOT to implement.

The flags and their description are listed below. Flags can be bitwise ORed together (in mostcases they may be added together as well, but care must be taken when using the + operatorto ensure that the same bit is not added more than once).

Table 1-5 Field Macro Flags

Flag Meaning

OVM_DEFAULT Use the default flag settings.

OVM_ALL_ON Set all operations on (default).

OVM_COPY Do a copy for this field (default).

OVM_NOCOPY Do not copy this field.

OVM_COMPARE Do a compare for this field (default).

OVM_NOCOMPARE Do not compare this field.

OVM_PRINT Print this field (default).

OVM_NOPRINT Do not print this field.

262

`ovm_field_int`ovm_field_int (ARG, FLAG)

This macro implements the data operations for packed integral types.

`ovm_field_enum`ovm_field_enum (TYPE, ARG, FLAG)

This macro implements the data operations for enumerated types.

For enums, the TYPE argument is necessary to specify the enumerated type. This isneeded because of SystemVerilog strong typing rules with respect to enumerated types.

`ovm_field_object`ovm_field_object (ARG, FLAG)

This macro implements the data operations for ovm_object derived objects.

`ovm_field_string`ovm_field_string (ARG, FLAG)

OVM_NODEFPRINT Do not print the field if it is the same as its default value.

OVM_PACK Pack and unpack this field (default).

OVM_NOPACK Do not pack or unpack this field.

OVM_PHYSICAL Treat as a physical field. Use physical setting in policyclass for this field.

OVM_ABSTRACT Treat as an abstract field. Use the abstract setting in thepolicy class for this field.

OVM_READONLY Do not allow setting of this field from the set_*_localmethods.

OVM_BIN, OVM_DEC,OVM_UNSIGNED, OVM_OCT,OVM_HEX, OVM_STRING,OVM_TIME, OVM_NORADIX

Radix settings for integral types. Hex is the default radix ifnone is specified.

263

This macro implements the data operations for string types.

`ovm_field_array_int`ovm_field_array_int (ARG, FLAG)

This macro implements the data operations for dynamic arrays of integral types.

`ovm_field_array_object`ovm_field_array_object (ARG, FLAG)

This macro implements the data operations for dynamic arrays of ovm_object types.

`ovm_field_array_string`ovm_field_array_string (ARG, FLAG)

This macro implements the data operations for dynamic arrays of string types.

`ovm_field_queue_int`ovm_field_queue_int (ARG, FLAG)

This macro implements the data operations for queues of integral types.

`ovm_field_queue_object`ovm_field_queue_object (ARG, FLAG)

This macro implements the data operations for queue of ovm_object types.

`ovm_field_queue_string`ovm_field_queue_string (ARG, FLAG)

This macro implements the data operations for queues of string types.

`ovm_field_aa_int_string`ovm_field_aa_int_string (ARG, FLAG)

This macro implements the data operations for associative arrays of integral typeswith string keys.

264

`ovm_field_aa_object_string`ovm_field_aa_object_string (ARG, FLAG)

This macro implements the data operations for associative arrays of ovm_object typeswith string keys.

`ovm_field_aa_string_string`ovm_field_aa_string_string (ARG, FLAG)

This macro implements the data operations for associative arrays of string types withstring keys.

`ovm_field_aa_int_<key_type>`ovm_field_aa_int_<key_type> (ARG, FLAG)

This macro implements the data operations for associative arrays of integral types withintegral keys.

The key type can be any of the following: int, integer, int_unsigned,integer_unsigned, byte, byte_unsigned, shortint, shortint_unsigned,longint, longint_unsigned.

`ovm_field_aa_string_int`ovm_field_aa_string_int (ARG, FLAG)

This macro implements the data operations for associative arrays of string types withint keys.

`ovm_field_aa_object_int`ovm_field_aa_object_int (ARG, FLAG)

This macro implements the data operations for associative arrays of ovm_object typeswith int keys.

Factory Registration Macros

These macros are used to simplify factory registration. They can be used inside or outside ofa class.

265

`ovm_object_registry(TYPE, STR)

This macro is very similar to the ovm_object_registry#(T,S) class for registeringa data object type with the factory.

TYPE is the type to be registered, and STR is the name that the factory will use to lookup the name.

Normally, STR is the same as TYPE. However, it is sometimes useful to use an aliasname. It is legal to register more than one string to produce the same type.

`ovm_component_registry(TYPE, STR)

This macro is very similar to the ovm_component_registry#(T,S) class forregistering a component type with the factory.

TYPE is the type to be registered, and STR is the name that the factory will use to lookup the name.

Normally, STR is the same as TYPE. However, it is sometimes useful to use an aliasname. It is legal to register more than one string to produce the same type.

Array Printing Macros

The array printing macros can be used inside of the do_print()method of an ovm_objectderived class to add the appropriate code from printing a queue, dynamic array or associativearray.

`print_aa_int_object2`print_aa_int_object2 (field, printer)

This macro implements array printing for an associative array of ovm_object types withan int key.

field is the field to print and is also used as the name of the field.

printer is the printer to use.

`print_aa_int_key4`print_aa_int_key (key_type, field, radix, printer)

This macro implements array printing for an associative array of integral types with anarbitrary key type.

266

key_type is the type of the indexing variable for the array.

field is the field to print and is also used as the name of the field.

radix is the radix to use for each element.

printer is the printer to use.

`print_aa_string_int3`print_aa_string_int3 (field, radix, printer)

This macro implements array printing for an associative array of integral types with astring key.

field is the field to print and is also used as the name of the field.

radix is the radix to use for the elements.

printer is the printer to use.

`print_aa_string_object2`print_aa_string_object2 (field, printer)

This macro implements array printing for an associative array of ovm_object types witha string key.

field is the field to print and is also used as the name of the field.

printer is the printer to use.

`print_aa_string_string2`print_aa_string_string2 (field, printer)

This macro implements array printing for an associative array of string types with astring key.

field is the field to print and is also used as the name of the field.

printer is the printer to use.

`print_object_qda3`print_string_qda3 (field, printer, arraytype)

This macro implements array printing for an ovm_object array type.

267

field is the field to print and is also used as the name of the field.

printer is the printer to use.

arraytype is the type name to use when printing the array (no quotes are used).

`print_qda_int4`print_qda_int4 (field, radix, printer, arraytype)

This macro implements array printing for an integral array type.

field is the field to print and is also used as the name of the field.

radix is the radix to use for the elements.

printer is the printer to use.

arraytype is the type name to use when printing the array (no quotes are used).

`print_string_qda3`print_string_qda3 (field, printer, arraytype)

This macro implements array printing for a string array type.

field is the field to print and is also used as the name of the field.

printer is the printer to use.

arraytype is the type name to use when printing the array (no quotes are used).

Sequence Action Macros

The sequence action macros simplify item and sequence execution. They are invoked withinthe body() task of sequences. Each macro performs one or more of the following steps onan item or sequence.

1. Create—Allocates and initializes the sequencer and parent sequence of the item orsequence. Any previously allocated data for the variable (if the variable is not null) islost.

2. Synchronize with sequencer—If the variable is an item, the item waits until the sequenceracknowledges that the item can continue. If the variable is a sequence, nosynchronization with the sequencer occurs.

268

3. pre_do—Execute the pre_do() user hook of the sequence executing the action. If thevariable is an item, pre_do() is called with the argument set to 1. If the variable is asequence, then pre_do() is called with the argument set to 0.

4. Randomize—Randomize the variable. If randomization fails, a warning is issued.

5. mid_do—Execute the mid_do() user hook of the sequence executing the action. Themid_do() is called with the argument being the item currently executing.

6. Post synchronization/body execution—If the variable is an item, the variable is providedto the sequencer with an indication that the item is ready to be provided to the consumer.Then, the action waits until the item has been consumed. If the variable is a sequence,its body() method is executed.

7. post_do —Execute the post_do() user hook of the sequence executing the action.The post_do() is called with argument being the variable that was just executed.

Action Macros

`ovm_do`ovm_do(variable)

Performs all seven of the listed steps. The variable must be ovm_sequence_item orovm_sequence.

`ovm_do_with`ovm_do_with(variable, {constraint-block} )

Performs all seven of the listed steps. However, the Randomize step performs arandomize() …with using the constraints supplied in the second argument.

The constraint block must include the curly braces.

The variable must be ovm_sequence_item or ovm_sequence. For example:

`ovm_do_with(trans, { addr > 0 && addr < 'h800; } )

`ovm_create`ovm_create(variable)

Performs only the Create step.

This action provides a variable that is initialized for execution such that you can thenmanipulate the variable before execution.

269

One example is to turn off constrains and/or disable the randomization mode onproperties of the variable. If a property’s randomization mode is 0, any values set will bepreserved after randomization.

The variable must be ovm_sequence_item or ovm_sequence.

`ovm_send`ovm_send(variable)

Performs steps 2 through 7, and skips step 4.

This action provides a means to execute a variable without any randomization occurring.

The variable must be initialized before executing this action using either `ovm_createor new() with the appropriate sequencer and parent sequence settings.

The variable must be ovm_sequence_item or ovm_sequence.

`ovm_rand_send`ovm_rand_send(variable)

Performs steps 2 through 7.

The variable must be initialized before executing this action using either `ovm_createor new() with the appropriate sequencer and parent sequence settings.

The variable must be ovm_sequence_item or ovm_sequence.

`ovm_rand_send_with`ovm_rand_send_with(variable, {constraint-block} )

Performs steps 2 through 7.

The variable must be initialized before executing this action using either `ovm_createor new() with the appropriate sequencer and parent sequence settings. This is similarto the `ovm_rand_send action, except the randomization step applies the givenconstraints using randomize()…with.

The variable must be ovm_sequence_item or ovm_sequence.

`ovm_do_seq`ovm_do_seq(variable, seq_cons_if )

270

Performs all steps, however, this action is used in virtual sequences to executesequences on other sequencers.

The first argument must include a variable of the sequence type to be executed. Thesecond argument is the sequence consumer interface connected to the sequencer onwhich the sequence is to be executed.

The variable should not be ovm_sequence_item.

`ovm_do_seq_with`ovm_do_seq_with(variable, seq_cons_if, {constraint-block} )

Performs all steps, however, this action is used in virtual sequences to executesequences on other sequencers.

The first argument must a variable of the sequence type to be executed. The secondargument is the sequence consumer interface connected to the sequencer on which thesequence is to be executed. This is similar to the `ovm_do_seq action, except therandomization step applies the given constraints using randomize()…with. Theconstraints are applied to the variable.

The variable should not be ovm_sequence_item.

`ovm_create_seq`ovm_create_seq (variable, seq_cons_if)

Performs only the Create step.

This action creates a sequence inside a virtual sequence that can be executed on thesequencer connected to the sequence consumer interface provided as the secondargument.

Like `ovm_create, the variable can be manually manipulated before execution.

Execution of the variable can be achieved using `ovm_send, `ovm_rand_send, or`ovm_rand_send_with action.

The variable should not be ovm_sequence_item.

271

Transactions

ovm_built_in_clone#(type T=int)

This policy class is used to clone built-in types. It is used to build generic components that willwork with either classes or built-in types.

Summaryclass ovm_built_in_clone #(type T=int);

static function T clone(input T from);

end class

File

methodology/ovm_policies.svh

Virtual

No

Parameterstype T = int

The return type of the clone() method.

Members

None

Methods

clonestatic function T clone(input T from)

Returns the value of from.

272

ovm_built_in_comp#(type T=int)

This policy class is used to compare built-in types. It is used to build generic components thatwork with either classes or built-in types.

Summaryclass ovm_built_in_comp #(type T=int);

static function bit comp(input T a, input T b);

end class

File

methodology/ovm_policies.svh.

Virtual

No

Parameterstype T = int

The type of the items to be compared.

Members

None

Methods

compstatic function bit comp(input T a, input T b)

Returns the value of a==b.

273

ovm_built_in_converter#(type T=int)

This policy class is used to convert built-in types to strings. It is used to build genericcomponents that will work with either classes or built-in types.

Summaryclass ovm_built_in_converter #(type T=int);

static function string convert2string(input T t);

end class

File

methodology/ovm_policies.svh

Virtual

No

Parameterstype T = int

The type of the item to be converted.

Members

None

Methods

convert2stringstatic function string convert2string(input T t);

Returns the value of t as a string.

274

ovm_built_in_pair#(type T1=int, type T2=T1) extends ovm_transaction

This class represents a pair of built in types.

Summaryclass ovm_built_in_pair #(type T1=int, type T2=T1) extends ovm_transaction;

virtual function string convert2string();

function bit comp(this_type t);

function void copy(input this_type t);

function ovm_transaction clone();

end class

File

utils/ovm_pair.svh

Virtual

No

Parameterstype T1 = int

The type of the first element of the pair.

type T2 = T1

The type of the second element of the pair. By default, the two types are the same.

Memberstypedef ovm_built_in_pair #(T1, T2) this_type

T1 first

The first element of the pair.

T2 second

The second element of the pair.

275

Methods

Since ovm_built_in_pair is a transaction class, it provides the four compulsorymethods as defined by ovm_object.

convert2stringvirtual function string convert2string()

compfunction bit comp(this_type t)

copyfunction void copy(input this_type t)

clonefunction ovm_transaction clone()

276

ovm_class_clone#(type T=int)

This policy class is used to clone classes. It is used to build generic components that workwith either classes or built-in types.

Summaryclass ovm_class_clone #(type T=int);

static function ovm_transaction clone(input T from);

end class

File

methodology/ovm_policies.svh

Virtual

No

Members

None

Methods

clonestatic function ovm_transaction clone(input T from)

This method returns from.clone().

277

ovm_class_comp#(type T=int)

This policy class is used to compare classes. It is used to build generic components that workwith either built-in types or classes.

Summaryclass ovm_class_comp #(type T=int);

static function bit comp(input T a, input T b);

end class

File

methodology/ovm_policies.svh

Virtual

No

Members

None

Methods

compstatic function bit comp(input T a, input T b)

This method returns a.comp(b).

278

ovm_class_converter#(type T=int)

This policy class is used to convert classes to strings. It is used to build generic componentsthat work with either built-in types or classes.

Summaryclass ovm_class_converter #(type T=int);

static function string convert2string(input T t);

end class

File

base/ovm_policies.svh

Virtual

No

Members

None

Methods

convert2stringstatic function string convert2string(input T t)

This method returns t.convert2string().

279

ovm_class_pair#(type T1=int, type T2=T1) extends ovm_transaction

This class represents a pair of classes.

Summaryclass ovm_class_pair #(type T1=int, type T2=T1) extends ovm_transaction;

function new(input T1 f=null, input T2 s=null);

function string convert2string;

function bit comp(this_type t);

function void copy(input this_type t);

function ovm_transaction clone;

end class

File

methodology/ovm_pairs.svh

Virtual

No

Memberstypedef ovm_class_pair #(T1, T2) this_type

T1 first

This is the first element in the pair.

T2 second

This is the second element in the pair.

Methods

newfunction new(input T1 f=null, input T2 s=null)

A constructor, with optional arguments for first and second. No cloning is performed fornondefault values.

280

convert2stringfunction string convert2string

compfunction bit comp(this_type t)

copyfunction void copy(input this_type t)

clonefunction ovm_transaction clone

Since ovm_built_in_pair is a transaction class, it provides the four compulsorymethods as defined by ovm_object.

281

Index

AArray Printing Macros

print_aa_int_key4 265print_aa_int_object2 265print_aa_string_int3 266print_aa_string_object2 266print_aa_string_string2 266print_object_qda3 266print_qda_int4 267print_string_qda3 267

BBase

ovm_object 11ovm_transaction 23ovm_void 10

Bi-Directional Interfacesbi-if

blocking_master 152blocking_slave 152blocking_transport 152master 152nonblocking_master 152nonblocking_slave 152nonblocking_transport 152slave 152transport 152

ovm_bi-if_export 152ovm_bi-if_imp 152ovm_bi-if_port 152

Built-In TLM Channels 168tlm_analysis_fifo 169tlm_fifo 171tlm_req_rsp_channel 175tlm_transport_channel 178

CClasses for Connectors 149Comparators 209

ovm_algorithmic_comparator 212ovm_in_order_built_in_comparator 210ovm_in_order_class_comparator 211ovm_in_order_comparator 215

Component Hierarchy 30ovm_component 30ovm_env 58ovm_phase 61ovm_threaded_component 54

Components 180ovm_agent 185ovm_driver 187ovm_monitor 198ovm_random_stimulus 181ovm_req_rsp_driver#(REQ, RSP) 207ovm_scoreboard 200ovm_sequencer 193ovm_sequencer_base 189ovm_subscriber 205ovm_test 183ovm_virtual_sequencer 202

FFactory 88

ovm_component_registry #(typeT, stringTname) 90

ovm_factory 94ovm_factory_wrapper 88ovm_object_registry #(typeT, string

Tname) 92Factory Registration Macros

ovm_component_registry 265ovm_object_registry 265

Fields Macros

282

ovm_field_aa_int_key_type 264ovm_field_aa_int_string 263ovm_field_aa_object_int 264ovm_field_aa_object_string 264ovm_field_aa_string_int 264, 265ovm_field_aa_string_string 264ovm_field_array_int 263ovm_field_array_object 263ovm_field_array_string 263ovm_field_enum 262ovm_field_int 262ovm_field_object 262ovm_field_queue_int 263ovm_field_queue_object 263ovm_field_queue_string 263ovm_field_string 262

LLayered Stimulus 249

ovm_scenario 250ovm_scenario_controller 255ovm_scenario_driver 257

MMacros 259

Array Printing Macros 265Factory Registration Macros 264Fields Macros 261Sequence Action Macros 267Utility Macros 259

PPolicies 114

default_line_printer 131default_printer 131default_table_printer 131default_tree_printer 131ovm_comparer 114ovm_packer 119

ovm_printer 128ovm_recorder 125

Policy Knobs 138ovm_hier_printer_knobs 142ovm_printer_knobs 138ovm_table_printer_knobs 140, 142ovm_tree_printer_knobs 143Printer Examples 143

Ports and Exports 153ovm_bi-if_export 155ovm_bi-if_imp 163ovm_bi-if_port 159ovm_port_base 165ovm_uni-if_imp 161ovm_uni-if_port 157

RReporting 67

ovm_report_handler 77ovm_report_object 68ovm_report_server 83ovm_reporter 76

SSequence Action Macros

ovm_create 268ovm_create_seq 270ovm_do 268ovm_do_seq 269ovm_do_seq_with 270ovm_do_with 268ovm_rand_send 269ovm_rand_send_with 269ovm_send 269

Sequence Interface Classes 238ovm_seq_cons_if 245ovm_seq_item_cons_if 241ovm_seq_item_prod_if 238ovm_seq_prod_if 243

Sequences 218ovm_exhaustive_sequence 234

283

ovm_random_sequence 232ovm_req_rsp_sequence#(REQ, RSP) 230ovm_sequence 222ovm_sequence_item 218ovm_simple_sequence 236

Synchronization 98ovm_barrier 108ovm_barrier_pool 111ovm_event 98ovm_event_callback 106ovm_event_pool 103

TTLM Interfaces 145

Bi-Directional Interfaces 152Classes for Connectors 149tlm_if_base 146Uni-Directional Interfaces 151

Transactions 271ovm_built_in_clone 271ovm_built_in_comp 272ovm_built_in_converter 273ovm_built_in_pair 274ovm_class_clone 276ovm_class_comp 277ovm_class_converter 278ovm_class_pair 279

UUni-Directional Interfaces 151

ovm_uni-if_export 151ovm_uni-if_imp 151ovm_uni-if_port 151uni-if

analysis 151blocking_get 151blocking_get_peek 151blocking_peek 151blocking_put 151get 151get_peek 151

nonblocking_get 151nonblocking_get_peek 151nonblocking_peek 151nonblocking_put 151peek 151put 151

Utility Macrosovm_component_utils 260ovm_component_utils_begin 260ovm_component_utils_end 260ovm_field_utils_begin 260ovm_field_utils_end 260ovm_object_utils 260ovm_object_utils_begin 260ovm_object_utils_end 260

284