Task Statements

You can call a task simply by giving its name and its parameter list. For example:

$bound_step(100n);

You cannot call a user-defined task from an analog process, but there are system-defined tasks available, such as $bound_step(), $discontinuity, and $strobe.

System Tasks

System tasks are predefined and provided by the simulator.

$display, $strobe

The $display() and $strobe() tasks takes a list of arguments and converts them into text that is written to the standard output. The first argument must be a string, and that string may include special character patterns that incorporate and format any remaining arguments. Those characters are given below. Once the arguments associated with the first string are exhausted, if there are any arguments remaining, the first must be a string, in which case the process repeats. Once the arguments have been printed, a newline is added. If there are no arguments, only the newline is printed.

Argument formatting codes for the display tasks.

Code

Args

Result

%b , %B

1

Interpolate integer argument with binary format.

%c , %C

1

Interpolate integer argument with ASCII character format.

%d , %D

1

Interpolate integer argument with decimal format.

%e , %E

1

Interpolate real argument with exponential format.

%f , %F

1

Interpolate real argument with decimal format.

%g , %G

1

Interpolate real argument with exponential or decimal format.

%h , %H

1

Interpolate integer argument with hexadecimal format.

%m , %M

0

Display hierarchical instance name.

%o , %O

1

Interpolate integer argument with octal format.

%r , %R

1

Interpolate real argument and display using SI scale factors.

%s , %S

1

Interpolate argument as a string.

%%

0

Display ‘%’ .

Example:

$strobe("Average period = %rs measured from %d periods.", period, total);

The format codes generally support C language style format specifications. Optional integers can be inserted into the format code to specify the field width, the precision, or both. For example, the format specification ‘%10.3g’ indicates the number should be formatted with a minimum field width of 10 and with 3 digits in the mantissa.

Note

The Cadence AMS simulator only supports %r and %R codes from within analog processes.

Display and strobe statements behave identically and are interchangeable in analog processes.

$finish, $stop

The $finish function terminates the simulation session:

$finish;

The $stop function is similar to $finish, except that it causes the simulation to be suspended rather than terminated. The difference being that the user may resume simulation after it has been suspended, but cannot do so after it has been terminated:

$stop;

$bound_step

The $bound_step function places a bound on the size of the next time step used by the continuous kernel. It does not specify what the next time step is, but rather how large it can be. The maximum allowed time step is specified as the argument. There is no return value.

For example:

$bound_step(100n)

indicates that the next time step should be 100ns or smaller.

$bound_step is intended to allow the user to specify Nyquist related time step criteria to the simulator. For example, if a module is producing a high frequency sinusoidal output without a corresponding input, as would occur is it were a sinusoidal source or a voltage-controlled oscillator, $bound_step would be used to indicate the simulator should not take a time step larger than one half period:

analog begin
   V(out) <+ transition(ampl, 0, 100n)*cos(`M_TWO_PI*freq);
   if (ampl)
      $bound_step(0.1/freq);
end

In any simulation, there can be any number of bound_step tasks active from any number of modules or perhaps from the same module. The smallest active bound is the one bounds the time step.

The bound it not remembered over time. It must be constantly applied for it to remain active.

In general, use of $bound_step to control simulation accuracy should be avoided. It should really only be used to specify Nyquist criteria.

$discontinuity

The $discontinuity function is used to notify the continuous-time kernel of discontinuous changes in the behavior of an analog component. This information helps the kernel maintain accurate results in exceptional situations.

It takes one optional argument, which is a non-negative integer that indicates the lowest order derivative that is discontinuous. An argument of i implies a discontinuity in the i th derivative of the constitutive equation with respect to either a signal value or time. Hence, $discontinuity(0) indicates a discontinuity in the model, $discontinuity(1) indicates a discontinuity in the model’s derivatives, etc.

For example, this is the analog process that might be used to describe an ideal switch:

analog begin
   @(cross(V(sense))
      $discontinuity(0);
   if (V(sense) > 0)
      V(p,n) <+ 0;
   else
      I(p,n) <+ 0;
end

Discontinuous behavior can cause convergence problems for the simulator and should be avoided whenever possible. To this end, the filter functions (transition, slew, etc.) can be used to smooth behavior that is discontinuous with respect to time.

Discontinuities caused by built-in functions, such as transition, need not be announced.