1Systasks(1) Systasks(1)
2
3
4
5 All Cver System tasks and Functions
6
8 These man pages document every system task and system function recog‐
9 nized by Cver including those not implemented. System tasks and func‐
10 tions are mixed together and appear in alphabetical order. Similar
11 tasks and system functions are intermixed. Functionally similar tasks
12 and functions are combined into one section and alphabetized according
13 to main task or function.
14
15 For system functions, the SYNOPSIS section contains normal user func‐
16 tion declaration notation to define return type and argument type even
17 though system functions are never really declared. There is no concept
18 of separate function header in Verilog. In the 2005 P1364 LRM most
19 system function are indicated as returning integer, now that signed
20 values are supported, system functions must be assigned to an integer
21 or a "signed [31:0]" reg.
22
23 System tasks appear in the SYNOPSIS section using the task invocation
24 form (i.e. task keyword omitted) and usually with meta descriptions of
25 parameters. In Verilog system tasks, unlike user defined tasks, can
26 always take a variable number of arguments and optional but not
27 required arguments can be omitted either with ",," or by ending the
28 argument list. Some system functions also have optional arguments that
29 can be omitted.
30
31 In Verilog all strings except $display type format specifiers can be
32 either expressions that are interpreted as strings (high 0 bits trimmed
33 off and then interpret each byte as a character) or literal strings
34 (enclosed by double quotation marks). Any [file name] can be either
35 type of string.
36
37 The 2005 P1364 LRM timing checks are not documented here because they
38 do not vary between simulators and are not really system functions.
39 See 2005 P1364 LRM section 15 and A.7.5 for documentation of timing
40 checks, edge control specifiers, and notifiers.
41
42------------------------------------------------------------------------------
43
45 $bitstoreal - convert 64 bit register to real
46 $realtobits - convert real to 64 bit register
47 $itor - convert integer to real
48 $rtoi - convert real to integer by rounding
49
51 function real $bitstoreal;
52 input [63:0] bit_val;
53 function [63:0] $realtobits;
54 input real real_val;
55 function real $itor;
56 input integer int_val;
57 function integer $rtoi;
58 input real real_val;
59
61 System functions to convert to and from reals. Use $realtobits and
62 $bitstoreal to pass reals across module ports. Use $itor and $rtoi to
63 convert between integer and real by rounding. In Verilog, assignments
64 also implicitly convert to or from a real depending on the left hand
65 side Lvalue type. Cver conversion to real from wider than 32 bit val‐
66 ues attempts to preserve as many bits as possible (usually 51 or 52
67 depending on hardware platform).
68
70 Defined in 2005 P1364 LRM section 17.8.
71
72------------------------------------------------------------------------------
73
75 $cleartrace - turn off statement tracing
76 $settrace - turn on statement tracing
77 $clearevtrace - turn off declarative event tracing
78 $setevtrace - turn on declarative event tracing
79 $tracefile - set separate output file for trace output
80
82 $cleartrace;
83 $settrace;
84 $clearevtrace;
85 $setevtrace;
86 $tracefile([file name]);
87
89 Cver supports separate control of statement and declarative event trac‐
90 ing. The options -t starts simulation with statement tracing on. The
91 option minus -et start simulation with event tracing on. The -t option
92 and $settrace and $cleartrace in some other simulators enable and dis‐
93 able both types of tracing. To approximate full tracing in other simu‐
94 lators use both -t and -et options or call both $settrace and $setev‐
95 trace.
96
97 The $tracefile system task set the output file for tracing (both types)
98 to [file]. The $tracefile argument can be a variable that is treated
99 as a string with high 0 bits removed. An alternative way to set a sep‐
100 arate trace output file is with the +tracefile [file] command line
101 option. Executing $tracefile replaces any +tracefile set file. If
102 $tracefile is not used, trace output is written to STDOUT and the log
103 file (if it exists). The tracefile can be the string "stdout" that has
104 the effect of restoring trace output to default STDOUT and the log
105 file. If a trace file is set, trace output is not written to stdout.
106
108 These system tasks are not mentioned in the P1364 LRM because they
109 apply to the interactive environment not addressed by the standard.
110
111------------------------------------------------------------------------------
112
114 $cos - compute cosine of real input
115 $sin - compute sin of real input
116 $tan - compute tangent of real input
117 $acos - compute arc cosine of real input
118 $asin - compute arc sin of real input
119 $atan - compute arc tangent of real input
120 $acosh - compute hyperbolic arc cosine of real input
121 $asinh - compute hyperbolic arc sine of real input
122 $atanh - compute hyperbolic arc tangent of real input
123 $sgn - compute sign of real input (returns integer)
124 $int - convert real input to 32 bit integer (uses C not Verilog conver‐
125 sion)
126 $ln - compute nature logarithm of real input
127 $log10 - compute base 10 logarithm of real input
128 $abs - compute absolute value of real input
129 $pow - compute exponent of first real input to second real argument
130 power
131 $sqrt - compute square root real input
132 $exp - compute e raised to power of real input
133 $min - compute minimum of 2 real inputs
134 $min - compute maximum of 2 real inputs
135
137 System function identical to IEEE math functions except for added $
138 prefix
139
141 This is non digital P1364 Cver enhancement that is available in digital
142 Cver because it is required for Verilog-AMS version of Cver. Functions
143 are defined in Verilog-AMS 2.0 OVI LRM. Behavior is identical to
144 behavior documented by Unix math function man pages.
145
146 Cver also allows use of system functions with constant arguments in
147 constant expressions so parameter definitions such as "parameter cos2 =
148 $cos(2.0);" are legal in Cver and are part of new Verilog 2001 stan‐
149 dard. Cver does not yet support constant argument user functions in
150 constant expressions.
151
152 The following Hspice math library variants are also supported: $hsqrt,
153 $hpow, $hpwr, $hlog, $hlog10 $hdb, and $hsign. See Hspice documenta‐
154 tion for behavior and required arguments.
155
157 See Verilog-AMS 2.0 OVI standard LRM. Standard IEEE math functions.
158 See any Hspice documentation.
159
160------------------------------------------------------------------------------
161
163 $countdrivers - return 1 if bus contention because more than one driver
164
166 function integer $countdrivers;
167 // must be wire
168 input net;
169 output integer net_is_forced;
170 output integer number_of_01x_drivers;
171 output integer number_of_0_drivers;
172 output integer number_of_1_drivers;
173 output integer number_of_x_drivers;
174
176 System function return 0 if there is no more than one driver (all wire
177 fan-in is tri-stated (in hiZ state) or a most one fan-in wire (or
178 select of wire) is non tri-stated). Returns 1 if there is more than
179 one non-tri-stated fan-in. The first net argument is required. If a
180 second argument is given, it must be a reg lvalue expression that is
181 set to the total number of fan-in any state other than hiZ. If a third
182 argument is given, it must be a reg lvalue expression that is set to
183 the total number of fan-in that drives 0. If a fourth argument is
184 given, it must be a reg lvalue expression that is set to the total num‐
185 ber of fan-in that drives 1. If a fifth argument is given, it must be
186 a reg lvalue expression that is set to the total number of fan-in that
187 drives x. If an argument is omitted, but an argument to its right is
188 needed, use ",,". Notice a statement: "always @w numdriv = $count‐
189 drivers(w);" does not work since the number of drivers may change with‐
190 out the wire's value changing especially for strength wires. Notice
191 that in the LRM, driver usually means non tri-stated fan-in. Sometimes
192 driver means instead any fan-in whether or not it is tri-stated.
193
195 Defined in 2005 P1364 LRM Appendix C.1
196
197------------------------------------------------------------------------------
198
200 $display, $displayb, $displayh, $displayo - write formatted value to
201 stdout
202 $write, $writeb, $writeh, $writeo - write formatted value to stdout
203
205 $display([intermixed list of format strings and expressions]);
206 $display[bho]([intermixed list of format strings and expressions]);
207 $write([intermixed list of format strings and expressions]);
208 $write[bho]([intermixed list of format strings and expressions]);
209
211 Write formatted values to standard out (and the log file). The format
212 is similar to C language printf format except the format string must be
213 literal, more than one format string can appear followed by values to
214 replace format references with, only qualifier is 0 that causes trim‐
215 ming of the value to narrowest field possible. The %g format for reals
216 is identical to C language printf %g format. $display always appends a
217 new line to the end of the displayed string. For $write, any new line
218 must be explicitly written. By default, variable that do not match any
219 format specifier are written in decimal. Use $displayb and $writeb to
220 change the default to binary, $displayh and $writeh to change default
221 to hex, and $displayo and $writeo to change to octal.
222
224 Defined in P1364 LRM section 17.1.
225
227 The same format is used by the $fdisplay and $fwrite tasks which write
228 to file(s), the $monitor and $fmonitor tasks that write changed expres‐
229 sions at the end of a time slot, and $strobe and $fstrobe that always
230 write value of an expression at the end of a time slot.
231
232------------------------------------------------------------------------------
233
235 $dist_chi_square - return random 32 bit value in Chi Square distribu‐
236 tion
237 $dist_erlang - return random 32 bit value in Erlangian distribution
238 $dist_exponential - return random 32 bit value in Exponential distribu‐
239 tion
240 $dist_normal - return random 32 bit value in Standard Normal distribu‐
241 tion
242 $dist_poisson - return random 32 bit value in Poisson distribution
243 $dist_t - return random 32 bit value in Standard T distribution
244 $dist_uniform - return random 32 bit value uniformly distributed in
245 range
246
248 function integer $dist_chi_square;
249 inout integer seed;
250 input integer degree_of_freedom;
251 function integer $dist_erlang;
252 inout integer seed;
253 input integer k_stage;
254 input integer mean;
255 function integer $dist_exponential;
256 inout integer seed;
257 input integer mean;
258 function integer $dist_normal;
259 inout integer seed;
260 input integer mean;
261 input integer standard_deviation;
262 function integer $dist_poisson;
263 inout integer seed;
264 input integer mean;
265 function integer $dist_t;
266 inout integer seed;
267 input integer degree_of_freedom;
268 function integer $dist_uniform;
269 inout integer seed;
270 input integer start;
271 input integer end;
272
274 These are the random deviate generation functions defined in P1364 LRM.
275 Algorithm follow "Numerical Recipes in C". However they are somewhat
276 unusual in taking integer arguments and producing scaled integer out‐
277 puts rather than the more normal real number inputs and outputs between
278 0.0 (sometimes -1.0) and 1.0. Each distribution function takes a first
279 argument that is a seed that sets cyclical starting point in the dis‐
280 tribution sequence. Each function returns a random value according to
281 the distribution type and updates the seed so that if a passed seed is
282 saved and reused, both the same value will be returned, and the same
283 new seed will be set. This properly allows repeatability for debug‐
284 ging.
285
286 The $dist_chi_square and $dist_t degree_of_freedom values determine the
287 shape of the distribution (larger values widen the distribution). The
288 mean parameter used in $dist_erlang, $dist_exponential, $dist_normal
289 and $disp_poisson cause the average value returned to converge to the
290 passed mean. The $dist_normal function standard deviation input param‐
291 eter determines shape of the standard normal distribution (larger value
292 widens the distribution). The $dist_uniform start and end determine
293 the range within which the uniformly distributed random number fits.
294 Start and end may be negative but start must be less than end. The
295 mean, k_stage and degree_of_freedom parameters must be positive
296
298 Defined 2005 in P1364 LRM section 17.9.2.
299
301 See any statistics textbook or CRC Handbook of Standard Math Tables for
302 definitions of the formulas. Also see "Numerical Recipes in C" for
303 algorithms.
304
305------------------------------------------------------------------------------
306
308 $dumpvars - set up variables that are written to VCD file
309 $dumpall - dump current value of all variables set up for dumpvaring
310 $dumpflush - make OS call to flush VCD file buffer to file
311 $dumplimit - set maximum size of VCD file
312 $dumpoff - turn off dumping to VCD file on variable changes
313 $dumpon - turn on dumping to VCD file on variable changes
314
316 $dumpvars([level], [list of scopes and/or variables to dump]);
317 $dumpall;
318 $dumpfile([file name]);
319 $dumpflush;
320 $dumplimit([limit number of bytes]);
321 $dumpoff;
322 $dumpon;
323
325 The $dumpvars system task causes first a header to be written to the
326 VCD (value change dump) file that defines a short code for each vari‐
327 ables. Then whenever a variable changes, the variable's code and value
328 are written to the VCD file. When $dumpvars is first called the value
329 of all variables is written to the VCD file.
330
331 $dumpvars must be called before any writing of changed variable values
332 to the VCD dump file can occur to set up the variables that are dumped.
333 The $dumpfile system task can change the name of the VCD dump file from
334 the default verilog.dump. It must be called before or at the same time
335 as $dumpvars. When $dumpvars is called actual dumping is set up at the
336 end of that time slot. It is an error for $dumpvars to be called more
337 than once.
338
339 $dumpvars takes either scopes or variable names as arguments. A Vari‐
340 able name (or hierarchical reference) causes just that variable to be
341 written to the VCD file. a Scope causes all variables in the scope and
342 all variables in [level] scopes down to be written to the VCD file on
343 change. [level] value 0 means descend to the bottom of the hierarchy.
344 If $dumpvars is called with no arguments, all variables in the design
345 are written to the VCD file.
346
347 $dump limits set the maximum size of the VCD dump file to [limit].
348 Once [limit] bytes have been written, no more writing to the dumpvars
349 file occurs. $dumpoff stop dumping of variables and writes every
350 dumped variable to the VCD dump file with unknown (x) value. $dumpon
351 restarts dumping of variable changes and starts by writing the current
352 value of every variable to the VCD dump file.
353
354 The +dumpvarsextended added Cver option writes a non standard VCD file
355 but allows strengths (not just the value part) to be written and uses
356 hex format instead of binary where possible to reduce the VCD file
357 size.
358
360 Defined in 2005 P1364 LRM section 18.
361
362------------------------------------------------------------------------------
363
365 $fdisplay, $fdisplayb, $fdisplayh, $fdisplayo - write formatted value
366 to file(s)
367 $fwrite, $fwriteb, $fwriteh, $fwriteo - write formatted value to
368 file(s)
369
371 $fdisplay([multi-channel or fd], [intermixed list of format strings and
372 expressions]);
373 $fdisplay[bho]([multi-channel or fd], [intermixed list of format
374 strings and expressions]);
375 $fwrite([multi-channel or fd], [intermixed list of format strings and
376 expressions]);
377 $fdisplay[bho]([multi-channel or fd], [intermixed list of format
378 strings and expressions]);
379
381 Same as $display and $write but writes to either a Unix style file
382 stream (abbreviated fd below) or all file descriptors selected by on
383 bits in passed 32 bit multi-channel descriptor. For multi-channel
384 descriptors if a bit is on but the file corresponding to the bit posi‐
385 tion is not opened with $fopen system function, no write occurs. The
386 multi-channel descriptor idea allows one $fdisplay to write to more
387 than one file in contrast to requiring multiple writes.
388
389 The modern Unix OS I/O stream form allows opening a file using the
390 stream two argument form of $fopen and then using that strean descrip‐
391 tor (fd) for Unix OS style fwriting. The old file descriptor with bit
392 31 turned on is now used to indicate the new Unix OS style fd stream.
393
395 Defined in 2005 P1364 2005 LRM section 17.2.2.
396
398 See related $display and $write system tasks. See $fopen and $fclose
399 for opening and closing new Unix OS file streams and assigning multi-
400 channel descriptors.
401
402------------------------------------------------------------------------------
403
405 $finish - exit Cver
406
408 $finish;
409 $finish([message level]);
410
412 Exit Cver and return control to the host operating system. if a value
413 is passed, if it is 0 (same as no argument) prints nothing, if 1 is
414 passed prints normal exit message, and if 1 prints message as if +ver‐
415 bose option were selected.
416
418 Defined in 2005 P1364 LRM section 17.4.1.
419
420------------------------------------------------------------------------------
421
423 $flushlog - flush log and trace file internal OS buffers
424
426 $flushlog;
427
429 Flush the log file OS buffers. If the $tracefile system task has been
430 used to set a separate trace output file, that stream also is flushed.
431
433 Not defined in P1364 LRM but commonly implemented.
434
435------------------------------------------------------------------------------
436
438 $fmonitor, $fmonitorb, $fmonitorh, $fmonitoro - write changed formatted
439 value to file(s)
440
442 $fmonitor([multi-channel or fd], [intermixed list of format strings and
443 expressions]);
444 $fmonitor[bho]([multi-channel of fd], [intermixed list of format
445 strings and expressions]);
446
448 If any expression in the format variable list changes, format and write
449 the value to the new Unix OS file descriptor (fd) or a multi-channel
450 descriptor file list at the end of the simulation time slot. If a time
451 returning system functions such as $time appears in the list, it does
452 not cause a change. Format is same as $fdisplay. Any number of $fmon‐
453 itors may be used and if more than one changed the format list for each
454 changed $fmonitor is written at time slot end.
455
457 Defined in new 2005 P1364 LRM section 17.2.2. Also 17.1.3 for $fmoni‐
458 tor.
459
461 $monitor is same but writes to stdout. See $display for format defini‐
462 tions.
463
464------------------------------------------------------------------------------
465
467 $fopen - open a file and assign a Unix OS stream or multi-descriptor
468 channel bit
469 $fclose - close a file and free for reuse a Unix OS stream or multi-
470 descriptor
471
473 function integer $fopen([file name]);
474 function integer $fopen([file name], [open description type]);
475 $fclose([multi-channel or fd]);
476
478 Verilog allows writing to multiple open files at once using a multi-
479 channel file descriptor. Bit 0 (least significant bit) is associated
480 with stdout and is always open. The $fclose call closes the file asso‐
481 ciated with any on bit in the passed 32 bit multi-channel value. The
482 file descript form of $fopen system function is passed a file name (can
483 be any length and need not be a literal string) and returns a multi-
484 channel descriptor with the next available bit (bit corresponding to
485 un-opened descriptor channel) set. $fopen reuses multi-channel bits
486 freed by the file descriptor form of $fclose.
487
488 The new file stream form of fopen can be used to open a Unix OS style
489 stream. For opening streams, the 2nd I/O type string must be present.
490 The strings correspond exactly Unix $fopen I/O types (see 2005 LRM ta‐
491 ble 17-7). The return Unix OS stream has bit 31 turned on. Therefore
492 bit 31 can no longer be used for old style file descriptors.
493
495 Defined in 2005 P1364 LRM section 17.2.1.
496
498 See $fdisplay, $fwrite, $fmonitor, and $fstrobe routines that write to
499 multi-channel descriptors or Unix OS streams.
500
501------------------------------------------------------------------------------
502
504 $swrite[bho], $sformat - write formatted value to a string
505
507 $swrite[bho]([ouput reg], [intermixed list of format strings and
508 expressions]);
509 $sformat([ouput reg, [format string], [list of arguments]]);
510
512 Routines to allow writing to Verilog regs. $swrite is the same as
513 $display except the output is written to as a string to a Verilog reg.
514 $sformat requires exactly one format string. The remaining arguments
515 are interpreted as format values (never as format strings). This
516 allows compile time checking of formats and is the same as the Unix OS
517 sprintf type routine.
518
520 Defined in 2005 P1364 LRM section 17.2.3.
521
522------------------------------------------------------------------------------
523
525 $fgetc, $ungetc, $fgets, $fscanf, $sscanf, $fread, $fseek, $ftell,
526 $rewind
527
529 integer $fread([reg], [fd only]);
530 integer $fread([Verilog array], [fd only]);
531 integer $fread([Verilog array], [fd only], [start], [count]);
532 [other routines have same arguments and order as UNIX I/O library input
533 routines]
534
536 All the Unix I/O library input routine are implemented. Except for
537 binary $fread that can read into arrays so it has extra arguments, all
538 the read routines are the same as the Unix OS library routines in
539 behavior and take the same arguments in the same order. See section
540 17.2.4.3 for a definition of the $fscanf and $sscanf legal format
541 strings because formats are available for the Verilog two bit values
542 and streng values (form v). Also unformatted binary data can be read
543 in 2 bit chunks using the %z format and 1 bit values that are expanded
544 to 4 value Verilog x/z values using the %u format.
545
546 Notice that only I/O streams (fds), not multi-channel descriptors can
547 be used as the file argument for the file I/O read routines. Also,
548 notice that the output value from these routines should be assigned to
549 an integer, not an unsigned value. $fseek, $fell, $rewind and $ungetc
550 correspond exactly to the Unix I/O library corresponding routines. All
551 read routines return the number of items read or EOF (-1) when end-of-
552 file is read. You must invoke $ferror to determine the cause of the
553 error.
554
556 Defined in 2005 P1364 LRM section 17.2.4.
557
558------------------------------------------------------------------------------
559
561 $fflush - writes any buffer output for an open file or stream
562
564 $flush([mcd]);
565 $flush([fd]);
566 $flush();
567
569 These routine flush any buffered output for either an open multi-chan‐
570 nel descriptor, a Unix OS file stream (fd) or all open multi-channel
571 descriptor files and streams.
572
574 Defined in 2005 P1364 LRM section 17.2.6.
575
576------------------------------------------------------------------------------
577
579 $ferror - returns I/O error status
580
582 integer $ferror([mcd or fd], str);
583
585 This routine correspeonds to the Unix OS I/O library ferror routine.
586 If an I/O error is detected, the OS error number is returned and the
587 [str] is set to a string indicating the error reason. The reason is
588 the same as the Unix OS returned I/O library error reason string.
589
591 Defined in 2005 P1364 LRM section 17.2.7.
592
593------------------------------------------------------------------------------
594
596 $getpattern - function for rapid assignment of memory bits to concate‐
597 nate of scalars
598
600 assign {<list of scalars or selects>]} = $getpattern(<memory>[<index>];
601
603 This function must be used on the right hand side of a continuous
604 assignment where the left hand side is a concatenate of scalars or con‐
605 stant bit selects. The argument must be a select of memory (normally
606 loaded using $reaadmem) that is a variable. When the variable select
607 index is changed the new memory value determined by the select index
608 will be rapidly (i.e. with no need for expression evaluation) assigned
609 to the scalars. Normally the assignment process will be driven by a
610 for loop that increments the index. No other use of $getpattern is
611 allowed.
612
614 Defined in 2005 P1364 LRM Appendix C.1
615
616------------------------------------------------------------------------------
617
619 $fstrobe, $fstrobeb, $fstrobeh, $fstrobeo - write formatted value to
620 file at end of time slot
621
623 $fstrobe([multi-channel or fd], [intermixed list of format strings and
624 expressions]);
625 $fstrobe[bho]([multi-channel or fd], [intermixed list of format strings
626 and expressions]);
627
629 Same as $fdisplay but formats and writes value at the end of time time
630 slot rather than when the $fstrobe statement is executed. Format is
631 identical to $fdisplay and [bho] suffix letter changes default for
632 expression that appears outside of any format as with $display. One
633 formated string is written for every $fstrobe and $strobe executed dur‐
634 ing the time slot.
635
637 Defined in 2005 P1364 LRM section 17.2.2.
638
640 $strobe is same except writes to stdout.
641
642------------------------------------------------------------------------------
643
645 $history - print list previously executed interactive commands
646 $nokeepcommands - do not add executed interactive commands to history
647 list
648 $keepcommands - add executed interactive commands to history list
649
651 $history([number of commands to list]);
652 $keepcommands;
653 $nokeepcommands;
654
656 $history lists either all or [number] of most recently executed inter‐
657 active commands. All commands except history enable, disable, and one
658 character abbreviation commands are entered in the history list. Added
659 : debugger commands are also added to the history list.
660
661 Each command is numbered so it can be re-executed by entering [number]
662 at the interactive prompt and, for scheduled and uncompleted commands,
663 disabled by typing -[history command number]. $nokeepcommands disables
664 collection of interactive commands into the history list and $keepcom‐
665 mands enables collection. Cver keeps all commands entered on the his‐
666 tory list until a :emptyhistory added debugger command is entered at
667 which point the history list is made empty. $input command scripts
668 should begin with $nokeepcommands and end with $keepcommands to mini‐
669 mize history list size. The added debugger :history command is more
670 flexible than $history. Multiple line commands (end with escaped new
671 line in Cver) are printed as one command.
672
674 Not defined in 2005 P1364 LRM. OVI LRM 1.0 section D.8.
675
677 See added debugger online ":help history" command for more detailed
678 description of Cver's history mechanism.
679
680------------------------------------------------------------------------------
681
683 $input - enter interactive commands from a file
684
686 $input([file]);
687
689 $input and the -i [file] Cver command argument cause interactive com‐
690 mands to be read from [file]. It can contain added debugger : com‐
691 mands. If an $input script file contains a $input call, command read‐
692 ing continues in the new script. The new script replaces the old and
693 any un-executed interactive commands after the $input are not called.
694 The new script is chained to not called. Interactive mode must be
695 entered before commands can be read from the $input file so both -i and
696 $input do nothing unless interactive mode is entered. $input should
697 not appear in Verilog source.
698
700 Defined in 2005 P1364 LRM section C.3.
701
703 See added debugger online ":help debugging" for additional documenta‐
704 tion.
705
706------------------------------------------------------------------------------
707
709 $key - save every press key stroke to a file
710 $nokey - disable saving of key strokes
711
713 Cver does not support $key because it depends on the original XL scheme
714 for tracking asynchronous interrupts and is not compatible with Cver's
715 added : debugger and line continuation scheme.
716
717 There are two better ways to allow restarting and simulating to a par‐
718 ticular problem statement at a particular problem time. First, prepare
719 a $input script and use -s with -i command options to rerun the script.
720 Second, use the added :ibreak or :break breakpoint command with the
721 :ignore [count] command to skip [count] break points to return to the
722 problem time. Use :info breakpoint to determine the number of times a
723 break point was hit. Alternative use the :breakpoint command :cond
724 [expression] command to attach a condition to a statement break point.
725
727 See 2005 P1364 LRM section C.4.
728
730 See added debugger :help online help system messages.
731
732------------------------------------------------------------------------------
733
735 $list - list source reconstructed from internal data base for scope
736
738 $list([scope]);
739
741 List scope to stdout and the log file by reconstructing source from
742 Cver's internal representation. All parameters and specparams are dis‐
743 played as numeric constants. If no argument is given, list the current
744 scope. If the -d command line option is used, reconstructed source for
745 an entire design is output. If $list is executed from interactive
746 mode, the current interactive scope (maybe set with the $scope system
747 task is used). It is better from interactive mode to use the :list
748 added debugger command that prints source lines exactly as they appear
749 in the source input and allows more control of lines to list.
750
752 See 2005 P1364 LRM section C.5.
753
755 Type ":help :list" in interactive mode for documentation of :list range
756 specification.
757
758------------------------------------------------------------------------------
759
761 $log - set new log output file or re-enable writing to log file
762 $nolog - disable writing to the log file
763
765 $log;
766 $log([file name]);
767 $nolog;
768
770 Normally all terminal (stdout) output is written to the log file that
771 has name verilog.log and is over-written for each new run of Cver com‐
772 mand option set the log file to [file]. Another way to disable writing
773 to the log file is to use file name /dev/null on Unix and nul on
774 OS2/DOS.
775
777 See 2005 P1364 LRM section C.6.
778
779------------------------------------------------------------------------------
780
782 $memuse - print message giving dynamically allocated memory.
783
785 $memuse;
786
788 System task that can be called to output to stdout and the log file the
789 number of bytes of dynamically allocated memory. Rather useless added
790 system task since it is better to use the +verbose option.
791
793 Cver extension not mentioned in the P1364 LRM.
794
795------------------------------------------------------------------------------
796
798 $monitor, $monitorb, $monitorh, $monitoro - write changed formatted
799 value to file(s)
800 $monitoroff- disable display of monitor changes
801 $monitoron- re-enable display of monitor changes
802
804 $monitor([intermixed list of format strings and expressions]);
805 $monitor[bho]([intermixed list of format strings and expressions]);
806 $monitoron;
807 $monitoroff;
808
810 If any expression in the format variable list changes, format and write
811 the value to stdout and the log file at the end of the simulation time
812 slot. Only one $monitor can be active at a time. Execution of a new
813 monitor replaces the previous (see $fmonitor if multiple active moni‐
814 tors are needed, use multi-channel channel 0 to write to stdout and log
815 file). If a time returning system functions such as $time appears in
816 the list, it does not cause a change. Format is same as $fdisplay.
817 $monitoroff turns off display of changed monitor values and $monitoron
818 re-enables writing of changed formatted values.
819
821 Defined in 2005 P1364 LRM section 17.1.3.
822
824 $fmonitor is same but writes to file using multi-channel descriptor,
825 See $display for format documentation.
826
827------------------------------------------------------------------------------
828
830 $q_add - place an entry on a queue
831 $q_exam - get selected queue status information
832 $q_initialize - create a new queue
833 $q_remove - get an entry from a queue
834 $q_full - return 1 if a queue if full else 0
835
837 $q_add;
838 input integer q_id; // unique number to identify queue
839 input integer job_id; // unique number to identify job
840 input integer inform_id; // user defined value added to queue
841 output integer status; // completion status
842 $q_exam;
843 input integer q_id; // unique number to identify queue
844 input integer q_stat_code; // what to return in q_stat_value
845 output integer q_stat_value;// returned value selected by q_stat_code
846 output integer status; // completion status
847 $q_initialize
848 input integer q_id; // unique number to identify queue
849 input integer q_type; // type, 1=fifo, 2=lifo
850 input max_length; // maximum number of elements allowed in queue
851 output integer status; // completion status
852 $q_remove;
853 input integer q_id; // unique number to identify queue
854 input integer job_id; // unique number to identify job
855 input integer inform_id; // user defined value removed from queue
856 output integer status; // completion status
857 function integer $q_full;
858 input integer q_id; // unique number to identify queue
859 output integer status; // completion status
860
862 In combination with stochastic random distribution (deviate) genera‐
863 tors, these routines provide routines to model statistical queue for
864 driving designs. Use the PLI routines for queues that must contain
865 values more complicated that 32 bit integers (or regs).
866
867 for $q_exam, the possible request types are: 1=current queue length,
868 2=mean inter-arrival time, 3=maximum queue length, 4=shortest wait time
869 ever, 5=longest wait time for jobs still in queue, and 6=average wait
870 time in the queue. Any queue routine may set the status output parame‐
871 ter to: 1=OK, 2=queue full, cannot add, 3=undefined q_id, 4=unsupported
872 queue type, cannot create queue, 5=specified length <=0, cannot create,
873 6=duplicate q_id, cannot create, not enough memory, cannot create.
874
876 Defined in 2005 P1364 LRM section 17.6.
877
878------------------------------------------------------------------------------
879
881 $random - generate signed random 32 bit value
882
884 function integer $random;
885 inout integer seed;
886 integer seed;
887
889 Cver uses good BSD random number generator that produces values with
890 almost 32 pseudo random bits, but the sequence of generated number will
891 probably not match the one returned by other simulators. If the the
892 optional seed variable lvalue is given, the starting location in the
893 2**32 (almost) element sequence of pseudo random values is altered.
894 Because the random generator only used 32 bit arithmetic the low bit is
895 unrandom.
896
898 See 2005 P1364 LRM section 17.9.1.
899
900------------------------------------------------------------------------------
901
903 $readmemb - read binary number from memory stored in file
904 $readmemh - read hex number from memory stored in file
905 $sreadmemb - read binary number from memory stored in string
906 $sreadmemh - read hex number from memory stored in string
907
909 $readmemb([file name], [memory name], [start_addr], [finish_addr]);
910 $readmemh([file name], [memory name], [start_addr], [finish_addr]);
911 $sreadmemb([memory name], [start_address], [finish_addr], [list of
912 strings]);
913 sreadmemb([memory name], [start_address], [finish_addr], [list of
914 strings]);
915
917 These system tasks read values from either a file or a string (the
918 $smemread[bh] routines). The format of the file or string, from which
919 to the memory is filled, is a list of white space separated values.
920 The values can contain digits, '_', x and z but no width specification.
921 For $readmemb and $sreadmemb the values must be binary. For $readmemh
922 and $sreadmemh, the values must be hex.
923
924 The basic memory filling algorithm is to read a word from the file or
925 string, fill the current memory location, then increment the memory
926 counter (decrement if [start_addr] is larger than [finish_addr]). The
927 special value @[hexadecimal number] in the file or string changes the
928 next address to write the memory data word into. If @[value] form
929 changes to an address outside the range, memory filling stops. Memory
930 address outside the range or outside the number of elements in the file
931 or string are not changed. For $smemread routines, a list of strings
932 is legal. The arguments may be arbitrary run time expressions that are
933 converted to strings. The list of strings is concatenated into one
934 long string and read exactly as if a file read of the string happened.
935 The list of strings is required because Verilog does not allow strings
936 to span line boundaries.
937
938 For $readmemb and $readmemh the [file] as a string (possibly an expres‐
939 sion that is converted to a string) and the memory identifier are
940 required. For $sreadmemb and $sreadmemh the memory identifier and at
941 least one string are required. The [start_addr] and [finish_addr] are
942 optional (must be indicated by ,, for $sreadmem functions) and give the
943 first address in the memory to use to write the first data word from
944 the file or string into. If the [finish_addr] is present, when that
945 memory address is reached, filling of the memory is stopped. It is
946 legal for [start_address] to be larger than [finish_addr] in which case
947 the memory if filled from high to low word. If only [start_address] is
948 given, [finish_addr] is the last (second) memory declaration range. If
949 only [finish_addr] is given, [start_addr] is the start (first) memory
950 declaration range.
951
953 See 2005 P1364 LRM sections and 17.2.9 and C.13.
954
955------------------------------------------------------------------------------
956
958 $reset - reset time to 0 and restart the simulation
959 $reset_value - returns value passed by most recent call of $reset
960 $reset_count - returns the number of times $reset has been executed
961
963 $reset([stop_value], [reset_value], [diagnostics_value]);
964 function integer $reset_value;
965 function integer $reset_count;
966
968 $reset allows rerunning a simulation from time 0 without re-translating
969 a model. It can have up to 3 optional arguments. If [stop_value] is
970 omitted or value 0, interactive mode is entered after reset. If
971 [reset_value] is present, it is preserved across the reset and can be
972 read with the the #reset_value system function after completing the
973 reset. The optional [diagnostic value] argument determines the amount
974 of diagnostic information printed after reset but prior to starting
975 again at time 0. Value 0 causes no information to be emitted, 1 some
976 information, and 2 is equivalent to the +verbose option. The
977 $reset_count system function returns the number of times the $reset
978 system task has been executed during the current run.
979
980 Cver also supports the :reset [option stop] added command debugger. It
981 does not effect either the [reset_value] or the number of times $reset
982 has been called so models that rely on $reset values can be debugged.
983 In Cver, all : added debugger setting are preserved except break points
984 and display expressions are disabled but not removed. Either type of
985 reset removes all quasi-continuous forces and assigns. If a simulation
986 is started with -s and -i [file], $reset will cause simulation to start
987 over in interactive mode running the first command in [file]. Cver
988 will never stop unless $reset_count is checked and used to cause end of
989 simulation.
990
992 See 2005 P1364 LRM section C.7.
993
995 See debugger online help for :reset added debugger command.
996
997------------------------------------------------------------------------------
998
1000 $save - save state of simulation to a file for later restart
1001 $incsave - save only changed values from last $save to a file
1002 $restart - restart simulation from a $save file
1003
1005 $save([file]);
1006 $incsave([file]);
1007 $restart([file]);
1008
1010 Cver does not yet support simulation check pointing that is needed for
1011 long simulations especially in cases where power or hardware failures
1012 occur. Cver design translation from source is fast enough that at
1013 least so far loading the binary data structure does not reduce load
1014 time. $incsave will probably not be supported since Cver already packs
1015 to the bit in order to support it, extra simulation event are needed.
1016
1018 See 2005 P1364 LRM section C.8.
1019
1020------------------------------------------------------------------------------
1021
1023 $scale - convert a time value from one module's time scale to another
1024 as real
1025
1027 function real $scale;
1028 input [time hierarchical value as either real or reg];
1029
1031 Given a time value as an hierarchical reference, convert to the time
1032 scale in which the $scale system task is executed. Usage: r =
1033 $scale(top.i1.i2.t1);
1034
1036 See 2005 P1364 LRM section C.9.
1037
1038------------------------------------------------------------------------------
1039
1041 $scope - change scope for use by interactive commands
1042
1044 $scope([hierarchal name]);
1045
1047 Use scope to change interactive scope from the default first top module
1048 for use after entering the interactive debugger. $scope is not very
1049 useful in Cver because, unless turned off by a debugger :set command,
1050 upon debugger entry (by $stop or interrupt) the interactive scope is
1051 set to the entering simulation scope. Also Cver supports an extended
1052 :scope command that allow relative movement between scopes and general
1053 reference for new scopes such as line numbers.
1054
1056 See 2005 P1364 LRM section C.10.
1057
1059 See the added debugger ":help :scope" help screen.
1060
1061------------------------------------------------------------------------------
1062
1064 $sdf_annotate - XL compatible sdf annotation system task
1065
1067 $sdf_annotate([required name of sdf file], [optional annotation scope],
1068 [optional ignored - no config files yet], [optional ignored - no sepa‐
1069 rate sdf log file], [optional mintypmax SDF override], [optional
1070 ignored - no scale factor], [optional ignored - no scale type]);
1071
1073 System function alternative to +sdf_annotate command line option.
1074 Function identical to XL $sdf_annotate system task so Verilog source
1075 that in XL can be run without change in Cver. $sdf_annotate system
1076 task also allows conditional choice of sdf annotation file. Third
1077 optional configuration file argument is ignored because Configurations
1078 are not yet supported in Cver. Optional fourth argument name of sepa‐
1079 rate log file is ignored because Cver writes all sdf messages to normal
1080 log file. Sdf annotation has also been changed to match XL so simula‐
1081 tion continues even if SDF contains errors. As much annotation as pos‐
1082 sible is made if SDF contains errors. Fourth optional mintypmax over‐
1083 ride argument is supported. Legal values are one of MINIMUM, TYPICAL,
1084 or MAXIMUM. Optional sixth scale factor and seventh scale factor type
1085 arguments are ignored. Extra scaling of SDF values in Cver is not sup‐
1086 ported.
1087
1089 De facto standardized routine. See document for any of the other Ver‐
1090 ilog simulators such as XL.
1091
1092------------------------------------------------------------------------------
1093
1095 $showallinstances
1096
1098 $showallinstances;
1099
1101 For every module in design, print its instance and gate usage in tabu‐
1102 lar form. This system tasks prints at run time the instance design
1103 statistics table printed by the +printstats command argument.
1104
1106 Not in P1364 LRM but commonly part of interactive environments.
1107
1108------------------------------------------------------------------------------
1109
1110------------------------------------------------------------------------------
1111
1113 $showscopes - display list of all scopes inside the current scope
1114
1116 $showscopes([value]);
1117
1119 List all scope objects in current scope. If invoked from interactive
1120 mode, the scope is the current interactive scope. If called during
1121 simulation, scope is current simulation scope. If value is present and
1122 non zero, print all scopes in or below the current scope to be output
1123 to stdout and the log file.
1124
1126 See 2005 P1364 LRM section C.11.
1127
1128------------------------------------------------------------------------------
1129
1131 $showvars - show information about variables
1132 $showvariables - alternative name for $showvars task
1133
1135 $showvars([optional list of variables]);
1136
1138 Display information about variables. If no argument is given, display
1139 information about all variables in current scope. If a list of vari‐
1140 ables is given display information about each variable. Hierarchical
1141 references are allowed. Cver's added interactive debugger supports
1142 additional commands for examining variable values and information. Use
1143 the :help data debugger command for more information.
1144
1146 See 2005 P1364 LRM section C.12.
1147
1149 See :print, :whatis, :expris, :varis added debugger commands.
1150
1151------------------------------------------------------------------------------
1152
1154 $snapshot - display active procedural thread tree and pending events
1155
1157 $snapshot;
1158
1160 Mechanism to print a snapshot of procedural location, pending events
1161 and thread execution status. If interactive debugger is disabled
1162 interrupt (^c) causes $snapshot to be called. Most information also
1163 generated by :where added debugger command. If you think some tasks or
1164 initial/always blocks should be active but they are not, or you think
1165 they should have completed but they have not, put $snapshot in your
1166 source or invoke from interactive mode to see the procedural active
1167 tree.
1168
1170 Not in P1364 LRM.
1171
1172------------------------------------------------------------------------------
1173
1175 $stop - enter interactive debugger
1176
1178 $stop;
1179 $stop([message level]);
1180
1182 Enter interactive debugger and if [message level] is 1 or 2, print a
1183 message. 1 prints simulation time and 2 prints +verbose simulation
1184 statistics. Interactive debugger can also be entered by pressing
1185 interrupt key (usually ^c) or from the -s option.
1186
1188 Defined in 2005 P1364 LRM section 17.4.
1189
1190------------------------------------------------------------------------------
1191
1193 $strobe, $strobeb, $strobeh, $strobeo - write formatted value to termi‐
1194 nal at end of time slot
1195
1197 $strobe([intermixed list of format strings and expressions]);
1198 $strobe[bho]([intermixed list of format strings and expressions]);
1199
1201 Same as $display but formats and writes value at the end of time time
1202 slot rather than when the $strobe statement is executed. Format is
1203 identical to $display and [bho] suffix letter changes default for
1204 expression that appears outside of any format as with $display. One
1205 format is written to stdout and log file for every $strobe executed
1206 during the time slot.
1207
1209 Defined in 2005 P1364 LRM section 17.1.2 and 17.2.2.
1210
1212 $fstrobe is same except writes to multi-channel file(s).
1213
1214------------------------------------------------------------------------------
1215
1217 $suppress_warns
1218 $allow_warns
1219
1221 $suppress_warns([comma separated list of warning or inform numbers]);
1222 $allow_warns([comma separated list of warning or inform numbers]);
1223
1225 It is possible to suppress writing of run time warning and inform mes‐
1226 sages by calling the $suppress_warns system task with a list of numbers
1227 that are printed when a warning or inform message is printed. Messages
1228 of class ERROR and FATAL ERROR can not be suppressed. The +sup‐
1229 press_warns+[list of + separated numbers] command line option also sup‐
1230 presses printing of messages and is the only way to suppers. transla‐
1231 tion time messages. $allow_warns re-enables printing of run time mes‐
1232 sages.
1233
1235 These system tasks are a Cver extension.
1236
1238 See +suppress_warns+[num]+[num]+... option.
1239
1240------------------------------------------------------------------------------
1241
1243 $system - execute operating system command from within Cver
1244
1246 $system([OS command line]);
1247
1249 Execute some operating system command string by means of a shell
1250 escape. $system; with no arguments or an empty argument runs an inter‐
1251 active shell if one is supported for the system you are running Cver
1252 on. The semantics of this task is slightly different on Unix based and
1253 non Unix systems. If you are running with multiple shell windows, it
1254 is better to execute commands in another window because a core dump
1255 will probably also cause Cver to core dump.
1256
1258 Not defined in P1364 LRM but commonly implemented.
1259
1260------------------------------------------------------------------------------
1261
1263 $test$plusargs - test Cver for existence of command argument
1264 $scan$plusargs - scan Cver command arguments to match prefix
1265
1267 function integer $test$plusargs([string]);
1268 function $scan$plusargs([plus option prefix as string], [string
1269 lvalue]);
1270
1272 $test$plusargs returns 1 if the argument appeared in the Cver command
1273 invocation argument list. The string expression argument must not
1274 include the leading + and must match an entire argument. Only Cver
1275 command arguments that begin with + are checked for a match.
1276
1277 The $scan$plusargs system function is equivalent to PLI tf_
1278 mc_scan_plusargs function. The first argument is plus option (without
1279 +) prefix as string expression. Second argument is lvalue expression
1280 that is assigned the remainder of the string to the right of the
1281 matched prefix. Returns 1 if match and assign tail, 0 if no match and
1282 no assign. In -f files, tokenization is by white space only so file=xx
1283 is legal, but depending on your shell the option may need to be quoted
1284 if given on the command line. Standard $test$plusargs supported and
1285 return 1 if entire string matches (no leading +) else 0.
1286
1288 Not defined in P1364 LRM. $test$plusargs is commonly implemented.
1289 $scan$plusargs allows use of PLI tf_ mc_scan_plusargs without linking
1290 in the PLI.
1291
1292------------------------------------------------------------------------------
1293
1295 $time - return time scaled to module as 64 bit time value
1296 $realtime - return time scaled scaled to module as real
1297 $stime - return time scaled to module as 32 bit value
1298 $tickstime - return time in internal simulation ticks as 64 bit value
1299 $stickstime - return time in internal simulation ticks as 32 bit value
1300
1302 function time $time;
1303 function real $realtime;
1304 function [31:0] $stime;
1305 function time $tickstime;
1306 function [31:0] $stickstime;
1307
1309 $time returns current time as 64 bit unsigned time value. It is scaled
1310 to time units of the module the $time task is invoked from. $realtime
1311 is the same as $time except the value returned is real and the $time‐
1312 format scale values are used to determine real value fraction accuracy.
1313 $stime is the same as $time except value is truncated to 32 bits.
1314 $tickstime returns current time in internal simulation ticks (smallest
1315 module time scale in design) in a 64 bit value. $stickstime is the
1316 same as $tickstime except it is truncated to fit in 32 bits. Simula‐
1317 tion ticks are the minimum time scale unit in any module and is the
1318 value used internally during simulation.
1319
1321 Defined in 2005 P1364 LRM section 17.7. $tickstime and $stickstime are
1322 Cver extensions.
1323
1324------------------------------------------------------------------------------
1325
1327 $printtimescale - display time unit and precision for a module
1328 $timeformat - specify format for the %t $display format specifier
1329
1331 $printtimescale([hierarchical_name]);
1332 $timeformat([units_number], [precision number], [suffix_string], [mini‐
1333 mum_field_width]);
1334
1336 The $printtimescale system task displays time unit and precision for a
1337 particular module. If the argument is omitted, the information for the
1338 current module is printed.
1339
1340 The $timeformat system task sets the format for the %t format speci‐
1341 fier.
1342
1344 See 2005 P1364 LRM section 17.3 and the `timescale directive discussion
1345 section 19.8.
1346
1347------------------------------------------------------------------------------
1348
1350 Verilog is a Trademark of Cadence Design Systems Licensed to Open Ver‐
1351 ilog International.
1352 Cver, CVC and Vcmp are Trademarks of Pragmatic C Software Corporation.
1353
1354 Copyright (c) 1991-2007 Pragmatic C Software. All Rights Reserved.
1355 This document contains confidential and proprietary information
1356 belonging to Pragmatic C Software Corp.
1357
1358
1359
1360Pragmatic C Software Release 3.0 Systasks(1)