VMM - (expanded) std_lib/vmm.sv

Expanded versions of source files are the output of the preprocessor. Lines subject to conditional compilation are not shown and all compiler pragmas have been stripped. Macros have been completely expanded.

std_lib/vmm.sv unexpanded source

00001: // 
00002: // -------------------------------------------------------------
00003: //    Copyright 2004-2008 Synopsys, Inc.
00004: //    All Rights Reserved Worldwide
00005: // 
00006: //    Licensed under the Apache License, Version 2.0 (the
00007: //    "License"); you may not use this file except in
00008: //    compliance with the License.  You may obtain a copy of
00009: //    the License at
00010: // 
00011: //        http://www.apache.org/licenses/LICENSE-2.0
00012: // 
00013: //    Unless required by applicable law or agreed to in
00014: //    writing, software distributed under the License is
00015: //    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00016: //    CONDITIONS OF ANY KIND, either express or implied.  See
00017: //    the License for the specific language governing
00018: //    permissions and limitations under the License.
00019: // -------------------------------------------------------------
00020: //
00021: 
00022: `define VMM_DOSFILE_CHECK If you get a syntax error on this line, \
00023:         the file is corrupt. Make sure you unpack the VMM distribution \
00024:         file with gunzip then tar, not a Windows tool
     : 
00025: 
00026: //
00027: // If you wish to use the parameterized classes version of vmm_channel
00028: // (requires VCS 2008.03 or later), the symbol `VMM_PARAM_CHANNEL must
00029: //  be defined
00030: 
00031: 
00032: 
00033: 
00034: //---------------------------------------------------------------------
00035: // Enable temporary work-arounds for features not yet implemented
00036: //
00040: 
00041: 
00042: //---------------------------------------------------------------------
00043: // Functionality that must be provided through DPI/System tasks
00044: //
00045: 
00047: `define VMM_DPI_
00048: 
00049: //
00050: // $sformatf()
00051: //
00052: // SV-2008 feature that may not be available. $sformat() could be used but
00053: // with lower performance as formatted strings would be always created even
00054: // if never used.
00055: //
00056: // VCS provides a precursor called $psprintf()
00057: //
00059: `define vmm_sformatf $psprintf
     : 
00061: 
00062: //
00063: // String-matching pseudo methods.
00064: //
00065: // Those are built-in VCS and may eventually be part of a revision of the
00066: // SV standard. In the meantime, they can be provided by DPI functions or
00067: // their functionality be disabled. These DPIs are provided by the file
00068: // $VMM_HOME/sv/std_lib/vmm_str_dpi.c
00069: //
00070: // Currently, they are used in vmm_log for name and instance name matching
00071: // and in the XVCs for command parsing and interpretation.
00072: //
00073: 
00074: 
00082: 
00091: 
00092: import "DPI-C" function int vmm_str_match(input string str1, input string regex);
00093: import "DPI-C" function string vmm_str_prematch();
00094: import "DPI-C" function string vmm_str_postmatch();
00095: import "DPI-C" function string vmm_str_backref(int n);
00096: 
00097: `define vmm_str_match(str, regex) vmm_str_match(str, regex)
     : 
00098: `define vmm_str_prematch(str)     vmm_str_prematch()
     : 
00099: `define vmm_str_postmatch(str)    vmm_str_postmatch()
     : 
00100: `define vmm_str_backref(str, n)   vmm_str_backref(n+1)
     : 
00101: 
00103: 
00105: 
00106: 
00108: 
00109: 
00110: //
00111: // The macros must be defined in a separate guard block to enable
00112: // separate compilation because `define symbols are compilation symbols,
00113: // not SV symbols that end up in the VMM package
00114: //
00115: 
00117: `define VMM_MACRO_DEFINED
00118:   
00119: 
00120: //---------------------------------------------------------------------
00121: // User customization macros
00122: //
00123: 
00124: 
00128: 
00129: 
00131:    `define VMM_DATA                 vmm_data
     : 
00134:    `define VMM_DATA_NEW_ARGS
00135:    `define VMM_DATA_NEW_EXTERN_ARGS
00136:    `define VMM_DATA_NEW_CALL
00139:    `define VMM_DATA_BASE_NEW_ARGS
00140:    `define VMM_DATA_BASE_NEW_EXTERN_ARGS
00148:    `define VMM_DATA_BASE_METHODS
00150: 
00152:    `define VMM_CHANNEL                vmm_channel
     : 
00160:    `define VMM_CHANNEL_BASE_METHODS
00162: 
00164:    `define VMM_CONSENSUS                vmm_consensus
     : 
00172:    `define VMM_CONSENSUS_BASE_METHODS
00174: 
00176:    `define VMM_LOG                 vmm_log
     : 
00184:    `define VMM_LOG_BASE_METHODS
00186: 
00188:    `define VMM_NOTIFY                 vmm_notify
     : 
00196:    `define VMM_NOTIFY_BASE_METHODS
00198: 
00200:    `define VMM_XACTOR                 vmm_xactor
     : 
00203:    `define VMM_XACTOR_NEW_ARGS
00204:    `define VMM_XACTOR_NEW_EXTERN_ARGS
00205:    `define VMM_XACTOR_NEW_CALL
00208:    `define VMM_XACTOR_BASE_NEW_ARGS
00209:    `define VMM_XACTOR_BASE_NEW_EXTERN_ARGS
00217:    `define VMM_XACTOR_BASE_METHODS
00219: 
00221:    `define VMM_SUBENV                 vmm_subenv
     : 
00224:    `define VMM_SUBENV_NEW_ARGS
00225:    `define VMM_SUBENV_NEW_EXTERN_ARGS
00226:    `define VMM_SUBENV_NEW_CALL
00229:    `define VMM_SUBENV_BASE_NEW_ARGS
00230:    `define VMM_SUBENV_BASE_NEW_EXTERN_ARGS
00238:    `define VMM_SUBENV_BASE_METHODS
00240: 
00242:    `define VMM_ENV                 vmm_env
     : 
00245:    `define VMM_ENV_NEW_ARGS
00246:    `define VMM_ENV_NEW_EXTERN_ARGS
00247:    `define VMM_ENV_NEW_CALL
00250:    `define VMM_ENV_BASE_NEW_ARGS
00251:    `define VMM_ENV_BASE_NEW_EXTERN_ARGS
00259:    `define VMM_ENV_BASE_METHODS
00261: 
00262: 
00263: 
00264: //---------------------------------------------------------------------
00265: // vmm_log ease-of-use macros
00266: //
00267: 
00268: `define vmm_warning(log, msg)  \
00269: do \
00270:    if (log.start_msg(vmm_log::FAILURE_TYP, vmm_log::WARNING_SEV)) begin \
00271:       void'(log.text(msg)); \
00272:       log.end_msg(); \
00273:    end \
00274: while(0)
     : 
00275: 
00276: `define vmm_error(log, msg)  \
00277: do \
00278:    if (log.start_msg(vmm_log::FAILURE_TYP, vmm_log::ERROR_SEV)) begin \
00279:       void'(log.text(msg)); \
00280:       log.end_msg(); \
00281:    end \
00282: while (0)
     : 
00283: 
00284: `define vmm_fatal(log, msg)  \
00285: do \
00286:    if (log.start_msg(vmm_log::FAILURE_TYP, vmm_log::FATAL_SEV)) begin \
00287:       void'(log.text(msg)); \
00288:       log.end_msg(); \
00289:    end \
00290: while (0)
     : 
00291: 
00292: //
00293: // If it is necessary to compile-out debug messages to gain every
00294: // milligram of performance, defining this macro will take them out.
00295: //
00296: 
00311: 
00312: `define vmm_trace(log, msg)  \
00313: do \
00314:    if (log.start_msg(vmm_log::DEBUG_TYP, vmm_log::TRACE_SEV)) begin \
00315:       void'(log.text(msg)); \
00316:       log.end_msg(); \
00317:    end \
00318: while (0)
     : 
00319: 
00320: `define vmm_debug(log, msg)  \
00321: do \
00322:    if (log.start_msg(vmm_log::DEBUG_TYP, vmm_log::DEBUG_SEV)) begin \
00323:       void'(log.text(msg)); \
00324:       log.end_msg(); \
00325:    end \
00326: while (0)
     : 
00327: 
00328: `define vmm_verbose(log, msg)  \
00329: do \
00330:    if (log.start_msg(vmm_log::DEBUG_TYP, vmm_log::VERBOSE_SEV)) begin \
00331:       void'(log.text(msg)); \
00332:       log.end_msg(); \
00333:    end \
00334: while (0)
     : 
00335: 
00336: `define vmm_note(log, msg)  \
00337: do \
00338:    if (log.start_msg(vmm_log::NOTE_TYP)) begin \
00339:       void'(log.text(msg)); \
00340:       log.end_msg(); \
00341:    end \
00342: while (0)
     : 
00343: 
00344: `define vmm_report(log, msg)  \
00345: do \
00346:    if (log.start_msg(vmm_log::REPORT_TYP)) begin \
00347:       void'(log.text(msg)); \
00348:       log.end_msg(); \
00349:    end \
00350: while (0)
     : 
00351: 
00352: `define vmm_command(log, msg)  \
00353: do \
00354:    if (log.start_msg(vmm_log::COMMAND_TYP)) begin \
00355:       void'(log.text(msg)); \
00356:       log.end_msg(); \
00357:    end \
00358: while (0)
     : 
00359: 
00360: `define vmm_protocol(log, msg)  \
00361: do \
00362:    if (log.start_msg(vmm_log::PROTOCOL_TYP)) begin \
00363:       void'(log.text(msg)); \
00364:       log.end_msg(); \
00365:    end \
00366: while (0)
     : 
00367: 
00368: `define vmm_transaction(log, msg)  \
00369: do \
00370:    if (log.start_msg(vmm_log::TRANSACTION_TYP)) begin \
00371:       void'(log.text(msg)); \
00372:       log.end_msg(); \
00373:    end \
00374: while (0)
     : 
00375: 
00376: `define vmm_cycle(log, msg)  \
00377: do \
00378:    if (log.start_msg(vmm_log::CYCLE_TYP)) begin \
00379:       void'(log.text(msg)); \
00380:       log.end_msg(); \
00381:    end \
00382: while (0)
     : 
00383: 
00384: `define vmm_user(n, log, msg)  \
00385: do \
00386:    if (log.start_msg(vmm_log::USER_TYP_``n)) begin \
00387:       void'(log.text(msg)); \
00388:       log.end_msg(); \
00389:    end \
00390: while (0)
     : 
00391: 
00393: 
00394: 
00395: 
00396: //---------------------------------------------------------------------
00397: // Transactor callback ease-of-invocation macro
00398: //
00399: 
00400: `define vmm_callback(facade, call) \
00401:  \
00402: do foreach (this.callbacks[vmm_i]) begin \
00403:    facade cb; \
00404:    if (!$cast(cb, this.callbacks[vmm_i])) continue; \
00405:  \
00406:    cb.call; \
00407: end while (0)
     : 
00408: 
00409: 
00410: 
00411: //---------------------------------------------------------------------
00412: // Other macros
00413: //
00414: 
00416: 
00417: 
00423: 
00424: `define vmm_channel_(T) T``_channel
     : 
00425: 
00426: `define vmm_channel(T) \
00427: class `vmm_channel_(T) extends vmm_channel; \
00428:  \
00429:    function new(string name, \
00430:                 string inst, \
00431:                 int    full = 1, \
00432:                 int    empty = 0, \
00433:                 bit    fill_as_bytes = 0); \
00434:       super.new(name, inst, full, empty, fill_as_bytes); \
00435:    endfunction: new \
00436:  \
00437:    function T unput(int offset = -1); \
00438:       $cast(unput, super.unput(offset)); \
00439:    endfunction: unput \
00440:  \
00441:    task get(output T obj, input int offset = 0); \
00442:       vmm_data o; \
00443:       super.get(o, offset); \
00444:       $cast(obj, o); \
00445:    endtask: get \
00446:  \
00447:    task peek(output T obj, input int offset = 0); \
00448:       vmm_data o; \
00449:       super.peek(o, offset); \
00450:       $cast(obj, o); \
00451:    endtask: peek \
00452:  \
00453:    task activate(output T obj, input int offset = 0); \
00454:       vmm_data o; \
00455:       super.activate(o, offset); \
00456:       $cast(obj, o); \
00457:    endtask: activate \
00458:  \
00459:    function T active_slot(); \
00460:       $cast(active_slot, super.active_slot()); \
00461:    endfunction: active_slot \
00462:  \
00463:    function T start(); \
00464:       $cast(start, super.start()); \
00465:    endfunction: start \
00466:  \
00467:    function T complete(vmm_data status = null); \
00468:       $cast(complete, super.complete(status)); \
00469:    endfunction: complete \
00470:  \
00471:    function T remove(); \
00472:       $cast(remove, super.remove()); \
00473:    endfunction: remove \
00474:  \
00475:    task tee(output T obj); \
00476:       vmm_data o; \
00477:       super.tee(o); \
00478:       $cast(obj, o); \
00479:    endtask: tee \
00480:  \
00481:    function T for_each(bit reset = 0); \
00482:       $cast(for_each, super.for_each(reset)); \
00483:    endfunction: for_each \
00484: endclass
     : 
00485: 
00487: 
00490: 
00491: 
00492: 
00493: 
00494: 
00496: 
00497: 
00498: //
00499: // Protect against multiple inclusion of this file
00500: //
00502: `define VMM__SV
00503: 
00504: 
00513: 
00514: 
00515: 
00516: //---------------------------------------------------------------------
00517: // vmm_version
00518: //
00519: 
00523: class vmm_version;
00524:    extern function int major();
00525:    extern function int minor();
00526:    extern function int patch();
00527:    extern function string vendor();
00528: 
00529:    extern function void   display(string prefix = "");
00530:    extern function string psdisplay(string prefix = "");
00531:    extern function void   cfdisplay(string prefix = "");
00532: endclass: vmm_version
00533: 
00534: 
00535: 
00536: //---------------------------------------------------------------------
00537: // Forward declarations
00538: //
00539: 
00540: typedef class vmm_log;
00541: typedef class vmm_data;
00542: typedef class vmm_xactor;
00543: typedef class vmm_notify;
00544: 
00545: 
00546: typedef class vmm_data;
00562: typedef class vmm_xactor;
00566: typedef class vmm_subenv;
00570: typedef class vmm_env;
00574: 
00575: 
00579: 
00580: 
00581: //---------------------------------------------------------------------
00582: // vmm_log
00583: //
00584: 
00588: class vmm_log_format;
00589:    extern virtual function string format_msg(string name,
00590:                                              string inst,
00591:                                              string msg_typ,
00592:                                              string severity,
00593:                                              ref string lines[$]);
00594: 
00595:    extern virtual function string continue_msg(string name,
00596:                                                string inst,
00597:                                                string msg_typ,
00598:                                                string severity,
00599:                                                ref string lines[$]);
00600: 
00601:    extern virtual function string abort_on_error(int count,
00602:                                                  int limit);
00603: 
00604:    extern virtual function string pass_or_fail(bit    pass,
00605:                                                string name,
00606:                                                string inst,
00607:                                                int    fatals,
00608:                                                int    errors,
00609:                                                int    warnings,
00610:                                                int    dem_errs,
00611:                                                int    dem_warns);
00612: endclass: vmm_log_format
00613: 
00614: 
00618: class vmm_log_callbacks;
00619:    virtual function void pre_abort(vmm_log log);
00620:    endfunction
00621: 
00622:    virtual function void pre_stop(vmm_log log);
00623:    endfunction
00624: 
00625:    virtual function void pre_debug(vmm_log log);
00626:    endfunction
00627: endclass: vmm_log_callbacks
00628: 
00629: 
00630: typedef class vmm_log_below_iter;
00631: typedef class vmm_log_msg;
00632: typedef class vmm_log_modifier;
00633: typedef class vmm_log_watchpoint;
00634: 
00638: class vmm_log
00642: ;
00643: 
00644:    //
00645:    // Symbolic constants shared by different contexts
00646:    //
00647:    typedef enum int {DEFAULT
00648:                      = -1
00649:                      , UNCHANGED
00650:                      = -2
00651:                      } symbols_e;
00652: 
00653:    //
00654:    // Symbolic constants for message types
00655:    //
00656:    typedef enum int {FAILURE_TYP     = 'h0001,
00657:                      NOTE_TYP        = 'h0002,
00658:                      DEBUG_TYP       = 'h0004,
00659:                      REPORT_TYP      = 'h0008,
00660:                      NOTIFY_TYP      = 'h0010,
00661:                      TIMING_TYP      = 'h0020,
00662:                      XHANDLING_TYP   = 'h0040,
00663:                      PROTOCOL_TYP    = 'h0080,
00664:                      TRANSACTION_TYP = 'h0100,
00665:                      COMMAND_TYP     = 'h0200,
00666:                      CYCLE_TYP       = 'h0400,
00667:                      USER_TYP_0      = 'h0800,
00668:                      USER_TYP_1      = 'h1000,
00669:                      USER_TYP_2      = 'h2000,
00670:                      INTERNAL_TYP    = 'h4000,
00671:                      DEFAULT_TYP     = -1,
00672:                      ALL_TYPS        = 'hFFFF
00673:                      } types_e;
00674: 
00675:    //
00676:    // Symbolic values for message severity
00677:    //
00678:    typedef enum int {FATAL_SEV   = 'h0001,
00679:                      ERROR_SEV   = 'h0002,
00680:                      WARNING_SEV = 'h0004,
00681:                      NORMAL_SEV  = 'h0008,
00682:                      TRACE_SEV   = 'h0010,
00683:                      DEBUG_SEV   = 'h0020,
00684:                      VERBOSE_SEV = 'h0040,
00685:                      HIDDEN_SEV  = 'h0080,
00686:                      IGNORE_SEV  = 'h0100,
00687:                      DEFAULT_SEV = -1,
00688:                      ALL_SEVS    = 'hFFFF
00689:                      } severities_e;
00690: 
00691:    //
00692:    // Symbolic values for simulation handling
00693:    //
00694:    typedef enum int {CONTINUE         = 'h0001,
00695:                      COUNT_ERROR      = 'h0002,
00696:                      DEBUGGER         = 'h0004,
00697:                      DUMP_STACK       = 'h0008,
00698:                      STOP_PROMPT      = 'h0010,
00699:                      ABORT_SIM        = 'h0020,
00700:                      IGNORE           = 'h0040,
00701:                      DEFAULT_HANDLING = -1
00702:                      } handling_e;
00703: 
00704:    //
00705:    // Pre-defined STDOUT in case the simulator does not already define it
00706:    //
00707:    typedef enum int {STDOUT = 32'h8000_0001} stdout_e;
00708:    
00709:    //
00710:    // Global control parameters
00711:    //
00712:    static local int    error_count = 0;     // Stop when # of errs
00713:    static local int    error_limit = 10;    // Stop when # of errs
00714:    static local string msg_format[$];
00715:    static local string prefix;
00716:    
00717:    //
00718:    // Local control parameters
00719:    //
00720:    static local int dflt_lvl  = NORMAL_SEV; // Default verbosity level
00721:    static local int force_lvl = DEFAULT_SEV; // Forced (global) verbosity level
00722:    static local bit plus_debug;     // +vmm_log_debug was specified!
00723: 
00724:    local string  name;            // Name for this object
00725:    local string  inst;            // Instance name for this object
00726: 
00727:    local int n_msg[*];            // # of messages, per severities 
00728:    local int n_demoted[*];        // # of demoted messages 
00729: 
00730:    //
00731:    // Partial message
00732:    //
00733:    local vmm_log_msg msg;
00734:    local string  msg_txt[$];
00735: 
00736:    static local int    type_list[$];
00737:    static local string type_images[*];
00738: 
00739:    static local int    sev_list[$];
00740:    static local string sev_images[*];
00741: 
00742:    static local vmm_log_modifier modifier_cache[*];
00743:           local int modifier_ids[$];
00744:           local int has_text_modifiers;
00745: 
00746:    static local vmm_log_watchpoint watchpoint_cache[*];
00747:           local int watchpoint_ids[$];
00748: 
00749:           local int enabled_typs;  // Filter if type not enableds
00750:           local int log_lvl;       // Filter trace messages > log_lvl
00751: 
00752:    //
00753:    // Callbacks are global to all instances
00754:    //
00755:    static local vmm_log_format fmt = new;
00756:    static local int in_callbacks = 0;
00757:    static local vmm_log_callbacks callbacks[$];
00758: 
00759:    //
00760:    // File logging
00761:    //
00762:    local int fp[$];
00763:    
00764:    //
00765:    // Iterator
00766:    //
00767:    local int             is_self;  // Trivial iterator?
00768:    local bit             is_all;   // Trivial iterator?
00769:    static local vmm_log  known[$]; // List of known logs
00770: 
00771:       /*local*/ vmm_log  below[$]; // Known logs below this one
00772:    static local int      recurse_id = 0;
00773:           local int      visited    = 0;
00774: 
00775:    static local string pattern[2];
00776:    static local bit    is_pattern[2];
00777:    static local int    known_idx = 0;
00778:    static local int    recurse;
00779:    static local vmm_log_below_iter recurse_stack[$];
00780:    
00782:    
00784: 
00785:    extern function new(string name,
00786:                        string inst,
00787:                        vmm_log under = null);
00788:       
00789:    extern virtual function void is_above(vmm_log log);
00790:    extern virtual function vmm_log copy(vmm_log to = null);
00791: 
00792:    extern virtual function void set_name(string name);
00793:    extern virtual function string get_name();
00794:    extern virtual function void set_instance(string inst);
00795:    extern virtual function string get_instance();
00796: 
00797:    extern function void reset(string name    = "/./",
00798:                               string inst    = "/./",
00799:                               bit    recurse = 0);
00800:    extern function vmm_log for_each();
00801:    extern virtual function void list(string name     = "/./",
00802:                                      string inst     = "/./",
00803:                                      bit    recurse  = 0);
00804: 
00805:    extern virtual function void display(string prefix = "");
00806:    extern virtual function string psdisplay(string prefix = "");
00807: 
00808:    extern virtual function void kill();
00809: 
00810:    //
00811:    // Formatting
00812:    //
00813:    extern virtual function vmm_log_format set_format(vmm_log_format fmt);
00814:    extern virtual function string set_typ_image(int typ, string  image);
00815:    extern virtual function string set_sev_image(int severity, string  image);
00816: 
00817:    extern /*local*/ function string typ_image(int typ);
00818:    extern /*local*/ function string sev_image(int severity);
00819:    extern /*local*/ function string handling_image(int handling);
00820:    extern local function int default_handling(int severity);
00821:       
00822:    extern virtual function void report(string name     = "/./",
00823:                                        string inst     = "/./",
00824:                                        bit    recurse  = 0);
00825:       
00826: 
00827:    //
00828:    // Issue messages
00829:    //
00830:    extern virtual function bit start_msg(int typ,
00831:                                          int severity = DEFAULT_SEV);
00832: 
00833:    extern virtual function bit text(string msg = "");
00834:    extern virtual function void end_msg();
00835:    extern local function void flush_msg();
00836: 
00837:    //
00838:    // Message management
00839:    //
00840:    extern virtual function void enable_types(int     typs,
00841:                                              string  name      = "",
00842:                                              string  inst      = "",
00843:                                              bit     recursive = 0);
00844:    extern virtual function void disable_types(int     typs,
00845:                                               string  name      = "",
00846:                                               string  inst      = "",
00847:                                               bit     recursive = 0);
00848:    extern virtual function int modify(string name         = "",
00849:                                       string inst         = "",
00850:                                       bit    recursive    = 0,
00851:                                       int    typ          = ALL_TYPS,
00852:                                       int    severity     = ALL_SEVS,
00853:                                       string text         = "",
00854:                                       int    new_typ      = UNCHANGED,
00855:                                       int    new_severity = UNCHANGED,
00856:                                       int    handling     = UNCHANGED);
00857:    extern virtual function void unmodify(int    modification_id = -1,
00858:                                          string name            = "",
00859:                                          string inst            = "",
00860:                                          bit    recursive       = 0);
00861: 
00862:    extern local function void promote();
00863:    extern local function void filter();
00864:    extern local function void notify();
00865: 
00866:    extern virtual function void set_verbosity(int    severity,
00867:                                               string name      = "",
00868:                                               string inst      = "",
00869:                                               bit    recursive = 0);
00870:    extern function int get_verbosity();
00871: 
00872:    //
00873:    // File logging
00874:    //
00875:    extern virtual function void log_start(int    file,
00876:                                           string name    = "",
00877:                                           string inst    = "",
00878:                                           bit    recurse = 0);
00879:    extern virtual function void log_stop(int    file,
00880:                                          string name    = "",
00881:                                          string inst    = "",
00882:                                          bit    recurse = 0);
00883: 
00884:    
00885:    //
00886:    // Manage error counts
00887:    //
00888:    extern virtual function void stop_after_n_errors(int n);
00889:    extern virtual function int get_message_count(int    severity = ALL_SEVS,
00890:                                                  string name     = "",
00891:                                                  string inst     = "",
00892:                                                  bit    recurse  = 0);
00893: 
00894:    //
00895:    // Synchronize with messages
00896:    //
00897:    extern virtual task wait_for_msg(string name     = "",
00898:                                     string inst     = "",
00899:                                     bit    recurse  = 0,
00900:                                     int    typs     = ALL_TYPS,
00901:                                     int    severity = ALL_SEVS,
00902:                                     string text     = "",
00903:                                     logic  issued   = 1'bx,
00904:                                     ref vmm_log_msg msg);
00905: 
00906:    extern virtual function int create_watchpoint(int    typs     = ALL_TYPS,
00907:                                                  int    severity = ALL_SEVS,
00908:                                                  string text     = "",
00909:                                                  logic  issued   = 1'bx);
00910:    extern virtual function void add_watchpoint(int    watchpoint_id,
00911:                                                string name            = "",
00912:                                                string inst            = "",
00913:                                                bit    recurse         = 0);
00914:    extern virtual function void remove_watchpoint(int    watchpoint_id = -1,
00915:                                                   string name          = "",
00916:                                                   string inst          = "",
00917:                                                   bit    recurse       = 0);
00918:    extern virtual task wait_for_watchpoint(int             watchpoint_id,
00919:                                            ref vmm_log_msg msg);
00920: 
00921:    //
00922:    // Callback Management
00923:    //
00924:    extern virtual function void prepend_callback(vmm_log_callbacks cb);
00925:    extern virtual function void append_callback(vmm_log_callbacks cb);
00926:    extern virtual function void unregister_callback(vmm_log_callbacks cb);
00927: 
00928: 
00929:   
00930: 
00931: endclass: vmm_log
00932: 
00933: 
00944:          
00945: 
00946: //---------------------------------------------------------------------
00947: // vmm_notify
00948: //
00949: 
00953: virtual class vmm_notify_callbacks;
00954:    virtual function void indicated(vmm_data status);
00955:    endfunction
00956: endclass
00957: 
00961: virtual class vmm_notification;
00962:    virtual task indicate(ref vmm_data status);
00963:       $write("FATAL: An instance of vmm_notification::indicate() was not overloaded or super.indicate() was called\n");
00964:       $finish;
00965:    endtask
00966:    virtual task reset();
00967:       $write("FATAL: An instance of vmm_notification::reset() was not overloaded or super.reset() was called\n");
00968:       $finish;
00969:    endtask
00970: endclass
00971: 
00972: 
00973: typedef class vmm_notification_config;
00974: 
00975: 
00979: class vmm_notify
00983: ;
00984:    vmm_log log;
00985: 
00986:    typedef enum int {ONE_SHOT = 2,
00987:                      BLAST    = 3,
00988:                      ON_OFF   = 5
00989:                      } sync_e;
00990: 
00991:    typedef enum bit {SOFT,
00992:                      HARD} reset_e;
00993:  
00994: 
00995:    local int last_notification_id = 1000000;
00996:    local vmm_notification_config configs[*];
00997: 
00998:    extern function new(vmm_log log);
00999: 
01001:    
01003: 
01004:    extern virtual function void display(string prefix = "");
01005:    extern virtual function string psdisplay(string prefix = "");
01006:       
01007:    extern virtual function vmm_notify copy(vmm_notify to = null);
01008:    extern virtual function int configure(int notification_id = -1,
01009:         			         sync_e sync = ONE_SHOT);
01010:    extern virtual function int is_configured(int notification_id);
01011: 
01012:    extern virtual function bit is_on(int notification_id);
01013: 
01014:    extern virtual task wait_for(int notification_id);
01015:    extern virtual task wait_for_off(int notification_id);
01016:       
01017:    extern virtual function bit is_waited_for(int notification_id);
01018:    extern virtual function void terminated(int notification_id);
01019: 
01020:    extern virtual function vmm_data status(int notification_id);
01021:    extern virtual function time timestamp(int notification_id);
01022:    extern virtual function void indicate(int notification_id,
01023: 	            		         vmm_data status = null);
01024: 
01025:    extern virtual function void set_notification(int          notification_id,
01026:     				                 vmm_notification ntfy = null);
01027:    extern virtual function vmm_notification get_notification(int notification_id);
01028:    extern virtual function void reset(int     notification_id = -1,
01029:                                       reset_e rst_typ         = SOFT);
01030: 
01031:    extern function void append_callback(int                  notification_id,
01032:                                         vmm_notify_callbacks cbs);
01033:    extern function void unregister_callback(int                  notification_id,
01034:                                             vmm_notify_callbacks cbs);
01035: 
01036: 
01037: 
01038: 
01047: 
01048: endclass
01049: 
01050: 
01051: //---------------------------------------------------------------------
01052: // vmm_data
01053: //
01054: 
01058: class vmm_data
01062: ;
01063: 
01064:    local vmm_log log;
01065: 
01066:    int stream_id;
01067:    int scenario_id;
01068:    int data_id;
01069: 
01070:    vmm_notify notify;
01071:    typedef enum int {EXECUTE = 999_999,
01072:                      STARTED = 999_998,
01073:                      ENDED = 999_997
01074:                      } notifications_e;
01075: 
01076:    extern function new(vmm_log log
01077:                        );
01078: 
01080:    
01082: 
01083:    extern function vmm_log set_log(vmm_log log);
01084:    
01085:    extern function void display(string prefix = "");
01086:    extern virtual function string psdisplay(string prefix = "");
01087: 
01088:    extern virtual function bit is_valid(bit silent = 1,
01089:                                         int kind   = -1);
01090:    extern virtual function vmm_data allocate();
01091:    extern virtual function vmm_data copy(vmm_data to = null);
01092:    extern virtual protected function void copy_data(vmm_data to);
01093: 
01094:    extern virtual function bit compare(       vmm_data to,
01095:                                        output string   diff,
01096:                                        input  int      kind = -1);
01097: 
01098:    extern virtual function int unsigned byte_size(int kind = -1);
01099:    extern virtual function int unsigned max_byte_size(int kind = -1);
01100:    extern virtual function int unsigned byte_pack(ref   logic [7:0]  bytes[],
01101:                                                   input int unsigned offset = 0,
01102:                                                   input int          kind   = -1);
01103:    extern virtual function int unsigned byte_unpack(const ref logic [7:0] bytes[],
01104:                                                     input int unsigned    offset = 0,
01105:                                                     input int             len    = -1,
01106:                                                     input int             kind   = -1);
01107:    extern virtual function bit load(int file);
01108:    extern virtual function void save(int file);
01109: 
01110:    //
01111:    // Methods and members to support the short-hand macros
01112:    //
01113:    protected static string       __vmm_prefix;
01114:    protected static string       __vmm_image;
01115:    protected static vmm_data     __vmm_rhs;
01116:    protected static int          __vmm_kind;
01117:    protected static int          __vmm_offset;
01118:    protected static int          __vmm_len;
01119:    protected static bit [4095:0] __vmm_maxbits;
01120:    protected static bit          __vmm_status;
01121:    protected static logic  [7:0] __vmm_bytes[];
01122:    protected static bit          __vmm_done_user;
01123: 
01124:    typedef enum {DO_PRINT   ='h001,
01125:                  DO_COPY    ='h002,
01126:                  DO_COMPARE ='h004,
01127:                  DO_PACK    ='h010,
01128:                  DO_UNPACK  ='h020,
01129: 		 DO_ALL     ='hFFF} do_what_e;
01130: 
01131:    typedef enum {DO_NOCOPY      ='h001,
01132:                  DO_REFCOPY     ='h002,
01133:                  DO_DEEPCOPY    ='h004,
01134:                  HOW_TO_COPY    ='h007, // OR of all DO_*COPY
01135:                  DO_NOCOMPARE   ='h008,
01136:                  DO_REFCOMPARE  ='h010,
01137:                  DO_DEEPCOMPARE ='h020,
01138:                  HOW_TO_COMPARE ='h038, // OR of all DO_*COMPARE
01139:                  DO_NONE        ='h009, // OR of all DO_NO*
01140:                  DO_REF         ='h012, // OR of all DO_REF*
01141:                  DO_DEEP        ='h024, // OR of all DO_DEEP*
01142:                  _DO_DUMMY} do_how_e;
01143: 
01144:    function void do_all(          do_what_e   what,
01145:                               ref logic [7:0] pack[],
01146:                         const ref logic [7:0] unpack[]);
01147:    endfunction
01148: 
01149:    extern virtual function string do_psdisplay(string prefix = "");
01150: 
01151:    extern virtual function bit do_is_valid(bit silent = 1,
01152:                                            int kind   = -1);
01153:    extern virtual function vmm_data do_allocate();
01154:    extern virtual function vmm_data do_copy(vmm_data to = null);
01155: 
01156:    extern virtual function bit do_compare(       vmm_data to,
01157:                                           output string   diff,
01158:                                           input  int      kind = -1);
01159: 
01160:    extern virtual function int unsigned do_byte_size(int kind = -1);
01161:    extern virtual function int unsigned do_max_byte_size(int kind = -1);
01162:    extern virtual function int unsigned do_byte_pack(ref   logic [7:0]  bytes[],
01163:                                                      input int unsigned offset = 0,
01164:                                                      input int          kind   = -1);
01165:    extern virtual function int unsigned do_byte_unpack(const ref logic [7:0] bytes[],
01166:                                                        input int unsigned    offset = 0,
01167:                                                        input int             len    = -1,
01168:                                                        input int             kind   = -1);
01169: 
01170: 
01177: endclass: vmm_data
01178: 
01179: 
01180: //---------------------------------------------------------------------
01181: // vmm_channel
01182: //
01183: 
01187: class vmm_channel
01191: ;
01192:    vmm_log    log;
01193:    vmm_notify notify;
01194: 
01195:    // Predefined notifications
01196:    typedef enum int unsigned {FULL,
01197:                               EMPTY,
01198:                               PUT,
01199:                               GOT,
01200:                               PEEKED,
01201:                               ACTIVATED,
01202:                               ACT_STARTED,
01203:                               ACT_COMPLETED,
01204:                               ACT_REMOVED,
01205:                               LOCKED,
01206:                               UNLOCKED} notifications_e;
01207: 
01208:    // Arguments for lock methods
01209:    typedef enum bit [1:0] {SOURCE = 2'b01,
01210:                            SINK   = 2'b10
01211:                            } endpoints_e;
01212: 
01213:    typedef enum int unsigned {INACTIVE  = 0,
01214:                               PENDING   = 1,
01215:                               STARTED   = 2,
01216:                               COMPLETED = 3
01217:                               } active_status_e;
01218: 
01219:    static local bit      one_log    = $test$plusargs("vmm_channel_shared_log");
01220:    static local vmm_log shared_log = null;
01221: 
01222:    local int full    = 0;
01223:    local int empty   = 0;
01224:    local bit is_sunk = 0;
01225: 
01226:    local vmm_data data[$];
01227:    local vmm_data tee_data[$];
01228:    local vmm_data active;
01229:    local active_status_e active_status;
01230:    local event teed;
01231:    local vmm_channel downstream;
01232:    local event       new_connection;
01233:    local bit tee_on = 0;
01234:    local bit [1:0] locks;
01235: 
01236:    local bit   full_chan;
01237:    local event item_added;
01238:    local event item_taken;
01239: 
01240:    local int iterator;
01241: 
01242:    extern function new(string       name,
01243:                        string       inst,
01244:                        int unsigned full           = 1,
01245:                        int unsigned empty          = 0,
01246:                        bit          fill_as_bytes  = 1'b0);
01247: 
01249:    
01251: 
01252:    extern function void reconfigure(int   full          = -1,
01253:                                     int   empty         = -1,
01254:                                     logic fill_as_bytes = 1'bx);
01255:    extern function int unsigned full_level();
01256:    extern function int unsigned empty_level();
01257:    extern function int unsigned level();
01258:    extern function int unsigned size();
01259: 
01260:    extern function bit is_full();
01261:    extern function void flush();
01262:    extern function void sink();
01263:    extern function void flow();
01264:    extern function void reset();
01265: 
01266:    extern function void lock(bit [1:0] who);
01267:    extern function void unlock(bit [1:0] who);
01268:    extern function bit  is_locked(bit [1:0] who);
01269: 
01270:    extern function void display(string prefix = "");
01271:    extern function string psdisplay(string prefix = "");
01272: 
01273:    extern task put(vmm_data obj, int offset = -1);
01274:    extern function void sneak(vmm_data obj, int offset = -1);
01275:    extern function vmm_data unput(int offset = -1);
01276: 
01277:    extern task get(output vmm_data obj,
01278:                    input  int      offset = 0);
01279:    extern local task get1(output vmm_data obj,
01280:                           input  int      offset = 0);
01281:    extern task peek(output vmm_data obj,
01282:                     input  int      offset = 0);
01283:    extern task activate(output vmm_data obj,
01284:                         input  int      offset = 0);
01285: 
01286:    extern function vmm_data active_slot();
01287:    extern function vmm_data start();
01288:    extern function vmm_data complete(vmm_data status = null);
01289:    extern function vmm_data remove();
01290:    extern function active_status_e status();
01291: 
01292:    extern function bit tee_mode(bit is_on);
01293:    extern task tee(output vmm_data obj);
01294: 
01295:    extern function void connect(vmm_channel downstream);
01296:    extern function vmm_data for_each(bit reset = 0);
01297:    extern function int unsigned for_each_offset();
01298: 
01299:    extern function bit record(string filename);
01300:    extern task playback(output bit      success,
01301:                         input  string   filename,
01302:                         input  vmm_data loader,
01303:                         input  bit      metered = 0);
01304: 
01305:    extern local function int index(int offset);
01306: 
01307: 
01308: 
01309: 
01310: 
01312:    extern local task block_producer();
01313:    extern local task block_consumer();
01315:    extern local function void unblock_producer();
01316: 
01325: endclass
01326: 
01327: 
01390: 
01391: 
01392: //---------------------------------------------------------------------
01393: // vmm_consensus
01394: //
01395: 
01396: typedef class vmm_voter;
01397: 
01401: class vmm_consensus
01405: ;
01406: 
01407:    vmm_log log;
01408: 
01409:    local int n_dissenters;
01410:    local int n_forcing;
01411: 
01412:    local vmm_voter voters[$];
01413: 
01414:    extern function new(string        name,
01415:                        string        inst);
01416: 
01418:    
01420: 
01421:    extern function vmm_voter register_voter(string name);
01422:    extern function void register_xactor(vmm_xactor xact);
01423:    extern function void register_channel(vmm_channel chan);
01424:    extern function void register_notification(vmm_notify notify,
01425:                                               int notification);
01426:    extern function void register_no_notification(vmm_notify notify,
01427:                                                  int notification);
01428:    extern function void register_consensus(vmm_consensus vote,
01429:                                            bit force_through = 0);
01430: 
01431:    extern function void unregister_voter(vmm_voter voter);
01432:    extern function void unregister_xactor(vmm_xactor xact);
01433:    extern function void unregister_channel(vmm_channel chan);
01434:    extern function void unregister_notification(vmm_notify notify,
01435:                                                 int notification);
01436:    extern function void unregister_consensus(vmm_consensus vote);
01437: 
01438:    extern task wait_for_consensus();
01439:    extern task wait_for_no_consensus();
01440:    extern function bit is_reached();
01441:    extern function bit is_forced();
01442: 
01443:    extern function string psdisplay(string prefix = "");
01444:    extern function void yeas(ref string who[],
01445:                              ref string why[]);
01446:    extern function void nays(ref string who[],
01447:                              ref string why[]);
01448:    extern function void forcing(ref string who[],
01449:                                 ref string why[]);
01450: 
01451: 
01452:    event new_results;
01453:    extern /*local*/ function void XvoteX(bit was_agree,
01454:                                          bit agree,
01455:                                          bit was_forced,
01456:                                          bit forced);
01457: endclass: vmm_consensus
01458: 
01462: class vmm_voter;
01463:    local string name;
01464:    local vmm_consensus consensus;
01465:    local bit vote;
01466:    local bit is_forced;
01467:    local string why;
01468:    local event killme;
01469:    local vmm_xactor xactor_voter;
01470:    local vmm_channel channel_voter;
01471:    local vmm_notify  notify_voter;
01472:    local int         notification;
01473:    local vmm_consensus sub_vote;
01474: 
01475:    // Constructor is undocumented
01476:    extern /*local*/ function new(string        name,
01477:                                  vmm_consensus vote);
01478: 
01479:    extern function void oppose(string why = "No reason specified");
01480:    extern function void consent(string why = "No reason specified");
01481:    extern function void forced(string why = "No reason specified");
01482: 
01483:    // These methods are not documented either
01484:    extern /*local*/ function string get_name();
01485:    extern /*local*/ function bit    get_vote();
01486:    extern /*local*/ function bit    get_forced();
01487:    extern /*local*/ function string get_reason();
01488:    extern /*local*/ function void xactor(vmm_xactor xact);
01489:    extern /*local*/ function void channel(vmm_channel chan);
01490:    extern /*local*/ function void notify(vmm_notify ntfy, int notification, bit is_on);
01491:    extern /*local*/ function void sub_consensus(vmm_consensus vote, bit force_through);
01492:    extern /*local*/ function void kill_voter();
01493:    extern /*local*/ function vmm_xactor get_xactor();
01494:    extern /*local*/ function vmm_channel get_channel();
01495:    extern /*local*/ function vmm_notify  get_notify();
01496:    extern /*local*/ function int         get_notification();
01497:    extern /*local*/ function vmm_consensus get_consensus();
01498: endclass
01499: 
01500: 
01501: //---------------------------------------------------------------------
01502: // vmm_subenv
01503: //
01504: 
01508: class vmm_subenv
01512: ;
01513:    vmm_log    log;
01514: 
01515:    protected vmm_consensus end_test;
01516: 
01517:    local enum {NEWED, CONFIGURED, STARTED, STOPPED, CLEANED} state = NEWED;
01518: 
01519:    extern function new(string         name,
01520:                        string         inst,
01521:                        vmm_consensus end_test
01522:                        );
01523: 
01525:    
01527: 
01528:    extern protected function void configured();
01529: 
01530:    extern virtual task start();
01531:    extern virtual task stop();
01532:    extern virtual task cleanup();
01533:    extern virtual function void report();
01534:    
01535: endclass: vmm_subenv
01536: 
01537: 
01538: //---------------------------------------------------------------------
01539: // vmm_env
01540: //
01541: 
01545: class vmm_env
01549: ;
01550:    vmm_log    log;
01551:    vmm_notify notify;
01552: 
01553:    typedef enum int unsigned {GEN_CFG = 1,
01554:                               BUILD,
01555:                               RESET_DUT,
01556:                               CFG_DUT,
01557:                               START,
01558:                               RESTART,
01559:                               WAIT_FOR_END,
01560:                               STOP,
01561:                               CLEANUP,
01562:                               REPORT,
01563:                               RESTARTED} notifications_e;
01564: 
01565:    event          end_test;
01566:    vmm_consensus end_vote;
01567: 
01568:    local int step;
01569: 
01570:    local bit             reset_rng_state;
01571:    local string thread_rng_state_after_new;
01572:    local string thread_rng_state_after_pre_test;
01573:    local string thread_rng_state_before_start;
01574: 
01575:    local bit soft_restart;
01576:    local bit soft_restartable;
01577: 
01578:    extern function new(string name = "Verif Env"
01579:                        );
01580: 
01582:    
01584: 
01585:    extern task run();
01586: 
01587:    extern task pre_test();
01588:    extern virtual function void gen_cfg();
01589:    extern virtual function void build();
01590:    extern virtual task reset_dut();
01591:    extern virtual task cfg_dut();
01592:    extern virtual task start();
01593:    extern virtual task wait_for_end();
01594:    extern virtual task stop();
01595:    extern virtual task cleanup();
01596:    extern virtual task restart(bit reconfig = 0);
01597:    extern virtual task report();
01598: 
01599:    extern virtual protected function void save_rng_state();
01600:    extern virtual protected function void restore_rng_state();
01601: endclass
01602: 
01603: 
01604: //---------------------------------------------------------------------
01605: // vmm_xactor
01606: //
01607: 
01608: 
01612: virtual class vmm_xactor_callbacks;
01613: endclass
01614: 
01618: class vmm_xactor
01622: ;
01623:    vmm_log    log;
01624:    vmm_notify notify;
01625: 
01626:    int stream_id;
01627: 
01628:    typedef enum int {XACTOR_IDLE     = 999999,
01629:                      XACTOR_BUSY     = 999998,
01630:                      XACTOR_STARTED  = 999997,
01631:                      XACTOR_STOPPED  = 999996,
01632:                      XACTOR_RESET    = 999995,
01633:                      XACTOR_STOPPING = 999994
01634:                      } notifications_e;
01635: 
01636:    local bit start_it;
01637:    local event start_it_event;
01638:    local bit stop_it;
01639:    local int n_threads_to_stop;
01640:    local int n_threads_stopped;
01641:    local bit reset_it;
01642:    local bit resetable;
01643:    local event reset_it_event;
01644:    protected int reset_pending = 0;
01645: 
01646:    local bit main_running;
01647: 
01648:    local bit save_main_rng_state;
01649:    local bit restore_main_rng_state;
01650:    local string main_rng_state;
01651: 
01652:    protected vmm_xactor_callbacks callbacks[$];
01653: 
01654:    extern function new(string name,
01655: 	    	       string inst,
01656: 		       int    stream_id = -1
01657:                        );
01658: 
01660:    
01662: 
01663: 
01664: 
01665: 
01667:    typedef enum int {SOFT_RST,
01668:                      PROTOCOL_RST,
01669:                      FIRM_RST,
01670:                      HARD_RST} reset_e;
01672: 
01673:    extern virtual function string get_name();
01674:    extern virtual function string get_instance();
01675: 
01676:    extern virtual function void start_xactor();
01677:    extern virtual function void stop_xactor();
01678:    extern virtual function void reset_xactor(reset_e rst_typ = SOFT_RST);
01679: 
01680:    extern virtual function void save_rng_state();
01681:    extern virtual function void restore_rng_state();
01682: 
01683:    extern virtual function void xactor_status(string prefix = "");
01684:    extern virtual protected task main();
01685:    extern protected task wait_if_stopped(int unsigned n_threads = 1);
01686:    extern protected task wait_if_stopped_or_empty(vmm_channel  chan,
01687:                                                   int unsigned n_threads = 1);
01688: 
01689:    extern virtual function void prepend_callback(vmm_xactor_callbacks cb);
01690:    extern virtual function void append_callback(vmm_xactor_callbacks cb);
01691:    extern virtual function void unregister_callback(vmm_xactor_callbacks cb);
01692: 
01693: 
01694: 
01695:    
01706: endclass
01707: 
01708: 
01712: class vmm_broadcast extends vmm_xactor;
01713: 
01714:    typedef enum {AFAP = 1,
01715:                  ALAP = 2
01716:                  } bcast_mode_e;
01717:    
01718:    local vmm_channel in_chan;
01719:    
01720:    local int n_out_chans;
01721:    local bit dflt_use_refs;
01722:    local int mode;
01723:    
01724:    local bit          use_refs[$];
01725:    local bit          is_on[$];
01726:    local vmm_channel  out_chans[$];
01727:    
01728:    local event new_cycle;
01729:    
01730:    extern function new(string      name,
01731:                        string      inst,
01732:                        vmm_channel source,
01733:                        bit         use_references = 1,
01734:                        int         mode           = AFAP
01735:                        );
01736:    extern virtual task broadcast_mode(bcast_mode_e mode);
01737:    extern virtual function int new_output(vmm_channel channel,
01738:                                           logic use_references = 1'bx);
01739:    extern virtual function void bcast_on(int unsigned output_id);
01740:    extern virtual function void bcast_off(int unsigned output_id);
01741:    extern virtual protected function bit add_to_output(int unsigned decision_id,
01742:                                                        int unsigned output_id,
01743:                                                        vmm_channel       channel,
01744:                                                        vmm_data          obj);
01745:    extern virtual function void start_xactor();
01746:    extern virtual function void stop_xactor();
01747:    extern virtual function void reset_xactor(vmm_xactor::reset_e rst_typ = SOFT_RST);
01748:    extern protected virtual task main();
01749: 
01750:    extern local function void bcast_on_off(int channel_id,
01751:                                            int on_off);
01752:    extern virtual task bcast_to_output(int channel_id,
01753:                                        int on_off);
01754:    extern local task broadcast();
01755:    extern local task sink_if_outs();
01756: endclass : vmm_broadcast 
01757: 
01758: 
01759: //---------------------------------------------------------------------
01760: // vmm_scheduler
01761: //
01762: 
01766: class vmm_scheduler_election;
01767:    int          instance_id;
01768:    int unsigned election_id;
01769: 
01770:    int unsigned      n_sources;   
01771:    vmm_channel       sources[$];
01772:    int unsigned      ids[$];
01773:    int unsigned      id_history[$];
01774:    vmm_data          obj_history[$];
01775:    int unsigned      next_idx;
01776: 
01777:    rand int unsigned source_idx;
01778:    rand int unsigned obj_offset;
01779: 
01780:    constraint vmm_scheduler_election_valid {
01781:       obj_offset == 0;
01782:       source_idx >= 0;
01783:       source_idx < n_sources;
01784:    }
01785: 
01786:    constraint default_round_robin {
01787:       source_idx == next_idx;
01788:    }
01789: endclass
01790: 
01791: 
01795: class vmm_scheduler extends vmm_xactor;
01796: 
01797:    vmm_scheduler_election randomized_sched;
01798:    
01799:    protected vmm_channel out_chan;
01800: 
01801:    local vmm_channel       sources[$];
01802:    local int               is_on[$];
01803:    local int               instance_id;
01804:    local int               election_count;
01805:    local event             next_cycle;
01806: 
01807:    extern function new(string       name,
01808:                        string       inst,
01809:                        vmm_channel  destination,
01810:                        int          instance_id = -1
01811:                        );
01812: 
01813:    extern virtual function int new_source(vmm_channel channel);
01814:    extern virtual task sched_from_input(int channel_id,
01815:                                         int on_off);
01816:    extern virtual protected task schedule(output vmm_data     obj,
01817:                                           input  vmm_channel  sources[$],
01818:                                           input  int unsigned input_ids[$]);
01819:    extern virtual protected task get_object(output vmm_data     obj,
01820:                                             input  vmm_channel  source,
01821:                                             input  int unsigned input_id,
01822:                                             input  int          offset);
01823:    extern virtual function void start_xactor();
01824:    extern virtual function void stop_xactor();
01825:    extern virtual function void reset_xactor(vmm_xactor::reset_e rst_typ = SOFT_RST);
01826:    extern protected virtual task main();
01827: 
01828:    extern local task schedule_cycle();
01829: endclass
01830:    
01831: 
01832: //---------------------------------------------------------------------
01833: // XVC
01834: //
01835: 
01836: typedef class xvc_xactor;
01837: 
01841: class xvc_action extends vmm_data;
01842:    local string name;
01843: 
01844:    vmm_xactor_callbacks callbacks[];
01845: 
01846:    extern function new(string name,
01847:                        vmm_log log);
01848: 
01849:    extern function string get_name();
01850: 
01851:    extern virtual function xvc_action parse(string argv[]);
01852:    extern virtual task execute(vmm_channel exec_chan,
01853:                                xvc_xactor  xvc);
01854: 
01855:    extern virtual function string psdisplay(string prefix = "");
01856:    extern virtual function bit is_valid(bit silent = 1,
01857:                                         int kind   = -1);
01858: 
01859:    extern virtual function vmm_data allocate();
01860:    extern virtual function vmm_data copy(vmm_data to = null);
01861:    extern virtual protected function void copy_data(vmm_data to);
01862: 
01863:    extern virtual function bit compare(input  vmm_data to,
01864:                                        output string   diff,
01865:                                        input  int      kind = -1);
01866: 
01867:    extern virtual function int unsigned byte_size(int kind = -1);
01868:    extern virtual function int unsigned max_byte_size(int kind = -1);
01869:    extern virtual function int unsigned byte_pack(ref logic [7:0]    bytes[],
01870:                                                   input int unsigned offset = 0,
01871:                                                   input int          kind   = -1);
01872:    extern virtual function int unsigned byte_unpack(const ref logic [7:0] bytes[],
01873:                                                     input int unsigned    offset = 0,
01874:                                                     input int             len    = -1,
01875:                                                     input int             kind   = -1);
01876: endclass: xvc_action
01877: 
01878: 
     : class xvc_action_channel extends vmm_channel; 
     :  
     :    function new(string name, 
     :                 string inst, 
     :                 int    full = 1, 
     :                 int    empty = 0, 
     :                 bit    fill_as_bytes = 0); 
     :       super.new(name, inst, full, empty, fill_as_bytes); 
     :    endfunction: new 
     :  
     :    function xvc_action unput(int offset = -1); 
     :       $cast(unput, super.unput(offset)); 
     :    endfunction: unput 
     :  
     :    task get(output xvc_action obj, input int offset = 0); 
     :       vmm_data o; 
     :       super.get(o, offset); 
     :       $cast(obj, o); 
     :    endtask: get 
     :  
     :    task peek(output xvc_action obj, input int offset = 0); 
     :       vmm_data o; 
     :       super.peek(o, offset); 
     :       $cast(obj, o); 
     :    endtask: peek 
     :  
     :    task activate(output xvc_action obj, input int offset = 0); 
     :       vmm_data o; 
     :       super.activate(o, offset); 
     :       $cast(obj, o); 
     :    endtask: activate 
     :  
     :    function xvc_action active_slot(); 
     :       $cast(active_slot, super.active_slot()); 
     :    endfunction: active_slot 
     :  
     :    function xvc_action start(); 
     :       $cast(start, super.start()); 
     :    endfunction: start 
     :  
     :    function xvc_action complete(vmm_data status = null); 
     :       $cast(complete, super.complete(status)); 
     :    endfunction: complete 
     :  
     :    function xvc_action remove(); 
     :       $cast(remove, super.remove()); 
     :    endfunction: remove 
     :  
     :    task tee(output xvc_action obj); 
     :       vmm_data o; 
     :       super.tee(o); 
     :       $cast(obj, o); 
     :    endtask: tee 
     :  
     :    function xvc_action for_each(bit reset = 0); 
     :       $cast(for_each, super.for_each(reset)); 
     :    endfunction: for_each 
     : endclass
01879: 
01880: 
01884: class xvc_xactor extends vmm_xactor;
01885: 
01886:    vmm_log trace;
01887: 
01888:    xvc_action_channel action_chan;
01889:    xvc_action_channel interrupt_chan;
01890:    
01891:    protected vmm_channel exec_chan;
01892:    protected vmm_xactor  xactors[];
01893: 
01894:    local xvc_action known_actions[$];
01895:    local xvc_action idle;
01896: 
01897:    local bit interrupt;
01898:    local bit interrupted;
01899:    local event interrupted_event;
01900:    local event rte;
01901:    local xvc_action executing;
01902:    local xvc_action suspended;
01903: 
01904:    extern function new(string             name,
01905:                        string             inst,
01906:                        int                stream_id = -1,
01907:                        xvc_action_channel action_chan = null,
01908:                        xvc_action_channel interrupt_chan = null
01909:                        );
01910: 
01911:    extern function void add_action(xvc_action action);
01912:    extern function xvc_action parse(string argv[]);
01913: 
01914:    extern virtual function void start_xactor();
01915:    extern virtual function void stop_xactor();
01916:    extern virtual function void reset_xactor(vmm_xactor::reset_e rst_typ = SOFT_RST);
01917: 
01918:    extern virtual function void xactor_status(string prefix = "");
01919: 
01920:    extern virtual task main();
01921: 
01922:    extern task wait_if_interrupted();
01923: 
01924:    extern local task execute_actions();
01925:    extern local task execute_interruptions();
01926:    extern local task execute_action(xvc_action_channel chan,
01927:                                     string             descr);
01928: 
01929:    extern virtual function void save_rng_state();
01930:    extern virtual function void restore_rng_state();
01931: endclass: xvc_xactor
01932: 
01933: 
01937: class xvc_manager;
01938: 
01939:    vmm_log    log;
01940:    vmm_log    trace;
01941: 
01942:    vmm_notify notify;
01943: 
01944:    protected xvc_xactor xvcQ[$];
01945: 
01946:    extern function new(string inst = "Main");
01947: 
01948:    extern function bit add_xvc(xvc_xactor xvc);
01949:    extern function bit remove_xvc(xvc_xactor xvc);
01950: 
01951:    extern function bit split(string     command,
01952:                              ref string argv[]);
01953: 
01954: endclass: xvc_manager
01955: 
01956: 
01957: //------------------------------------------------------------
01958: // vmm_version
01959: //
01960: 
01961: function int vmm_version::major();
01962:    major = 1;
01963: endfunction: major
01964: 
01965: function int vmm_version::minor();
01966:    minor = 5;
01967: endfunction: minor
01968: 
01969: function int vmm_version::patch();
01970:    patch = 3;
01971: endfunction: patch
01972: 
01973: function string vmm_version::vendor();
01974:    vendor = "Synopsys";
01975: endfunction: vendor
01976: 
01977: function void vmm_version::display(string prefix);
01978:    $write("%s\n", this.psdisplay(prefix));
01979: endfunction: display
01980: 
01981: function string vmm_version::psdisplay(string prefix);
01982:    $sformat(psdisplay, "%sVMM Version %0d.%0d.%0d (%s)",
01983:             prefix, this.major(), this.minor(), this.patch(), this.vendor());
01984: endfunction: psdisplay
01985: 
01986: 
01987: function void vmm_version::cfdisplay(string prefix);
01988:    this.display(prefix);
01989:    $write("%s\n%sMacro Definitions:",
01990:           prefix, prefix);
01991: 
01992:    $write("\n");
01993:    $write("%s   VMM_CHANNEL                     %s\n",
01994:           prefix, `"`VMM_CHANNEL`");
02001: 
02002:    $write("\n");
02003:    $write("%s   VMM_CONSENSUS                   %s\n",
02004:           prefix, `"`VMM_CONSENSUS`");
02011: 
02012:    $write("\n");
02013:    $write("%s   VMM_DATA                        %s\n",
02014:           prefix, `"`VMM_DATA`");
02015:    $write("%s   VMM_DATA_NEW_ARGS               %s\n",
02016:           prefix, `"`VMM_DATA_NEW_ARGS`");
02017:    $write("%s   VMM_DATA_NEW_EXTERN_ARGS        %s\n",
02018:           prefix, `"`VMM_DATA_NEW_EXTERN_ARGS`");
02019:    $write("%s   VMM_DATA_NEW_CALL               %s\n",
02020:           prefix, `"`VMM_DATA_NEW_CALL`");
02031: 
02032:    $write("\n");
02033:    $write("%s   VMM_ENV                         %s\n",
02034:           prefix, `"`VMM_ENV`");
02035:    $write("%s   VMM_ENV_NEW_ARGS                %s\n",
02036:           prefix, `"`VMM_ENV_NEW_ARGS`");
02037:    $write("%s   VMM_ENV_NEW_EXTERN_ARGS         %s\n",
02038:           prefix, `"`VMM_ENV_NEW_EXTERN_ARGS`");
02039:    $write("%s   VMM_ENV_NEW_CALL                %s\n",
02040:           prefix, `"`VMM_ENV_NEW_CALL`");
02051: 
02052:    $write("\n");
02053:    $write("%s   VMM_LOG                         %s\n",
02054:           prefix, `"`VMM_LOG`");
02061: 
02062:    $write("\n");
02063:    $write("%s   VMM_NOTIFY                      %s\n",
02064:           prefix, `"`VMM_NOTIFY`");
02071: 
02072:    $write("\n");
02073:    $write("%s   VMM_XACTOR                      %s\n",
02074:           prefix, `"`VMM_XACTOR`");
02075:    $write("%s   VMM_XACTOR_NEW_ARGS             %s\n",
02076:           prefix, `"`VMM_XACTOR_NEW_ARGS`");
02077:    $write("%s   VMM_XACTOR_NEW_EXTERN_ARGS      %s\n",
02078:           prefix, `"`VMM_XACTOR_NEW_EXTERN_ARGS`");
02079:    $write("%s   VMM_XACTOR_NEW_CALL             %s\n",
02080:           prefix, `"`VMM_XACTOR_NEW_CALL`");
02091: endfunction: cfdisplay
02092: 
02093: 
02107: 
02108: 
02112: 
02114: 
00001: // 
00002: // -------------------------------------------------------------
00003: //    Copyright 2004-2008 Synopsys, Inc.
00004: //    All Rights Reserved Worldwide
00005: // 
00006: //    Licensed under the Apache License, Version 2.0 (the
00007: //    "License"); you may not use this file except in
00008: //    compliance with the License.  You may obtain a copy of
00009: //    the License at
00010: // 
00011: //        http://www.apache.org/licenses/LICENSE-2.0
00012: // 
00013: //    Unless required by applicable law or agreed to in
00014: //    writing, software distributed under the License is
00015: //    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00016: //    CONDITIONS OF ANY KIND, either express or implied.  See
00017: //    the License for the specific language governing
00018: //    permissions and limitations under the License.
00019: // -------------------------------------------------------------
00020: //
00021: 
00022: `define VMM_DOSFILE_CHECK If you get a syntax error on this line, \
00023:         the file is corrupt. Make sure you unpack the VMM distribution \
00024:         file with gunzip then tar, not a Windows tool
     : 
00025: 
00026: //
00027: // If you wish to use the parameterized classes version of vmm_channel
00028: // (requires VCS 2008.03 or later), the symbol `VMM_PARAM_CHANNEL must
00029: //  be defined
00030: 
00031: 
00032: 
00033: 
00034: //---------------------------------------------------------------------
00035: // Enable temporary work-arounds for features not yet implemented
00036: //
00040: 
00041: 
00042: //---------------------------------------------------------------------
00043: // Functionality that must be provided through DPI/System tasks
00044: //
00045: 
00108: 
00109: 
00110: //
00111: // The macros must be defined in a separate guard block to enable
00112: // separate compilation because `define symbols are compilation symbols,
00113: // not SV symbols that end up in the VMM package
00114: //
00115: 
00496: 
00497: 
00498: //
00499: // Protect against multiple inclusion of this file
00500: //
02114: 
00001: // 
00002: // -------------------------------------------------------------
00003: //    Copyright 2004-2008 Synopsys, Inc.
00004: //    All Rights Reserved Worldwide
00005: // 
00006: //    Licensed under the Apache License, Version 2.0 (the
00007: //    "License"); you may not use this file except in
00008: //    compliance with the License.  You may obtain a copy of
00009: //    the License at
00010: // 
00011: //        http://www.apache.org/licenses/LICENSE-2.0
00012: // 
00013: //    Unless required by applicable law or agreed to in
00014: //    writing, software distributed under the License is
00015: //    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00016: //    CONDITIONS OF ANY KIND, either express or implied.  See
00017: //    the License for the specific language governing
00018: //    permissions and limitations under the License.
00019: // -------------------------------------------------------------
00020: //
00021: 
00022: `define VMM_DOSFILE_CHECK If you get a syntax error on this line, \
00023:         the file is corrupt. Make sure you unpack the VMM distribution \
00024:         file with gunzip then tar, not a Windows tool
     : 
00025: 
00026: //
00027: // If you wish to use the parameterized classes version of vmm_channel
00028: // (requires VCS 2008.03 or later), the symbol `VMM_PARAM_CHANNEL must
00029: //  be defined
00030: 
00031: 
00032: 
00033: 
00034: //---------------------------------------------------------------------
00035: // Enable temporary work-arounds for features not yet implemented
00036: //
00040: 
00041: 
00042: //---------------------------------------------------------------------
00043: // Functionality that must be provided through DPI/System tasks
00044: //
00045: 
00108: 
00109: 
00110: //
00111: // The macros must be defined in a separate guard block to enable
00112: // separate compilation because `define symbols are compilation symbols,
00113: // not SV symbols that end up in the VMM package
00114: //
00115: 
00496: 
00497: 
00498: //
00499: // Protect against multiple inclusion of this file
00500: //
02114: 
00001: // 
00002: // -------------------------------------------------------------
00003: //    Copyright 2004-2008 Synopsys, Inc.
00004: //    All Rights Reserved Worldwide
00005: // 
00006: //    Licensed under the Apache License, Version 2.0 (the
00007: //    "License"); you may not use this file except in
00008: //    compliance with the License.  You may obtain a copy of
00009: //    the License at
00010: // 
00011: //        http://www.apache.org/licenses/LICENSE-2.0
00012: // 
00013: //    Unless required by applicable law or agreed to in
00014: //    writing, software distributed under the License is
00015: //    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00016: //    CONDITIONS OF ANY KIND, either express or implied.  See
00017: //    the License for the specific language governing
00018: //    permissions and limitations under the License.
00019: // -------------------------------------------------------------
00020: //
00021: 
00022: `define VMM_DOSFILE_CHECK If you get a syntax error on this line, \
00023:         the file is corrupt. Make sure you unpack the VMM distribution \
00024:         file with gunzip then tar, not a Windows tool
     : 
00025: 
00026: //
00027: // If you wish to use the parameterized classes version of vmm_channel
00028: // (requires VCS 2008.03 or later), the symbol `VMM_PARAM_CHANNEL must
00029: //  be defined
00030: 
00031: 
00032: 
00033: 
00034: //---------------------------------------------------------------------
00035: // Enable temporary work-arounds for features not yet implemented
00036: //
00040: 
00041: 
00042: //---------------------------------------------------------------------
00043: // Functionality that must be provided through DPI/System tasks
00044: //
00045: 
00108: 
00109: 
00110: //
00111: // The macros must be defined in a separate guard block to enable
00112: // separate compilation because `define symbols are compilation symbols,
00113: // not SV symbols that end up in the VMM package
00114: //
00115: 
00496: 
00497: 
00498: //
00499: // Protect against multiple inclusion of this file
00500: //
02114: 
00001: // 
00002: // -------------------------------------------------------------
00003: //    Copyright 2004-2008 Synopsys, Inc.
00004: //    All Rights Reserved Worldwide
00005: // 
00006: //    Licensed under the Apache License, Version 2.0 (the
00007: //    "License"); you may not use this file except in
00008: //    compliance with the License.  You may obtain a copy of
00009: //    the License at
00010: // 
00011: //        http://www.apache.org/licenses/LICENSE-2.0
00012: // 
00013: //    Unless required by applicable law or agreed to in
00014: //    writing, software distributed under the License is
00015: //    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00016: //    CONDITIONS OF ANY KIND, either express or implied.  See
00017: //    the License for the specific language governing
00018: //    permissions and limitations under the License.
00019: // -------------------------------------------------------------
00020: //
00021: 
00022: `define VMM_DOSFILE_CHECK If you get a syntax error on this line, \
00023:         the file is corrupt. Make sure you unpack the VMM distribution \
00024:         file with gunzip then tar, not a Windows tool
     : 
00025: 
00026: //
00027: // If you wish to use the parameterized classes version of vmm_channel
00028: // (requires VCS 2008.03 or later), the symbol `VMM_PARAM_CHANNEL must
00029: //  be defined
00030: 
00031: 
00032: 
00033: 
00034: //---------------------------------------------------------------------
00035: // Enable temporary work-arounds for features not yet implemented
00036: //
00040: 
00041: 
00042: //---------------------------------------------------------------------
00043: // Functionality that must be provided through DPI/System tasks
00044: //
00045: 
00108: 
00109: 
00110: //
00111: // The macros must be defined in a separate guard block to enable
00112: // separate compilation because `define symbols are compilation symbols,
00113: // not SV symbols that end up in the VMM package
00114: //
00115: 
00496: 
00497: 
00498: //
00499: // Protect against multiple inclusion of this file
00500: //
02114: 
00001: // 
00002: // -------------------------------------------------------------
00003: //    Copyright 2004-2008 Synopsys, Inc.
00004: //    All Rights Reserved Worldwide
00005: // 
00006: //    Licensed under the Apache License, Version 2.0 (the
00007: //    "License"); you may not use this file except in
00008: //    compliance with the License.  You may obtain a copy of
00009: //    the License at
00010: // 
00011: //        http://www.apache.org/licenses/LICENSE-2.0
00012: // 
00013: //    Unless required by applicable law or agreed to in
00014: //    writing, software distributed under the License is
00015: //    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00016: //    CONDITIONS OF ANY KIND, either express or implied.  See
00017: //    the License for the specific language governing
00018: //    permissions and limitations under the License.
00019: // -------------------------------------------------------------
00020: //
00021: 
00022: `define VMM_DOSFILE_CHECK If you get a syntax error on this line, \
00023:         the file is corrupt. Make sure you unpack the VMM distribution \
00024:         file with gunzip then tar, not a Windows tool
     : 
00025: 
00026: //
00027: // If you wish to use the parameterized classes version of vmm_channel
00028: // (requires VCS 2008.03 or later), the symbol `VMM_PARAM_CHANNEL must
00029: //  be defined
00030: 
00031: 
00032: 
00033: 
00034: //---------------------------------------------------------------------
00035: // Enable temporary work-arounds for features not yet implemented
00036: //
00040: 
00041: 
00042: //---------------------------------------------------------------------
00043: // Functionality that must be provided through DPI/System tasks
00044: //
00045: 
00108: 
00109: 
00110: //
00111: // The macros must be defined in a separate guard block to enable
00112: // separate compilation because `define symbols are compilation symbols,
00113: // not SV symbols that end up in the VMM package
00114: //
00115: 
00496: 
00497: 
00498: //
00499: // Protect against multiple inclusion of this file
00500: //
02114: