Expressions

Indexing

Reference

coefs[3]
coefs[3:0]
coefs[{5,3,1}]

Signals

Reference

V(out)
I(in,gnd)
V(in[1])

Operators

Arithmetic Operators

Reference

Symbol

Usage

Description

+

a + b

Sum a and b

-

a - b

Subtract b from a

-

-a

Negate a

*

a * b

Multiply a and b

/

a / b

Divide a by b

%

a % b

Modulus (remainder) of a/b

**

a ** b

a raised to the power of b

Bitwise Operators

Reference

Symbol

Usage

Description

~

~a

Invert each bit of a

&

a&b

Logical ‘and’ of each bit of a and b

~&

a~&b

Logical ‘nand’ of each bit of a and b

|

a|b

Logical ‘or’ of each bit of a and b

~|

a~|b

Logical ‘nor’ of each bit of a and b

^

a^b

Logical ‘xor’ of each bit of a and b

~^

a~^b

Logical ‘xnor’ of each bit of a and b

^~

a^~b

Same as ~^

Reduction Operators

Reference

Symbol

Usage

Description

&

&a

Logical ‘and’ all bits in a to form 1 bit result

~&

~&a

Logical ‘nand’ all bits in a to form 1 bit result

|

|a

Logical ‘or’ all bits in a to form 1 bit result

~|

~|a

Logical ‘nor’ all bits in a to form 1 bit result

^

^a

Logical ‘xor’ all bits in a to form 1 bit result

~^

~^a

Logical ‘xnor’ all bits in a to form 1 bit result

^~

^~a

Same as ~^

Logical Operators

Reference

Symbol

Usage

Description

!

!a

Is a false?

&&

a&&b

Are both a and b true?

||

a||b

Are either a or b true?

Equality Operators

Reference

Symbol

Usage

Description

==

a==b

Is a equal to b?

!=

a!=b

Is a not equal to b?

Identity Operators

Reference

Symbol

Usage

Description

===

a===b

Is a identical to b?

!==

a!==b

Is a not identical to b?

Relational Operators

Reference

Symbol

Usage

Description

<

a<b

Is a less than b?

>

a>b

Is a greater than b?

<=

a<=b

Is a less than or equal to b?

>=

a>=b

Is a greater than or equal to b?

Shift Operators

Reference

Symbol

Usage

Description

<<

a<<b

Shift a left b bits, vacated bits are filled with 0

>>

a>>b

Shift a right b bits, vacated bits are filled with 0

<<<

a<<<b

Shift a left b bits, vacated bits are filled with 0

>>>

a>>>b

Shift a right b bits, vacated bits are filled with 0 if a is unsigned and by the sign bit of a otherwise

Miscellaneous Operators

Reference

Symbol

Usage

Description

? :

a ? b : c

Evaluated to b if a is true and c otherwise

{}

{a,b}

Concatenates sized bit vectors a and b

{{}}

{a{b}}

Replicate b, a times

Size of Integer Results

Reference

Form

Operators

Size

i op j

+, -, *, /, %, &, |, ^, ^~

max(L(i), L(j))

op i

+, -, ~

L(i)

i op j

==, !=, ===, !==, &&, ||, >, >=, <, <=

1

op i

&, ~&, |, ~|, ^, ~^

1

i op j

>>, <<

L(i)

i ? j : k

max(L(j), L(k)

{i, …, j}

L(i) + … + L(j)

{i {j, …, k}}

i * (L(j) + … + L(k))

Math Functions

Reference

Verilog-A and Verilog-AMS support the following functions.

Function

Description

ln(x)

Natural logarithm (base e)

log(x)

Common logarithm (base 10)

exp(x)

Exponential

sqrt(x)

Square root: √x

min(x,y)

Minimum

max(x,y)

Maximum

abs(x)

Absolute value

floor(x)

Floor (largest integer less than or equal to x)

ceil(x)

Ceiling (smallest integer greater than or equal to x)

pow(x,y)

Power: xy (y must be integer if x < 0)

sin(x)

Sine (argument is in radians)

cos(x)

Cosine (argument is in radians)

tan(x)

Tangent (argument is in radians)

asin(x)

Arc sine (result is in radians)

acos(x)

Arc cosine (result is in radians)

atan(x)

Arc tangent (result is in radians)

atan2(y,x)

Angle from the origin to the point x, y

hypot(x,y)

Distance from the origin to the point x, y; hypot(x,y) = √(x2 + y2)

sinh(x)

Hyperbolic sine (argument is in radians)

cosh(x)

Hyperbolic cosine (argument is in radians)

tanh(x)

Hyperbolic tangent (argument is in radians)

asinh(x)

Hyperbolic arc sine (result is in radians)

acosh(x)

Hyperbolic arc cosine (result is in radians)

atanh(x)

Hyperbolic arc tangent (result is in radians)

$abstime

The current time in seconds

$realtime

The current time in the current Verilog time units.

$temperature

The ambient temperature

$vt

The thermal voltage (VT = kT/q) at the ambient temperature

$vt(T)

The thermal voltage (VT = kT/q) at the given temperature

Verilog, SystemVerilog, and Verilog-AMS all support the following functions.

Function

Description

$clog2(x)

Ceiling of the base-2 logarithm

$ln(x)

Natural logarithm (base e)

$log10(x)

Common logarithm (base 10)

$exp(x)

Exponential

$sqrt(x)

Square root: √x

$floor(x)

Floor (largest integer less than or equal to x)

$ceil(x)

Ceiling (smallest integer greater than or equal to x)

$pow(x,y)

Power: xy (y must be integer if x < 0)

$sin(x)

Sine (argument is in radians)

$cos(x)

Cosine (argument is in radians)

$tan(x)

Tangent (argument is in radians)

$asin(x)

Arc sine (result is in radians)

$acos(x)

Arc cosine (result is in radians)

$atan(x)

Arc tangent (result is in radians)

$atan2(y,x)

Angle from the origin to the point x, y

$hypot(x,y)

Distance from the origin to the point x, y;

$hypot(x,y)

√(x2 + y2)

$sinh(x)

Hyperbolic sine (argument is in radians)

$cosh(x)

Hyperbolic cosine (argument is in radians)

$tanh(x)

Hyperbolic tangent (argument is in radians)

$asinh(x)

Hyperbolic arc sine (result is in radians)

$acosh(x)

Hyperbolic arc cosine (result is in radians)

$atanh(x)

Hyperbolic arc tangent (result is in radians)

Random Functions

Reference

Function

Description

$random(seed)

Uniformly distributed random 32-bit integer

$dist_uniform(seed, lb, ub)

Uniformly distributed random integer

$rdist_uniform(seed, lb, ub)

Uniformly distributed random real value

$dist_normal(seed, mean, sd)

Normally distributed random integer

$rdist_normal(seed, mean, sd)

Normally distributed random real value

$dist_exponential(seed, mean)

Exponentially distributed random integer

$rdist_exponential(seed, mean)

Exponentially distributed random real value

$dist_poisson(seed, mean)

Poisson distributed random integer

$rdist_poisson(seed, mean)

Poisson distributed random real value

$dist_chi_square(seed, dof)

Chi square distributed random integer

$rdist_chi_square(seed, dof)

Chi square distributed random real value

$dist_t(seed, dof)

Student T distributed random integer

$rdist_t(seed, dof)

Student T distributed random real value

$dist_erlang(seed, k, mean)

Erlang distributed random integer

$rdist_erlang(seed, k, mean)

Erlang distributed random real value

Analog Operators

Reference

Operator

Description

ddt(operand, [abstol|nature])

Time derivative

idt(operand, [ic], [assert], [abstol|nature])

Time integral

idtmod(operand, [ic], [modulus], [offset], [abstol|nature])

Circular integrator

transition(operand, delay, trise, [tfall])

Transition

slew(operand, [rising_sr], [falling_sr])

Slew

absdelay(operand, delay, [max_delay])

Delay

laplace_zp(operand, [zeta], [rho], [epsilon])

Laplace, zero-pole form

laplace_nd(operand, [n], [d], [epsilon])

Laplace, numerator-denominator form

laplace_zd(operand, [zeta], [d], [epsilon])

Laplace, zero-denominator form

laplace_np(operand, [n], [rho], [epsilon])

Laplace, numerator-pole form

zi_zp(operand, [zeta], [rho], T, tau, t0)

Z transform, zero-pole form

zi_nd(operand, [n], [d], T, tau, t0)

Z transform, numerator-denominator form

zi_zd(operand, [zeta], [d], T, tau, t0)

Z transform, zero-denominator form

zi_np(operand, [n], [rho], T, tau, t0)

Z transform, numerator-pole form

last_crossing(operand, [direction])

Last crossing

limexp(operand)

Limited exponential

Small-Signal Stimulus Functions

Reference

Function

Description

ac_stim([name], [mag], [phase]))

AC stimulus

white_noise(pwr, [name])

White noise

flicker_noise(pwr, [exp], [name])

Flicker noise

noise_table(pwr, [name])

Noise table

File Operations

Reference

Function

Description

fopen(filename, mode))

File open

fclose(file)

File close