00001 // $Id: ovm__component_8svh-source.html,v 1.1 2008/10/07 21:54:53 alex.marin Exp $ 00002 //------------------------------------------------------------------------------ 00003 // Copyright 2007-2008 Mentor Graphics Corporation 00004 // Copyright 2007-2008 Cadence Design Systems, Inc. 00005 // All Rights Reserved Worldwide 00006 // 00007 // Licensed under the Apache License, Version 2.0 (the 00008 // "License"); you may not use this file except in 00009 // compliance with the License. You may obtain a copy of 00010 // the License at 00011 // 00012 // http://www.apache.org/licenses/LICENSE-2.0 00013 // 00014 // Unless required by applicable law or agreed to in 00015 // writing, software distributed under the License is 00016 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 00017 // CONDITIONS OF ANY KIND, either express or implied. See 00018 // the License for the specific language governing 00019 // permissions and limitations under the License. 00020 //------------------------------------------------------------------------------ 00021 00022 `ifndef OVM_COMPONENT_SVH 00023 `define OVM_COMPONENT_SVH 00024 00025 typedef class ovm_config_setting; 00026 typedef class ovm_phase; 00027 typedef class ovm_event_pool; 00028 typedef class ovm_object; 00029 typedef class ovm_transaction; 00030 typedef class ovm_printer; 00031 typedef class ovm_root; 00032 00033 //------------------------------------------------------------------------------ 00034 // 00035 // CLASS: ovm_component 00036 // 00037 //------------------------------------------------------------------------------ 00038 // Root base class for structural elements. Provides name and hiearchy 00039 // information about the object. 00040 //------------------------------------------------------------------------------ 00041 00042 virtual class ovm_component extends ovm_report_object; 00043 00044 //---------------------------------------------------------------------------- 00045 // Constructor 00046 //---------------------------------------------------------------------------- 00047 // When creating a new component, you must always provide a local "instance", 00048 // or "leaf" name. You must also provide a handle to the component's parent, 00049 // unless the component is a top-level component (i.e. it is created in a 00050 // static component such as a module or interface). 00051 //---------------------------------------------------------------------------- 00052 00053 extern function new (string name, ovm_component parent); 00054 00055 00056 //---------------------------------------------------------------------------- 00057 // Hierarchy 00058 //---------------------------------------------------------------------------- 00059 // These methods provide user access to information about the component 00060 // hierarchy. 00061 // 00062 // - Children info can be obtained via get_first_child, get_next_child, 00063 // and get_child methods. These operate like the built-in methods to the 00064 // associative array data-type. 00065 // 00066 // - The set_name method overrides the one in ovm_object so that name change 00067 // can be reflected in the component hierarchy: The parent's children list 00068 // must be updated, and the children's full names must now incorporate this 00069 // component's new name. 00070 // 00071 // - The lookup method can be used to find a component having the given 00072 // hierarchical path. If the path begins with a '.', then it is taken to 00073 // be an absolute path. Else, the given path is relative to this component. 00074 //---------------------------------------------------------------------------- 00075 00076 extern virtual function ovm_component get_parent (); 00077 extern virtual function string get_full_name (); 00078 extern function string get_type_name (); 00079 extern function ovm_component get_child (string name); 00080 extern function int get_first_child (`ref string name); 00081 extern function int get_next_child (`ref string name); 00082 extern function int get_num_children (); 00083 extern function int has_child (string name); 00084 extern virtual function void set_name (string name); 00085 extern function ovm_component lookup (string name ); 00086 00087 /*protected*/ ovm_component m_parent; 00088 protected ovm_component m_children[string]; 00089 00090 00091 //---------------------------------------------------------------------------- 00092 // Phases 00093 //---------------------------------------------------------------------------- 00094 // Components execute their behavior in strictly ordered, pre-defined phases. 00095 // Each phase is defined by its own method, which derived components can 00096 // override to incorporate component-specific behavior. During simulation, 00097 // the phases are executed one by one, where one phase must complete before 00098 // the next phase begins. The following brieft describe each phase: 00099 // 00100 // new 00101 // Also known as the constructor, the component does basic initialization 00102 // of any members not subject to configuration. 00103 // 00104 // build 00105 // The component constructs its children. It uses get_config 00106 // interface to obtain any configuration for itself, the set_config 00107 // interface to set any configuration for its own children, and the 00108 // factory interface for actually creating the children and other 00109 // objects it might need. 00110 // 00111 // connect 00112 // The component now makes connections (binds TLM ports and exports) 00113 // from child-to-child or from child-to-self (i.e. to promote a child 00114 // port or export up the hierarchy for external access. Afterward, 00115 // all connections are checked via resolve_bindings before entering 00116 // the end_of_elaboration phase. 00117 // 00118 // configure 00119 // <todo> 00120 // 00121 // end_of_elaboration 00122 // At this point, the entire testbench environment has been built and 00123 // connected. No new components and connections may be created from 00124 // this point forward. Components can do final checks for proper 00125 // connectivity, and it can initiate communication with other tools 00126 // that require stable, quasi-static component structure.. 00127 // 00128 // start_of_simulation 00129 // The simulation is about to begin, and this phase can be used to 00130 // perform any pre-run activity such as displaying banners, printing 00131 // final testbench topology and configuration information. 00132 // 00133 // run 00134 // This is where verification takes place. It is the only predefined, 00135 // time-consuming phase. A component's primary function is implemented 00136 // in the 'run' task. Other processes may be forked if desired. When 00137 // a component returns from its run task, it does not signify completion 00138 // of its run phase. Any processes that it may have forked CONTINUE TO 00139 // RUN. The run phase terminates in one of three ways: 00140 // 00141 // stop - When a component's enable_stop_interrupt bit is set and 00142 // global_stop_request is called, the component's stop task 00143 // is called. Components can implement stop to allow completion 00144 // of in-progress transactions, flush queues, etc. Upon return 00145 // from stop by all enabled components, a kill is issued. 00146 // 00147 // kill - When called, all component's run processes are killed 00148 // immediately. While kill can be called directly, it is 00149 // recommended that components use the stopping mechanism. 00150 // This affords a more ordered and safe shut-down. 00151 // 00152 // timeout - If a timeout was set, then the phase ends if it expires 00153 // before either of the above occur. 00154 // 00155 // If none of the above occur, simulation can continue "forever", or 00156 // the simulator may end simulation prematurely if it determines that 00157 // all processes are waiting 00158 // 00159 // extract 00160 // This phase can be used to extract simulation results from coverage 00161 // collectors and scoreboards, collect status/error counts, statistics, 00162 // and other information from components in bottom-up order. Being a 00163 // separate phase, extract ensures all relevant data from potentially 00164 // independent sources (i.e. other components) are collected before 00165 // being checked in the next phase. 00166 // 00167 // check 00168 // Having extracted vital simulation results in the previous phase, 00169 // the check phase can be used to validate such data and determine 00170 // the overall simulation outcome. It too executes bottom-up. 00171 // 00172 // report 00173 // Finally, the report phase is used to output results to files and/or 00174 // the screen. 00175 // 00176 // All task-based phases (run is the only pre-defined task phase) will run 00177 // forever until killed or stopped via do_kill_all or global_stop_request. 00178 // The latter causes the component's stop() method to get called back if 00179 // the enable_stop_interrupt bit is set. After all components' stop() tasks 00180 // return, the OVM will call do_kill_all to end the phase. 00181 // 00182 // The kill method kills all processes spawned by this component in this 00183 // task-based phase. The do_kill_all method recursively calls kill() on 00184 // all its children. 00185 // 00186 // The flush method can be overridden in derived components to flush queues 00187 // and other such cleanup. The do_flush method will recursively call flush 00188 // on the entire sub-tree bottom up. 00189 // 00190 // The do_func_phase and do_task_phase methods are hooks for calling all of 00191 // the phases. By default, they merely invoke the appropriate phase method. 00192 // The component may override this for any pre or post phase activities. 00193 // 00194 // A components build phase callback is not called if m_build_done is set. 00195 // You must set this build if you calls build directly, else build will be 00196 // called again. 00197 // 00198 // Note: the post_new, export_connections, import_connections, and pre_run 00199 // phases are deprecated. build replaces post_new, connect replace both 00200 // import_ and export_connections, and start_of_simulation replaces pre_run. 00201 // 00202 //---------------------------------------------------------------------------- 00203 00204 extern virtual function void build (); 00205 extern virtual function void connect (); 00206 extern virtual function void configure (); 00207 extern virtual function void end_of_elaboration (); 00208 extern virtual function void start_of_simulation (); 00209 extern virtual function void extract (); 00210 extern virtual function void check (); 00211 extern virtual function void report (); 00212 extern virtual function void resolve_bindings (); 00213 extern function void do_resolve_bindings (); 00214 00215 extern virtual function void do_kill_all (); 00216 00217 extern function void do_flush(); 00218 extern virtual function void flush (); 00219 00220 extern virtual task stop (string ph_name); // no arg? 00221 00222 extern virtual function void do_func_phase(ovm_phase phase); 00223 00224 ovm_phase m_curr_phase=null; 00225 protected int enable_stop_interrupt = 0; 00226 00227 protected bit m_build_done=0; 00228 00229 //---------------------------------------------------------------------------- 00230 // Configuration 00231 //---------------------------------------------------------------------------- 00232 // Components can be designed to be user-configurable in terms of its 00233 // topology (the kind and number of children it has), mode of operation, and 00234 // run-time parameters (knobs). The configuration interface accommodates 00235 // this common need, allowing component composition and state to be modified 00236 // without having to derive new classes and new class hierarchies for 00237 // every configuration scenario. 00238 // 00239 // 00240 // set_config_* 00241 // Calling set_config_* causes configuration settings to be created and 00242 // placed in a table internal to this component. There are similar global 00243 // methods that store settings in a global table. Each setting stores the 00244 // supplied inst_name, field_name, and value for later use by descendent 00245 // components during their construction. (The global table applies to 00246 // all components.) 00247 // 00248 // get_config_* 00249 // When a descendant component calls a get_config_* method, the inst_name 00250 // and field_name provided in the get call are matched against all the 00251 // configuration settings stored in the global table and then in each 00252 // component in the parent hierarchy, top-down. Upon the first match, 00253 // the value stored in the configuration setting is returned. Thus, 00254 // precedence is global, following by the top-level component, and so on 00255 // down to the descendent component's parent. If a get_config_* all 00256 // succeeds in finding a setting for the given inst_name and field_name, 00257 // the output value is assigned the value from the original set_config_* 00258 // call and 1 returned, else 0 is returned. 00259 // 00260 // The clone bit clones the data inbound. The get_config_object method can 00261 // also clone the data outbound. 00262 // 00263 // apply_config_settings 00264 // Searches for all config settings matching this component's instance path. 00265 // For each match, the appropriate set_*_local method is called using the 00266 // matching config setting's field_name and value. Provided the set_*_local 00267 // method is implemented, the component property associated with the 00268 // field_name is assigned the given value. 00269 // 00270 // print_config_settings 00271 // Used for debugging configuration settings, this routine prints the list 00272 // of settings that apply to this component. The settings are printing in 00273 // the order of their precedence. A null comp argument causes this 00274 // component's settings to be printed. An empty field argument means show 00275 // all matches for this component, i.e. all fields. The recurse argument 00276 // indicate to print config from comp (or this component) and below. 00277 // 00278 // static bit print_config_matches 00279 // Setting this static variable causes get_config_* to print info about 00280 // matching configuration settings as they are being applied. 00281 // 00282 // REVIEW: print_config_matches should work with apply_config_settings as well 00283 // should not be in ovm_component? What if in ovm_root as non-static? 00284 //---------------------------------------------------------------------------- 00285 00286 extern virtual function void set_config_int (string inst_name, 00287 string field_name, 00288 ovm_bitstream_t value); 00289 00290 00291 extern virtual function void set_config_object (string inst_name, 00292 string field_name, 00293 ovm_object value, 00294 bit clone=1); 00295 00296 extern virtual function void set_config_string (string inst_name, 00297 string field_name, 00298 string value); 00299 00300 extern virtual function bit get_config_int (string field_name, 00301 inout ovm_bitstream_t value); 00302 00303 extern virtual function bit get_config_object (string field_name, 00304 inout ovm_object value, 00305 input bit clone=1); 00306 00307 extern virtual function bit get_config_string (string field_name, 00308 inout string value); 00309 00310 extern virtual function void apply_config_settings (bit verbose=0); 00311 00312 extern function void print_config_settings (string field="", 00313 ovm_component comp=null, 00314 bit recurse=0); 00315 static bit print_config_matches = 0; 00316 protected ovm_config_setting m_configuration_table[$]; 00317 00318 00319 //---------------------------------------------------------------------------- 00320 // Factory 00321 //---------------------------------------------------------------------------- 00322 // The factory interface provides components convenient access to the OVM's 00323 // central ovm_factory object. The create_*, set_*, and print_override_info 00324 // methods call the corresponding method in ovm_factory, passing what 00325 // arguments it can to reduce the number of arguments required of the user. 00326 // 00327 // create/clone 00328 // The create and clone methods from the ovm_object base class are disabled 00329 // for components. Components are instead created via the ovm_factory. 00330 //---------------------------------------------------------------------------- 00331 00332 00333 extern function ovm_component create_component (string type_name, 00334 string inst_name); 00335 00336 extern function ovm_object create_object (string type_name, 00337 string name=""); 00338 00339 extern static function void set_type_override(string override_type, 00340 string type_name, 00341 bit replace=1); 00342 00343 extern function void set_inst_override(string inst_path, 00344 string override_type, 00345 string type_name); 00346 00347 extern function void print_override_info (string type_name, 00348 string inst_name=""); 00349 00350 // overridden to disable 00351 extern virtual function ovm_object create (string name=""); 00352 extern virtual function ovm_object clone (); 00353 00354 00355 //---------------------------------------------------------------------------- 00356 // Hierarchical Reporting 00357 //---------------------------------------------------------------------------- 00358 // This interface provides versions of the set_report_* methods in 00359 // the ovm_report_object base class that are applied recursively 00360 // to this component and all its children. 00361 // 00362 // set_report_*_action_hier 00363 // These methods recursively associate the specified action 00364 // with reports of the given severity, id, or severity-id pair. An 00365 // action associated with a particular severity-id pair takes 00366 // precedence over an action associated with id, which take 00367 // precedence over an an action associated with a severity. 00368 // 00369 // set_report_*_file_hier 00370 // These methods recursively associate the specified FILE 00371 // descriptor with reports of the given severity, id, or severity-id 00372 // pair. A FILE associated with a particular severity-id pair takes 00373 // precedence over a FILE associated with id, which take precedence 00374 // over an a FILE associated with a severity, which takes precedence 00375 // over the default FILE descriptor. 00376 // 00377 // set_report_verbosity_level_hier 00378 // This method recursively sets the maximum verbosity 00379 // level for reports for this component and all those below it. 00380 // Any report from this component subtree whose verbosity exceeds 00381 // this maximum will be ignored. 00382 // 00383 // When a report is issued and its associated action has the LOG bit 00384 // set, the report will be sent to its associated FILE descriptor. 00385 //---------------------------------------------------------------------------- 00386 00387 extern function void set_report_severity_action_hier (ovm_severity s, 00388 ovm_action a); 00389 00390 extern function void set_report_id_action_hier (string id, 00391 ovm_action a); 00392 00393 extern function void set_report_severity_id_action_hier(ovm_severity s, 00394 string id, 00395 ovm_action a); 00396 00397 extern function void set_report_default_file_hier (OVM_FILE f); 00398 00399 extern function void set_report_severity_file_hier (ovm_severity s, 00400 OVM_FILE f); 00401 00402 extern function void set_report_id_file_hier (string id, 00403 OVM_FILE f); 00404 00405 extern function void set_report_severity_id_file_hier(ovm_severity s, 00406 string id, 00407 OVM_FILE f); 00408 00409 extern function void set_report_verbosity_level_hier (int v); 00410 00411 00412 //---------------------------------------------------------------------------- 00413 // Recording 00414 //---------------------------------------------------------------------------- 00415 // These methods comprise the component-based transaction recording 00416 // interface. The methods can be used to record the transactions that 00417 // this component "sees", i.e. produces or consumes. 00418 // 00419 // NOTE: The API and implementation are subject to change once a 00420 // vendor-independent use-model is determined. 00421 //---------------------------------------------------------------------------- 00422 00423 extern protected 00424 function integer m_begin_tr (ovm_transaction tr, 00425 integer parent_handle=0, 00426 bit has_parent=0, 00427 string stream_name="main", 00428 string label="", 00429 string desc="", 00430 time begin_time=0); 00431 00432 extern function void accept_tr (ovm_transaction tr, 00433 time accept_time=0); 00434 00435 extern function integer begin_tr (ovm_transaction tr, 00436 string stream_name="main", 00437 string label="", 00438 string desc="", 00439 time begin_time=0); 00440 00441 extern function integer begin_child_tr (ovm_transaction tr, 00442 integer parent_handle=0, 00443 string stream_name="main", 00444 string label="", 00445 string desc="", 00446 time begin_time=0); 00447 00448 extern function void end_tr (ovm_transaction tr, 00449 time end_time=0, 00450 bit free_handle=1); 00451 00452 extern function integer record_error_tr 00453 (string stream_name="main", 00454 ovm_object info=null, 00455 string label="error_tr", 00456 string desc="", 00457 time error_time=0, 00458 bit keep_active=0); 00459 00460 extern function integer record_event_tr 00461 (string stream_name="main", 00462 ovm_object info=null, 00463 string label="event_tr", 00464 string desc="", 00465 time event_time=0, 00466 bit keep_active=0); 00467 extern virtual protected 00468 function void do_accept_tr(ovm_transaction tr); 00469 00470 extern virtual protected 00471 function void do_begin_tr(ovm_transaction tr, 00472 string stream_name, 00473 integer tr_handle); 00474 00475 extern virtual protected 00476 function void do_end_tr (ovm_transaction tr, 00477 integer tr_handle); 00478 00479 protected ovm_event_pool event_pool; 00480 00481 00482 //---------------------------------------------------------------------------- 00483 // PRIVATE or PSUEDO-PRIVATE members 00484 // *** Do not call directly *** 00485 // Implementation and even existence are subject to change. 00486 //---------------------------------------------------------------------------- 00487 // Most local methods are prefixed with m_, indicating they are not 00488 // user-level methods. SystemVerilog does not support friend classes, 00489 // which forces some otherwise internal methods to be exposed (i.e. not 00490 // be protected via 'local' keyword). These methods are also prefixed 00491 // with m_ to indicate they are not intended for public use. 00492 // 00493 // Internal methods will not be documented, although their implementa- 00494 // tions are freely available via the open-source license. 00495 //---------------------------------------------------------------------------- 00496 00497 extern virtual local function void m_set_full_name (); 00498 00499 extern local function void m_extract_name(string name , 00500 output string leaf , 00501 output string remainder ); 00502 local static bit m_phases_loaded = 0; 00503 00504 local integer m_stream_handle[string]; 00505 local integer m_tr_h[ovm_transaction]; 00506 00507 extern virtual function bit m_add_child (ovm_component child); 00508 00509 /*local*/ string m_name; // hierarchical name 00510 00511 00512 //---------------------------------------------------------------------------- 00513 // DEPRECATED MEMBERS 00514 // *** Do not use in new code *** 00515 // Convert existing code when appropriate. 00516 //---------------------------------------------------------------------------- 00517 // Deprecated static methods: 00518 // 00519 // global_stop_request 00520 // replaced by ovm_top.stop_request 00521 // 00522 // Deprecated phases: 00523 // 00524 // post_new 00525 // replaced by build (top-down) 00526 // 00527 // import/export_connections 00528 // Consolidated into the connect phase; deferred binding enforcement 00529 // via resolve_bindings allows connections to be order-independent 00530 // 00531 // pre_run 00532 // replaced by start_of_simulation 00533 //---------------------------------------------------------------------------- 00534 00535 extern static function void global_stop_request(); 00536 00537 extern virtual function void post_new (); 00538 extern virtual function void import_connections (); 00539 extern virtual function void export_connections (); 00540 extern virtual function void pre_run (); 00541 00542 00543 extern virtual function void check_connection_size (); 00544 extern local function void build_debug_lists(); 00545 extern virtual protected 00546 function void add_to_debug_list(); 00547 00548 extern virtual function void do_display (int max_level = -1 , 00549 int level = 0 , 00550 bit display_connectors = 0); 00551 00552 extern function ovm_component absolute_lookup (string name); 00553 extern function ovm_component relative_lookup (string name); 00554 00555 extern static function ovm_component find_component (string comp_match); 00556 extern static function void find_components (string comp_match, 00557 ref ovm_component comps[$]); 00558 extern static function ovm_component get_component (int ele); 00559 extern static function int get_num_components (); 00560 00561 00562 // member data 00563 static ovm_env m_env; 00564 00565 protected ovm_component m_components[string]; 00566 protected ovm_component m_ports[string]; 00567 protected ovm_component m_exports[string]; 00568 protected ovm_component m_implementations[string]; 00569 bit m_is_removed = 0; 00570 bit print_enabled = 1; 00571 00572 `include "compatibility/urm_message_compatibility.svh" 00573 00574 00575 endclass : ovm_component 00576 00577 00578 `endif // OVM_COMPONENT_SVH 00579
![]() Intelligent Design Verification Project: OVM, Revision: 1.1.0 |
Copyright (c) 2008 Intelligent Design Verification. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included here: http://www.intelligentdv.com/licenses/fdl.txt |
![]() Doxygen Version: 1.4.6 Mon Sep 29 14:20:12 2008 |