ovm_component.svh

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

Intelligent Design Verification
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
Doxygen Version: 1.4.6
Mon Sep 29 14:23:29 2008
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV