_TOP_MENU

May 10, 2014

Verilog - System Task


$bitstoreal 
Convert bits into real number.
Syntax
wire [64:1]  abc;
real  num = $bitstoreal(abc);

$countdrivers
The $countdrivers system function is provided to count the number of drivers on a specified net so that bus contention can be identified.

Syntax -
$countdrivers(net, net_is_forced, number_of_01x_drivers, number_of_0_drivers, number_of_1_drivers, number_of_x_drivers);

This system function returns a 0 if there is no more than one driver on the net and returns a 1 otherwise (indicating contention).

net_is_forced returns a "1" if the net is forced and a "0" if the net is not forced
number_of_01x_drivers returns an integer representing the number of drivers that are in a 0, 1, or x state; this represents the total number of drivers on the net that are not forced
number_of_0_drivers returns an integer representing the number of drivers on the net that are in the "0" state
number_of_1_drivers returns an integer representing the number of drivers on the net that are in the "1" state
number_of_x_drivers returns an integer representing the number of drivers on the net that are in the "x" state

$display or $write
These are the main system task routines for displaying information.
Syntax -
$display (Q1,Q2,Q3....Qn );


The contents of string parameters are output literally except when certain escape sequences are inserted to display special characters or specify the display format for a subsequent expression.
It could be inserted in 3 different ways -
1. The special character \ indicates that the character to follow is a literal or non-printable character.
2. The special character % indicates that the next character should be interpreted as a format specification
3. The special character string %% indicates the display of the percent sign character %

\n is the newline character
\t is the tab character
\\ is the \ character
\" is the " character
\o is a character specified in octal digits
%% is the percent character

%h or %H display in hexadecimal format
%d or %D display in decimal format
%o or %O display in octal format
%b or %B display in binary format
%c or %C display in ASCII character format
%v or %V display net signal strength
%m or %M display hierarchical name
%s or %S display as a string
%t or %T display in current time format

%e or %E display `real' in an exponential format
%f or %F display `real' in a decimal format
%g or %G display `real' in exponential or decimal format, whichever format results in the shorter printed output

$strobe
Syntax -
Same as $display.  escape charc and all are same as used in $display.

The difference between $display and $strobe is , $strobe executed at the end of current simulation cycles , which means after all events executed then actual value will be displayed by $strobe.

$monitor
Syntax  - same as $display

The $monitor task provides the ability to monitor and display the values of any variables or expressions specified as parameters to the task.
When you invoke a $monitor task with one or more parameters, the simulator sets up a mechanism whereby each time a variable or an expression in the parameter list changes value–with the exception of the $time, $stime or $realtime system functions–the entire parameter list is displayed at the end of the time step as if reported by the $display task. If two or more parameters change value at the same time, however, only one display is produced that shows the new values.

Note that only one $monitor display list can be active at any one time; however, you can issue a new $monitor task with a new display list any number of times during simulation.

$monitoroff
$monitoron
The $monitoron and $monitoroff tasks control a monitor flag that enables and disables the monitoring, so that you can easily control when monitoring should occur. Use $monitoroff to turn off the flag and disable monitoring. Use $monitoron to turn on the flag so that monitoring is enabled and the most recent call to $monitor can resume its display. A call to $monitoron always produces a display immediately after it is invoked, regardless of whether a value change has taken place; this is used to establish the initial values at the beginning of a monitoring session. By default, the monitor flag is turned on at the beginning of simulation.


$fopen , $fclose , $fwrite, $fdisplay, $fmonitor, $fstrobe 
Each of the four formatted display tasks—$display, $write, $monitor, and $strobe—has a counterpart that writes to specific files as opposed to the log file and standard output. These counterpart tasks—$fdisplay, $fwrite, $fmonitor, and $fstrobe—accept the same type of parameters as the tasks they are based upon, with one exception: The first parameter must be a multichannel descriptor that indicates where to direct the file output.

integer filepp = $fopen("<file_for_writing>");
$fwrite(filepp, " same as $write" );
$fdisplay(filepp, "same as $display");
$fmonitor(filepp, "same as $monitor");
$fstrobe(filepp, "same as strobe" );
$fclose(filepp);



$finish
Syntax:
$finish;
$finish (n);
The $finish system task simply makes the simulator exit and pass control back to the host operating system. If a parameter expression is supplied to this task, then its value determines the diagnostic messages that are printed before the prompt is issued. If no parameter is supplied, then a value of 1 is taken as the default.

0 prints nothing
1 prints simulation time and location
2 prints simulation time, location, and statistics about the memory and CPU time used in simulation

$getpattern


$history
The $history system task prints out a list of all interactive commands that have been entered to a tool.


$input
Syntax - $input("<filename>");
The $input system task allows command input text to come from a named file instead of from the terminal. At the end of the command file the input is automatically switched back to the terminal.

$itor
converts integers to real values (for example, 123 becomes 123.0)

$rtoi
converts real values to integers by truncating the real value (for example, 123.45 becomes 123)

$key
$nokey
$key(“<filename>”);$key;$nokey;
A key file is created by a tool whenever interactive mode is entered for the first time. The key file contains all of the text that has been typed in from the standard input. The file also contains information about asynchronous interrupts.

The $nokey and $key system tasks are used to disable and re-enable output to the key file. An optional file name parameter for $key causes the old key file to be closed, a new file to be created, and output to be directed to the new file.

$list
Syntax -
$list;$list (<name>);

When invoked without a parameter, $list produces a listing of the module, task, function, or named block that is defined as the current scope setting. If an optional parameter is supplied, it must refer to a specific module, task, function or named block, in which case the specified object will be listed.

$log
$nolog
Syntax -
$log(“<filename>”);$log;$nolog;
Tools may create a log file that contains a copy of all the text that is printed to the standard output. The log file may also contain, at the beginning of the file, the host command that was used to run the tool.

The $nolog and $log system tasks are used to disable and re-enable output to the log file. The $nolog task disables output to the log file, while the $log task re-enables the output. An optional file name parameter for $log causes the old file to be closed, a new log file to be created, and output to be directed to the new log file.

$printtimescale
Syntax:

$printtimescale <hierarchical_name>;
When no argument is specified, $printtimescale displays the time unit and precision of the module that is the current scope (as set by $scope).

When an argument is specified, $printtimescale displays the time unit and precision of the module passed to it.

$readmemb
$readmemh
$readmemb("<filename>", <memname>);
$readmemb("<filename>", <memname>, <start_addr>);
$readmemb("<filename>", <memname>, <start_addr>, <finish_addr>);

$readmemh("<filename>", <memname>);$readmemh("<filename>", <memname>, <start_addr>);

$realtime , $time 
The $realtime system function returns a real number time that, like $time, is scaled to the time unit of the module that invoked it.
The $time and $realtime system functions return the current simulation time. The function $time returns a 64 bit value, scaled to the time unit of the module that invoked it. If the time value is a fraction of an integer, $time returns zero. The function $realtime returns a real number that is scaled to the time unit of the module that invoked it.

For example:
`timescale 10 ns / 1 ns
module test;
reg set;
parameter p = 1.55;
initial
begin
$monitor($realtime,,"set=",set);
#p set = 0;
#p set = 1;
end
endmodule
// The output from this example is as follows:
// 0 set=x
// 1.6 set=0

// 3.2 set=1


$realtobits
converts real values to integers by truncating the real value (for example, 123.45 becomes 123)

$reset
$reset_count
$reset_value
The $reset system task enables a tool to be reset to its “Time 0” state so that processing (e.g., simulation) can begin again.
The $reset_count system function keeps track of the number of times the tool is reset. The $reset_value system function returns the value specified by the reset_value parameter argument to the $reset system task. The $reset_value system function is used to communicate information from before a reset of a tool to the time 0 state to after the reset.
The following are some of the simulation methods that you can employ with this system task and these system functions:
• determine the force statements your design needs to operate correctly, reset the simulation time to 0, enter these force statements, and start to simulate again
• reset the simulation time to 0 and apply new stimuli
Verilog HDL LRM 260 • List of System Task and System Function Keywords
• determine that debug system tasks, such as $monitor and $strobe, are keeping track of the correct nets or registers, reset the simulation time to 0, and begin simulation again
The $reset system task tells a tool (for example a simulator) to return the processing of your design to its logical state at time 0. When a tool executes the $reset system task, it takes the following actions to stop the process (e.g., simulation):
• disables all concurrent activity, initiated in either initial and always procedural blocks in the source description or through interactive mode (disables, for example, all force and assign statements, the current $monitor system task, and any other active task)
• cancels all scheduled simulation events
After a simulation tool executes the $reset system task, the simulation is in the following state:
• The simulation time is 0.
• All registers and nets contain their initial values.
• The tool begins to execute the first procedural statements in all initial and always blocks.
Syntax:
$reset;
$reset(<stop_value>);
$reset(<stop_value>,<reset_value>);

$reset(<stop_value>,<reset_value>,<diagnostics_value>);

$restart
$save
$incsave
Three system tasks, $save, $restart, and $incsave, work in conjunction with one another to save the complete state of a tool into a permanent file such that the tool state can be reloaded at a later time and the tool can continue processing where it left off.
Syntax:
$save("<name_of_file>");
$restart("<name_of_file>");

$incsave("<incremental_filename>");

$scale
$scale(<hierarchical_name>);

The $scale function allows the user to take a time value from a module with one time unit to be used in a module with a different time unit. The time value is converted from the time unit of one module to the time unit of the module that invokes $scale.

$scope
$scope("<name>");

The $scope system task allows a particular level of hierarchy to be specified as the interactive scope for identifying objects. This task accepts a single parameter argument that must be the complete hierarchical name of a module, task, function, or named block. The initial setting of the interactive scope is the first top-level module.

$showscopes
$showscopes;$showscopes(n);

The $showscopes system task produces a complete list of modules, tasks, functions, and named blocks that are defined at the current scope level. An optional integer parameter can be given to $showscopes. A nonzero parameter causes all the modules, tasks, functions and named blocks in or below the current hierarchical scope to be listed. No parameter or a zero results in only objects at the current scope level to be listed.

$showvariables
$showvars
$showvars;$showvars(<list_of_variables>);
The $showvars system task produces status information for register and net variables, both scalar and vector. When invoked without parameters, $showvars displays the status of all variables in the current scope. When invoked with a <list_of_variables>, $showvars shows only the status of the specified variables. If the <list_of_variables> includes a bit-select or part-select of a register or net then the status information for all the bits of that register or net are displayed.

The system task $showvariables displays information similar to that of $showvars, but allows more control over the information displayed.

$stop
$stop;
$stop(n);
The $stop system task puts the tool (for example a simulator) into halt mode, issues an interactive command prompt, and passes control to the user. This task takes an optional expression parameter (0, 1, or 2) that determines what type of diagnostic message is printed. The amount of diagnostic messages output increases with the value of the optional parameter passed to $stop.

$timeformat
The $timeformat system task performs the following two functions:
1. It specifies how the %t format specification reports time information for the $write, $display, $strobe, $monitor, $fwrite, $fdisplay, $fstrobe, and $fmonitor system tasks.
2. It specifies the time unit for delays entered interactively.
Syntax:
$timeformat (<units_number>, <precision_number>, <suffix_string>, <minimum_field_width>);

NEXT

You may like to visit below pages -
Source - Verilog LRM 2005 Edition

1 comment: