Verilog-A Usage and Language Summary (veriloga)
Description
Verilog-A is an analog hardware description language standard from Open Verilog International. It enables analog circuit behavior to be described at a high level of abstraction. Behavioral descriptions of modules and components may be instantiated in a Spectre netlist along with regular Spectre primitives.
Verilog-A descriptions are written in files different from the Spectre netlist file. These descriptions are written in modules (see the module alpha below). To include a module in the Spectre netlist, first add the line ahdl_include "VerilogAfile.va to the Spectre netlist file (where, VerilogAfile.va is the name of the file in which the required module is defined). The module is instantiated in the Spectre netlist in the same manner as Spectre primitives, for example:
name (node1 node2) alpha arg1=4.0 arg2=2
This instantiates an element alpha, which has two nodes and two parameters.
AHDL Linter can be used to improve Verilog-A model quality. It can help to avoid potential convergence or performance problems, and to improve model accuracy, reusability and portability. Refer to the Verilog-A Language Reference manual for more information.
Verilog-A simulation performance has been improved by compiling the Verilog-A modules. This is explained in more detail in the Verilog-A compilation section below.
Module Template
The following is a Verilog-A module template
include "discipline.h"
include "constants.h"
module alpha( n1, n2 );
electrical n1, n2;
parameter real arg1 = 2.0;
parameter integer arg2 = 0;
real local;
// this is a comment
analog begin
@ ( initial_step ) begin
// performed at the first timestep of an analysis
end
// module behavioral description
V(n1, n2) <+ I(n1, n2) * arg1;
@ ( final_step ) begin
// performed at the last time step of an analysis
end
end
endmodule
Verilog-A Compilation
The first time a verilogA file is used in simulation, Spectre performs a one-time compilation step. Following the initial compilation, recompilation is performed only if the Verilog-A source is changed.
The compiled C code flow stores the compiled shared objects in a database on the disk for the simulation to use. The shared objects are stored in a directory named ahdlSimDB. By default, this database is created in the current working directory and given a name created by appending .ahdlSimDB to the circuit name. You can specify an alternative location for ahdlSimDB by setting the CDS_AHDLCMI_SIMDB_DIR environment variable to the path of a directory, as follows:
setenv CDS_AHDLCMI_SIMDB_DIR /projects/ahdlcmiSimDirs
If the path is writable, adhlSimDB is created there. If the path is not writable or does not exist, an error is reported.
To store compiled objects, use a second type of database, named ahdlShipDBs. To create such databases, set the CDS_AHDLCMI_SHIPDB_COPY to YES, as follows:
setenv CDS_AHDLCMI_SHIPDB_COPY YES
In this case, an ahdlShipDB is created for each Verilog-A file in the directory that contains the Verilog-A files, if the directory is writable. If the directory is not writable, no ahdlShipDBs are created for the modules in the Verilog-A file that is being processed.
If the CDS_AHDLCMI_SHIPDB_DIR environment variable (or the equivalent, but obsolete, CDS_AHDLCMI_DIR variable) is also set to a writable path, the ahdlShipDB database is created there and shared by all the Verilog-A files used for simulations that are run while this environmental variable is set. If the CDS_AHDLCMI_SHIPDB_DIR is not set to a writable path or the path does not exist, a warning is reported and ahdlShipDBs are not created.
The reuse of Verilog-A compiled library can also be achieved by command-line options, refer to the usage of the Spectre command-line options: -ahdlshipdbdir and -ahdlshipdbmode.
Language Summary
The following provides a summary of the Verilog-A analog hardware description language. For more information refer to Verilog-A Reference Manual.
Analog Operators/Waveform Filters
|
ddt(x <,abstol> )
|
Differentiate x with respect to time.
|
|
idt(x, ic <, assert <, abstol> > )
|
|
|
Integrate x with respect to time. Output = ic during dc analysis and when assert is 1.
|
|
idtmod(x <, <ic <, modulus <, offset <, abstol> > > > )
|
|
|
Circular Integration of x with respect to time. Output = ic during DC analysis. Integration is performed with given offset and modulus, if specified.
|
|
transition(x <, delay <, trise <, tfall <, timetol> > > >)
|
|
|
Specify details of signal transitions. For efficient simulation, it is recommended that x not be a continuous signal, that is, a function of a probe. See the Verilog-A manual for further explanation of this issue.
|
|
slew(x <, SRpos <, SRneg>>)
|
|
|
Model slew rate behavior.
|
|
delay(x, time_delay, max_delay)
|
|
|
Response(t) = x(t - time_delay).
|
|
zi_nd(x, numer, denom, period, < ttransition <,sample offset time > )
|
|
|
z-domain filter function, numerator-denominator form.
|
|
zi_zd(x, zeros, denom, period, < ttransition <,sample offset time > )
|
|
|
z-domain filter function, zero-denominator form.
|
|
zi_np(x, numer, poles, period, < ttransition <,sample offset time > )
|
|
|
z-domain filter function, numerator-pole form.
|
|
zi_zp(x, zeros, poles, period, < ttransition <,sample offset time > )
|
|
|
z-domain filter function, zero-pole form.
|
|
laplace_nd(x, numer, denom, <, abstol > )
|
|
|
s-domain filter function, numerator-denominator form.
|
|
laplace_zd(x, zeros, denom, <, abstol > )
|
|
|
s-domain filter function, zero-denominator form.
|
|
laplace_np(x, numer, poles, <, abstol > )
|
|
|
s-domain filter function, numerator-pole form.
|
|
laplace_zp(x, zeros, poles, <, abstol > )
|
|
|
s-domain filter function, zero-pole form.
|
Built-In Mathematical Functions
|
abs(x)
|
Absolute value
|
|
exp(x)
|
Exponential if x < 80
|
|
ln(x)
|
Natural logarithm
|
|
log(x)
|
Log base 10
|
|
sqrt(x)
|
Square root
|
|
min(x,y)
|
Minimum
|
|
max(x,y)
|
Maximum
|
|
pow(x,y)
|
x to the power of y
|
Noise Functions
|
white_noise( power <, tag > )
|
|
|
Generates white noise with given power. Noise contributions with the same tag are combined for a module.
|
|
flicker_noise( power, exp <, tag > )
|
|
|
Generates pink noise with given power at 1 Hz that varies in proportion to 1/f^exp. Noise contributions with the same tag are combined for a module.
|
|
noise_table( vector <, tag > )
|
|
|
Generates noise where power is determined by linear interpolation from the given vector of frequency-power pairs. Noise contributions with the same tag are combined for a module.
|
AC Analysis Stimuli
|
ac_stim( <analysis_name <, mag <, phase > > > )
|
|
|
Small signal source of specified magnitude and phase in radians, active for given analysis.
|
Analog Events
Analog events must be contained in an analog event detection statement; @(analog_event) statement.
|
cross(x, direction <, timetol <, abstol <, enable >>>)
|
|
|
Generates an event when x crosses zero.
|
|
above(x <, timetol <, abstol <, enable >>>)
|
|
|
Generates an event when x becomes greater than or equal to zero. An above event can be generated and detected during initialization. By contrast, a cross event can be generated and detected only after at least one transient time step is complete.
|
|
timer(start_time <, period <, timetol <, enable >>> )
|
|
|
Set (optionally periodic) breakpoint event at time = start_time.
|
|
initial_step< ( arg1 <, arg2 <, etc... > > )
|
|
|
Generate an event at the initial step of an analysis. arg1, arg2, and so on. Examples of analyses strings are "dc", "tran", "ac", "pss", "noise", "pdisto", "qpss", "pac", "pnoise", "pxf", "sp", "tdr", "xf", "envlp", "psp", "qpsp", "qpac", "qpnoise", "qpxf", "static", "ic", and so on.
|
|
final_step< ( arg1 <, arg2 <, etc... > > )
|
|
|
Generate an event at the final step of an analysis. arg1, arg2, and so on. Examples of analyses strings are "dc", "tran", "ac", "pss", "noise", "pdisto", "qpss", "pac", "pnoise", "pxf", "sp", "tdr", "xf", "envlp", "psp", "qpsp", "qpac", "qpnoise", "qpxf", "static", "ic", and so on.
|
Timestep Control
|
bound_step(max_step)
|
Limit timestep, (timestep <= max_step).
|
|
last_crossing(x, direction)
|
Return time when expression last crossed zero in a given direction.
|
|
discontinuity(n)
|
Hint to simulator that discontinuity is present in nth derivative.
|
Simulator IO Functions
|
$display(argument_list)
|
Print data to stdout. Formatting strings may be interspersed between arguments/data.
|
|
$fdisplay(fptr, argument_list)
|
Print data to a file. Formatting strings may be interspersed between arguments/data.
|
|
$strobe(argument_list)
|
Print data to stdout. Formatting strings may be interspersed between arguments/data.
|
|
$fstrobe(fptr, argument_list)
|
Print data to a file. Formatting strings may be interspersed between arguments/data.
|
|
$fscanf(fptr, "format string" <, arguments>)
|
|
|
Read data from a file
|
|
$fopen("filename", mode)
|
Open a file for reading/writing
|
|
$fclose(fptr)
|
Close a file
|
|
$finish<(n)>
|
Finish the simulation
|
|
$stop<(n)>
|
Stop the simulation
|
Simulator Environment Functions
|
$realtime
|
Returns current simulation time
|
|
$temperature
|
Returns ambient simulation temperature (K)
|
|
$vt
|
Returns thermal voltage
|
|
$vt(temp)
|
Returns thermal voltage at given temp
|
|
$analysis(analysis_string1<, analysis_string2 <, ...>>)
|
|
|
Returns true(1) if the current analysis phase matches one of the given analyses strings. The following are the examples of analyses strings: "dc", "tran", "ac", "pss", "noise", "pdisto", "qpss", "pac", "pnoise", "pxf", "sp", "tdr", "xf", "envlp", "psp", "qpsp", "qpac", "qpnoise", "qpxf", "static", "ic", and so on.
|
Parameter Functions
|
$pwr( x )
|
Assignment of model power consumption. Adds the expression x to the pwr parameter of a module.
|
Data Types
|
integer
|
Discrete numerical type.
|
|
real
|
Continuous numerical type.
|
Data Qualifiers
|
parameter
|
Indicates that a variable is a parameter and so may be given a different value when the module is instantiated, and that it may not be assigned a different value inside the module.
|
Structural Statements
Structural statements are used inside the module block but outside the analog block.
|
module_or_primitive #(<.param1(expr1)<,...>>) inst_name (<node1 <, ..>> );
|
|
|
Creates a new instance of module_or_primitive named inst_name.
|
Environment Variables
|
CDS_AHDLCMI_SHIPDB_COPY
|
Set this environment variable to YES to use AHDL ship databases (ahdlShipDBs). When the environment variable is to YES, the software creates an ahdlShipDB for each Verilog-A file in the directory that contains the Verilog-A file, if the directory is writable. If the directory is not writable, the software does not create any ahdlShipDBs for the modules in the Verilog-A file (see CDS_AHDLCMI_SHIPDB_DIR).
|
|
CDS_AHDLCMI_SHIPDB_DIR
|
Specifies the path to a directory for ahdlShipDB. All Verilog-A files share this path. If the path specified by this variable is not writable, or the path does not exist, the software does not create any ahdlShipDB and generates a warning. For example, setenv CDS_AHDLCMI_SHIPDB_DIR /export/shared/objects.
|
|
CDS_AHDL_COMPILEC_MAX_LOAD
|
Set this environment variable to change the max_load value for parallel compilation of AHDL generated C code. When the system load average is above max_load, parallel compilation is turned off. For example, setenv CDS_AHDL_COMPILEC_MAX_LOAD 4.0.
|
|
CDS_AHDL_DDT_SCALE
|
Set this environment variable to scale the value of ddt to the specified range for better convergence. The default value is 1e-17.
|
|
CDS_AHDL_FINISH_MODE
|
Set this environment variable to 1 to cause the $finish function to stop the current analysis instead of stopping the whole simulation. The default value is 0.
|
|
CDS_AHDL_IDT_SCALE
|
Set this environment variable to scale the value of idt to the specified range for better convergence. The default value is 1.
|
|
CDS_AHDL_IGNORE_HIDDEN_STATE
|
Set this environment variable to YES to process all hidden state variables as non-hidden state variables for all Verilog-A modules.
|
|
CDS_AHDL_IGNORE_OPPOINT
|
Set this environment variable to YES to ignore all operating point calculations. Set the environment variable to NO to disable optimization. The default value is YES for compact models and NO for normal models.
|
|
CDS_AHDL_REUSE_LIB
|
In +aps, ++aps, +xps and +ms modes, the software automatically searches the pre-run shared library and reuses it. Set this environment variable to NO to disable the automatic search and reuse of pre-run shared library.
|
|
CDS_CMI_COMPLEVEL
|
Set this environment variable to control GCC optimization level when compiling AHDL-generated C code flow. The environment value is from 0 to 3, which implies that GCC will use level O0 ~ O3 to compile AHDL C code. O3 is the default compilation level and gives better optimization.
|
|
CDS_VLOGA_INCLUDE
|
Set this environment variable to specify the directory that contains the file with the "include" directive. You can specify more than one directory by using comma(,), colon(:), or semicolon(;) as delimiters to separate the directories. For example, setenv CDS_VLOGA_INCLUDE "dir1;dir2" or setenv CDS_VLOGA_INCLUDE dir1:dir2.
|
|
CDS_AHDL_LRM_COMPATIBILITY
|
Set this environment variable to specify the version of LRM. The default value is 2.3. For example, setenv CDS_AHDL_LRM_COMPATIBILITY 2.4.
|
|
CDS_AHDL_AUTOGDEV_SUPPORT
|
Set this environment variable to NO to prevent a Verilog-A model from automatically adding the simulation parameter gdev at a non-linear branch when the kernel uses the gdev method. The default value is YES, which means that the Verilog-A model adds the simulation parameter gdev by default.
|
|
CDS_AHDL_AUTOGMIN_INSERT
|
Set this environment variable to YES to enable a Verilog-A model to add the simulation parameter gmin at a non-linear branch. The default value is NO.
|
Return to top