Product Documentation
Cadence Verilog-AMS Language Reference
Product Version 22.09, April 2022

7


Built-In Mathematical Functions

This chapter describes the mathematical functions provided by the Cadence® Verilog®-AMS language. These functions include

Because the simulator uses differentiation to evaluate expressions, Cadence recommends that you use only mathematical expressions that are continuously differentiable. To prevent run-time domain errors, make sure that each argument is within a function’s domain.

Standard Mathematical Functions

These are the standard mathematical functions supported by Verilog-AMS. The operands must be integers or real numbers.

Function Description Domain Returned Value

abs(x)

Absolute

All x

Integer, if x is integer; otherwise, real

ceil(x)

Smallest integer larger than or equal to x

All x

Integer

exp(x)

Exponential. See also “Limited Exponential Function”.

Real

floor(x)

Largest integer less than or equal to x

All x

Integer

ln(x)

Natural logarithm

x > 0

Real

log(x)

Decimal logarithm

x > 0

Real

max(x,y)

Maximum

All x, all y

Integer, if x and y are integers; otherwise, real

min(x,y)

Minimum

All x, all y

Integer, if x and y are integers; otherwise, real

pow(x,y)

Power of (xy)

All y, if x > 0
y > 0, if x = 0
y integer, if x < 0

Real

sqrt(x)

Square root

x >= 0

Real

Trigonometric and Hyperbolic Functions

These are the trigonometric and hyperbolic functions supported by Verilog-AMS. The operands must be integers or real numbers. The simulator converts operands to real numbers if necessary.

The trigonometric and hyperbolic functions require operands specified in radians.

Function Description Domain

sin(x)

Sine

All x

cos(x)

Cosine

All x

tan(x)

Tangent

, n is odd

asin(x)

Arc-sine

-1 <= x <= 1

acos(x)

Arc-cosine

-1 <= x <= 1

atan(x)

Arc-tangent

All x

atan2(x,y)

Arc-tangent of x/y

All x, all y

hypot(x,y)

Sqrt(x2 + y2)

All x, all y

sinh(x)

Hyperbolic sine

All x

cosh(x)

Hyperbolic cosine

All x

tanh(x)

Hyperbolic tangent

All x

asinh(x)

Arc-hyperbolic sine

All x

acosh(x)

Arc-hyperbolic cosine

x >= 1

atanh(x)

Arc-hyperbolic tangent

-1 <= x <= 1

Controlling How Math Domain Errors Are Handled

To control how math domain errors are handled in Verilog-A modules, you can use the options ahdldomainerror parameter in a Spectre control file. (In Verilog-AMS code, this parameter can be used only in the analog block.) This parameter controls how domain (out-of-range) errors in Verilog-A math functions such as log or atan are handled and determines what kind of message is issued when a domain error is found.

The ahdldomainerror parameter format is

Name options ahdldomainerror=value

where the syntax items are defined as follows.

Name

The unique name you give to the options statement. The Spectre simulator uses this name to identify this statement in error or annotation messages

value

none

If a domain error occurs, no message is issued. The simulation continues with the argument of the math function set to the nearest reasonable number to the invalid argument.

For example, if the `sqrt() function is passed a negative value, the argument is reset to 0.0.

warning

If a domain error occurs, a warning message is issued. The simulation continues with the argument of the math function set to the nearest reasonable number to the invalid argument. This is the default.

For example, if the `sqrt() function is passed a negative value, the argument is reset to 0.0.

error

If a domain error occurs, a message such as the following (which, in this example, indicates a problem with the `sqrt function) is issued.

Fatal error found by spectre during IC analysis, during transient analysis `mytran'.
"acosh.va" 20: r1: negative argument passed to `sqrt()'. (value passed was -1.000000)

The simulation then terminates.

For example, you might have the following in a Spectre control file to ensure that simulation stops when a domain error occurs.

myoption options ahdldomainerror=error

Return to top
 ⠀
X