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 `ifndef VMM_DOSFILE_CHECK
00023 `define VMM_DOSFILE_CHECK If you get a syntax error on this line, \
00024 the file is corrupt. Make sure you unpack the VMM distribution \
00025 file with gunzip then tar, not a Windows tool
00026 `endif
00027
00028 //
00029 // If you wish to use the parameterized classes version of vmm_channel
00030 // (requires VCS 2008.03 or later), the symbol `VMM_PARAM_CHANNEL must
00031 // be defined
00032
00033
00034
00035
00036 //---------------------------------------------------------------------
00037 // Enable temporary work-arounds for features not yet implemented
00038 //
00039
00040 `ifdef VCS
00041 //`define VCS2006_06
00042
00043 `ifndef VCS_VMM_VERSION_PATCH
00044 `define VCS_VMM_VERSION_PATCH
00045 `endif
00046 `endif
00047
00048
00049 `ifdef VCS2006_06
00050 `define NO_STATIC_METHODS
00051 `define NO_TYPED_AA_IDX
00052 `endif
00053
00054
00055 //---------------------------------------------------------------------
00056 // Functionality that must be provided through DPI/System tasks
00057 //
00058
00059 `ifndef VMM_DPI_
00060 `define VMM_DPI_
00061
00062 //
00063 // $sformatf()
00064 //
00065 // SV-2008 feature that may not be available. $sformat() could be used but
00066 // with lower performance as formatted strings would be always created even
00067 // if never used.
00068 //
00069 // VCS provides a precursor called $psprintf()
00070 //
00071 `ifndef vmm_sformatf
00072 `define vmm_sformatf $psprintf
00073 `endif
00074
00075 //
00076 // String-matching pseudo methods.
00077 //
00078 // Those are built-in VCS and may eventually be part of a revision of the
00079 // SV standard. In the meantime, they can be provided by DPI functions or
00080 // their functionality be disabled. These DPIs are provided by the file
00081 // $VMM_HOME/sv/std_lib/vmm_str_dpi.c
00082 //
00083 // Currently, they are used in vmm_log for name and instance name matching
00084 // and in the XVCs for command parsing and interpretation.
00085 //
00086
00087
00088 `ifdef VCS
00089 `define vmm_str_match(str, regex) str.match(regex)
00090 `define vmm_str_prematch(str) str.prematch()
00091 `define vmm_str_postmatch(str) str.postmatch()
00092 `define vmm_str_backref(str, n) str.backref(n)
00093
00094 `else
00095
00096 `ifdef VMM_NO_STR_DPI
00097
00098 `define vmm_str_match(str, regex) 0
00099 `define vmm_str_prematch(str) `"`"
00100 `define vmm_str_postmatch(str) `"`"
00101 `define vmm_str_backref(str, n) `"`"
00102
00103 `else
00104
00105 import "DPI-C" function int vmm_str_match(input string str1, input string regex);
00106 import "DPI-C" function string vmm_str_prematch();
00107 import "DPI-C" function string vmm_str_postmatch();
00108 import "DPI-C" function string vmm_str_backref(int n);
00109
00110 `define vmm_str_match(str, regex) vmm_str_match(str, regex)
00111 `define vmm_str_prematch(str) vmm_str_prematch()
00112 `define vmm_str_postmatch(str) vmm_str_postmatch()
00113 `define vmm_str_backref(str, n) vmm_str_backref(n+1)
00114
00115 `endif
00116
00117 `endif
00118
00119
00120 `endif // VMM_DPI_
00121
00122
00123 //
00124 // The macros must be defined in a separate guard block to enable
00125 // separate compilation because `define symbols are compilation symbols,
00126 // not SV symbols that end up in the VMM package
00127 //
00128
00129 `ifndef VMM_MACRO_DEFINED
00130 `define VMM_MACRO_DEFINED
00131
00132 `define VMM_MACRO_TO_STRING(x) `"x`"
00133
00134
00135 //---------------------------------------------------------------------
00136 // User customization macros
00137 //
00138
00139
00140 `ifdef VMM_PRE_INCLUDE
00141 `include `MM_MACRO_TO_STRING(`VMM_PRE_INCLUDE)
00142 `endif
00143
00144
00145 `ifndef VMM_DATA
00146 `define VMM_DATA vmm_data
00147 `endif
00148 `ifndef VMM_DATA_NEW_ARGS
00149 `define VMM_DATA_NEW_ARGS
00150 `define VMM_DATA_NEW_EXTERN_ARGS
00151 `define VMM_DATA_NEW_CALL
00152 `endif
00153 `ifndef VMM_DATA_BASE_NEW_ARGS
00154 `define VMM_DATA_BASE_NEW_ARGS
00155 `define VMM_DATA_BASE_NEW_EXTERN_ARGS
00156 `endif
00157 `ifdef VMM_DATA_BASE
00158 `ifndef VMM_DATA_BASE_NEW_CALL
00159 `define VMM_DATA_BASE_NEW_CALL
00160 `endif
00161 `endif
00162 `ifndef VMM_DATA_BASE_METHODS
00163 `define VMM_DATA_BASE_METHODS
00164 `endif
00165
00166 `ifndef VMM_SCENARIO
00167 `define VMM_SCENARIO vmm_scenario
00168 `endif
00169 `ifndef VMM_SCENARIO_NEW_ARGS
00170 `define VMM_SCENARIO_NEW_ARGS `VMM_DATA_NEW_ARGS
00171 `define VMM_SCENARIO_NEW_EXTERN_ARGS `VMM_DATA_NEW_EXTERN_ARGS
00172 `define VMM_SCENARIO_NEW_CALL `VMM_DATA_NEW_CALL
00173 `endif
00174 `ifndef VMM_SCENARIO_BASE
00175 `define VMM_SCENARIO_BASE vmm_data
00176 `endif
00177 `ifndef VMM_SCENARIO_BASE_NEW_ARGS
00178 `define VMM_SCENARIO_BASE_NEW_ARGS `VMM_DATA_BASE_NEW_ARGS
00179 `define VMM_SCENARIO_BASE_NEW_EXTERN_ARGS `VMM_DATA_BASE_NEW_EXTERN_ARGS
00180 `endif
00181 `ifndef VMM_SCENARIO_BASE_NEW_CALL
00182 `define VMM_SCENARIO_BASE_NEW_CALL `VMM_DATA_BASE_NEW_CALL
00183 `endif
00184 `ifndef VMM_SCENARIO_BASE_METHODS
00185 `define VMM_SCENARIO_BASE_METHODS `VMM_DATA_BASE_METHODS
00186 `endif
00187
00188 `ifndef VMM_CHANNEL
00189 `define VMM_CHANNEL vmm_channel
00190 `endif
00191 `ifdef VMM_CHANNEL_BASE
00192 `ifndef VMM_CHANNEL_BASE_NEW_CALL
00193 `define VMM_CHANNEL_BASE_NEW_CALL
00194 `endif
00195 `endif
00196 `ifndef VMM_CHANNEL_BASE_METHODS
00197 `define VMM_CHANNEL_BASE_METHODS
00198 `endif
00199
00200 `ifndef VMM_CONSENSUS
00201 `define VMM_CONSENSUS vmm_consensus
00202 `endif
00203 `ifdef VMM_CONSENSUS_BASE
00204 `ifndef VMM_CONSENSUS_BASE_NEW_CALL
00205 `define VMM_CONSENSUS_BASE_NEW_CALL
00206 `endif
00207 `endif
00208 `ifndef VMM_CONSENSUS_BASE_METHODS
00209 `define VMM_CONSENSUS_BASE_METHODS
00210 `endif
00211
00212 `ifndef VMM_LOG
00213 `define VMM_LOG vmm_log
00214 `endif
00215 `ifdef VMM_LOG_BASE
00216 `ifndef VMM_LOG_BASE_NEW_CALL
00217 `define VMM_LOG_BASE_NEW_CALL
00218 `endif
00219 `endif
00220 `ifndef VMM_LOG_BASE_METHODS
00221 `define VMM_LOG_BASE_METHODS
00222 `endif
00223
00224 `ifndef VMM_NOTIFY
00225 `define VMM_NOTIFY vmm_notify
00226 `endif
00227 `ifdef VMM_NOTIFY_BASE
00228 `ifndef VMM_NOTIFY_BASE_NEW_CALL
00229 `define VMM_NOTIFY_BASE_NEW_CALL
00230 `endif
00231 `endif
00232 `ifndef VMM_NOTIFY_BASE_METHODS
00233 `define VMM_NOTIFY_BASE_METHODS
00234 `endif
00235
00236 `ifndef VMM_XACTOR
00237 `define VMM_XACTOR vmm_xactor
00238 `endif
00239 `ifndef VMM_XACTOR_NEW_ARGS
00240 `define VMM_XACTOR_NEW_ARGS
00241 `define VMM_XACTOR_NEW_EXTERN_ARGS
00242 `define VMM_XACTOR_NEW_CALL
00243 `endif
00244 `ifndef VMM_XACTOR_BASE_NEW_ARGS
00245 `define VMM_XACTOR_BASE_NEW_ARGS
00246 `define VMM_XACTOR_BASE_NEW_EXTERN_ARGS
00247 `endif
00248 `ifdef VMM_XACTOR_BASE
00249 `ifndef VMM_XACTOR_BASE_NEW_CALL
00250 `define VMM_XACTOR_BASE_NEW_CALL
00251 `endif
00252 `endif
00253 `ifndef VMM_XACTOR_BASE_METHODS
00254 `define VMM_XACTOR_BASE_METHODS
00255 `endif
00256
00257 `ifndef VMM_SUBENV
00258 `define VMM_SUBENV vmm_subenv
00259 `endif
00260 `ifndef VMM_SUBENV_NEW_ARGS
00261 `define VMM_SUBENV_NEW_ARGS
00262 `define VMM_SUBENV_NEW_EXTERN_ARGS
00263 `define VMM_SUBENV_NEW_CALL
00264 `endif
00265 `ifndef VMM_SUBENV_BASE_NEW_ARGS
00266 `define VMM_SUBENV_BASE_NEW_ARGS
00267 `define VMM_SUBENV_BASE_NEW_EXTERN_ARGS
00268 `endif
00269 `ifdef VMM_SUBENV_BASE
00270 `ifndef VMM_SUBENV_BASE_NEW_CALL
00271 `define VMM_SUBENV_BASE_NEW_CALL
00272 `endif
00273 `endif
00274 `ifndef VMM_SUBENV_BASE_METHODS
00275 `define VMM_SUBENV_BASE_METHODS
00276 `endif
00277
00278 `ifndef VMM_ENV
00279 `define VMM_ENV vmm_env
00280 `endif
00281 `ifndef VMM_ENV_NEW_ARGS
00282 `define VMM_ENV_NEW_ARGS
00283 `define VMM_ENV_NEW_EXTERN_ARGS
00284 `define VMM_ENV_NEW_CALL
00285 `endif
00286 `ifndef VMM_ENV_BASE_NEW_ARGS
00287 `define VMM_ENV_BASE_NEW_ARGS
00288 `define VMM_ENV_BASE_NEW_EXTERN_ARGS
00289 `endif
00290 `ifdef VMM_ENV_BASE
00291 `ifndef VMM_ENV_BASE_NEW_CALL
00292 `define VMM_ENV_BASE_NEW_CALL
00293 `endif
00294 `endif
00295 `ifndef VMM_ENV_BASE_METHODS
00296 `define VMM_ENV_BASE_METHODS
00297 `endif
00298
00299
00300
00301 //---------------------------------------------------------------------
00302 // vmm_log ease-of-use macros
00303 //
00304
00305 `ifndef __FILE__
00306 `define __FILE__ `"`"
00307 `endif
00308 `ifndef __LINE__
00309 `define __LINE__ -1
00310 `endif
00311
00312 `define vmm_warning(log, msg) \
00313 do \
00314 /* synopsys translate_off */ \
00315 if (log.start_msg(vmm_log::FAILURE_TYP, vmm_log::WARNING_SEV, `__FILE__, `__LINE__)) begin \
00316 void'(log.text(msg)); \
00317 log.end_msg(); \
00318 end \
00319 /* synopsys translate_on */ \
00320 while(0)
00321
00322 `define vmm_error(log, msg) \
00323 do \
00324 /* synopsys translate_off */ \
00325 if (log.start_msg(vmm_log::FAILURE_TYP, vmm_log::ERROR_SEV, `__FILE__, `__LINE__)) begin \
00326 void'(log.text(msg)); \
00327 log.end_msg(); \
00328 end \
00329 /* synopsys translate_on */ \
00330 while (0)
00331
00332 `define vmm_fatal(log, msg) \
00333 do \
00334 /* synopsys translate_off */ \
00335 if (log.start_msg(vmm_log::FAILURE_TYP, vmm_log::FATAL_SEV, `__FILE__, `__LINE__)) begin \
00336 void'(log.text(msg)); \
00337 log.end_msg(); \
00338 end \
00339 /* synopsys translate_on */ \
00340 while (0)
00341
00342 //
00343 // If it is necessary to compile-out debug messages to gain every
00344 // milligram of performance, defining this macro will take them out.
00345 //
00346
00347 `ifdef VMM_NULL_LOG_MACROS
00348
00349 `define vmm_trace(log, msg)
00350 `define vmm_debug(log, msg)
00351 `define vmm_verbose(log, msg)
00352 `define vmm_note(log, msg)
00353 `define vmm_report(log, msg)
00354 `define vmm_command(log, msg)
00355 `define vmm_protocol(log, msg)
00356 `define vmm_transaction(log, msg)
00357 `define vmm_cycle(log, msg)
00358 `define vmm_user(n, log, msg)
00359
00360 `else
00361
00362 `define vmm_trace(log, msg) \
00363 do \
00364 /* synopsys translate_off */ \
00365 if (log.start_msg(vmm_log::DEBUG_TYP, vmm_log::TRACE_SEV, `__FILE__, `__LINE__)) begin \
00366 void'(log.text(msg)); \
00367 log.end_msg(); \
00368 end \
00369 /* synopsys translate_on */ \
00370 while (0)
00371
00372 `define vmm_debug(log, msg) \
00373 do \
00374 /* synopsys translate_off */ \
00375 if (log.start_msg(vmm_log::DEBUG_TYP, vmm_log::DEBUG_SEV, `__FILE__, `__LINE__)) begin \
00376 void'(log.text(msg)); \
00377 log.end_msg(); \
00378 end \
00379 /* synopsys translate_on */ \
00380 while (0)
00381
00382 `define vmm_verbose(log, msg) \
00383 do \
00384 /* synopsys translate_off */ \
00385 if (log.start_msg(vmm_log::DEBUG_TYP, vmm_log::VERBOSE_SEV, `__FILE__, `__LINE__)) begin \
00386 void'(log.text(msg)); \
00387 log.end_msg(); \
00388 end \
00389 /* synopsys translate_on */ \
00390 while (0)
00391
00392 `define vmm_note(log, msg) \
00393 do \
00394 /* synopsys translate_off */ \
00395 if (log.start_msg(vmm_log::NOTE_TYP, , `__FILE__, `__LINE__)) begin \
00396 void'(log.text(msg)); \
00397 log.end_msg(); \
00398 end \
00399 /* synopsys translate_on */ \
00400 while (0)
00401
00402 `define vmm_report(log, msg) \
00403 do \
00404 /* synopsys translate_off */ \
00405 if (log.start_msg(vmm_log::REPORT_TYP, , `__FILE__, `__LINE__)) begin \
00406 void'(log.text(msg)); \
00407 log.end_msg(); \
00408 end \
00409 /* synopsys translate_on */ \
00410 while (0)
00411
00412 `define vmm_command(log, msg) \
00413 do \
00414 /* synopsys translate_off */ \
00415 if (log.start_msg(vmm_log::COMMAND_TYP, , `__FILE__, `__LINE__)) begin \
00416 void'(log.text(msg)); \
00417 log.end_msg(); \
00418 end \
00419 /* synopsys translate_on */ \
00420 while (0)
00421
00422 `define vmm_protocol(log, msg) \
00423 do \
00424 /* synopsys translate_off */ \
00425 if (log.start_msg(vmm_log::PROTOCOL_TYP, , `__FILE__, `__LINE__)) begin \
00426 void'(log.text(msg)); \
00427 log.end_msg(); \
00428 end \
00429 /* synopsys translate_on */ \
00430 while (0)
00431
00432 `define vmm_transaction(log, msg) \
00433 do \
00434 /* synopsys translate_off */ \
00435 if (log.start_msg(vmm_log::TRANSACTION_TYP, , `__FILE__, `__LINE__)) begin \
00436 void'(log.text(msg)); \
00437 log.end_msg(); \
00438 end \
00439 /* synopsys translate_on */ \
00440 while (0)
00441
00442 `define vmm_cycle(log, msg) \
00443 do \
00444 /* synopsys translate_off */ \
00445 if (log.start_msg(vmm_log::CYCLE_TYP, , `__FILE__, `__LINE__)) begin \
00446 void'(log.text(msg)); \
00447 log.end_msg(); \
00448 end \
00449 /* synopsys translate_on */ \
00450 while (0)
00451
00452 `define vmm_user(n, log, msg) \
00453 do \
00454 /* synopsys translate_off */ \
00455 if (log.start_msg(vmm_log::USER_TYP_``n, , `__FILE__, `__LINE__)) begin \
00456 void'(log.text(msg)); \
00457 log.end_msg(); \
00458 end \
00459 /* synopsys translate_on */ \
00460 while (0)
00461
00462 `endif
00463
00464
00465
00466 //---------------------------------------------------------------------
00467 // Transactor callback and iterator ease-of-invocation macros
00468 //
00469
00470 `define vmm_callback(facade, call) \
00471 \
00472 do foreach (this.callbacks[vmm_i]) begin \
00473 facade cb; \
00474 if (!$cast(cb, this.callbacks[vmm_i])) continue; \
00475 \
00476 cb.call; \
00477 end while (0)
00478
00479
00480 `define foreach_vmm_xactor(xactor, name, inst) \
00481 xactor xact; \
00482 vmm_xactor_iter xactor_iter = new(name, inst); \
00483 for (vmm_xactor _xact = xactor_iter.first(); \
00484 _xact != null; \
00485 _xact = xactor_iter.next()) \
00486 if ($cast(xact, _xact))
00487
00488
00489 //---------------------------------------------------------------------
00490 // Other macros
00491 //
00492
00493 `ifndef VMM_OBJECT_SET_PARENT
00494 `define VMM_OBJECT_SET_PARENT(_child, _parent)
00495 `endif
00496
00497 `include "std_lib/vmm_data_macros.sv"
00498 `include "std_lib/vmm_xactor_macros.sv"
00499 `include "std_lib/vmm_subenv_macros.sv"
00500 `include "std_lib/vmm_env_macros.sv"
00501
00502
00503 `ifdef VMM_PARAM_CHANNEL
00504
00505 `define vmm_channel(T) typedef vmm_channel_typed#(T) T``_channel;
00506
00507 `else
00508
00509 `define vmm_channel_(T) T``_channel
00510
00511 `define vmm_channel(T) \
00512 class `vmm_channel_(T) extends vmm_channel; \
00513 \
00514 function new(string name, \
00515 string inst, \
00516 int full = 1, \
00517 int empty = 0, \
00518 bit fill_as_bytes = 0); \
00519 super.new(name, inst, full, empty, fill_as_bytes); \
00520 endfunction: new \
00521 \
00522 function T unput(int offset = -1); \
00523 $cast(unput, super.unput(offset)); \
00524 endfunction: unput \
00525 \
00526 task get(output T obj, input int offset = 0); \
00527 vmm_data o; \
00528 super.get(o, offset); \
00529 $cast(obj, o); \
00530 endtask: get \
00531 \
00532 task peek(output T obj, input int offset = 0); \
00533 vmm_data o; \
00534 super.peek(o, offset); \
00535 $cast(obj, o); \
00536 endtask: peek \
00537 \
00538 task activate(output T obj, input int offset = 0); \
00539 vmm_data o; \
00540 super.activate(o, offset); \
00541 $cast(obj, o); \
00542 endtask: activate \
00543 \
00544 function T active_slot(); \
00545 $cast(active_slot, super.active_slot()); \
00546 endfunction: active_slot \
00547 \
00548 function T start(); \
00549 $cast(start, super.start()); \
00550 endfunction: start \
00551 \
00552 function T complete(vmm_data status = null); \
00553 $cast(complete, super.complete(status)); \
00554 endfunction: complete \
00555 \
00556 function T remove(); \
00557 $cast(remove, super.remove()); \
00558 endfunction: remove \
00559 \
00560 task tee(output T obj); \
00561 vmm_data o; \
00562 super.tee(o); \
00563 $cast(obj, o); \
00564 endtask: tee \
00565 \
00566 function T for_each(bit reset = 0); \
00567 $cast(for_each, super.for_each(reset)); \
00568 endfunction: for_each \
00569 \
00570 endclass
00571
00572 `endif
00573
00574 `include "std_lib/vmm_atomic_gen.sv"
00575
00576 `ifdef VCS
00577 `ifndef VMM_SOLVE_BEFORE_OPT
00578 `define VMM_SOLVE_BEFORE_OPT hard
00579 `endif
00580 `endif
00581 `ifndef VMM_SOLVE_BEFORE_OPT
00582 `define VMM_SOLVE_BEFORE_OPT
00583 `endif
00584
00585 `include "std_lib/vmm_scenario_gen.sv"
00586
00587
00588
00589
00590
00591
00592 //-------------------------------------------------------
00593 // vmm_test shorthand macros
00594 //
00595
00596 `define vmm_test_begin(testclassname, envclassname, doc) \
00597 class testclassname extends vmm_test; \
00598 envclassname env; \
00599 function new(); \
00600 super.new(`"testclassname`", doc); \
00601 endfunction \
00602 static testclassname testclassname``_inst = new(); \
00603 task run(vmm_env env1); \
00604 $cast(env, env1); \
00605 begin
00606
00607 `define vmm_test_end(testclassname) \
00608 end \
00609 endtask \
00610 endclass
00611
00612
00613 //---------------------------------------------------------------------
00614 // Work-arounds
00615 //
00616
00617 `ifdef NO_STATIC_METHODS
00618 `define VMM_STATIC_M
00619 `else
00620 `define VMM_STATIC_M static
00621 `endif
00622
00623 `ifdef NO_TYPED_AA_IDX
00624 `define VMM_AA_INT *
00625 `else
00626 `define VMM_AA_INT int
00627 `endif
00628
00629
00630 `endif // VMM_MACRO_DEFINED
00631
00632
00633 //
00634 // Protect against multiple inclusion of this file
00635 //
00636 `ifndef VMM__SV
00637 `define VMM__SV
00638
00639
00640 `ifdef VMM_IN_PACKAGE
00641
00642
00643 `ifdef VCS
00644 (* _vcs_vmm_pkg = 1 *)
00645 `endif
00646 package vmm_std_lib;
00647 `endif
00648
00649
00650
00651 `ifdef VCS
00652 (* _vcs_vmm_class = 1 *)
00653 `endif
00654
00655 `include "std_lib/vmm_version.sv"
00656
00657 //---------------------------------------------------------------------
00658 // Forward declarations
00659 //
00660
00661 typedef class vmm_opts;
00662 typedef class vmm_opts_info;
00663 typedef class vmm_log;
00664 typedef class vmm_data;
00665 typedef class vmm_scenario;
00666 typedef class vmm_channel;
00667 typedef class vmm_xactor;
00668 typedef class vmm_notify;
00669 typedef class vmm_consensus;
00670 typedef class vmm_voter;
00671 typedef class vmm_subenv;
00672 typedef class vmm_env;
00673 typedef class vmm_test;
00674 typedef class vmm_test_registry;
00675
00676
00677 typedef class `VMM_DATA;
00678 `ifdef VMM_DATA_BASE
00679 typedef class `VMM_DATA_BASE;
00680 `endif
00681 `ifdef VMM_CHANNEL_BASE
00682 typedef class `VMM_CHANNEL_BASE;
00683 `endif
00684 `ifdef VMM_CONSENSUS_BASE
00685 typedef class `VMM_CONSENSUS_BASE;
00686 `endif
00687 `ifdef VMM_LOG_BASE
00688 typedef class `VMM_LOG_BASE;
00689 `endif
00690 `ifdef VMM_NOTIFY_BASE
00691 typedef class `VMM_NOTIFY_BASE;
00692 `endif
00693 typedef class `VMM_XACTOR;
00694 `ifdef VMM_XACTOR_BASE
00695 typedef class `VMM_XACTOR_BASE;
00696 `endif
00697 typedef class `VMM_SUBENV;
00698 `ifdef VMM_SUBENV_BASE
00699 typedef class `VMM_SUBENV_BASE;
00700 `endif
00701 typedef class `VMM_ENV;
00702 `ifdef VMM_ENV_BASE
00703 typedef class `VMM_ENV_BASE;
00704 `endif
00705
00706
00707 `ifdef VMM_POST_INCLUDE
00708 `include `MM_MACRO_TO_STRING(`VMM_POST_INCLUDE)
00709 `endif
00710
00711
00712 //---------------------------------------------------------------------
00713 // vmm_opts
00714 //
00715
00716 `ifdef VCS
00717 (* _vcs_vmm_class = 1 *)
00718 `endif
00719 class vmm_opts;
00720 static local vmm_opts_info opts_info[string];
00721 static local bit opts_extracted;
00722 static vmm_log log;
00723
00724 extern `VMM_STATIC_M function bit get_bit(string name,
00725 string doc = "");
00726
00727 extern `VMM_STATIC_M function string get_string(string name,
00728 string dflt = "",
00729 string doc = "");
00730 extern `VMM_STATIC_M function int get_int(string name,
00731 int dflt = 0,
00732 string doc = "");
00733
00734 extern `VMM_STATIC_M function void get_help();
00735
00736 extern `VMM_STATIC_M local function bit extract_opts_info();
00737
00738 extern `VMM_STATIC_M local function void add_specified_option(string frmt,
00739 string fname = "Command Line");
00740
00741 extern `VMM_STATIC_M local function void parse_opts_file(string filename);
00742
00743 extern `VMM_STATIC_M local function vmm_opts_info get_opts_by_name(string name);
00744
00745 extern `VMM_STATIC_M local function bit split(string line,
00746 output string argv[$]);
00747 endclass
00748
00749
00750 //---------------------------------------------------------------------
00751 // vmm_log
00752 //
00753
00754 `ifdef VCS
00755 (* _vcs_vmm_class = 1 *)
00756 `endif
00757 class vmm_log_format;
00758 extern virtual function string format_msg(string name,
00759 string inst,
00760 string msg_typ,
00761 string severity,
00762 `ifdef VMM_LOG_FORMAT_FILE_LINE
00763 string fname,
00764 int line,
00765 `endif
00766 ref string lines[$]);
00767
00768 extern virtual function string continue_msg(string name,
00769 string inst,
00770 string msg_typ,
00771 string severity,
00772 `ifdef VMM_LOG_FORMAT_FILE_LINE
00773 string fname,
00774 int line,
00775 `endif
00776 ref string lines[$]);
00777
00778 extern virtual function string abort_on_error(int count,
00779 int limit);
00780
00781 extern virtual function string pass_or_fail(bit pass,
00782 string name,
00783 string inst,
00784 int fatals,
00785 int errors,
00786 int warnings,
00787 int dem_errs,
00788 int dem_warns);
00789 endclass: vmm_log_format
00790
00791
00792 `ifdef VCS
00793 (* vmm_callback_class, _vcs_vmm_class = 1 *)
00794 `endif
00795 class vmm_log_callbacks;
00796 virtual function void pre_abort(vmm_log log);
00797 endfunction
00798
00799 virtual function void pre_stop(vmm_log log);
00800 endfunction
00801
00802 virtual function void pre_debug(vmm_log log);
00803 endfunction
00804 endclass: vmm_log_callbacks
00805
00806
00807 typedef class vmm_log_below_iter;
00808 typedef class vmm_log_msg;
00809 typedef class vmm_log_modifier;
00810 typedef class vmm_log_watchpoint;
00811 typedef class vmm_log_catcher_descr;
00812
00813
00814 `ifdef VCS
00815 (* vmm_private_class, _vcs_vmm_class = 1 *)
00816 `endif
00817 virtual class vmm_log_catcher;
00818 /*local*/ bit issued = 0; //set to 1 if issue function is called
00819 /*local*/ bit thrown = 0 ; //set to 1 if throw function is called
00820
00821 virtual function void caught(vmm_log_msg msg);
00822 this.throw(msg);
00823 endfunction
00824 extern virtual protected function void throw(vmm_log_msg msg);
00825 extern virtual protected function void issue(vmm_log_msg msg);
00826
00827 endclass
00828
00829
00830 `ifdef VCS
00831 (* _vcs_vmm_class = 1 *)
00832 `endif
00833 class vmm_log
00834 `ifdef VMM_LOG_BASE
00835 extends `VMM_LOG_BASE
00836 `endif
00837 ;
00838
00839 //
00840 // Symbolic constants shared by different contexts
00841 //
00842 typedef enum int {DEFAULT
00843 = -1
00844 , UNCHANGED
00845 = -2
00846 } symbols_e;
00847
00848 //
00849 // Symbolic constants for message types
00850 //
00851 typedef enum int {FAILURE_TYP = 'h0001,
00852 NOTE_TYP = 'h0002,
00853 DEBUG_TYP = 'h0004,
00854 REPORT_TYP = 'h0008,
00855 NOTIFY_TYP = 'h0010,
00856 TIMING_TYP = 'h0020,
00857 XHANDLING_TYP = 'h0040,
00858 PROTOCOL_TYP = 'h0080,
00859 TRANSACTION_TYP = 'h0100,
00860 COMMAND_TYP = 'h0200,
00861 CYCLE_TYP = 'h0400,
00862 USER_TYP_0 = 'h0800,
00863 USER_TYP_1 = 'h1000,
00864 USER_TYP_2 = 'h2000,
00865 INTERNAL_TYP = 'h4000,
00866 DEFAULT_TYP = -1,
00867 ALL_TYPS = 'hFFFF
00868 } types_e;
00869
00870 //
00871 // Symbolic values for message severity
00872 //
00873 typedef enum int {FATAL_SEV = 'h0001,
00874 ERROR_SEV = 'h0002,
00875 WARNING_SEV = 'h0004,
00876 NORMAL_SEV = 'h0008,
00877 TRACE_SEV = 'h0010,
00878 DEBUG_SEV = 'h0020,
00879 VERBOSE_SEV = 'h0040,
00880 HIDDEN_SEV = 'h0080,
00881 IGNORE_SEV = 'h0100,
00882 DEFAULT_SEV = -1,
00883 ALL_SEVS = 'hFFFF
00884 } severities_e;
00885
00886 //
00887 // Symbolic values for simulation handling
00888 //
00889 typedef enum int {CONTINUE = 'h0001,
00890 COUNT_ERROR = 'h0002,
00891 DEBUGGER = 'h0004,
00892 DUMP_STACK = 'h0008,
00893 STOP_PROMPT = 'h0010,
00894 ABORT_SIM = 'h0020,
00895 IGNORE = 'h0040,
00896 DEFAULT_HANDLING = -1
00897 } handling_e;
00898
00899 //
00900 // Pre-defined STDOUT in case the simulator does not already define it
00901 //
00902 typedef enum int {STDOUT = 32'h8000_0001} stdout_e;
00903
00904 //
00905 // Global control parameters
00906 //
00907 static local int error_count = 0; // Stop when # of errs
00908 static local int error_limit = 10; // Stop when # of errs
00909 static local string msg_format[$];
00910 static local string prefix;
00911
00912 //vmm log catcher data
00913 static local vmm_log_catcher_descr catcher_cache[`VMM_AA_INT];
00914 local int catcher_ids[$];
00915 static local bit in_catcher = 0;
00916
00917 //
00918 // Local control parameters
00919 //
00920 static local int dflt_lvl = NORMAL_SEV; // Default verbosity level
00921 static local int force_lvl = DEFAULT_SEV; // Forced (global) verbosity level
00922 static local bit plus_debug; // +vmm_log_debug was specified!
00923
00924 local string name; // Name for this object
00925 local string inst; // Instance name for this object
00926 local string orig_inst; // Original instance name for this object
00927
00928 extern function bit uses_hier_inst_name();
00929 extern function void use_hier_inst_name();
00930 extern function void use_orig_inst_name();
00931 local static bit is_orig = 1; // Which one is being used?
00932 local int unsigned parent_count;
00933 extern local function void make_hier_inst_name(string prefix = "");
00934
00935 local int n_msg[`VMM_AA_INT]; // # of messages, per severities
00936 local int n_demoted[`VMM_AA_INT]; // # of demoted messages
00937
00938 //
00939 // Partial message
00940 //
00941 local vmm_log_msg msg;
00942 local string msg_txt[$];
00943
00944 static local int type_list[$];
00945 static local string type_images[`VMM_AA_INT];
00946
00947 static local int sev_list[$];
00948 static local string sev_images[`VMM_AA_INT];
00949
00950 static local vmm_log_modifier modifier_cache[`VMM_AA_INT];
00951 local int modifier_ids[$];
00952 local int has_text_modifiers;
00953
00954 static local vmm_log_watchpoint watchpoint_cache[`VMM_AA_INT];
00955 local int watchpoint_ids[$];
00956
00957 local int enabled_typs; // Filter if type not enableds
00958 local int log_lvl; // Filter trace messages > log_lvl
00959
00960 //
00961 // Callbacks are global to all instances
00962 //
00963 static local vmm_log_format fmt = new;
00964 static local int in_callbacks = 0;
00965 static local vmm_log_callbacks callbacks[$];
00966
00967 //
00968 // File logging
00969 //
00970 local int fp[$];
00971
00972 //
00973 // Iterator
00974 //
00975 local int is_self; // Trivial iterator?
00976 local bit is_all; // Trivial iterator?
00977 static local vmm_log known[$]; // List of known logs
00978
00979 /*local*/ vmm_log below[$]; // Known logs below this one
00980 static local int recurse_id = 0;
00981 local int visited = 0;
00982
00983 static local string pattern[2];
00984 static local bit is_pattern[2];
00985 static local int known_idx = 0;
00986 static local int recurse;
00987 static local vmm_log_below_iter recurse_stack[$];
00988
00989 static vmm_opts _vmm_opts = new;
00990
00991 `ifdef VMM_LOG_BASE_METHODS
00992 `VMM_LOG_BASE_METHODS
00993 `endif
00994
00995 extern function new(string name,
00996 string inst,
00997 vmm_log under = null);
00998
00999 extern virtual function void is_above(vmm_log log);
01000 extern virtual function void is_not_above(vmm_log log);
01001 extern virtual function vmm_log copy(vmm_log to = null);
01002
01003 extern virtual function void set_name(string name);
01004 extern virtual function string get_name();
01005 extern virtual function void set_instance(string inst);
01006 extern virtual function string get_instance();
01007
01008 extern function void reset(string name = "/./",
01009 string inst = "/./",
01010 bit recurse = 0);
01011 extern function vmm_log for_each();
01012 extern virtual function void list(string name = "/./",
01013 string inst = "/./",
01014 bit recurse = 0);
01015
01016 extern virtual function void display(string prefix = "");
01017 extern virtual function string psdisplay(string prefix = "");
01018
01019 extern virtual function void kill();
01020
01021 //
01022 // Formatting
01023 //
01024 extern virtual function vmm_log_format set_format(vmm_log_format fmt);
01025 extern virtual function string set_typ_image(int typ, string image);
01026 extern virtual function string set_sev_image(int severity, string image);
01027
01028 extern /*local*/ function string typ_image(int typ);
01029 extern /*local*/ function string sev_image(int severity);
01030 extern /*local*/ function string handling_image(int handling);
01031 extern local function int default_handling(int severity);
01032
01033 extern virtual function void report(string name = "/./",
01034 string inst = "/./",
01035 bit recurse = 0);
01036
01037
01038 //
01039 // Issue messages
01040 //
01041 extern virtual function bit start_msg(int typ,
01042 int severity = DEFAULT_SEV,
01043 string fname = "",
01044 int line = -1);
01045
01046 extern virtual function bit text(string msg = "");
01047 extern virtual function void end_msg();
01048 extern local function void flush_msg();
01049
01050 //
01051 // Message management
01052 //
01053 extern virtual function void enable_types(int typs,
01054 string name = "",
01055 string inst = "",
01056 bit recursive = 0);
01057 extern virtual function void disable_types(int typs,
01058 string name = "",
01059 string inst = "",
01060 bit recursive = 0);
01061 extern virtual function int modify(string name = "",
01062 string inst = "",
01063 bit recursive = 0,
01064 int typ = ALL_TYPS,
01065 int severity = ALL_SEVS,
01066 string text = "",
01067 int new_typ = UNCHANGED,
01068 int new_severity = UNCHANGED,
01069 int handling = UNCHANGED);
01070 extern virtual function void unmodify(int modification_id = -1,
01071 string name = "",
01072 string inst = "",
01073 bit recursive = 0);
01074
01075 extern local function void promote();
01076 extern local function void filter();
01077 extern local function void notify();
01078
01079 extern virtual function void set_verbosity(int severity,
01080 string name = "",
01081 string inst = "",
01082 bit recursive = 0);
01083 extern function int get_verbosity();
01084
01085 //
01086 // File logging
01087 //
01088 extern virtual function void log_start(int file,
01089 string name = "",
01090 string inst = "",
01091 bit recurse = 0);
01092 extern virtual function void log_stop(int file,
01093 string name = "",
01094 string inst = "",
01095 bit recurse = 0);
01096
01097
01098 //
01099 // Manage error counts
01100 //
01101 extern virtual function void stop_after_n_errors(int n);
01102 extern virtual function int get_message_count(int severity = ALL_SEVS,
01103 string name = "",
01104 string inst = "",
01105 bit recurse = 0);
01106
01107 //
01108 // Synchronize with messages
01109 //
01110 extern virtual task wait_for_msg(string name = "",
01111 string inst = "",
01112 bit recurse = 0,
01113 int typs = ALL_TYPS,
01114 int severity = ALL_SEVS,
01115 string text = "",
01116 logic issued = 1'bx,
01117 ref vmm_log_msg msg);
01118
01119 extern virtual function int create_watchpoint(int typs = ALL_TYPS,
01120 int severity = ALL_SEVS,
01121 string text = "",
01122 logic issued = 1'bx);
01123 extern virtual function void add_watchpoint(int watchpoint_id,
01124 string name = "",
01125 string inst = "",
01126 bit recurse = 0);
01127 extern virtual function void remove_watchpoint(int watchpoint_id = -1,
01128 string name = "",
01129 string inst = "",
01130 bit recurse = 0);
01131 extern virtual task wait_for_watchpoint(int watchpoint_id,
01132 ref vmm_log_msg msg);
01133
01134 extern local function void process_catch(vmm_log_msg msg);
01135 extern function int catch(vmm_log_catcher catcher,
01136 string name = "",
01137 string inst = "",
01138 bit recurse = 0,
01139 int typs = ALL_TYPS,
01140 int severity = ALL_SEVS,
01141 string text = "");
01142 extern function bit uncatch(int catcher_id);
01143 extern function void uncatch_all();
01144
01145 //
01146 // Callback Management
01147 //
01148 extern virtual function void prepend_callback(vmm_log_callbacks cb);
01149 extern virtual function void append_callback(vmm_log_callbacks cb);
01150 extern virtual function void unregister_callback(vmm_log_callbacks cb);
01151
01152
01153
01154
01155 endclass: vmm_log
01156
01157
01158 `ifdef VMM_SB_DS_IN_STDLIB
01159 `include "sb/vmm_sb.sv"
01160 (* _vcs_vmm_class = 1 *)
01161 class vmm_sb_ds_registration;
01162 vmm_sb_ds sb;
01163 bit is_in;
01164 bit is_out;
01165 vmm_sb_ds::ordering_e order;
01166 endclass
01167 `endif
01168
01169
01170 //---------------------------------------------------------------------
01171 // vmm_notify
01172 //
01173
01174 `ifdef VCS
01175 (* vmm_callback_class, _vcs_vmm_class = 1 *)
01176 `endif
01177 virtual class vmm_notify_callbacks;
01178 virtual function void indicated(vmm_data status);
01179 endfunction
01180 endclass
01181
01182 `ifdef VCS
01183 (* _vcs_vmm_class = 1 *)
01184 `endif
01185 virtual class vmm_notification;
01186 virtual task indicate(ref vmm_data status);
01187 $write("FATAL: An instance of vmm_notification::indicate() was not overloaded or super.indicate() was called\n");
01188 $finish;
01189 endtask
01190 virtual task reset();
01191 $write("FATAL: An instance of vmm_notification::reset() was not overloaded or super.reset() was called\n");
01192 $finish;
01193 endtask
01194 endclass
01195
01196
01197 typedef class vmm_notification_config;
01198
01199
01200 `ifdef VCS
01201 (* _vcs_vmm_class = 1 *)
01202 `endif
01203 class vmm_notify
01204 `ifdef VMM_NOTIFY_BASE
01205 extends `VMM_NOTIFY_BASE
01206 `endif
01207 ;
01208 `VMM_LOG log;
01209
01210 typedef enum int {ONE_SHOT = 2,
01211 BLAST = 3,
01212 ON_OFF = 5
01213 } sync_e;
01214
01215 typedef enum bit {SOFT,
01216 HARD} reset_e;
01217
01218
01219 local int last_notification_id = 1000000;
01220 local vmm_notification_config configs[`VMM_AA_INT];
01221
01222 extern function new(`VMM_LOG log);
01223
01224 `ifdef VMM_NOTIFY_BASE_METHODS
01225 `VMM_NOTIFY_BASE_METHODS
01226 `endif
01227
01228 extern virtual function void display(string prefix = "");
01229 extern virtual function string psdisplay(string prefix = "");
01230
01231 extern virtual function vmm_notify copy(vmm_notify to = null);
01232 extern virtual function int configure(int notification_id = -1,
01233 sync_e sync = ONE_SHOT);
01234 extern virtual function int is_configured(int notification_id);
01235
01236 extern virtual function bit is_on(int notification_id);
01237
01238 extern virtual task wait_for(int notification_id);
01239 extern virtual task wait_for_off(int notification_id);
01240
01241 extern virtual function bit is_waited_for(int notification_id);
01242 extern virtual function void terminated(int notification_id);
01243
01244 extern virtual function vmm_data status(int notification_id);
01245 extern virtual function time timestamp(int notification_id);
01246 extern virtual function void indicate(int notification_id,
01247 vmm_data status = null);
01248
01249 extern virtual function void set_notification(int notification_id,
01250 vmm_notification ntfy = null);
01251 extern virtual function vmm_notification get_notification(int notification_id);
01252 extern virtual function void reset(int notification_id = -1,
01253 reset_e rst_typ = SOFT);
01254
01255 extern function void append_callback(int notification_id,
01256 vmm_notify_callbacks cbs);
01257 extern function void unregister_callback(int notification_id,
01258 vmm_notify_callbacks cbs);
01259
01260
01261
01262
01263 `ifdef VMM_SB_DS_IN_STDLIB
01264 extern function void register_vmm_sb_ds(int notification_id,
01265 vmm_sb_ds sb,
01266 vmm_sb_ds::kind_e kind,
01267 vmm_sb_ds::ordering_e order = vmm_sb_ds::IN_ORDER);
01268 extern function void unregister_vmm_sb_ds(int notification_id,
01269 vmm_sb_ds sb);
01270 `endif
01271
01272 endclass
01273
01274
01275 //---------------------------------------------------------------------
01276 // vmm_data
01277 //
01278
01279 `ifdef VCS
01280 (* _vcs_vmm_class = 1 *)
01281 `endif
01282 class vmm_data
01283 `ifdef VMM_DATA_BASE
01284 extends `VMM_DATA_BASE
01285 `endif
01286 ;
01287
01288 local `VMM_LOG log;
01289
01290 int stream_id;
01291 int scenario_id;
01292 int data_id;
01293
01294 `VMM_NOTIFY notify;
01295 typedef enum int {EXECUTE = 999_999,
01296 STARTED = 999_998,
01297 ENDED = 999_997
01298 } notifications_e;
01299
01300 extern function new(`VMM_LOG log
01301 `VMM_DATA_BASE_NEW_ARGS);
01302
01303 `ifdef VMM_DATA_BASE_METHODS
01304 `VMM_DATA_BASE_METHODS
01305 `endif
01306
01307 extern function vmm_log set_log(`VMM_LOG log);
01308
01309 extern function void display(string prefix = "");
01310 extern virtual function string psdisplay(string prefix = "");
01311
01312 extern virtual function bit is_valid(bit silent = 1,
01313 int kind = -1);
01314 extern virtual function vmm_data allocate();
01315 extern virtual function vmm_data copy(vmm_data to = null);
01316 extern virtual protected function void copy_data(vmm_data to);
01317
01318 extern virtual function bit compare( vmm_data to,
01319 output string diff,
01320 input int kind = -1);
01321
01322 extern virtual function int unsigned byte_size(int kind = -1);
01323 extern virtual function int unsigned max_byte_size(int kind = -1);
01324 extern virtual function int unsigned byte_pack(ref logic [7:0] bytes[],
01325 input int unsigned offset = 0,
01326 input int kind = -1);
01327 extern virtual function int unsigned byte_unpack(const ref logic [7:0] bytes[],
01328 input int unsigned offset = 0,
01329 input int len = -1,
01330 input int kind = -1);
01331 extern virtual function bit load(int file);
01332 extern virtual function void save(int file);
01333
01334 //
01335 // Methods and members to support the short-hand macros
01336 //
01337 protected static string __vmm_prefix;
01338 protected static string __vmm_image;
01339 protected static vmm_data __vmm_rhs;
01340 protected static int __vmm_kind;
01341 protected static int __vmm_offset;
01342 protected static int __vmm_len;
01343 protected static bit [4095:0] __vmm_maxbits;
01344 protected static bit __vmm_status;
01345 protected static logic [7:0] __vmm_bytes[];
01346 protected static bit __vmm_done_user;
01347 extern virtual protected function int unsigned __vmm_byte_size(int kind = -1);
01348
01349 typedef enum {DO_PRINT ='h001,
01350 DO_COPY ='h002,
01351 DO_COMPARE ='h004,
01352 DO_PACK ='h010,
01353 DO_UNPACK ='h020,
01354 DO_ALL ='hFFF} do_what_e;
01355
01356 typedef enum {DO_NOCOPY ='h001,
01357 DO_REFCOPY ='h002,
01358 DO_DEEPCOPY ='h004,
01359 HOW_TO_COPY ='h007, // OR of all DO_*COPY
01360 DO_NOCOMPARE ='h008,
01361 DO_REFCOMPARE ='h010,
01362 DO_DEEPCOMPARE ='h020,
01363 HOW_TO_COMPARE ='h038, // OR of all DO_*COMPARE
01364 DO_NONE ='h009, // OR of all DO_NO*
01365 DO_REF ='h012, // OR of all DO_REF*
01366 DO_DEEP ='h024, // OR of all DO_DEEP*
01367 _DO_DUMMY} do_how_e;
01368
01369 function void do_all( do_what_e what,
01370 ref logic [7:0] pack[],
01371 const ref logic [7:0] unpack[]);
01372 endfunction
01373
01374 extern virtual function string do_psdisplay(string prefix = "");
01375
01376 extern virtual function bit do_is_valid(bit silent = 1,
01377 int kind = -1);
01378 extern virtual function vmm_data do_allocate();
01379 extern virtual function vmm_data do_copy(vmm_data to = null);
01380
01381 extern virtual function bit do_compare( vmm_data to,
01382 output string diff,
01383 input int kind = -1);
01384
01385 extern virtual function int unsigned do_byte_size(int kind = -1);
01386 extern virtual function int unsigned do_max_byte_size(int kind = -1);
01387 extern virtual function int unsigned do_byte_pack(ref logic [7:0] bytes[],
01388 input int unsigned offset = 0,
01389 input int kind = -1);
01390 extern virtual function int unsigned do_byte_unpack(const ref logic [7:0] bytes[],
01391 input int unsigned offset = 0,
01392 input int len = -1,
01393 input int kind = -1);
01394
01395
01396 `ifdef VCS
01397 extern function int vmt_hook(vmm_xactor xactor = null,
01398 vmm_data obj = null);
01399
01400
01401 `endif
01402 endclass: vmm_data
01403
01404
01405 //---------------------------------------------------------------------
01406 // vmm_scenario
01407 //
01408
01409 `ifdef VCS
01410 (* _vcs_vmm_class = 1 *)
01411 `endif
01412 class vmm_scenario extends `VMM_SCENARIO_BASE;
01413
01414 local int next_scenario_kind = 0;
01415 local int max_length = 0;
01416 local string scenario_names[`VMM_AA_INT];
01417 local vmm_scenario parent;
01418
01419 int stream_id;
01420 int scenario_id;
01421
01422 rand int unsigned scenario_kind;
01423 rand int unsigned length;
01424 rand int unsigned repeated = 0;
01425 static int unsigned repeat_thresh = 100;
01426
01427 constraint vmm_scenario_valid {
01428 scenario_kind >= 0;
01429 scenario_kind < next_scenario_kind;
01430
01431 length >= 0;
01432 length <= max_length;
01433
01434 repeated >= 0;
01435
01436 solve scenario_kind before length `VMM_SOLVE_BEFORE_OPT;
01437 }
01438
01439 constraint repetition {
01440 repeated == 0;
01441 }
01442
01443 extern function new(`VMM_LOG log `VMM_SCENARIO_NEW_ARGS);
01444
01445 `ifdef VMM_SCENARIO_BASE_METHODS
01446 `VMM_SCENARIO_BASE_METHODS
01447 `endif
01448
01449 extern virtual function string psdisplay(string prefix = "");
01450
01451 extern function int unsigned define_scenario(string name,
01452 int unsigned max_len);
01453 extern function void redefine_scenario(int unsigned scenario_kind,
01454 string name,
01455 int unsigned max_len);
01456 extern function string scenario_name(int unsigned scenario_kind);
01457
01458 extern protected function int unsigned get_max_length();
01459
01460 extern function void set_parent_scenario(vmm_scenario parent);
01461 extern function vmm_scenario get_parent_scenario();
01462 extern virtual task execute(ref int n);
01463 endclass: vmm_scenario
01464
01465
01466 //---------------------------------------------------------------------
01467 // vmm_ms_scenario
01468 //
01469 typedef class vmm_ms_scenario_gen;
01470
01471 `ifdef VCS
01472 (* _vcs_vmm_class = 1 *)
01473 `endif
01474 class vmm_ms_scenario extends `VMM_SCENARIO;
01475 static `VMM_LOG log;
01476 local vmm_ms_scenario_gen context_scenario_gen;
01477
01478 extern function new(`VMM_SCENARIO parent = null
01479 `VMM_SCENARIO_NEW_ARGS);
01480
01481 extern virtual task execute(ref int n);
01482
01483 /*local*/ extern virtual function void Xset_context_genX(vmm_ms_scenario_gen gen);
01484 /*local*/ extern virtual function vmm_ms_scenario_gen Xget_context_genX();
01485
01486 extern virtual function string psdisplay(string prefix);
01487 extern virtual function vmm_ms_scenario get_ms_scenario(string scenario,
01488 string gen = "");
01489 extern virtual function vmm_channel get_channel(string name);
01490 extern virtual task grab_channels(ref vmm_channel channels[$]);
01491 endclass: vmm_ms_scenario
01492
01493
01494 //---------------------------------------------------------------------
01495 // vmm_ms_scenario_election
01496 //
01497 `ifdef VCS
01498 (* _vcs_vmm_class = 1 *)
01499 `endif
01500 class vmm_ms_scenario_election;
01501 int stream_id;
01502 int scenario_id;
01503 int unsigned n_scenarios;
01504 int unsigned last_selected[$];
01505 int unsigned next_in_set;
01506
01507 vmm_ms_scenario scenario_set[$];
01508 rand int select;
01509
01510 constraint vmm_ms_scenario_election_valid {
01511 select >= 0;
01512 select < n_scenarios;
01513 }
01514
01515 constraint round_robin {
01516 select == next_in_set;
01517 }
01518 endclass: vmm_ms_scenario_election
01519
01520
01521 //---------------------------------------------------------------------
01522 // vmm_channel
01523 //
01524
01525 `ifdef VCS
01526 (* _vcs_vmm_class = 1 *)
01527 `endif
01528 class vmm_channel
01529 `ifdef VMM_CHANNEL_BASE
01530 extends `VMM_CHANNEL_BASE
01531 `endif
01532 ;
01533 `VMM_LOG log;
01534 `VMM_NOTIFY notify;
01535
01536 // Predefined notifications
01537 typedef enum int unsigned {FULL,
01538 EMPTY,
01539 PUT,
01540 GOT,
01541 PEEKED,
01542 ACTIVATED,
01543 ACT_STARTED,
01544 ACT_COMPLETED,
01545 ACT_REMOVED,
01546 LOCKED,
01547 UNLOCKED,
01548 GRABBED,
01549 UNGRABBED,
01550 RECORDING,
01551 PLAYBACK,
01552 PLAYBACK_DONE} notifications_e;
01553
01554 // Arguments for lock methods
01555 typedef enum bit [1:0] {SOURCE = 2'b01,
01556 SINK = 2'b10
01557 } endpoints_e;
01558
01559 typedef enum int unsigned {INACTIVE = 0,
01560 PENDING = 1,
01561 STARTED = 2,
01562 COMPLETED = 3
01563 } active_status_e;
01564
01565 static vmm_opts _vmm_opts = new;
01566 static local bit one_log;
01567 static local `VMM_LOG shared_log = null;
01568
01569 local int full = 0;
01570 local int empty = 0;
01571 local bit is_sunk = 0;
01572
01573 local vmm_data data[$];
01574 local vmm_data tee_data[$];
01575 local vmm_data active;
01576 local active_status_e active_status;
01577 local event teed;
01578 local vmm_channel downstream;
01579 local event new_connection;
01580 local bit tee_on = 0;
01581 local bit [1:0] locks;
01582
01583 local bit full_chan;
01584 local event item_added;
01585 local event item_taken;
01586
01587 local int iterator;
01588
01589 local int record_fp;
01590 local time last_record_time;
01591 local bit is_put;
01592 local bit is_playback;
01593 local vmm_xactor producer;
01594 local vmm_xactor consumer;
01595
01596 local `VMM_SCENARIO grab_owners[$];
01597
01598 extern function new(string name,
01599 string inst,
01600 int unsigned full = 1,
01601 int unsigned empty = 0,
01602 bit fill_as_bytes = 1'b0);
01603
01604 `ifdef VMM_CHANNEL_BASE_METHODS
01605 `VMM_CHANNEL_BASE_METHODS
01606 `endif
01607
01608 extern function void reconfigure(int full = -1,
01609 int empty = -1,
01610 logic fill_as_bytes = 1'bx);
01611 extern function int unsigned full_level();
01612 extern function int unsigned empty_level();
01613 extern function int unsigned level();
01614 extern function int unsigned size();
01615
01616 extern function bit is_full();
01617 extern function void flush();
01618 extern function void sink();
01619 extern function void flow();
01620 extern function void reset();
01621
01622 extern function void lock(bit [1:0] who);
01623 extern function void unlock(bit [1:0] who);
01624 extern function bit is_locked(bit [1:0] who);
01625
01626 extern task grab(`VMM_SCENARIO grabber);
01627 extern function void ungrab(`VMM_SCENARIO grabber);
01628 extern function bit is_grabbed();
01629 extern function bit try_grab(`VMM_SCENARIO grabber);
01630 `ifndef VMM_GRAB_DISABLED
01631 // Define the methods for grabbing and releasing the channel
01632 extern local function bit check_grab_owners(`VMM_SCENARIO grabber);
01633 extern local function bit check_all_grab_owners(`VMM_SCENARIO grabber);
01634 extern local function void reset_grabbers();
01635 extern function void sneak(vmm_data obj, int offset = -1, `VMM_SCENARIO grabber = null);
01636 extern task put(vmm_data obj, int offset = -1, `VMM_SCENARIO grabber = null);
01637 /*local*/ extern protected task XputX(vmm_data obj, int offset = -1, `VMM_SCENARIO grabber = null);
01638 extern task playback(output bit success,
01639 input string filename,
01640 input vmm_data factory,
01641 input bit metered = 0,
01642 `VMM_SCENARIO grabber = null);
01643 `else
01644 extern function void sneak(vmm_data obj, int offset = -1);
01645 extern task put(vmm_data obj, int offset = -1);
01646 /*local*/ extern protected task XputX(vmm_data obj, int offset = -1);
01647 extern task playback(output bit success,
01648 input string filename,
01649 input vmm_data factory,
01650 input bit metered = 0);
01651 `endif
01652
01653 extern virtual function void display(string prefix = "");
01654 extern virtual function string psdisplay(string prefix = "");
01655
01656 extern function vmm_data unput(int offset = -1);
01657
01658 extern task get(output vmm_data obj,
01659 input int offset = 0);
01660 extern local task get1(output vmm_data obj,
01661 input int offset = 0);
01662 extern task peek(output vmm_data obj,
01663 input int offset = 0);
01664 extern task activate(output vmm_data obj,
01665 input int offset = 0);
01666
01667 extern function vmm_data active_slot();
01668 extern function vmm_data start();
01669 extern function vmm_data complete(vmm_data status = null);
01670 extern function vmm_data remove();
01671 extern function active_status_e status();
01672
01673 extern function bit tee_mode(bit is_on);
01674 extern task tee(output vmm_data obj);
01675
01676 extern function void connect(vmm_channel downstream);
01677 extern function vmm_data for_each(bit reset = 0);
01678 extern function int unsigned for_each_offset();
01679
01680 extern function bit record(string filename);
01681
01682 extern local function int index(int offset);
01683
01684 /*local*/ extern function void Xrecord_to_fileX(bit [7:0] op_code,
01685 int offset,
01686 time diff_time);
01687
01688
01689 extern function void set_producer(vmm_xactor producer);
01690 extern function void set_consumer(vmm_xactor consumer);
01691 extern function vmm_xactor get_producer();
01692 extern function vmm_xactor get_consumer();
01693 extern function void kill();
01694
01695
01696
01697
01698 `ifndef VMM_GRAB_DISABLED
01699 extern local task block_producer(`VMM_SCENARIO grabber);
01700 `else
01701 extern local task block_producer();
01702 `endif
01703 extern local task block_consumer();
01704 extern local function void unblock_producer();
01705
01706 `ifdef VMM_SB_DS_IN_STDLIB
01707 local vmm_sb_ds_registration _vmm_sb_ds[$];
01708
01709 extern function void register_vmm_sb_ds(vmm_sb_ds sb,
01710 vmm_sb_ds::kind_e kind,
01711 vmm_sb_ds::ordering_e order = vmm_sb_ds::IN_ORDER);
01712 extern function void unregister_vmm_sb_ds(vmm_sb_ds sb);
01713 `endif
01714 endclass
01715
01716
01717 `ifdef VMM_PARAM_CHANNEL
01718
01719 class vmm_channel_typed #(type T = vmm_data) extends vmm_channel;
01720
01721 function new(string name,
01722 string inst,
01723 int full = 1,
01724 int empty = 0,
01725 bit fill_as_bytes = 0);
01726 super.new(name, inst, full, empty, fill_as_bytes);
01727 endfunction: new
01728
01729 function T unput(int offset = -1);
01730 $cast(unput, super.unput(offset));
01731 endfunction: unput
01732
01733 task get(output T obj, input int offset = 0);
01734 vmm_data o;
01735 super.get(o, offset);
01736 $cast(obj, o);
01737 endtask: get
01738
01739 task peek(output T obj, input int offset = 0);
01740 vmm_data o;
01741 super.peek(o, offset);
01742 $cast(obj, o);
01743 endtask: peek
01744
01745 task activate(output T obj, input int offset = 0);
01746 vmm_data o;
01747 super.activate(o, offset);
01748 $cast(obj, o);
01749 endtask: activate
01750
01751 function T active_slot();
01752 $cast(active_slot, super.active_slot());
01753 endfunction: active_slot
01754
01755 function T start();
01756 $cast(start, super.start());
01757 endfunction: start
01758
01759 function T complete(vmm_data status = null);
01760 $cast(complete, super.complete(status));
01761 endfunction: complete
01762
01763 function T remove();
01764 $cast(remove, super.remove());
01765 endfunction: remove
01766
01767 task tee(output T obj);
01768 vmm_data o;
01769 super.tee(o);
01770 $cast(obj, o);
01771 endtask: tee
01772
01773 function T for_each(bit reset = 0);
01774 $cast(for_each, super.for_each(reset));
01775 endfunction: for_each
01776
01777 endclass
01778
01779 `endif
01780
01781
01782 //---------------------------------------------------------------------
01783 // vmm_consensus
01784 //
01785
01786 typedef class vmm_voter;
01787
01788 `ifdef VCS
01789 (* _vcs_vmm_class = 1 *)
01790 `endif
01791 class vmm_consensus
01792 `ifdef VMM_CONSENSUS_BASE
01793 extends `VMM_CONSENSUS_BASE
01794 `endif
01795 ;
01796
01797 `VMM_LOG log;
01798
01799 local int n_dissenters;
01800 local int n_forcing;
01801
01802 local vmm_voter voters[$];
01803
01804 extern function new(string name,
01805 string inst);
01806
01807 `ifdef VMM_CONSENSUS_BASE_METHODS
01808 `VMM_CONSENSUS_BASE_METHODS
01809 `endif
01810
01811 extern function vmm_voter register_voter(string name);
01812 extern function void register_xactor(vmm_xactor xact);
01813 extern function void register_channel(vmm_channel chan);
01814 extern function void register_notification(vmm_notify notify,
01815 int notification);
01816 extern function void register_no_notification(vmm_notify notify,
01817 int notification);
01818 extern function void register_consensus(vmm_consensus vote,
01819 bit force_through = 0);
01820
01821 extern function void unregister_voter(vmm_voter voter);
01822 extern function void unregister_xactor(vmm_xactor xact);
01823 extern function void unregister_channel(vmm_channel chan);
01824 extern function void unregister_notification(vmm_notify notify,
01825 int notification);
01826 extern function void unregister_consensus(vmm_consensus vote);
01827 extern function void unregister_all();
01828
01829 extern task wait_for_consensus();
01830 extern task wait_for_no_consensus();
01831 extern function bit is_reached();
01832 extern function bit is_forced();
01833
01834 extern virtual function string psdisplay(string prefix = "");
01835 extern function void yeas(ref string who[],
01836 ref string why[]);
01837 extern function void nays(ref string who[],
01838 ref string why[]);
01839 extern function void forcing(ref string who[],
01840 ref string why[]);
01841
01842
01843 event new_results;
01844 extern /*local*/ function void XvoteX(bit was_agree,
01845 bit agree,
01846 bit was_forced,
01847 bit forced);
01848 endclass: vmm_consensus
01849
01850 `ifdef VCS
01851 (* _vcs_vmm_class = 1 *)
01852 `endif
01853 class vmm_voter;
01854 local string name;
01855 local vmm_consensus consensus;
01856 local bit vote;
01857 local bit is_forced;
01858 local string why;
01859 local event killme;
01860 local vmm_xactor xactor_voter;
01861 local vmm_channel channel_voter;
01862 local vmm_notify notify_voter;
01863 local int notification;
01864 local vmm_consensus sub_vote;
01865
01866 // Constructor is undocumented
01867 extern /*local*/ function new(string name,
01868 vmm_consensus vote);
01869
01870 extern function void oppose(string why = "No reason specified");
01871 extern function void consent(string why = "No reason specified");
01872 extern function void forced(string why = "No reason specified");
01873
01874 // These methods are not documented either
01875 extern /*local*/ function string get_name();
01876 extern /*local*/ function bit get_vote();
01877 extern /*local*/ function bit get_forced();
01878 extern /*local*/ function string get_reason();
01879 extern /*local*/ function void xactor(vmm_xactor xact);
01880 extern /*local*/ function void channel(vmm_channel chan);
01881 extern /*local*/ function void notify(vmm_notify ntfy, int notification, bit is_on);
01882 extern /*local*/ function void sub_consensus(vmm_consensus vote, bit force_through);
01883 extern /*local*/ function void kill_voter();
01884 extern /*local*/ function vmm_xactor get_xactor();
01885 extern /*local*/ function vmm_channel get_channel();
01886 extern /*local*/ function vmm_notify get_notify();
01887 extern /*local*/ function int get_notification();
01888 extern /*local*/ function vmm_consensus get_consensus();
01889 endclass
01890
01891
01892 //---------------------------------------------------------------------
01893 // vmm_env
01894 //
01895
01896 `ifdef VCS
01897 (* _vcs_vmm_class = 1 *)
01898 `endif
01899 class vmm_env
01900 `ifdef VMM_ENV_BASE
01901 extends `VMM_ENV_BASE
01902 `endif
01903 ;
01904 `VMM_LOG log;
01905 `VMM_NOTIFY notify;
01906
01907 typedef enum int unsigned {GEN_CFG = 1,
01908 BUILD,
01909 RESET_DUT,
01910 CFG_DUT,
01911 START,
01912 RESTART,
01913 WAIT_FOR_END,
01914 STOP,
01915 CLEANUP,
01916 REPORT,
01917 RESTARTED} notifications_e;
01918
01919 typedef enum int unsigned {HARD, SOFT, FIRM} restart_e;
01920
01921 event end_test;
01922 `VMM_CONSENSUS end_vote;
01923
01924 local int step;
01925
01926 local bit reset_rng_state;
01927 local string thread_rng_state_after_new;
01928 local string thread_rng_state_after_pre_test;
01929 local string thread_rng_state_before_start;
01930
01931 local bit soft_restart;
01932 local bit soft_restartable;
01933
01934 static vmm_opts _vmm_opts = new;
01935
01936 extern function new(string name = "Verif Env"
01937 `VMM_ENV_BASE_NEW_ARGS);
01938
01939 `ifdef VMM_ENV_BASE_METHODS
01940 `VMM_ENV_BASE_METHODS
01941 `endif
01942
01943 extern virtual function string psdisplay(string prefix = "");
01944
01945 extern task run();
01946
01947 extern virtual protected task reset_env(restart_e kind);
01948
01949 extern virtual protected task power_on_reset();
01950 extern virtual task hw_reset();
01951
01952 extern virtual task power_up();
01953
01954 extern task pre_test();
01955 extern virtual function void gen_cfg();
01956 extern virtual function void build();
01957 extern virtual task reset_dut();
01958 extern virtual task cfg_dut();
01959 extern virtual task start();
01960 extern virtual task wait_for_end();
01961 extern virtual task stop();
01962 extern virtual task cleanup();
01963 extern virtual task restart(bit reconfig = 0);
01964 extern virtual task restart_test();
01965 extern virtual task report();
01966
01967 extern virtual protected function void save_rng_state();
01968 extern virtual protected function void restore_rng_state();
01969
01970 //
01971 // Methods and members to support the short-hand macros
01972 //
01973 protected static string __vmm_prefix;
01974 protected static string __vmm_image;
01975 protected bit __vmm_done_user;
01976 protected int __vmm_forks;
01977 protected restart_e __vmm_restart;
01978
01979 typedef enum {DO_PRINT ='h001,
01980 DO_START ='h002,
01981 DO_STOP ='h004,
01982 DO_RESET ='h008,
01983 DO_VOTE ='h010,
01984 DO_ALL ='hFFF} do_what_e;
01985
01986
01987 function void do_all(do_what_e what,
01988 vmm_env::restart_e restart_kind = vmm_env::FIRM);
01989 endfunction
01990
01991 extern protected virtual function string do_psdisplay(string prefix = "");
01992 extern protected virtual task do_vote();
01993 extern protected virtual task do_start();
01994 extern protected virtual task do_stop();
01995 extern protected virtual task do_reset(vmm_env::restart_e kind);
01996
01997 endclass
01998
01999
02000 //---------------------------------------------------------------------
02001 // vmm_subenv
02002 //
02003
02004 `ifdef VCS
02005 (* _vcs_vmm_class = 1 *)
02006 `endif
02007 class vmm_subenv
02008 `ifdef VMM_SUBENV_BASE
02009 extends `VMM_SUBENV_BASE
02010 `endif
02011 ;
02012 `VMM_LOG log;
02013
02014 protected `VMM_CONSENSUS end_test;
02015
02016 local enum {NEWED, CONFIGURED, STARTED, STOPPED, CLEANED} state = NEWED;
02017
02018 extern function new(string name,
02019 string inst,
02020 `VMM_CONSENSUS end_test
02021 `VMM_SUBENV_BASE_NEW_ARGS);
02022
02023 `ifdef VMM_SUBENV_BASE_METHODS
02024 `VMM_SUBENV_BASE_METHODS
02025 `endif
02026
02027 extern virtual function string psdisplay(string prefix = "");
02028
02029 extern function vmm_consensus get_consensus();
02030
02031 extern protected function void configured();
02032
02033 extern virtual task start();
02034 extern virtual task stop();
02035 extern virtual task reset(vmm_env::restart_e kind = vmm_env::FIRM);
02036 extern virtual task cleanup();
02037 extern virtual function void report();
02038
02039 //
02040 // Methods and members to support the short-hand macros
02041 //
02042 protected static string __vmm_prefix;
02043 protected static string __vmm_image;
02044 protected bit __vmm_done_user;
02045 protected int __vmm_forks;
02046 protected vmm_env::restart_e __vmm_restart;
02047
02048 typedef enum {DO_PRINT ='h001,
02049 DO_START ='h002,
02050 DO_STOP ='h004,
02051 DO_RESET ='h008,
02052 DO_VOTE ='h010,
02053 DO_ALL ='hFFF} do_what_e;
02054
02055
02056 function void do_all(do_what_e what,
02057 vmm_env::restart_e restart_kind = vmm_env::FIRM);
02058 endfunction
02059
02060 extern protected virtual function string do_psdisplay(string prefix = "");
02061 extern protected virtual task do_vote();
02062 extern protected virtual task do_start();
02063 extern protected virtual task do_stop();
02064 extern protected virtual task do_reset(vmm_env::restart_e kind);
02065
02066 endclass: vmm_subenv
02067
02068
02069 //---------------------------------------------------------------------
02070 // vmm_xactor
02071 //
02072
02073
02074 `ifdef VCS
02075 (* vmm_callback_class, _vcs_vmm_class = 1 *)
02076 `endif
02077 virtual class vmm_xactor_callbacks;
02078 endclass
02079
02080
02081 `ifdef VCS
02082 (* _vcs_vmm_class = 1 *)
02083 `endif
02084 class vmm_xactor
02085 `ifdef VMM_XACTOR_BASE
02086 extends `VMM_XACTOR_BASE
02087 `endif
02088 ;
02089 `VMM_LOG log;
02090 `VMM_NOTIFY notify;
02091
02092 int stream_id;
02093
02094 typedef enum int {XACTOR_IDLE = 999999,
02095 XACTOR_BUSY = 999998,
02096 XACTOR_STARTED = 999997,
02097 XACTOR_STOPPED = 999996,
02098 XACTOR_RESET = 999995,
02099 XACTOR_STOPPING = 999994,
02100 XACTOR_IS_STOPPED = 999993
02101 } notifications_e;
02102
02103 local bit start_it;
02104 local bit stop_it;
02105 local bit reset_it;
02106 local event control_event;
02107 local int n_threads_to_stop;
02108 local int n_threads_stopped;
02109 local bit is_stopped;
02110 protected int reset_pending = 0;
02111
02112 local bit main_running;
02113
02114 local bit save_main_rng_state;
02115 local bit restore_main_rng_state;
02116 local string main_rng_state;
02117
02118 /*local*/ vmm_channel Xinput_chansX[$];
02119 /*local*/ vmm_channel Xoutput_chansX[$];
02120 /*local*/ static vmm_xactor _vmm_available_xactor[$];
02121
02122 protected vmm_xactor_callbacks callbacks[$];
02123
02124 extern function new(string name,
02125 string inst,
02126 int stream_id = -1
02127 `VMM_XACTOR_BASE_NEW_ARGS);
02128
02129 extern virtual function void kill();
02130
02131 `ifdef VMM_XACTOR_BASE_METHODS
02132 `VMM_XACTOR_BASE_METHODS
02133 `endif
02134
02135
02136
02137
02138 typedef enum int {SOFT_RST,
02139 PROTOCOL_RST,
02140 FIRM_RST,
02141 HARD_RST} reset_e;
02142
02143 extern virtual function string get_name();
02144 extern virtual function string get_instance();
02145
02146 extern virtual function void start_xactor();
02147 extern virtual function void stop_xactor();
02148 extern virtual function void reset_xactor(vmm_xactor::reset_e rst_typ = SOFT_RST);
02149
02150 extern virtual function void save_rng_state();
02151 extern virtual function void restore_rng_state();
02152
02153 extern virtual function string psdisplay(string prefix = "");
02154 extern virtual function void xactor_status(string prefix = "");
02155
02156 extern virtual protected task main();
02157 extern local function void check_all_threads_stopped();
02158 extern protected task wait_if_stopped(int unsigned n_threads = 1);
02159 extern protected task wait_if_stopped_or_empty(vmm_channel chan,
02160 int unsigned n_threads = 1);
02161
02162 extern virtual function void prepend_callback(vmm_xactor_callbacks cb);
02163 extern virtual function void append_callback(vmm_xactor_callbacks cb);
02164 extern virtual function void unregister_callback(vmm_xactor_callbacks cb);
02165
02166 extern function void get_input_channels(ref vmm_channel chans[$]);
02167 extern function void get_output_channels(ref vmm_channel chans[$]);
02168
02169
02170
02171
02172 `ifdef VMM_SB_DS_IN_STDLIB
02173 local vmm_sb_ds_registration _vmm_sb_ds[$];
02174
02175 extern protected function void inp_vmm_sb_ds(vmm_data tr);
02176 extern protected function void exp_vmm_sb_ds(vmm_data tr);
02177 extern function void register_vmm_sb_ds(vmm_sb_ds sb,
02178 vmm_sb_ds::kind_e kind,
02179 vmm_sb_ds::ordering_e order = vmm_sb_ds::IN_ORDER);
02180 extern function void unregister_vmm_sb_ds(vmm_sb_ds sb);
02181 `endif
02182
02183 //
02184 // Methods and members to support the short-hand macros
02185 //
02186 protected static string __vmm_prefix;
02187 protected static string __vmm_image;
02188 protected static bit __vmm_done_user;
02189
02190 typedef enum {DO_PRINT ='h001,
02191 DO_START ='h002,
02192 DO_STOP ='h004,
02193 DO_RESET ='h010,
02194 DO_KILL ='h020,
02195 DO_ALL ='hFFF} do_what_e;
02196
02197
02198 function void do_all(do_what_e what,
02199 vmm_xactor::reset_e rst_typ = SOFT_RST);
02200 endfunction
02201
02202 extern protected virtual function string do_psdisplay(string prefix = "");
02203 extern protected virtual function void do_start_xactor();
02204 extern protected virtual function void do_stop_xactor();
02205 extern protected virtual function void do_reset_xactor(vmm_xactor::reset_e rst_typ);
02206 extern protected virtual function void do_kill_xactor();
02207 endclass
02208
02209
02210 class vmm_xactor_iter;
02211 static `VMM_LOG log = new("vmm_xactor_iter", "class");
02212
02213 string name;
02214 string inst;
02215
02216 local static vmm_xactor _vmm_xactor = new("vmm_xactor_iter::_vmm_xactor", "static");
02217 local int idx;
02218
02219 extern function new(string name = "",
02220 string inst = "");
02221 extern function vmm_xactor first();
02222 extern function vmm_xactor next();
02223 extern function vmm_xactor xactor();
02224
02225 extern protected function void move_iterator();
02226 endclass
02227
02228
02229 //---------------------------------------------------------------------
02230 // vmm_ms_scenario_gen
02231 //
02232 `ifdef VCS
02233 (* _vcs_vmm_class = 1 *)
02234 `endif
02235 class vmm_ms_scenario_gen_callbacks extends vmm_xactor_callbacks;
02236 virtual task pre_scenario_randomize(vmm_ms_scenario_gen gen,
02237 ref vmm_ms_scenario scenario);
02238 endtask
02239
02240 virtual task post_scenario_gen(vmm_ms_scenario_gen gen,
02241 vmm_ms_scenario scenario,
02242 ref bit dropped);
02243 endtask
02244 endclass: vmm_ms_scenario_gen_callbacks
02245
02246
02247 `ifdef VCS
02248 (* _vcs_vmm_class = 1 *)
02249 `endif
02250 class vmm_ms_scenario_gen extends `VMM_XACTOR;
02251 local vmm_channel channel_registry[string];
02252 local vmm_ms_scenario mss_registry[string];
02253 local vmm_ms_scenario_gen mssg_registry[string];
02254
02255 int unsigned stop_after_n_insts;
02256 int unsigned stop_after_n_scenarios;
02257
02258 typedef enum int {GENERATED, DONE} symbols_e;
02259
02260 vmm_ms_scenario_election select_scenario;
02261 vmm_ms_scenario scenario_set[$];
02262
02263 protected int scenario_count;
02264 protected int inst_count;
02265
02266 extern function new(string inst, int stream_id=-1
02267 `VMM_XACTOR_NEW_ARGS);
02268 extern virtual function string psdisplay(string prefix = "");
02269
02270 extern function int unsigned get_n_insts();
02271 extern function int unsigned get_n_scenarios();
02272 extern virtual function void reset_xactor(vmm_xactor::reset_e rst_typ = SOFT_RST);
02273
02274 extern virtual function void register_channel(string name,
02275 vmm_channel chan);
02276 extern virtual function bit channel_exists(string name);
02277 extern virtual function void replace_channel(string name,
02278 vmm_channel chan);
02279 extern virtual function void get_all_channel_names(ref string name[$]);
02280 extern virtual function void get_names_by_channel(vmm_channel chan,
02281 ref string name[$]);
02282 extern virtual function string get_channel_name(vmm_channel chan);
02283 extern virtual function bit unregister_channel(vmm_channel chan);
02284 extern virtual function vmm_channel unregister_channel_by_name(string name);
02285 extern virtual function vmm_channel get_channel(string name);
02286
02287 extern virtual function void register_ms_scenario(string name,
02288 vmm_ms_scenario scenario);
02289 extern virtual function bit ms_scenario_exists(string name);
02290 extern virtual function void replace_ms_scenario(string name,
02291 vmm_ms_scenario scenario);
02292 extern virtual function void get_all_ms_scenario_names(ref string name[$]);
02293 extern virtual function void get_names_by_ms_scenario(vmm_ms_scenario scenario,
02294 ref string name[$]);
02295 extern virtual function string get_ms_scenario_name(vmm_ms_scenario scenario);
02296 extern virtual function int get_ms_scenario_index(vmm_ms_scenario scenario);
02297 extern virtual function bit unregister_ms_scenario(vmm_ms_scenario scenario);
02298 extern virtual function vmm_ms_scenario unregister_ms_scenario_by_name(string name);
02299 extern virtual function vmm_ms_scenario get_ms_scenario(string name);
02300
02301 extern virtual function void register_ms_scenario_gen(string name,
02302 vmm_ms_scenario_gen scenario_gen);
02303 extern virtual function bit ms_scenario_gen_exists(string name);
02304 extern virtual function void replace_ms_scenario_gen(string name,
02305 vmm_ms_scenario_gen scenario_gen);
02306 extern virtual function void get_all_ms_scenario_gen_names(ref string name[$]);
02307 extern virtual function void get_names_by_ms_scenario_gen(vmm_ms_scenario_gen scenario_gen,
02308 ref string name[$]);
02309 extern virtual function string get_ms_scenario_gen_name(vmm_ms_scenario_gen scenario_gen);
02310 extern virtual function bit unregister_ms_scenario_gen(vmm_ms_scenario_gen scenario_gen);
02311 extern virtual function vmm_ms_scenario_gen unregister_ms_scenario_gen_by_name(string name);
02312 extern virtual function vmm_ms_scenario_gen get_ms_scenario_gen(string name);
02313
02314 extern virtual protected task main();
02315 endclass: vmm_ms_scenario_gen
02316
02317
02318 `ifdef VCS
02319 (* _vcs_vmm_class = 1 *)
02320 `endif
02321 class vmm_broadcast extends `VMM_XACTOR;
02322
02323 typedef enum {AFAP = 1,
02324 ALAP = 2
02325 } bcast_mode_e;
02326
02327 local vmm_channel in_chan;
02328
02329 local int n_out_chans;
02330 local bit dflt_use_refs;
02331 local int mode;
02332
02333 local bit use_refs[$];
02334 local bit is_on[$];
02335 local vmm_channel out_chans[$];
02336
02337 local event new_cycle;
02338
02339 extern function new(string name,
02340 string inst,
02341 vmm_channel source,
02342 bit use_references = 1,
02343 int mode = AFAP
02344 `VMM_XACTOR_NEW_ARGS);
02345 extern virtual function string psdisplay(string prefix = "");
02346
02347 extern virtual task broadcast_mode(bcast_mode_e mode);
02348 extern virtual function int new_output(vmm_channel channel,
02349 logic use_references = 1'bx);
02350 extern virtual function void bcast_on(int unsigned output_id);
02351 extern virtual function void bcast_off(int unsigned output_id);
02352 extern virtual protected function bit add_to_output(int unsigned decision_id,
02353 int unsigned output_id,
02354 vmm_channel channel,
02355 vmm_data obj);
02356 extern virtual function void start_xactor();
02357 extern virtual function void stop_xactor();
02358 extern virtual function void reset_xactor(vmm_xactor::reset_e rst_typ = SOFT_RST);
02359 extern protected virtual task main();
02360
02361 extern local function void bcast_on_off(int channel_id,
02362 int on_off);
02363 extern virtual task bcast_to_output(int channel_id,
02364 int on_off);
02365 extern local task broadcast();
02366 extern local task sink_if_outs();
02367 endclass : vmm_broadcast
02368
02369
02370 //---------------------------------------------------------------------
02371 // vmm_scheduler
02372 //
02373
02374 `ifdef VCS
02375 (* _vcs_vmm_class = 1 *)
02376 `endif
02377 class vmm_scheduler_election;
02378 int instance_id;
02379 int unsigned election_id;
02380
02381 int unsigned n_sources;
02382 vmm_channel sources[$];
02383 int unsigned ids[$];
02384 int unsigned id_history[$];
02385 vmm_data obj_history[$];
02386 int unsigned next_idx;
02387
02388 rand int unsigned source_idx;
02389 rand int unsigned obj_offset;
02390
02391 constraint vmm_scheduler_election_valid {
02392 obj_offset == 0;
02393 source_idx >= 0;
02394 source_idx < n_sources;
02395 }
02396
02397 constraint default_round_robin {
02398 source_idx == next_idx;
02399 }
02400 endclass
02401
02402
02403 `ifdef VCS
02404 (* _vcs_vmm_class = 1 *)
02405 `endif
02406 class vmm_scheduler extends `VMM_XACTOR;
02407
02408 vmm_scheduler_election randomized_sched;
02409
02410 protected vmm_channel out_chan;
02411
02412 local vmm_channel sources[$];
02413 local int is_on[$];
02414 local int instance_id;
02415 local int election_count;
02416 local event next_cycle;
02417
02418 extern function new(string name,
02419 string inst,
02420 vmm_channel destination,
02421 int instance_id = -1
02422 `VMM_XACTOR_NEW_ARGS);
02423 extern virtual function string psdisplay(string prefix = "");
02424
02425 extern virtual function int new_source(vmm_channel channel);
02426 extern virtual task sched_from_input(int channel_id,
02427 int on_off);
02428 extern virtual protected task schedule(output vmm_data obj,
02429 input vmm_channel sources[$],
02430 input int unsigned input_ids[$]);
02431 extern virtual protected task get_object(output vmm_data obj,
02432 input vmm_channel source,
02433 input int unsigned input_id,
02434 input int offset);
02435 extern virtual function void start_xactor();
02436 extern virtual function void stop_xactor();
02437 extern virtual function void reset_xactor(vmm_xactor::reset_e rst_typ = SOFT_RST);
02438 extern protected virtual task main();
02439
02440 extern local task schedule_cycle();
02441 endclass
02442
02443
02444 //---------------------------------------------------------------------
02445 // XVC
02446 //
02447
02448 typedef class xvc_xactor;
02449
02450 `ifdef VCS
02451 (* _vcs_vmm_class = 1 *)
02452 `endif
02453 class xvc_action extends `VMM_DATA;
02454 local string name;
02455
02456 vmm_xactor_callbacks callbacks[];
02457
02458 extern function new(string name,
02459 vmm_log log);
02460
02461 extern function string get_name();
02462
02463 extern virtual function xvc_action parse(string argv[]);
02464 extern virtual task execute(vmm_channel exec_chan,
02465 xvc_xactor xvc);
02466
02467 extern virtual function string psdisplay(string prefix = "");
02468 extern virtual function bit is_valid(bit silent = 1,
02469 int kind = -1);
02470
02471 extern virtual function vmm_data allocate();
02472 extern virtual function vmm_data copy(vmm_data to = null);
02473 extern virtual protected function void copy_data(vmm_data to);
02474
02475 extern virtual function bit compare(input vmm_data to,
02476 output string diff,
02477 input int kind = -1);
02478
02479 extern virtual function int unsigned byte_size(int kind = -1);
02480 extern virtual function int unsigned max_byte_size(int kind = -1);
02481 extern virtual function int unsigned byte_pack(ref logic [7:0] bytes[],
02482 input int unsigned offset = 0,
02483 input int kind = -1);
02484 extern virtual function int unsigned byte_unpack(const ref logic [7:0] bytes[],
02485 input int unsigned offset = 0,
02486 input int len = -1,
02487 input int kind = -1);
02488 endclass: xvc_action
02489
02490 `vmm_channel(xvc_action)
02491
02492
02493 `ifdef VCS
02494 (* _vcs_vmm_class = 1 *)
02495 `endif
02496 class xvc_xactor extends `VMM_XACTOR;
02497
02498 `VMM_LOG trace;
02499
02500 xvc_action_channel action_chan;
02501 xvc_action_channel interrupt_chan;
02502
02503 protected vmm_channel exec_chan;
02504 protected vmm_xactor xactors[];
02505
02506 local xvc_action known_actions[$];
02507 local xvc_action idle;
02508
02509 local bit interrupt;
02510 local bit interrupted;
02511 local event interrupted_event;
02512 local event rte;
02513 local xvc_action executing;
02514 local xvc_action suspended;
02515
02516 extern function new(string name,
02517 string inst,
02518 int stream_id = -1,
02519 xvc_action_channel action_chan = null,
02520 xvc_action_channel interrupt_chan = null
02521 `VMM_XACTOR_NEW_ARGS);
02522
02523 extern function void add_action(xvc_action action);
02524 extern function xvc_action parse(string argv[]);
02525
02526 extern virtual function void start_xactor();
02527 extern virtual function void stop_xactor();
02528 extern virtual function void reset_xactor(vmm_xactor::reset_e rst_typ = SOFT_RST);
02529
02530 extern virtual function void xactor_status(string prefix = "");
02531
02532 extern virtual task main();
02533
02534 extern task wait_if_interrupted();
02535
02536 extern local task execute_actions();
02537 extern local task execute_interruptions();
02538 extern local task execute_action(xvc_action_channel chan,
02539 string descr);
02540
02541 extern virtual function void save_rng_state();
02542 extern virtual function void restore_rng_state();
02543 endclass: xvc_xactor
02544
02545
02546 `ifdef VCS
02547 (* _vcs_vmm_class = 1 *)
02548 `endif
02549 class xvc_manager;
02550
02551 `VMM_LOG log;
02552 `VMM_LOG trace;
02553
02554 `VMM_NOTIFY notify;
02555
02556 protected xvc_xactor xvcQ[$];
02557
02558 extern function new(string inst = "Main");
02559
02560 extern function bit add_xvc(xvc_xactor xvc);
02561 extern function bit remove_xvc(xvc_xactor xvc);
02562
02563 extern function bit split(string command,
02564 ref string argv[]);
02565
02566 endclass: xvc_manager
02567
02568
02569 //------------------------------------------------------------
02570 // vmm_test
02571 //
02572 `ifdef VCS
02573 (* _vcs_vmm_class = 1 *)
02574 `endif
02575 class vmm_test;
02576 local string name;
02577 local string doc;
02578 vmm_log log;
02579
02580 static vmm_test_registry registry = new;
02581
02582 extern function new(string name,
02583 string doc = "");
02584
02585 extern virtual task run(vmm_env env);
02586
02587 extern virtual function string get_name();
02588 extern virtual function string get_doc();
02589
02590 extern /*local*/ function void Xset_log_instanceX(string inst);
02591 endclass
02592
02593
02594 `include "std_lib/vmm_opts.sv"
02595 `include "std_lib/vmm_log.sv"
02596 `include "std_lib/vmm_notify.sv"
02597 `include "std_lib/vmm_data.sv"
02598 `include "std_lib/vmm_scenario.sv"
02599 `include "std_lib/vmm_channel.sv"
02600 `include "std_lib/vmm_consensus.sv"
02601 `include "std_lib/vmm_subenv.sv"
02602 `include "std_lib/vmm_env.sv"
02603 `include "std_lib/vmm_xactor.sv"
02604 `include "std_lib/vmm_broadcast.sv"
02605 `include "std_lib/vmm_scheduler.sv"
02606 `include "std_lib/vmm_ms_scenario_gen.sv"
02607 `include "std_lib/xvc_action.sv"
02608 `include "std_lib/xvc_xactor.sv"
02609 `include "std_lib/xvc_manager.sv"
02610 `ifdef VMM_XVC_MANAGER
02611 `include "std_lib/vmm_xvc_manager.sv"
02612 `endif
02613 `include "std_lib/vmm_test.sv"
02614
02615
02616 `ifdef VMM_IN_PACKAGE
02617 endpackage: vmm_std_lib
02618 `endif
02619
02620 `endif
02621
02622 `ifdef VMM_IN_PACKAGE
02623 import vmm_std_lib::*;
02624 `endif