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 // 00037 `ifdef VCS 00038 `define VCS2006_06 00039 `endif 00040 00041 00042 //--------------------------------------------------------------------- 00043 // Functionality that must be provided through DPI/System tasks 00044 // 00045 00046 `ifndef VMM_DPI_ 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 // 00058 `ifndef vmm_sformatf 00059 `define vmm_sformatf $psprintf 00060 `endif 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 00075 `ifdef VCS 00076 `define vmm_str_match(str, regex) str.match(regex) 00077 `define vmm_str_prematch(str) str.prematch() 00078 `define vmm_str_postmatch(str) str.postmatch() 00079 `define vmm_str_backref(str, n) str.backref(n) 00080 00081 `else 00082 00083 `ifdef VMM_NO_STR_DPI 00084 00085 `define vmm_str_match(str, regex) 0 00086 `define vmm_str_prematch(str) "" 00087 `define vmm_str_postmatch(str) "" 00088 `define vmm_str_backref(str, n) "" 00089 00090 `else 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 00102 `endif 00103 00104 `endif 00105 00106 00107 `endif // VMM_DPI_ 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 00116 `ifndef VMM_MACRO_DEFINED 00117 `define VMM_MACRO_DEFINED 00118 00119 00120 //--------------------------------------------------------------------- 00121 // User customization macros 00122 // 00123 00124 00125 `ifdef VMM_PRE_INCLUDE 00126 `include `MM_PRE_INCLUDE 00127 `endif 00128 00129 00130 `ifndef VMM_DATA 00131 `define VMM_DATA vmm_data 00132 `endif 00133 `ifndef VMM_DATA_NEW_ARGS 00134 `define VMM_DATA_NEW_ARGS 00135 `define VMM_DATA_NEW_EXTERN_ARGS 00136 `define VMM_DATA_NEW_CALL 00137 `endif 00138 `ifndef VMM_DATA_BASE_NEW_ARGS 00139 `define VMM_DATA_BASE_NEW_ARGS 00140 `define VMM_DATA_BASE_NEW_EXTERN_ARGS 00141 `endif 00142 `ifdef VMM_DATA_BASE 00143 `ifndef VMM_DATA_BASE_NEW_CALL 00144 `define VMM_DATA_BASE_NEW_CALL 00145 `endif 00146 `endif 00147 `ifndef VMM_DATA_BASE_METHODS 00148 `define VMM_DATA_BASE_METHODS 00149 `endif 00150 00151 `ifndef VMM_CHANNEL 00152 `define VMM_CHANNEL vmm_channel 00153 `endif 00154 `ifdef VMM_CHANNEL_BASE 00155 `ifndef VMM_CHANNEL_BASE_NEW_CALL 00156 `define VMM_CHANNEL_BASE_NEW_CALL 00157 `endif 00158 `endif 00159 `ifndef VMM_CHANNEL_BASE_METHODS 00160 `define VMM_CHANNEL_BASE_METHODS 00161 `endif 00162 00163 `ifndef VMM_CONSENSUS 00164 `define VMM_CONSENSUS vmm_consensus 00165 `endif 00166 `ifdef VMM_CONSENSUS_BASE 00167 `ifndef VMM_CONSENSUS_BASE_NEW_CALL 00168 `define VMM_CONSENSUS_BASE_NEW_CALL 00169 `endif 00170 `endif 00171 `ifndef VMM_CONSENSUS_BASE_METHODS 00172 `define VMM_CONSENSUS_BASE_METHODS 00173 `endif 00174 00175 `ifndef VMM_LOG 00176 `define VMM_LOG vmm_log 00177 `endif 00178 `ifdef VMM_LOG_BASE 00179 `ifndef VMM_LOG_BASE_NEW_CALL 00180 `define VMM_LOG_BASE_NEW_CALL 00181 `endif 00182 `endif 00183 `ifndef VMM_LOG_BASE_METHODS 00184 `define VMM_LOG_BASE_METHODS 00185 `endif 00186 00187 `ifndef VMM_NOTIFY 00188 `define VMM_NOTIFY vmm_notify 00189 `endif 00190 `ifdef VMM_NOTIFY_BASE 00191 `ifndef VMM_NOTIFY_BASE_NEW_CALL 00192 `define VMM_NOTIFY_BASE_NEW_CALL 00193 `endif 00194 `endif 00195 `ifndef VMM_NOTIFY_BASE_METHODS 00196 `define VMM_NOTIFY_BASE_METHODS 00197 `endif 00198 00199 `ifndef VMM_XACTOR 00200 `define VMM_XACTOR vmm_xactor 00201 `endif 00202 `ifndef VMM_XACTOR_NEW_ARGS 00203 `define VMM_XACTOR_NEW_ARGS 00204 `define VMM_XACTOR_NEW_EXTERN_ARGS 00205 `define VMM_XACTOR_NEW_CALL 00206 `endif 00207 `ifndef VMM_XACTOR_BASE_NEW_ARGS 00208 `define VMM_XACTOR_BASE_NEW_ARGS 00209 `define VMM_XACTOR_BASE_NEW_EXTERN_ARGS 00210 `endif 00211 `ifdef VMM_XACTOR_BASE 00212 `ifndef VMM_XACTOR_BASE_NEW_CALL 00213 `define VMM_XACTOR_BASE_NEW_CALL 00214 `endif 00215 `endif 00216 `ifndef VMM_XACTOR_BASE_METHODS 00217 `define VMM_XACTOR_BASE_METHODS 00218 `endif 00219 00220 `ifndef VMM_SUBENV 00221 `define VMM_SUBENV vmm_subenv 00222 `endif 00223 `ifndef VMM_SUBENV_NEW_ARGS 00224 `define VMM_SUBENV_NEW_ARGS 00225 `define VMM_SUBENV_NEW_EXTERN_ARGS 00226 `define VMM_SUBENV_NEW_CALL 00227 `endif 00228 `ifndef VMM_SUBENV_BASE_NEW_ARGS 00229 `define VMM_SUBENV_BASE_NEW_ARGS 00230 `define VMM_SUBENV_BASE_NEW_EXTERN_ARGS 00231 `endif 00232 `ifdef VMM_SUBENV_BASE 00233 `ifndef VMM_SUBENV_BASE_NEW_CALL 00234 `define VMM_SUBENV_BASE_NEW_CALL 00235 `endif 00236 `endif 00237 `ifndef VMM_SUBENV_BASE_METHODS 00238 `define VMM_SUBENV_BASE_METHODS 00239 `endif 00240 00241 `ifndef VMM_ENV 00242 `define VMM_ENV vmm_env 00243 `endif 00244 `ifndef VMM_ENV_NEW_ARGS 00245 `define VMM_ENV_NEW_ARGS 00246 `define VMM_ENV_NEW_EXTERN_ARGS 00247 `define VMM_ENV_NEW_CALL 00248 `endif 00249 `ifndef VMM_ENV_BASE_NEW_ARGS 00250 `define VMM_ENV_BASE_NEW_ARGS 00251 `define VMM_ENV_BASE_NEW_EXTERN_ARGS 00252 `endif 00253 `ifdef VMM_ENV_BASE 00254 `ifndef VMM_ENV_BASE_NEW_CALL 00255 `define VMM_ENV_BASE_NEW_CALL 00256 `endif 00257 `endif 00258 `ifndef VMM_ENV_BASE_METHODS 00259 `define VMM_ENV_BASE_METHODS 00260 `endif 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 00297 `ifdef VMM_NULL_LOG_MACROS 00298 00299 `define vmm_trace(log, msg) 00300 `define vmm_debug(log, msg) 00301 `define vmm_verbose(log, msg) 00302 `define vmm_note(log, msg) 00303 `define vmm_report(log, msg) 00304 `define vmm_command(log, msg) 00305 `define vmm_protocol(log, msg) 00306 `define vmm_transaction(log, msg) 00307 `define vmm_cycle(log, msg) 00308 `define vmm_user(n, log, msg) 00309 00310 `else 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 00392 `endif 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 00415 `include "std_lib/vmm_data_macros.sv" 00416 00417 00418 `ifdef VMM_PARAM_CHANNEL 00419 00420 `define vmm_channel(T) typedef vmm_channel_typed#(T) T``_channel; 00421 00422 `else 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 00486 `endif 00487 00488 `include "std_lib/vmm_atomic_gen.sv" 00489 `include "std_lib/vmm_scenario_gen.sv" 00490 00491 00492 00493 00494 00495 `endif // VMM_MACRO_DEFINED 00496 00497 00498 // 00499 // Protect against multiple inclusion of this file 00500 // 00501 `ifndef VMM__SV 00502 `define VMM__SV 00503 00504 00505 `ifdef VMM_IN_PACKAGE 00506 00507 00508 `ifdef VCS 00509 (* _vcs_vmm_pkg = 1 *) 00510 `endif 00511 package vmm_std_lib; 00512 `endif 00513 00514 00515 00516 //--------------------------------------------------------------------- 00517 // vmm_version 00518 // 00519 00520 `ifdef VCS 00521 (* _vcs_vmm_class = 1 *) 00522 `endif 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; 00547 `ifdef VMM_DATA_BASE 00548 typedef class `VMM_DATA_BASE; 00549 `endif 00550 `ifdef VMM_CHANNEL_BASE 00551 typedef class `VMM_CHANNEL_BASE; 00552 `endif 00553 `ifdef VMM_CONSENSUS_BASE 00554 typedef class `VMM_CONSENSUS_BASE; 00555 `endif 00556 `ifdef VMM_LOG_BASE 00557 typedef class `VMM_LOG_BASE; 00558 `endif 00559 `ifdef VMM_NOTIFY_BASE 00560 typedef class `VMM_NOTIFY_BASE; 00561 `endif 00562 typedef class `VMM_XACTOR; 00563 `ifdef VMM_XACTOR_BASE 00564 typedef class `VMM_XACTOR_BASE; 00565 `endif 00566 typedef class `VMM_SUBENV; 00567 `ifdef VMM_SUBENV_BASE 00568 typedef class `VMM_SUBENV_BASE; 00569 `endif 00570 typedef class `VMM_ENV; 00571 `ifdef VMM_ENV_BASE 00572 typedef class `VMM_ENV_BASE; 00573 `endif 00574 00575 00576 `ifdef VMM_POST_INCLUDE 00577 `include `MM_POST_INCLUDE 00578 `endif 00579 00580 00581 //--------------------------------------------------------------------- 00582 // vmm_log 00583 // 00584 00585 `ifdef VCS 00586 (* _vcs_vmm_class = 1 *) 00587 `endif 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 00615 `ifdef VCS 00616 (* vmm_callback_class, _vcs_vmm_class = 1 *) 00617 `endif 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 00635 `ifdef VCS 00636 (* _vcs_vmm_class = 1 *) 00637 `endif 00638 class vmm_log 00639 `ifdef VMM_LOG_BASE 00640 extends `VMM_LOG_BASE 00641 `endif 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 00781 `ifdef VMM_LOG_BASE_METHODS 00782 `VMM_LOG_BASE_METHODS 00783 `endif 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 00934 `ifdef VMM_SB_DS_IN_STDLIB 00935 `include "sb/vmm_sb.sv" 00936 (* _vcs_vmm_class = 1 *) 00937 class vmm_sb_ds_registration; 00938 vmm_sb_ds sb; 00939 bit is_in; 00940 bit is_out; 00941 vmm_sb_ds::ordering_e order; 00942 endclass 00943 `endif 00944 00945 00946 //--------------------------------------------------------------------- 00947 // vmm_notify 00948 // 00949 00950 `ifdef VCS 00951 (* vmm_callback_class, _vcs_vmm_class = 1 *) 00952 `endif 00953 virtual class vmm_notify_callbacks; 00954 virtual function void indicated(vmm_data status); 00955 endfunction 00956 endclass 00957 00958 `ifdef VCS 00959 (* _vcs_vmm_class = 1 *) 00960 `endif 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 00976 `ifdef VCS 00977 (* _vcs_vmm_class = 1 *) 00978 `endif 00979 class vmm_notify 00980 `ifdef VMM_NOTIFY_BASE 00981 extends `VMM_NOTIFY_BASE 00982 `endif 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 01000 `ifdef VMM_NOTIFY_BASE_METHODS 01001 `VMM_NOTIFY_BASE_METHODS 01002 `endif 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 01039 `ifdef VMM_SB_DS_IN_STDLIB 01040 extern function void register_vmm_sb_ds(int notification_id, 01041 vmm_sb_ds sb, 01042 vmm_sb_ds::kind_e kind, 01043 vmm_sb_ds::ordering_e order = vmm_sb_ds::IN_ORDER); 01044 extern function void unregister_vmm_sb_ds(int notification_id, 01045 vmm_sb_ds sb); 01046 `endif 01047 01048 endclass 01049 01050 01051 //--------------------------------------------------------------------- 01052 // vmm_data 01053 // 01054 01055 `ifdef VCS 01056 (* _vcs_vmm_class = 1 *) 01057 `endif 01058 class vmm_data 01059 `ifdef VMM_DATA_BASE 01060 extends `VMM_DATA_BASE 01061 `endif 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 `VMM_DATA_BASE_NEW_ARGS); 01078 01079 `ifdef VMM_DATA_BASE_METHODS 01080 `VMM_DATA_BASE_METHODS 01081 `endif 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 01171 `ifdef VCS 01172 extern function int vmt_hook(vmm_xactor xactor = null, 01173 vmm_data obj = null); 01174 01175 01176 `endif 01177 endclass: vmm_data 01178 01179 01180 //--------------------------------------------------------------------- 01181 // vmm_channel 01182 // 01183 01184 `ifdef VCS 01185 (* _vcs_vmm_class = 1 *) 01186 `endif 01187 class vmm_channel 01188 `ifdef VMM_CHANNEL_BASE 01189 extends `VMM_CHANNEL_BASE 01190 `endif 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 01248 `ifdef VMM_CHANNEL_BASE_METHODS 01249 `VMM_CHANNEL_BASE_METHODS 01250 `endif 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 01311 `ifndef VMM_OV_INTEROP 01312 extern local task block_producer(); 01313 extern local task block_consumer(); 01314 `endif 01315 extern local function void unblock_producer(); 01316 01317 `ifdef VMM_SB_DS_IN_STDLIB 01318 local vmm_sb_ds_registration _vmm_sb_ds[$]; 01319 01320 extern function void register_vmm_sb_ds(vmm_sb_ds sb, 01321 vmm_sb_ds::kind_e kind, 01322 vmm_sb_ds::ordering_e order = vmm_sb_ds::IN_ORDER); 01323 extern function void unregister_vmm_sb_ds(vmm_sb_ds sb); 01324 `endif 01325 endclass 01326 01327 01328 `ifdef VMM_PARAM_CHANNEL 01329 01330 class vmm_channel_typed #(type T = vmm_data) extends vmm_channel; 01331 01332 function new(string name, 01333 string inst, 01334 int full = 1, 01335 int empty = 0, 01336 bit fill_as_bytes = 0); 01337 super.new(name, inst, full, empty, fill_as_bytes); 01338 endfunction: new 01339 01340 function T unput(int offset = -1); 01341 $cast(unput, super.unput(offset)); 01342 endfunction: unput 01343 01344 task get(output T obj, input int offset = 0); 01345 vmm_data o; 01346 super.get(o, offset); 01347 $cast(obj, o); 01348 endtask: get 01349 01350 task peek(output T obj, input int offset = 0); 01351 vmm_data o; 01352 super.peek(o, offset); 01353 $cast(obj, o); 01354 endtask: peek 01355 01356 task activate(output T obj, input int offset = 0); 01357 vmm_data o; 01358 super.activate(o, offset); 01359 $cast(obj, o); 01360 endtask: activate 01361 01362 function T active_slot(); 01363 $cast(active_slot, super.active_slot()); 01364 endfunction: active_slot 01365 01366 function T start(); 01367 $cast(start, super.start()); 01368 endfunction: start 01369 01370 function T complete(vmm_data status = null); 01371 $cast(complete, super.complete(status)); 01372 endfunction: complete 01373 01374 function T remove(); 01375 $cast(remove, super.remove()); 01376 endfunction: remove 01377 01378 task tee(output T obj); 01379 vmm_data o; 01380 super.tee(o); 01381 $cast(obj, o); 01382 endtask: tee 01383 01384 function T for_each(bit reset = 0); 01385 $cast(for_each, super.for_each(reset)); 01386 endfunction: for_each 01387 endclass 01388 01389 `endif 01390 01391 01392 //--------------------------------------------------------------------- 01393 // vmm_consensus 01394 // 01395 01396 typedef class vmm_voter; 01397 01398 `ifdef VCS 01399 (* _vcs_vmm_class = 1 *) 01400 `endif 01401 class vmm_consensus 01402 `ifdef VMM_CONSENSUS_BASE 01403 extends `VMM_CONSENSUS_BASE 01404 `endif 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 01417 `ifdef VMM_CONSENSUS_BASE_METHODS 01418 `VMM_CONSENSUS_BASE_METHODS 01419 `endif 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 01459 `ifdef VCS 01460 (* _vcs_vmm_class = 1 *) 01461 `endif 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 01505 `ifdef VCS 01506 (* _vcs_vmm_class = 1 *) 01507 `endif 01508 class vmm_subenv 01509 `ifdef VMM_SUBENV_BASE 01510 extends `VMM_SUBENV_BASE 01511 `endif 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 `VMM_SUBENV_BASE_NEW_ARGS); 01523 01524 `ifdef VMM_SUBENV_BASE_METHODS 01525 `VMM_SUBENV_BASE_METHODS 01526 `endif 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 01542 `ifdef VCS 01543 (* _vcs_vmm_class = 1 *) 01544 `endif 01545 class vmm_env 01546 `ifdef VMM_ENV_BASE 01547 extends `VMM_ENV_BASE 01548 `endif 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 `VMM_ENV_BASE_NEW_ARGS); 01580 01581 `ifdef VMM_ENV_BASE_METHODS 01582 `VMM_ENV_BASE_METHODS 01583 `endif 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 01609 `ifdef VCS 01610 (* vmm_callback_class, _vcs_vmm_class = 1 *) 01611 `endif 01612 virtual class vmm_xactor_callbacks; 01613 endclass 01614 01615 `ifdef VCS 01616 (* _vcs_vmm_class = 1 *) 01617 `endif 01618 class vmm_xactor 01619 `ifdef VMM_XACTOR_BASE 01620 extends `VMM_XACTOR_BASE 01621 `endif 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 `VMM_XACTOR_BASE_NEW_ARGS); 01658 01659 `ifdef VMM_XACTOR_BASE_METHODS 01660 `VMM_XACTOR_BASE_METHODS 01661 `endif 01662 01663 01664 01665 01666 `ifndef VMM_OV_INTEROP 01667 typedef enum int {SOFT_RST, 01668 PROTOCOL_RST, 01669 FIRM_RST, 01670 HARD_RST} reset_e; 01671 `endif 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 01696 `ifdef VMM_SB_DS_IN_STDLIB 01697 local vmm_sb_ds_registration _vmm_sb_ds[$]; 01698 01699 extern protected function void inp_vmm_sb_ds(vmm_data tr); 01700 extern protected function void exp_vmm_sb_ds(vmm_data tr); 01701 extern function void register_vmm_sb_ds(vmm_sb_ds sb, 01702 vmm_sb_ds::kind_e kind, 01703 vmm_sb_ds::ordering_e order = vmm_sb_ds::IN_ORDER); 01704 extern function void unregister_vmm_sb_ds(vmm_sb_ds sb); 01705 `endif 01706 endclass 01707 01708 01709 `ifdef VCS 01710 (* _vcs_vmm_class = 1 *) 01711 `endif 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 `VMM_XACTOR_NEW_ARGS); 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 01763 `ifdef VCS 01764 (* _vcs_vmm_class = 1 *) 01765 `endif 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 01792 `ifdef VCS 01793 (* _vcs_vmm_class = 1 *) 01794 `endif 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 `VMM_XACTOR_NEW_ARGS); 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 01838 `ifdef VCS 01839 (* _vcs_vmm_class = 1 *) 01840 `endif 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 `vmm_channel(xvc_action) 01879 01880 01881 `ifdef VCS 01882 (* _vcs_vmm_class = 1 *) 01883 `endif 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 `VMM_XACTOR_NEW_ARGS); 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 01934 `ifdef VCS 01935 (* _vcs_vmm_class = 1 *) 01936 `endif 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`"); 01995 `ifdef VMM_CHANNEL_BASE 01996 $write("%s VMM_CHANNEL_BASE %s\n", 01997 prefix, `"`VMM_CHANNEL_BASE`"); 01998 $write("%s VMM_CHANNEL_NEW_CALL %s\n", 01999 prefix, `"`VMM_CHANNEL_BASE_NEW_CALL`"); 02000 `endif 02001 02002 $write("\n"); 02003 $write("%s VMM_CONSENSUS %s\n", 02004 prefix, `"`VMM_CONSENSUS`"); 02005 `ifdef VMM_CONSENSUS_BASE 02006 $write("%s VMM_CONSENSUS_BASE %s\n", 02007 prefix, `"`VMM_CONSENSUS_BASE`"); 02008 $write("%s VMM_CONSENSUS_NEW_CALL %s\n", 02009 prefix, `"`VMM_CONSENSUS_BASE_NEW_CALL`"); 02010 `endif 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`"); 02021 `ifdef VMM_DATA_BASE 02022 $write("%s VMM_DATA_BASE %s\n", 02023 prefix, `"`VMM_DATA_BASE`"); 02024 $write("%s VMM_DATA_BASE_NEW_ARGS %s\n", 02025 prefix, `"`VMM_DATA_BASE_NEW_ARGS`"); 02026 $write("%s VMM_DATA_BASE_NEW_EXTERN_ARGS %s\n", 02027 prefix, `"`VMM_DATA_BASE_NEW_EXTERN_ARGS`"); 02028 $write("%s VMM_DATA_BASE_NEW_CALL %s\n", 02029 prefix, `"`VMM_DATA_BASE_NEW_CALL`"); 02030 `endif 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`"); 02041 `ifdef VMM_ENV_BASE 02042 $write("%s VMM_ENV_BASE %s\n", 02043 prefix, `"`VMM_ENV_BASE`"); 02044 $write("%s VMM_ENV_BASE_NEW_ARGS %s\n", 02045 prefix, `"`VMM_ENV_BASE_NEW_ARGS`"); 02046 $write("%s VMM_ENV_BASE_NEW_EXTERN_ARGS %s\n", 02047 prefix, `"`VMM_ENV_BASE_NEW_EXTERN_ARGS`"); 02048 $write("%s VMM_ENV_BASE_NEW_CALL %s\n", 02049 prefix, `"`VMM_ENV_BASE_NEW_CALL`"); 02050 `endif 02051 02052 $write("\n"); 02053 $write("%s VMM_LOG %s\n", 02054 prefix, `"`VMM_LOG`"); 02055 `ifdef VMM_LOG_BASE 02056 $write("%s VMM_LOG_BASE %s\n", 02057 prefix, `"`VMM_LOG_BASE`"); 02058 $write("%s VMM_LOG_NEW_CALL %s\n", 02059 prefix, `"`VMM_LOG_BASE_NEW_CALL`"); 02060 `endif 02061 02062 $write("\n"); 02063 $write("%s VMM_NOTIFY %s\n", 02064 prefix, `"`VMM_NOTIFY`"); 02065 `ifdef VMM_NOTIFY_BASE 02066 $write("%s VMM_NOTIFY_BASE %s\n", 02067 prefix, `"`VMM_NOTIFY_BASE`"); 02068 $write("%s VMM_NOTIFY_NEW_CALL %s\n", 02069 prefix, `"`VMM_NOTIFY_BASE_NEW_CALL`"); 02070 `endif 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`"); 02081 `ifdef VMM_XACTOR_BASE 02082 $write("%s VMM_XACTOR_BASE %s\n", 02083 prefix, `"`VMM_XACTOR_BASE`"); 02084 $write("%s VMM_XACTOR_BASE_NEW_ARGS %s\n", 02085 prefix, `"`VMM_XACTOR_BASE_NEW_ARGS`"); 02086 $write("%s VMM_XACTOR_BASE_NEW_EXTERN_ARGS %s\n", 02087 prefix, `"`VMM_XACTOR_BASE_NEW_EXTERN_ARGS`"); 02088 $write("%s VMM_XACTOR_BASE_NEW_CALL %s\n", 02089 prefix, `"`VMM_XACTOR_BASE_NEW_CALL`"); 02090 `endif 02091 endfunction: cfdisplay 02092 02093 02094 `include "std_lib/vmm_log.sv" 02095 `include "std_lib/vmm_notify.sv" 02096 `include "std_lib/vmm_data.sv" 02097 `include "std_lib/vmm_channel.sv" 02098 `include "std_lib/vmm_consensus.sv" 02099 `include "std_lib/vmm_subenv.sv" 02100 `include "std_lib/vmm_env.sv" 02101 `include "std_lib/vmm_xactor.sv" 02102 `include "std_lib/vmm_broadcast.sv" 02103 `include "std_lib/vmm_scheduler.sv" 02104 `include "std_lib/xvc_action.sv" 02105 `include "std_lib/xvc_xactor.sv" 02106 `include "std_lib/xvc_manager.sv" 02107 02108 02109 `ifdef VMM_IN_PACKAGE 02110 endpackage: vmm_std_lib 02111 `endif 02112 02113 `endif 02114 02115 `ifdef VMM_IN_PACKAGE 02116 import vmm_std_lib::*; 02117 `endif