00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 `ifndef VMM_DPI_
00034 `define VMM_DPI_
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 `ifndef vmm_sformatf
00046 `define vmm_sformatf $psprintf
00047 `endif
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 `ifdef VCS
00063 `define vmm_str_match(str, regex) str.match(regex)
00064 `define vmm_str_prematch(str) str.prematch()
00065 `define vmm_str_postmatch(str) str.postmatch()
00066 `define vmm_str_backref(str, n) str.backref(n)
00067
00068 `else
00069
00070 `ifdef VMM_NO_STR_DPI
00071
00072 `define vmm_str_match(str, regex) 0
00073 `define vmm_str_prematch(str) ""
00074 `define vmm_str_postmatch(str) ""
00075 `define vmm_str_backref(str, n) ""
00076
00077 `else
00078
00079 import "DPI-C" function int vmm_str_match(input string str1, input string regex);
00080 import "DPI-C" function string vmm_str_prematch();
00081 import "DPI-C" function string vmm_str_postmatch();
00082 import "DPI-C" function string vmm_str_backref(int n);
00083
00084 `define vmm_str_match(str, regex) vmm_str_match(str, regex)
00085 `define vmm_str_prematch(str) vmm_str_prematch()
00086 `define vmm_str_postmatch(str) vmm_str_postmatch()
00087 `define vmm_str_backref(str, n) vmm_str_backref(n+1)
00088
00089 `endif
00090
00091 `endif
00092
00093
00094 `endif
00095
00096
00097
00098
00099
00100
00101
00102
00103 `ifndef VMM_MACRO_DEFINED
00104 `define VMM_MACRO_DEFINED
00105
00106
00107
00108
00109
00110
00111
00112 `ifdef VMM_PRE_INCLUDE
00113 `include `VMM_PRE_INCLUDE
00114 `endif
00115
00116
00117 `ifndef VMM_DATA
00118 `define VMM_DATA vmm_data
00119 `endif
00120 `ifndef VMM_DATA_NEW_ARGS
00121 `define VMM_DATA_NEW_ARGS
00122 `define VMM_DATA_NEW_EXTERN_ARGS
00123 `define VMM_DATA_NEW_CALL
00124 `endif
00125 `ifndef VMM_DATA_BASE_NEW_ARGS
00126 `define VMM_DATA_BASE_NEW_ARGS
00127 `define VMM_DATA_BASE_NEW_EXTERN_ARGS
00128 `endif
00129 `ifdef VMM_DATA_BASE
00130 `ifndef VMM_DATA_BASE_NEW_CALL
00131 `define VMM_DATA_BASE_NEW_CALL
00132 `endif
00133 `endif
00134 `ifndef VMM_DATA_BASE_METHODS
00135 `define VMM_DATA_BASE_METHODS
00136 `endif
00137
00138 `ifndef VMM_CHANNEL
00139 `define VMM_CHANNEL vmm_channel
00140 `endif
00141 `ifdef VMM_CHANNEL_BASE
00142 `ifndef VMM_CHANNEL_BASE_NEW_CALL
00143 `define VMM_CHANNEL_BASE_NEW_CALL
00144 `endif
00145 `endif
00146 `ifndef VMM_CHANNEL_BASE_METHODS
00147 `define VMM_CHANNEL_BASE_METHODS
00148 `endif
00149
00150 `ifndef VMM_CONSENSUS
00151 `define VMM_CONSENSUS vmm_consensus
00152 `endif
00153 `ifdef VMM_CONSENSUS_BASE
00154 `ifndef VMM_CONSENSUS_BASE_NEW_CALL
00155 `define VMM_CONSENSUS_BASE_NEW_CALL
00156 `endif
00157 `endif
00158 `ifndef VMM_CONSENSUS_BASE_METHODS
00159 `define VMM_CONSENSUS_BASE_METHODS
00160 `endif
00161
00162 `ifndef VMM_LOG
00163 `define VMM_LOG vmm_log
00164 `endif
00165 `ifdef VMM_LOG_BASE
00166 `ifndef VMM_LOG_BASE_NEW_CALL
00167 `define VMM_LOG_BASE_NEW_CALL
00168 `endif
00169 `endif
00170 `ifndef VMM_LOG_BASE_METHODS
00171 `define VMM_LOG_BASE_METHODS
00172 `endif
00173
00174 `ifndef VMM_NOTIFY
00175 `define VMM_NOTIFY vmm_notify
00176 `endif
00177 `ifdef VMM_NOTIFY_BASE
00178 `ifndef VMM_NOTIFY_BASE_NEW_CALL
00179 `define VMM_NOTIFY_BASE_NEW_CALL
00180 `endif
00181 `endif
00182 `ifndef VMM_NOTIFY_BASE_METHODS
00183 `define VMM_NOTIFY_BASE_METHODS
00184 `endif
00185
00186 `ifndef VMM_XACTOR
00187 `define VMM_XACTOR vmm_xactor
00188 `endif
00189 `ifndef VMM_XACTOR_NEW_ARGS
00190 `define VMM_XACTOR_NEW_ARGS
00191 `define VMM_XACTOR_NEW_EXTERN_ARGS
00192 `define VMM_XACTOR_NEW_CALL
00193 `endif
00194 `ifndef VMM_XACTOR_BASE_NEW_ARGS
00195 `define VMM_XACTOR_BASE_NEW_ARGS
00196 `define VMM_XACTOR_BASE_NEW_EXTERN_ARGS
00197 `endif
00198 `ifdef VMM_XACTOR_BASE
00199 `ifndef VMM_XACTOR_BASE_NEW_CALL
00200 `define VMM_XACTOR_BASE_NEW_CALL
00201 `endif
00202 `endif
00203 `ifndef VMM_XACTOR_BASE_METHODS
00204 `define VMM_XACTOR_BASE_METHODS
00205 `endif
00206
00207 `ifndef VMM_SUBENV
00208 `define VMM_SUBENV vmm_subenv
00209 `endif
00210 `ifndef VMM_SUBENV_NEW_ARGS
00211 `define VMM_SUBENV_NEW_ARGS
00212 `define VMM_SUBENV_NEW_EXTERN_ARGS
00213 `define VMM_SUBENV_NEW_CALL
00214 `endif
00215 `ifndef VMM_SUBENV_BASE_NEW_ARGS
00216 `define VMM_SUBENV_BASE_NEW_ARGS
00217 `define VMM_SUBENV_BASE_NEW_EXTERN_ARGS
00218 `endif
00219 `ifdef VMM_SUBENV_BASE
00220 `ifndef VMM_SUBENV_BASE_NEW_CALL
00221 `define VMM_SUBENV_BASE_NEW_CALL
00222 `endif
00223 `endif
00224 `ifndef VMM_SUBENV_BASE_METHODS
00225 `define VMM_SUBENV_BASE_METHODS
00226 `endif
00227
00228 `ifndef VMM_ENV
00229 `define VMM_ENV vmm_env
00230 `endif
00231 `ifndef VMM_ENV_NEW_ARGS
00232 `define VMM_ENV_NEW_ARGS
00233 `define VMM_ENV_NEW_EXTERN_ARGS
00234 `define VMM_ENV_NEW_CALL
00235 `endif
00236 `ifndef VMM_ENV_BASE_NEW_ARGS
00237 `define VMM_ENV_BASE_NEW_ARGS
00238 `define VMM_ENV_BASE_NEW_EXTERN_ARGS
00239 `endif
00240 `ifdef VMM_ENV_BASE
00241 `ifndef VMM_ENV_BASE_NEW_CALL
00242 `define VMM_ENV_BASE_NEW_CALL
00243 `endif
00244 `endif
00245 `ifndef VMM_ENV_BASE_METHODS
00246 `define VMM_ENV_BASE_METHODS
00247 `endif
00248
00249
00250
00251
00252
00253
00254
00255 `define vmm_warning(log, msg) \
00256 do \
00257 if (log.start_msg(vmm_log::FAILURE_TYP, vmm_log::WARNING_SEV)) begin \
00258 void'(log.text(msg)); \
00259 log.end_msg(); \
00260 end \
00261 while(0)
00262
00263 `define vmm_error(log, msg) \
00264 do \
00265 if (log.start_msg(vmm_log::FAILURE_TYP, vmm_log::ERROR_SEV)) begin \
00266 void'(log.text(msg)); \
00267 log.end_msg(); \
00268 end \
00269 while (0)
00270
00271 `define vmm_fatal(log, msg) \
00272 do \
00273 if (log.start_msg(vmm_log::FAILURE_TYP, vmm_log::FATAL_SEV)) begin \
00274 void'(log.text(msg)); \
00275 log.end_msg(); \
00276 end \
00277 while (0)
00278
00279
00280
00281
00282
00283
00284 `ifdef VMM_NULL_LOG_MACROS
00285
00286 `define vmm_trace(log, msg)
00287 `define vmm_debug(log, msg)
00288 `define vmm_verbose(log, msg)
00289 `define vmm_note(log, msg)
00290 `define vmm_report(log, msg)
00291 `define vmm_command(log, msg)
00292 `define vmm_protocol(log, msg)
00293 `define vmm_transaction(log, msg)
00294 `define vmm_cycle(log, msg)
00295 `define vmm_user(n, log, msg)
00296
00297 `else
00298
00299 `define vmm_trace(log, msg) \
00300 do \
00301 if (log.start_msg(vmm_log::DEBUG_TYP, vmm_log::TRACE_SEV)) begin \
00302 void'(log.text(msg)); \
00303 log.end_msg(); \
00304 end \
00305 while (0)
00306
00307 `define vmm_debug(log, msg) \
00308 do \
00309 if (log.start_msg(vmm_log::DEBUG_TYP, vmm_log::DEBUG_SEV)) begin \
00310 void'(log.text(msg)); \
00311 log.end_msg(); \
00312 end \
00313 while (0)
00314
00315 `define vmm_verbose(log, msg) \
00316 do \
00317 if (log.start_msg(vmm_log::DEBUG_TYP, vmm_log::VERBOSE_SEV)) begin \
00318 void'(log.text(msg)); \
00319 log.end_msg(); \
00320 end \
00321 while (0)
00322
00323 `define vmm_note(log, msg) \
00324 do \
00325 if (log.start_msg(vmm_log::NOTE_TYP)) begin \
00326 void'(log.text(msg)); \
00327 log.end_msg(); \
00328 end \
00329 while (0)
00330
00331 `define vmm_report(log, msg) \
00332 do \
00333 if (log.start_msg(vmm_log::REPORT_TYP)) begin \
00334 void'(log.text(msg)); \
00335 log.end_msg(); \
00336 end \
00337 while (0)
00338
00339 `define vmm_command(log, msg) \
00340 do \
00341 if (log.start_msg(vmm_log::COMMAND_TYP)) begin \
00342 void'(log.text(msg)); \
00343 log.end_msg(); \
00344 end \
00345 while (0)
00346
00347 `define vmm_protocol(log, msg) \
00348 do \
00349 if (log.start_msg(vmm_log::PROTOCOL_TYP)) begin \
00350 void'(log.text(msg)); \
00351 log.end_msg(); \
00352 end \
00353 while (0)
00354
00355 `define vmm_transaction(log, msg) \
00356 do \
00357 if (log.start_msg(vmm_log::TRANSACTION_TYP)) begin \
00358 void'(log.text(msg)); \
00359 log.end_msg(); \
00360 end \
00361 while (0)
00362
00363 `define vmm_cycle(log, msg) \
00364 do \
00365 if (log.start_msg(vmm_log::CYCLE_TYP)) begin \
00366 void'(log.text(msg)); \
00367 log.end_msg(); \
00368 end \
00369 while (0)
00370
00371 `define vmm_user(n, log, msg) \
00372 do \
00373 if (log.start_msg(vmm_log::USER_TYP_``n)) begin \
00374 void'(log.text(msg)); \
00375 log.end_msg(); \
00376 end \
00377 while (0)
00378
00379 `endif
00380
00381
00382
00383
00384
00385
00386
00387 `define vmm_callback(facade, call) \
00388 \
00389 do foreach (this.callbacks[vmm_i]) begin \
00390 facade cb; \
00391 if (!$cast(cb, this.callbacks[vmm_i])) continue; \
00392 \
00393 cb.call; \
00394 end while (0)
00395
00396
00397
00398
00399
00400
00401
00402 `include "std_lib/vmm_data_macros.sv"
00403
00404
00405 `ifdef VMM_PARAM_CHANNEL
00406
00407 `define vmm_channel(T) typedef vmm_channel_typed#(T) T``_channel;
00408
00409 `else
00410
00411 `define vmm_channel_(T) T``_channel
00412
00413 `define vmm_channel(T) \
00414 class `vmm_channel_(T) extends vmm_channel; \
00415 \
00416 function new(string name, \
00417 string inst, \
00418 int full = 1, \
00419 int empty = 0, \
00420 bit fill_as_bytes = 0); \
00421 super.new(name, inst, full, empty, fill_as_bytes); \
00422 endfunction: new \
00423 \
00424 function T unput(int offset = -1); \
00425 $cast(unput, super.unput(offset)); \
00426 endfunction: unput \
00427 \
00428 task get(output T obj, input int offset = 0); \
00429 vmm_data o; \
00430 super.get(o, offset); \
00431 $cast(obj, o); \
00432 endtask: get \
00433 \
00434 task peek(output T obj, input int offset = 0); \
00435 vmm_data o; \
00436 super.peek(o, offset); \
00437 $cast(obj, o); \
00438 endtask: peek \
00439 \
00440 task activate(output T obj, input int offset = 0); \
00441 vmm_data o; \
00442 super.activate(o, offset); \
00443 $cast(obj, o); \
00444 endtask: activate \
00445 \
00446 function T active_slot(); \
00447 $cast(active_slot, super.active_slot()); \
00448 endfunction: active_slot \
00449 \
00450 function T start(); \
00451 $cast(start, super.start()); \
00452 endfunction: start \
00453 \
00454 function T complete(vmm_data status = null); \
00455 $cast(complete, super.complete(status)); \
00456 endfunction: complete \
00457 \
00458 function T remove(); \
00459 $cast(remove, super.remove()); \
00460 endfunction: remove \
00461 \
00462 task tee(output T obj); \
00463 vmm_data o; \
00464 super.tee(o); \
00465 $cast(obj, o); \
00466 endtask: tee \
00467 \
00468 function T for_each(bit reset = 0); \
00469 $cast(for_each, super.for_each(reset)); \
00470 endfunction: for_each \
00471 endclass
00472
00473 `endif
00474
00475 `include "std_lib/vmm_atomic_gen.sv"
00476 `include "std_lib/vmm_scenario_gen.sv"
00477
00478
00479
00480
00481
00482 `endif
00483
00484
00485
00486
00487
00488 `ifndef VMM__SV
00489 `define VMM__SV
00490
00491
00492 `ifdef VMM_IN_PACKAGE
00493
00494
00495 `ifdef VCS
00496 (* _vcs_vmm_pkg = 1 *)
00497 `endif
00498 package vmm_std_lib;
00499 `endif
00500
00501
00502
00503
00504
00505
00506
00507 `ifdef VCS
00508 (* _vcs_vmm_class = 1 *)
00509 `endif
00510 class vmm_version;
00511 extern function int major();
00512 extern function int minor();
00513 extern function int patch();
00514 extern function string vendor();
00515
00516 extern function void display(string prefix = "");
00517 extern function string psdisplay(string prefix = "");
00518 extern function void cfdisplay(string prefix = "");
00519 endclass: vmm_version
00520
00521
00522
00523
00524
00525
00526
00527 typedef class vmm_log;
00528 typedef class vmm_data;
00529 typedef class vmm_xactor;
00530 typedef class vmm_notify;
00531
00532
00533 typedef class `VMM_DATA;
00534 `ifdef VMM_DATA_BASE
00535 typedef class `VMM_DATA_BASE;
00536 `endif
00537 `ifdef VMM_CHANNEL_BASE
00538 typedef class `VMM_CHANNEL_BASE;
00539 `endif
00540 `ifdef VMM_CONSENSUS_BASE
00541 typedef class `VMM_CONSENSUS_BASE;
00542 `endif
00543 `ifdef VMM_LOG_BASE
00544 typedef class `VMM_LOG_BASE;
00545 `endif
00546 `ifdef VMM_NOTIFY_BASE
00547 typedef class `VMM_NOTIFY_BASE;
00548 `endif
00549 typedef class `VMM_XACTOR;
00550 `ifdef VMM_XACTOR_BASE
00551 typedef class `VMM_XACTOR_BASE;
00552 `endif
00553 typedef class `VMM_SUBENV;
00554 `ifdef VMM_SUBENV_BASE
00555 typedef class `VMM_SUBENV_BASE;
00556 `endif
00557 typedef class `VMM_ENV;
00558 `ifdef VMM_ENV_BASE
00559 typedef class `VMM_ENV_BASE;
00560 `endif
00561
00562
00563 `ifdef VMM_POST_INCLUDE
00564 `include `VMM_POST_INCLUDE
00565 `endif
00566
00567
00568
00569
00570
00571
00572 `ifdef VCS
00573 (* _vcs_vmm_class = 1 *)
00574 `endif
00575 class vmm_log_format;
00576 extern virtual function string format_msg(string name,
00577 string inst,
00578 string msg_typ,
00579 string severity,
00580 ref string lines[$]);
00581
00582 extern virtual function string continue_msg(string name,
00583 string inst,
00584 string msg_typ,
00585 string severity,
00586 ref string lines[$]);
00587
00588 extern virtual function string abort_on_error(int count,
00589 int limit);
00590
00591 extern virtual function string pass_or_fail(bit pass,
00592 string name,
00593 string inst,
00594 int fatals,
00595 int errors,
00596 int warnings,
00597 int dem_errs,
00598 int dem_warns);
00599 endclass: vmm_log_format
00600
00601
00602 `ifdef VCS
00603 (* vmm_callback_class, _vcs_vmm_class = 1 *)
00604 `endif
00605 class vmm_log_callbacks;
00606 virtual function void pre_abort(vmm_log log);
00607 endfunction
00608
00609 virtual function void pre_stop(vmm_log log);
00610 endfunction
00611
00612 virtual function void pre_debug(vmm_log log);
00613 endfunction
00614 endclass: vmm_log_callbacks
00615
00616
00617 typedef class vmm_log_below_iter;
00618 typedef class vmm_log_msg;
00619 typedef class vmm_log_modifier;
00620 typedef class vmm_log_watchpoint;
00621
00622 `ifdef VCS
00623 (* _vcs_vmm_class = 1 *)
00624 `endif
00625 class vmm_log
00626 `ifdef VMM_LOG_BASE
00627 extends `VMM_LOG_BASE
00628 `endif
00629 ;
00630
00631
00632
00633
00634 typedef enum int {DEFAULT
00635 = -1
00636 , UNCHANGED
00637 = -2
00638 } symbols_e;
00639
00640
00641
00642
00643 typedef enum int {FAILURE_TYP = 'h0001,
00644 NOTE_TYP = 'h0002,
00645 DEBUG_TYP = 'h0004,
00646 REPORT_TYP = 'h0008,
00647 NOTIFY_TYP = 'h0010,
00648 TIMING_TYP = 'h0020,
00649 XHANDLING_TYP = 'h0040,
00650 PROTOCOL_TYP = 'h0080,
00651 TRANSACTION_TYP = 'h0100,
00652 COMMAND_TYP = 'h0200,
00653 CYCLE_TYP = 'h0400,
00654 USER_TYP_0 = 'h0800,
00655 USER_TYP_1 = 'h1000,
00656 USER_TYP_2 = 'h2000,
00657 INTERNAL_TYP = 'h4000,
00658 DEFAULT_TYP = -1,
00659 ALL_TYPS = 'hFFFF
00660 } types_e;
00661
00662
00663
00664
00665 typedef enum int {FATAL_SEV = 'h0001,
00666 ERROR_SEV = 'h0002,
00667 WARNING_SEV = 'h0004,
00668 NORMAL_SEV = 'h0008,
00669 TRACE_SEV = 'h0010,
00670 DEBUG_SEV = 'h0020,
00671 VERBOSE_SEV = 'h0040,
00672 HIDDEN_SEV = 'h0080,
00673 IGNORE_SEV = 'h0100,
00674 DEFAULT_SEV = -1,
00675 ALL_SEVS = 'hFFFF
00676 } severities_e;
00677
00678
00679
00680
00681 typedef enum int {CONTINUE = 'h0001,
00682 COUNT_ERROR = 'h0002,
00683 DEBUGGER = 'h0004,
00684 DUMP_STACK = 'h0008,
00685 STOP_PROMPT = 'h0010,
00686 ABORT_SIM = 'h0020,
00687 IGNORE = 'h0040,
00688 DEFAULT_HANDLING = -1
00689 } handling_e;
00690
00691 //
00692 // Pre-defined STDOUT in case the simulator does not already define it
00693 //
00694 typedef enum int {STDOUT = 32'h8000_0001} stdout_e;
00695
00696
00697
00698
00699 static local int error_count = 0;
00700 static local int error_limit = 10;
00701 static local string msg_format[$];
00702 static local string prefix;
00703
00704
00705
00706
00707 static local int dflt_lvl = NORMAL_SEV;
00708 static local int force_lvl = DEFAULT_SEV;
00709 static local bit plus_debug;
00710
00711 local string name;
00712 local string inst;
00713
00714 local int n_msg[*];
00715 local int n_demoted[*];
00716
00717
00718
00719
00720 local vmm_log_msg msg;
00721 local string msg_txt[$];
00722
00723 static local int type_list[$];
00724 static local string type_images[*];
00725
00726 static local int sev_list[$];
00727 static local string sev_images[*];
00728
00729 static local vmm_log_modifier modifier_cache[*];
00730 local int modifier_ids[$];
00731 local int has_text_modifiers;
00732
00733 static local vmm_log_watchpoint watchpoint_cache[*];
00734 local int watchpoint_ids[$];
00735
00736 local int enabled_typs;
00737 local int log_lvl;
00738
00739
00740
00741
00742 static local vmm_log_format fmt = new;
00743 static local int in_callbacks = 0;
00744 static local vmm_log_callbacks callbacks[$];
00745
00746
00747
00748
00749 local int fp[$];
00750
00751
00752
00753
00754 local int is_self;
00755 local bit is_all;
00756 static local vmm_log known[$];
00757
00758 vmm_log below[$];
00759 static local int recurse_id = 0;
00760 local int visited = 0;
00761
00762 static local string pattern[2];
00763 static local bit is_pattern[2];
00764 static local int known_idx = 0;
00765 static local int recurse;
00766 static local vmm_log_below_iter recurse_stack[$];
00767
00768 `ifdef VMM_LOG_BASE_METHODS
00769 `VMM_LOG_BASE_METHODS
00770 `endif
00771
00772 extern function new(string name,
00773 string inst,
00774 vmm_log under = null);
00775
00776 extern virtual function void is_above(vmm_log log);
00777 extern virtual function vmm_log copy(vmm_log to = null);
00778
00779 extern virtual function void set_name(string name);
00780 extern virtual function string get_name();
00781 extern virtual function void set_instance(string inst);
00782 extern virtual function string get_instance();
00783
00784 extern function void reset(string name = "/./",
00785 string inst = "/./",
00786 bit recurse = 0);
00787 extern function vmm_log for_each();
00788 extern virtual function void list(string name = "/./",
00789 string inst = "/./",
00790 bit recurse = 0);
00791
00792 extern virtual function void display(string prefix = "");
00793 extern virtual function string psdisplay(string prefix = "");
00794
00795 extern virtual function void kill();
00796
00797
00798
00799
00800 extern virtual function vmm_log_format set_format(vmm_log_format fmt);
00801 extern virtual function string set_typ_image(int typ, string image);
00802 extern virtual function string set_sev_image(int severity, string image);
00803
00804 extern function string typ_image(int typ);
00805 extern function string sev_image(int severity);
00806 extern function string handling_image(int handling);
00807 extern local function int default_handling(int severity);
00808
00809 extern virtual function void report(string name = "/./",
00810 string inst = "/./",
00811 bit recurse = 0);
00812
00813
00814
00815
00816
00817 extern virtual function bit start_msg(int typ,
00818 int severity = DEFAULT_SEV);
00819
00820 extern virtual function bit text(string msg = "");
00821 extern virtual function void end_msg();
00822 extern local function void flush_msg();
00823
00824
00825
00826
00827 extern virtual function void enable_types(int typs,
00828 string name = "",
00829 string inst = "",
00830 bit recursive = 0);
00831 extern virtual function void disable_types(int typs,
00832 string name = "",
00833 string inst = "",
00834 bit recursive = 0);
00835 extern virtual function int modify(string name = "",
00836 string inst = "",
00837 bit recursive = 0,
00838 int typ = ALL_TYPS,
00839 int severity = ALL_SEVS,
00840 string text = "",
00841 int new_typ = UNCHANGED,
00842 int new_severity = UNCHANGED,
00843 int handling = UNCHANGED);
00844 extern virtual function void unmodify(int modification_id = -1,
00845 string name = "",
00846 string inst = "",
00847 bit recursive = 0);
00848
00849 extern local function void promote();
00850 extern local function void filter();
00851 extern local function void notify();
00852
00853 extern virtual function void set_verbosity(int severity,
00854 string name = "",
00855 string inst = "",
00856 bit recursive = 0);
00857 extern function int get_verbosity();
00858
00859
00860
00861
00862 extern virtual function void log_start(int file,
00863 string name = "",
00864 string inst = "",
00865 bit recurse = 0);
00866 extern virtual function void log_stop(int file,
00867 string name = "",
00868 string inst = "",
00869 bit recurse = 0);
00870
00871
00872
00873
00874
00875 extern virtual function void stop_after_n_errors(int n);
00876 extern virtual function int get_message_count(int severity = ALL_SEVS,
00877 string name = "",
00878 string inst = "",
00879 bit recurse = 0);
00880
00881
00882
00883
00884 extern virtual task wait_for_msg(string name = "",
00885 string inst = "",
00886 bit recurse = 0,
00887 int typs = ALL_TYPS,
00888 int severity = ALL_SEVS,
00889 string text = "",
00890 logic issued = 1'bx,
00891 ref vmm_log_msg msg);
00892
00893 extern virtual function int create_watchpoint(int typs = ALL_TYPS,
00894 int severity = ALL_SEVS,
00895 string text = "",
00896 logic issued = 1'bx);
00897 extern virtual function void add_watchpoint(int watchpoint_id,
00898 string name = "",
00899 string inst = "",
00900 bit recurse = 0);
00901 extern virtual function void remove_watchpoint(int watchpoint_id = -1,
00902 string name = "",
00903 string inst = "",
00904 bit recurse = 0);
00905 extern virtual task wait_for_watchpoint(int watchpoint_id,
00906 ref vmm_log_msg msg);
00907
00908
00909
00910
00911 extern virtual function void prepend_callback(vmm_log_callbacks cb);
00912 extern virtual function void append_callback(vmm_log_callbacks cb);
00913 extern virtual function void unregister_callback(vmm_log_callbacks cb);
00914
00915
00916 `ifdef VCS
00917 `ifdef VCS_SMARTLOG
00918 static local bit plus_sml = $test$plusargs("smartlog");
00919 static local int unsigned sml_count = 0;
00920 local int unsigned sml_id = sml_count++;
00921 `endif
00922
00923
00924 `endif
00925 endclass: vmm_log
00926
00927
00928 `ifdef VMM_SB_DS_IN_STDLIB
00929 `include "sb/vmm_sb.sv"
00930 (* _vcs_vmm_class = 1 *)
00931 class vmm_sb_ds_registration;
00932 vmm_sb_ds sb;
00933 bit is_in;
00934 bit is_out;
00935 vmm_sb_ds::ordering_e order;
00936 endclass
00937 `endif
00938
00939
00940
00941
00942
00943
00944 `ifdef VCS
00945 (* vmm_callback_class, _vcs_vmm_class = 1 *)
00946 `endif
00947 virtual class vmm_notify_callbacks;
00948 virtual function void indicated(vmm_data status);
00949 endfunction
00950 endclass
00951
00952 `ifdef VCS
00953 (* _vcs_vmm_class = 1 *)
00954 `endif
00955 virtual class vmm_notification;
00956 virtual task indicate(ref vmm_data status);
00957 $write("FATAL: An instance of vmm_notification::indicate() was not overloaded or super.indicate() was called\n");
00958 $finish;
00959 endtask
00960 virtual task reset();
00961 $write("FATAL: An instance of vmm_notification::reset() was not overloaded or super.reset() was called\n");
00962 $finish;
00963 endtask
00964 endclass
00965
00966
00967 typedef class vmm_notification_config;
00968
00969
00970 `ifdef VCS
00971 (* _vcs_vmm_class = 1 *)
00972 `endif
00973 class vmm_notify
00974 `ifdef VMM_NOTIFY_BASE
00975 extends `VMM_NOTIFY_BASE
00976 `endif
00977 ;
00978 `VMM_LOG log;
00979
00980 typedef enum int {ONE_SHOT = 2,
00981 BLAST = 3,
00982 ON_OFF = 5
00983 } sync_e;
00984
00985 typedef enum bit {SOFT,
00986 HARD} reset_e;
00987
00988
00989 local int last_notification_id = 1000000;
00990 local vmm_notification_config configs[*];
00991
00992 extern function new(`VMM_LOG log);
00993
00994 `ifdef VMM_NOTIFY_BASE_METHODS
00995 `VMM_NOTIFY_BASE_METHODS
00996 `endif
00997
00998 extern virtual function void display(string prefix = "");
00999 extern virtual function string psdisplay(string prefix = "");
01000
01001 extern virtual function vmm_notify copy(vmm_notify to = null);
01002 extern virtual function int configure(int notification_id = -1,
01003 sync_e sync = ONE_SHOT);
01004 extern virtual function int is_configured(int notification_id);
01005
01006 extern virtual function bit is_on(int notification_id);
01007
01008 extern virtual task wait_for(int notification_id);
01009 extern virtual task wait_for_off(int notification_id);
01010
01011 extern virtual function bit is_waited_for(int notification_id);
01012 extern virtual function void terminated(int notification_id);
01013
01014 extern virtual function vmm_data status(int notification_id);
01015 extern virtual function time timestamp(int notification_id);
01016 extern virtual function void indicate(int notification_id,
01017 vmm_data status = null);
01018
01019 extern virtual function void set_notification(int notification_id,
01020 vmm_notification ntfy = null);
01021 extern virtual function vmm_notification get_notification(int notification_id);
01022 extern virtual function void reset(int notification_id = -1,
01023 reset_e rst_typ = SOFT);
01024
01025 extern function void append_callback(int notification_id,
01026 vmm_notify_callbacks cbs);
01027 extern function void unregister_callback(int notification_id,
01028 vmm_notify_callbacks cbs);
01029
01030
01031 `ifdef VMM_SB_DS_IN_STDLIB
01032 extern function void register_vmm_sb_ds(int notification_id,
01033 vmm_sb_ds sb,
01034 vmm_sb_ds::kind_e kind,
01035 vmm_sb_ds::ordering_e order = vmm_sb_ds::IN_ORDER);
01036 extern function void unregister_vmm_sb_ds(int notification_id,
01037 vmm_sb_ds sb);
01038 `endif
01039
01040 endclass
01041
01042
01043
01044
01045
01046
01047 `ifdef VCS
01048 (* _vcs_vmm_class = 1 *)
01049 `endif
01050 class vmm_data
01051 `ifdef VMM_DATA_BASE
01052 extends `VMM_DATA_BASE
01053 `endif
01054 ;
01055
01056 local `VMM_LOG log;
01057
01058 int stream_id;
01059 int scenario_id;
01060 int data_id;
01061
01062 `VMM_NOTIFY notify;
01063 typedef enum int {EXECUTE = 999_999,
01064 STARTED = 999_998,
01065 ENDED = 999_997
01066 } notifications_e;
01067
01068 extern function new(`VMM_LOG log
01069 `VMM_DATA_BASE_NEW_ARGS);
01070
01071 `ifdef VMM_DATA_BASE_METHODS
01072 `VMM_DATA_BASE_METHODS
01073 `endif
01074
01075 extern function vmm_log set_log(`VMM_LOG log);
01076
01077 extern function void display(string prefix = "");
01078 extern virtual function string psdisplay(string prefix = "");
01079
01080 extern virtual function bit is_valid(bit silent = 1,
01081 int kind = -1);
01082 extern virtual function vmm_data allocate();
01083 extern virtual function vmm_data copy(vmm_data to = null);
01084 extern virtual protected function void copy_data(vmm_data to);
01085
01086 extern virtual function bit compare( vmm_data to,
01087 output string diff,
01088 input int kind = -1);
01089
01090 extern virtual function int unsigned byte_size(int kind = -1);
01091 extern virtual function int unsigned max_byte_size(int kind = -1);
01092 extern virtual function int unsigned byte_pack(ref logic [7:0] bytes[],
01093 input int unsigned offset = 0,
01094 input int kind = -1);
01095 extern virtual function int unsigned byte_unpack(const ref logic [7:0] bytes[],
01096 input int unsigned offset = 0,
01097 input int len = -1,
01098 input int kind = -1);
01099 extern virtual function bit load(int file);
01100 extern virtual function void save(int file);
01101
01102
01103
01104
01105 protected static string __vmm_prefix;
01106 protected static string __vmm_image;
01107 protected static vmm_data __vmm_rhs;
01108 protected static int __vmm_kind;
01109 protected static int __vmm_offset;
01110 protected static int __vmm_len;
01111 protected static bit [4095:0] __vmm_maxbits;
01112 protected static bit __vmm_status;
01113 protected static logic [7:0] __vmm_bytes[];
01114 protected static bit __vmm_done_user;
01115
01116 typedef enum {DO_PRINT ='h001,
01117 DO_COPY ='h002,
01118 DO_COMPARE ='h004,
01119 DO_PACK ='h010,
01120 DO_UNPACK ='h020,
01121 DO_ALL ='hFFF} do_what_e;
01122
01123 typedef enum {DO_NOCOPY ='h001,
01124 DO_REFCOPY ='h002,
01125 DO_DEEPCOPY ='h004,
01126 HOW_TO_COPY ='h007,
01127 DO_NOCOMPARE ='h008,
01128 DO_REFCOMPARE ='h010,
01129 DO_DEEPCOMPARE ='h020,
01130 HOW_TO_COMPARE ='h038,
01131 DO_NONE ='h009, // OR of all DO_NO*
01132 DO_REF ='h012,
01133 DO_DEEP ='h024, // OR of all DO_DEEP*
01134 _DO_DUMMY} do_how_e;
01135
01136 function void do_all( do_what_e what,
01137 ref logic [7:0] pack[],
01138 const ref logic [7:0] unpack[]);
01139 endfunction
01140
01141 extern virtual function string do_psdisplay(string prefix = "");
01142
01143 extern virtual function bit do_is_valid(bit silent = 1,
01144 int kind = -1);
01145 extern virtual function vmm_data do_allocate();
01146 extern virtual function vmm_data do_copy(vmm_data to = null);
01147
01148 extern virtual function bit do_compare( vmm_data to,
01149 output string diff,
01150 input int kind = -1);
01151
01152 extern virtual function int unsigned do_byte_size(int kind = -1);
01153 extern virtual function int unsigned do_max_byte_size(int kind = -1);
01154 extern virtual function int unsigned do_byte_pack(ref logic [7:0] bytes[],
01155 input int unsigned offset = 0,
01156 input int kind = -1);
01157 extern virtual function int unsigned do_byte_unpack(const ref logic [7:0] bytes[],
01158 input int unsigned offset = 0,
01159 input int len = -1,
01160 input int kind = -1);
01161
01162 `ifdef VCS
01163 extern function int vmt_hook(vmm_xactor xactor = null,
01164 vmm_data obj = null);
01165
01166 `endif
01167 endclass: vmm_data
01168
01169
01170 //---------------------------------------------------------------------
01171 // vmm_channel
01172 //
01173
01174 `ifdef VCS
01175 (* _vcs_vmm_class = 1 *)
01176 `endif
01177 class vmm_channel
01178 `ifdef VMM_CHANNEL_BASE
01179 extends `VMM_CHANNEL_BASE
01180 `endif
01181 ;
01182 `VMM_LOG log;
01183 `VMM_NOTIFY notify;
01184
01185 // Predefined notifications
01186 typedef enum int unsigned {FULL,
01187 EMPTY,
01188 PUT,
01189 GOT,
01190 PEEKED,
01191 ACTIVATED,
01192 ACT_STARTED,
01193 ACT_COMPLETED,
01194 ACT_REMOVED,
01195 LOCKED,
01196 UNLOCKED} notifications_e;
01197
01198 // Arguments for lock methods
01199 typedef enum bit [1:0] {SOURCE = 2'b01,
01200 SINK = 2'b10
01201 } endpoints_e;
01202
01203 typedef enum int unsigned {INACTIVE = 0,
01204 PENDING = 1,
01205 STARTED = 2,
01206 COMPLETED = 3
01207 } active_status_e;
01208
01209 static local bit one_log = $test$plusargs("vmm_channel_shared_log");
01210 static local `VMM_LOG shared_log = null;
01211
01212 local int full = 0;
01213 local int empty = 0;
01214 local bit is_sunk = 0;
01215
01216 local vmm_data data[$];