Verilog Pli
Verilog Pli
Reference Manual
Version 1.0
November 1, 1991
No part of this work covered by the copyright hereon may be reproduced or used in any form or by any means
-- graphic, electronic, or mechanical, including photocopying, recording, taping, or information storage and
retrieval systems -- without the prior written approval of Open Verilog International.
Additional copies of this manual may be purchased by contacting OpenVerilog International at the address
shown below.
Notices
The information contained in this manual represents the definition of the Programming Language Interface (PLI)
as it existed at the time Cadence Design Systems, Inc. transferred PLI and its documentation to Open Verilog
International (OVI). This manual does not contain any PLI changes or additions developed or approved by OVI.
This information constitutes the basis from which OVI may make refinements and/or additions to PLI.
Open Verilog International makes no warranties whatsoever with respect to the completeness, accuracy, or
applicability of the information in this manual to a user’s requirements.
Open Verilog International reserves the right to make changes to PLI and this manual at any time without notice.
Open Verilog International does not endorse any particular simulator or other CAE tool based on the Verilog
hardware description language and/or PLI.
Suggestions for improvements to the Verilog hardware description language, PLI, and/or this manual will be
welcome. They should be sent to the address below.
Information about Open Verilog International and membership enrollment can be obtained by inquiring at the
address below.
Contents-1
PLI Reference Manual
1
Introduction
This reference manual outlines a C programming interface for a Verilog-HDL
simulation environment. It is based on the Cadence PLI Reference Manual and
describes the Verilog PLI as implemented by Cadence. This document in no way
represents a standard established by the Open Verilog International (OVI), nor should
it be interpreted to be the proposed or suggested method of implementation. Instead,
it is intended as a baseline and beginning for defining an open Programming Language
Interface (PLI). The OVI PLI Task Force is actively working on version 2.0 of the PLI
Reference Manual, which will define major enhancements to PLI.
1.1
Procedural Interface Components
The components of an HDL procedural interface can be broken down into the following
groups:
• Language interface
Allows a procedure to be associated with a language construct. For PLI, this
is implemented as a link between a C routine and a user-defined system task.
• Language access
This includes read access to the information contained in the language (e.g.
connectivity, along with read/write access to selected items (e.g. delays).
• Dynamic simulation
This provides read/write access to certain dynamic values, and access to
information such as simulation time and state.
• Simulation synchronization
This can be achieved with a simulation callback mechanism which invokes
user routines when predefined events occur such as value changes,
simulation time advance, etc.
1.2
Contents of this Manual
This document presents the PLI in the following chapters:
• Access routines
A set of routines which provide language access, dynamic simulation access,
and some synchronization.
• Interface mechanism
The PLI language interface, and some synchronization methods.
• Utility routines
A set of routines aimed mainly at dynamic access and synchronization. Much
of this code is made obsolete by analogous access routines.
Figure 1-0
2
Table 1-0
Example 1-0
Access Routines
2.1
Overview
This chapter describes the PLI access routines, beginning with a general discussion of
how and why to use them, followed by descriptions of the individual routines.
2.1.1
Prerequisites
Before exploring access routines, we recommend that you acquire these skills:
1. a working knowledge of the C programming language
2. familiarity with the PLI mechanism
3. an understanding of how to use the Verilog Hardware Design Language (HDL)
to connect structural objects in a design hierarchy
Please use the references listed below if you need to review any of these topics before
reading further in this chapter:
2.2
What Are Access Routines?
2.2.1
Definition
Access routines are C programming language routines that provide procedural access
to information within Verilog-HDL.
2.2.2
What Access Routines Can Do
Access routines perform one of two operations:
1. read data about particular objects in your circuit design directly from internal
data structures
2. write new information about objects in your circuit design into the internal data
structures
Access routines can read information about the following objects:
• module instances
• module ports
• module paths
• inter-module paths
• top-level modules
• primitive instances
• primitive terminals
• nets
• registers
• parameters
• specparams
• timing checks
• named events
• integer, real and time variables
Access routines can write timing information—delays values or timing check limits—
for the following objects:
• inter-module paths
• module paths
• primitive instances
• timing checks
2.2.3
Names
All access routine names indicate the type of information the access routine reads or
writes. These names begin with the prefix acc_ so you can recognize them easily. For
example, acc_fetch_fullname is the name of an access routine that reads and
returns the full hierarchical name of any named accessible object in a design.
2.3
Handles
2.3.1
Definition
A handle is a predefined data type that is a pointer to a specific object in the design
hierarchy. Each handle conveys information to access routines about a unique instance
of an accessible object—information about the object’s type, plus how and where to
find data about the object.
2.3.2
How Handles Work With Access Routines
Most access routines require a handle argument to indicate the objects about which they
need to read or write information; many access routines also return handles.
The PLI provides two categories of access routines that return handles for objects:
HANDLE routines, which begin with the prefix acc_handle_, and NEXT routines,
which begin with the prefix acc_next_. Refer to Section 2.10 for a discussion of
HANDLE routines and Section 2.12 for more information about NEXT routines.
2.3.3
Handle Variables
Handles are passed to and from access routines through handle variables. To declare a
handle variable, use the keyword handle (all lower case) followed by the variable
name, as in this example:
handle net_handle;
After you declare a handle variable, you can pass it to any access routine that requires
a handle argument or use it to pick up any handle returned by an access routine. The
following C-language code fragment uses the variable net_handle to store the
handle returned by the access routine acc_handle_object:
•
•
•
handle net_handle;
net_handle = acc_handle_object("top.mod1.w3");
•
•
2.4
Accessible Objects
Access routines may retrieve and examine information about the following objects:
• module instances
• module ports
• individual bits of a port
• module or data paths
• inter-module paths
• top-level modules
• primitive instances
• primitive terminals
• nets
• registers
• parameters
• specparams
• timing checks
• named events
• integer, real and time variables
Each object allows its own set of access operations. Table 2 - 1 through Table 2-15 in
the following sections describe the operations that can be performed for each object
type.
2.4.1
Operations on Module Instances
To: Use:
obtain handles for all module instances acc_next_cell
tagged as cells within a hierarchical
scope
2.4.2
Operations on Module Ports
To: Use:
obtain handles for all ports of a acc_next_port
module instance
2.4.3
Operations on Bits of a Port
To: Use:
obtain handles for all bits of a acc_next_bit
module port
acc_append_delays
modify MIPD delays
acc_replace_delays
2.4.4
Operations on Module or Data Paths
To: Use:
obtain handles for all module paths acc_next_modpath
within a scope
find first connected nets acc_handle_pathin
acc_handle_pathout
read delays acc_fetch_delays
2.4.5
Operations on Inter-Module Paths
To: Use:
obtain handle for an inter-module acc_handle_path
path
2.4.6
Operations on Top-Level Modules
To: Use:
obtain handles for all top-level mod- acc_next_topmod
ules in a design
2.4.7
Operations on Primitive Instances
To: Use:
obtain handles for all primitive acc_next_primitive
instances within a module instance
2.4.8
Operations on Primitive Terminals
To: Use:
obtain handles for all terminals of a acc_next_terminal
primitive instance
2.4.9
Operations on Nets
To: Use:
obtain handles for all nets within a acc_next_net
module instance
2.4.10
Registers
To: Use:
retrieve handles to all objects within a acc_next
given scope
find instance name acc_fetch_name
find full hierarchical name acc_fetch_fullname
find parent acc_handle_parent
find bit size acc_fetch_size
retrieve value acc_fetch_value
set the value acc_set_value
find msb and lsb acc_fetch_range
find all load terminals acc_next_load
2.4.11
Operations on Parameters
To: Use:
obtain handles for all parameters acc_next_parameter
within a module instance
2.4.12
Operations on Specparams
To: Use:
obtain handles for all specparams acc_next_specparam
within a module instance
2.4.13
Operations on Timing Checks
To: Use:
obtain handles for all timing checks acc_next_tchk
within a module instance
2.4.14
Named events
To: Use:
retrieve handles to all objects within a acc_next
given scope
find instance name acc_fetch_name
find full hierarchical name acc_fetch_fullname
find parent acc_handle_parent
2.4.15
Integer, real, and time variables
To: Use:
retrieve handles to all objects within a acc_next
given scope
find instance name acc_fetch_name
find full hierarchical name acc_fetch_fullname
find parent acc_handle_parent
retrieve value acc_fetch_value
2.5
Using Access Routines
2.5.1
Header File
You must include the header file, acc_user.h, at the top of any C-language source
file containing an application program that calls access routines. The include statement
looks like this:
#include "acc_user.h"
Refer to Appendix A to view the contents of acc_user.h.
2.5.2
Initializing Access Routines
The access routine acc_initialize initializes the environment for access routines
and must be called from your C-language application program before the program
invokes any other access routines.
See Section 2.15.47 for more information about acc_initialize.
2.5.3
Setting the Development Version
After initializing access routines, you must also set the configuration parameter
accDevelopmentVersion to indicate which version of access routines you used
to develop the application.
To set this parameter, call acc_configure in your C-language application program
immediately after you call acc_initialize. Following is a sample call that sets
accDevelopmentVersion to the PLI 1.6a version of access routines:
acc_configure(accDevelopmentVersion, "1.6a");
Configuring the parameter in this way guarantees that the C-language application code
will run successfully with all future releases of access routines. See Section 2.15.5 for
more information about acc_configure.
2.5.4
Exiting Access Routines
Before exiting a C-language application program that calls access routines, it is
necessary to also exit the access routine environment by calling acc_close at the
end of the program. See Section 2.15.2 for more information about acc_close.
2.5.5
Compiling and Linking
To create a new Verilog executable that includes your application program, you must
perform the following steps:
1. In the file veriuser.c, define the new Verilog system tasks and functions to
be associated with your C- language routines using the PLI mechanism
(discussed in Chapter 3).
2. Compile your application source files and veriuser.c.
3. Link the resulting application and veriuser object files with the object files that
are included with your release.
2.6
Error Handling
When an access routine detects an error, it performs the following operations:
1. sets the global error flag acc_error_flag to true
2. displays an informative error message at run time to standard output in a format
similar to Verilog error messages (unless you specifically suppress error
reporting as described in the next section)
3. returns an exception value
When an access routine is called, it automatically resets acc_error_flag to
false.
2.6.1
Suppressing Error Messages
By default, access routines display error messages. Error messages can be suppressed
with the use of the access routine acc_configure to set the configuration parameter
accDisplayErrors to "false".
2.6.2
Warnings
When access routines detect warning conditions, they set acc_error_flag to
true, but, by default, do not display warning messages. To instruct the access
routines to display warning messages, use the access routine acc_configure to set
the configuration parameter accDisplayWarnings to "true".
2.6.3
Testing for Errors
If you decide to suppress automatic error reporting, you can perform your own error
handling by checking acc_error_flag explicitly after calling a routine. This
procedure is described in the flowchart in Figure 2-1:
call
access
routine
is yes perform
acc_error_flag error
processing
set?
no
continue
normal
processing
2.6.4
Example: Error Checking for Access Routines
Figure 2-2 shows an example of C-language code that performs error checking for
access routines.
#include "acc_user.h"
check_new_timing()
{
handle gate_handle;
2.6.5
Exception Values
Access routines return one of three exception values when an error occurs:
pointers null
or
handles
Because access routines can return valid values that are the same as exception values,
the only definitive way to detect errors explicitly is to check acc_error_flag.
Note that null and false are predefined constants, declared in acc_user.h.
2.7
String Handling
2.7.1
Access Routines Share an Internal String Buffer
Access routines share an internal buffer to store string values. This buffer is used by
all routines that return pointers to strings, as in the following list:
• acc_fetch_defname
• acc_fetch_fullname
• acc_fetch_name
• acc_fetch_value
• acc_fetch_attribute
• acc_fetch_paramval
Each of these routines returns a pointer to the location in the buffer that contains the
first character of the string, as illustrated in Figure 2-3. In this example, mod_name
points to the location in the buffer where top.m1—the name of the module associated
with module_handle—is stored.
"d"
"f"
"f"
"/0"
"t"
"o"
"p"
"."
"m"
"1"
"/0"
Figure 2-3: How access routines store strings in the internal buffer
2.7.2
Buffer Reset
Access routines always try to place strings at the next available sequential location in
the string buffer which, by default, stores up to 4096 characters. However, if there is
not enough room to store an entire string starting at that location, a condition known as
buffer reset occurs.
When buffer reset occurs, the access routine places its string starting at the beginning
of the buffer, overwriting data already stored there. The result is a loss of data, as
shown in Figure 2-4.
Action: Results:
mod_name = acc_fetch_fullname( module_handle ); mod_name points to
"top.m1"
THE INTERNAL STRING BUFFER
"d"
"f"
"f"
"/0"
mod_name "t"
"o"
"p"
"."
"m"
"1"
"/0"
Figure 2-4: Buffer reset causes acc_fetch_fullname to overwrite the name of module_handle in the
string buffer
Figure 2-4 shows that the second call to acc_fetch_fullname corrupts the
module name by overwriting it in the string buffer.
2.7.3
Preserving String Values
Applications that use strings for short periods of time—for example, to print names of
objects—generally do not need to be concerned about overwrites after a string buffer
reset. The risk of losing data is greater, however, for applications that must preserve
string values for a long time while calling many access routines that write to the string
buffer.
To preserve a string value, use the C routine strcpy to copy the string to a local
character array that you allocate in your C-language application. These are the steps to
follow:
1. Allocate a character array that is large enough to store the string.
2. Call strcpy with the following arguments:
• the pointer to your character array as the first argument
• the character pointer returned by the access routine as the second
argument
#include "acc_user.h"
#define NAME_SIZE 256
void display_cells_in_module(mod)
handle mod;
{
handle cell;
char mod_name[NAME_SIZE];
/*save the module name in local buffer mod_name*/
strcpy saves the full module
name in array mod_name
strcpy( mod_name, acc_fetch_fullname( mod ) );
2.8
Types of Access Routines
The six categories of access routines are:
1. FETCH
2. HANDLE
3. MODIFY
4. NEXT
5. UTILITY
6. VCL
Sections 2.9 through 2.14 describe each type of access routine in detail, while
Section 2.15 presents an alphabetical list of individual access routines, explaining their
functions, syntax, and usage.
2.9
FETCH Routines
2.9.1
Function
FETCH routines return a variety of information about different objects in the design
hierarchy.
2.9.2
Names
The name of each routine begins with the prefix acc_fetch_ and indicates the type
of information desired. For example, acc_fetch_fullname retrieves the full
hierarchical path name for any named object, while acc_fetch_paramval
retrieves the value of a parameter or specify parameter.
2.9.3
How to Use FETCH Routines
Follow these steps to use FETCH routines to retrieve data from the design hierarchy:
1. Declare a variable of the same data type as the value returned by the routine.
2. Call the routine with the appropriate number and type of arguments, assigning
the return value to the variable.
2.9.4
List of FETCH Routines
2.10
HANDLE Routines
2.10.1
Function
HANDLE routines return handles to a variety of objects in the design hierarchy.
2.10.2
Names
The name of each routine begins with the prefix acc_handle_ and indicates the type
of handle desired. For example, acc_handle_object retrieves a handle for any
named object, while acc_handle_conn retrieves a handle for a net connected to a
particular terminal.
2.10.3
Return Values
Each HANDLE routine returns a handle to an object—a handle that can, in turn, be
passed as an argument to another access routine.
2.10.4
How to Use HANDLE Routines
Follow these steps to use HANDLE routines for retrieving handles to objects in the
design hierarchy:
1. Declare a handle variable, as described in Section 2.3.
2. Call the routine with the appropriate number and type of arguments, assigning
the return value to the handle variable.
2.10.5
List of HANDLE Routines
2.11
MODIFY Routines
2.11.1
Function
MODIFY routines alter the values of a variety of objects in the design hierarchy. The
following table shows the types of values that can be modified for particular objects:
value register
UDPs
2.11.2
List of MODIFY Routines
2.12
NEXT Routines
2.12.1
Function
When used inside a loop construct, NEXT routines find each object of a given type that
is related to a particular reference object in the design hierarchy.
2.12.2
Names
The name of each routine begins with the prefix acc_next_ and indicates the type of
object desired—the target object. For example, acc_next_net retrieves each net in
a module, while acc_next_driver retrieves each terminal driving a net.
2.12.3
Reference Objects and Target Objects
A target object is the type of object to be returned by a NEXT routine. A reference
object indicates to the NEXT routine where it must look for its first target object. Often,
a reference object relates to a target object in some way—for example, by containing
or connecting to the target object.
2.12.4
Arguments
Typically, NEXT routines require two arguments:
1. The first argument is a handle to the reference object.
2. The second argument is an input handle that indicates whether to retrieve the first
or next target object.
The one exception is acc_next_topmod which finds each top-level module in the
design; its reference object—top-level module— is implied in the routine name, so it
does not require the first argument.
2.12.5
Return Values
Each call to a NEXT routine returns a handle to the object it finds. You can pass this
handle as an argument to other access routines.
2.12.6
How NEXT Routines Work
The following table summarizes how NEXT routines work (assuming their first
argument is a valid reference object):
Looping
Each call to a NEXT routine returns only one handle; therefore, to retrieve all objects
of a desired type for a particular reference object, place the NEXT routine in a while
loop that terminates when the routine returns null.
2.12.7
How to Use NEXT Routines
Follow these steps to use NEXT routines for retrieving all objects of a given type at a
certain level in the design hierarchy:
1. Declare handle variables for the reference object argument and the first/next
argument.
2. Use an access routine to retrieve the handle of the desired reference object.
3. Set the first/next handle variable to null.
4. Call the NEXT routine using the same handle variable for the return value and
for the first/next argument; this technique automatically updates the first/next
argument to point to the last object found for a particular reference object.
5. Place the NEXT routine call inside a while loop that terminates when the return
value is null.
2.12.8
Example: Display Names of Nets Within a Module
The following sample C-language routine display_net_names uses a NEXT
routine to display the names of all nets in a module.
#include "acc_user.h"
display_net_names()
{
handle module_handle;
handle net_handle;
/*initialize environment for access routines*/
acc_initialize();
/*set the development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*get handle for module*/
module_handle = acc_handle_tfarg(1);
/*display names of all nets in the module*/
net_handle = null;
while( net_handle = acc_next_net( module_handle, net_handle ) )
io_printf( "Net name is: %s\n", acc_fetch_fullname( net_handle ) );
acc_close();
}
2.12.9
List of NEXT Routines
2.13
UTILITY Routines
2.13.1
Function
UTILITY routines perform a variety of operations, such as initializing and configuring
the access routine environment.
2.13.2
List of UTILITY Routines
2.14
VCL Routines
The Value Change Link (VCL) allows a PLI application to monitor the value changes
of selected objects. It consists of two PLI access routines that tell the Verilog simulator
to start or stop informing an application when an object changes value.
2.14.1
VCL Objects
The VCL can monitor value changes for the following objects:
• events
• scalar and vector registers
• scalar nets
• bit-selects of expanded vector nets
• unexpanded vector nets
The VCL cannot extract information about the following objects:
• bit-selects of unexpanded vector nets or registers
• part-selects
• memories
• expressions (such as a+b)
2.14.2
List of VCL Routines
2.15
Alphabetical List of Access Routines
This section describes the various PLI access routines, explaining their function,
syntax, and usage. The routines are described in alphabetical order.
2.15.1
acc_append_delays
function when accMinTypMaxDelays is "false", adds delays passed as arguments to existing delay
values for primitives, module paths, timing checks or module input ports
syntax
primitives: acc_append_delays( primitive_handle,
rise_delay, fall_delay, z_delay);
function when accMinTypMaxDelays is "true", adds min:typ:max delay values contained in an array to
existing delay values for primitives, module paths, timing checks or module input ports
syntax
primitives: acc_append_delays( primitive_handle, array_ptr);
related Use acc_configure(accMinTypMaxDelays, "true") for min:typ:max delays for each transition
routines
In single delay mode, it is up to the user to supply the correct number of delay
arguments to acc_append_delays, as follows:
• MIPDs and Z-state primitives require three delay arguments— rise_delay,
fall_delay and Z_delay—if accToHiZDelay is set to " from_user"
(the default).
• MIPDs and Z-state primitives require two delay arguments— rise_delay and
fall_delay—if accToHiZDelay is set to " average", " max" or " min".
• Primitives with no Z state require two delay arguments— rise_delay and
fall_delay.
• Module paths require one, two, three or six delay arguments, depending on how
you configure accPathDelayCount.
• Timing checks require one limit argument— limit.
For more information on the configuration parameters accToHiZDelay and
accPathDelayCount, refer to Table 2-21, Table 2-22 and Table 2-23.
Table 2-20 shows how acc_append_delays writes delays in min:typ:max delay
mode.
module paths writes one, two, three or six sets of three, six, nine or18 values:
min:typ:max delays: (see Table 2-22)
depends on how you configure
accPathDelayCount
(see Table 2-22)
When
accPathDelayCount is: acc_append_delays writes:
1 one delay value, the same for all
transitions: delay1
(last five delay arguments may be dropped)
Table 2-21: How accPathDelayCount affects module path delays in single delay mode
Table 2-22: The relationship between accPathDelayCount and min:typ:max delays for module paths
Effect of timescales
The routine acc_append_delays writes delays in the timescale of the module that
contains object_handle.
rise delay
• turn-off delay
•
top.m1.buf4 10.5 15.0 20.7
•
name of gate • fall delay
#include <stdio.h>
#include "acc_user.h"
write_gate_delays()
{
FILE *infile;
char full_gate_name[NAME_SIZE];
double rise,fall,toz;
handle gate_handle;
Note that the identifier EOF is a predefined constant that stands for end of file;
NAME_SIZE is a user-defined constant that represents the maximum number of
characters allowed for any object name in an input file.
#include "acc_user.h"
#include "veriuser.h"
delay_array must be
append_mintypmax_delays( ) large enough to hold
{ nine values to handle
both Z-state primitives
handle prim; and primitives with no
double delay_array[9]; Z states
int i;
2.15.2
acc_close
acc_close
function frees internal memory used by access routines; resets all configuration parameters to default values
syntax acc_close( );
arguments none
related acc_initialize()
routines
Usage example
The following example presents a C-language routine, show_versions, that calls
acc_close before exiting.
#include "acc_user.h"
show_versions()
{
handle module_handle;
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*show version of access routines*/
/* and version of simulator that is linked to access routines*/
io_printf("Running %s with %s\n",acc_version(),acc_product_version() );
acc_close();
}
Figure 2-10: Using show_versions to display the version of access routines linked to a Verilog simulator
2.15.3
acc_collect
acc_collect
returns a pointer to an array that contains handles for all objects related to a particular reference object
function
inputs: NEXT_routine pointer to a NEXT routine: actual name (unquoted) of the NEXT routine
that finds the object of interest
Managing memory
The routine acc_collect allocates memory for the array of handles it returns. When
you no longer need the contents of the handle array, it is important to free this memory
by calling the access routine acc_free, described in Section 2.15.26.
Usage example
The following example presents a C-language routine, display_nets, that uses
acc_collect to collect and display all nets in a module.
#include "acc_user.h"
display_nets()
{
handle *list_of_nets,module_handle;
int net_count, i;
acc_close();
}
2.15.4
acc_compare_handles
acc_compare_handles
returns true if the two input handles refer to the same object
function
In some cases, two different handles can reference the same object if each handle is
retrieved in a different way—for example, if a NEXT routine returns one handle and
acc_handle_object returns the other. The access routine
acc_compare_handles allows you to determine if two handles refer to the same
object.
Usage example
The following C-language function uses acc_compare_handles to determine if a
primitive drives the specified output of a scalar port of a module.
#include "acc_user.h"
#include "veriuser.h"
/* compare handles */
if ( acc_compare_handles( port_conn, prim_conn ) )
return( true );
else
return( false ); If port_conn and prim_conn
} refer to the same connection,
then the prim drives port
2.15.5
acc_configure
acc_configure
function sets parameters that control the operation of various access routines
"acc_handle_tchk" acc_handle_tchk
accEnableArgs recognizes its optional
arguments
"2" acc_append_delays,
acc_fetch_delays, acc_replace_delays
take two delay arguments when
accMinTypMaxDelays is "false" and a
pointer to an array of size 6 when
accMinTypMaxDelays is "true"
accPathDelayCount
"3" acc_append_delays,
acc_fetch_delays, acc_replace_delays
take three delay arguments when
accMinTypMaxDelays is "false" and a
pointer to an array of size 9 when
accMinTypMaxDelays is "true"
"6" acc_append_delays,
acc_fetch_delays, acc_replace_delays
take six delay arguments when
accMinTypMaxDelays is "false" and a
pointer to an array of size 18 when
accMinTypMaxDelays is "true"
accPathDelimStr any sequence of use the string literal as the delimiter that "$"
letters, numbers, $ separates the source from the destination
or _ in module path names
#include "acc_user.h"
display_load_capacitance()
{
handle module_handle, port_handle, net_handle;
double cap_val;
#include "acc_user.h"
display_net_names()
{
handle module_handle;
handle net_handle;
acc_close();
}
#include "acc_user.h"
display_top_modules()
{
handle top_mod_handle;
top_mod_handle = null;
while( top_mod_handle = acc_next_topmod(top_mod_handle) )
io_printf("Top module: %s\n", acc_fetch_name(top_mod_handle));
acc_close();
}
#include "acc_user.h"
check_new_timing()
{
handle gate_handle;
acc_close();
}
Example: accEnableArgs
The following example presents a C-language routine, get_path, that displays the
name of a module path. It uses acc_configure to set accEnableArgs and,
therefore, force acc_handle_modpath to ignore its null name arguments and
recognize its optional handle arguments, src_handle and dst_handle.
#include "acc_user.h"
get_path()
{
handle path_handle,mod_handle,src_handle,dst_handle;
acc_close();
}
#include "acc_user.h"
set_path_delays()
{
handle mod_handle;
handle path_handle;
double rise_delay,fall_delay,max_delay;
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*get handle to module*/
mod_handle = acc_handle_tfarg( 1 );
/*fetch rise delays for all paths in module "top.m1"*/
path_handle = null;
while( path_handle = acc_next_modpath(mod_handle, path_handle) )
{
/*configure accPathDelayCount for rise and fall delays only*/
acc_configure( accPathDelayCount, "2" ); only 2 delay
acc_fetch_delays(path_handle, &rise_delay, &fall_delay); arguments are needed
#include "acc_user.h"
set_buf_delays()
{
handle primitive_handle;
handle path_handle;
double added_rise, added_fall;
acc_close();
}
2.15.6
acc_count
acc_count
function returns an integer count of the number of objects related to a particular reference object
Usage example
The following example shows a C-language routine, count_nets, that uses
acc_count to count the number of nets in a module.
#include "acc_user.h"
count_nets()
{
handle module_handle;
int number_of_nets;
acc_close();
}
2.15.7
acc_fetch_attribute
acc_fetch_attribute
function returns the value of a parameter or specparam named as an attribute in your source description
Use acc_configure( accDefaultAttr0...) to set default value returned when attribute is not found
related Use acc_fetch_paramval for parameters or specparams not declared in attribute/object format
routines Use acc_handle_object to obtain the handle for the first argument, object_handle
Naming attributes
The routine acc_fetch_attribute obtains the value of a parameter or specparam
that you declare as an attribute in your source description. Any parameter or specparam
can be an attribute, as long you name it in one of the following ways:
• to associate the attribute with a particular object in the module where the
attribute is declared
• to specify a more general attribute—that is, one that may be associated with
more than one object in the module where the attribute is declared
Each of these methods uses its own naming convention, as described in Table 2-34.
For either convention, attribute_string names the attribute and must be passed
as the second argument to acc_fetch_attribute. The object_name is the
actual name of a design object in your source description.
The following example shows how to name a specparam as an attribute associated with
a particular object—the drive strength of a gate called g1:
specparam DriveStrength$g1 = 2.8;
Here, attribute_string is DriveStrength$ and object_name is g1.
To make the drive strength a more general attribute, specify it this way:
specparam DriveStrength$ = 2.8;
Now, the name contains only the attribute_string, which is
DriveStrength$.
The following examples show how to name module paths using different delimiter
strings:
The next example shows how to use this naming convention to describe the rise
strength of module path ( a => q ) = 10 as an attribute in a source description:
specparam RiseStrength$a$q = 20;
Here, the attribute_string is RiseStrength$, the object_name is a$q,
and the path_delimiter is $, the default.
no
yes
found?
no
This illustration shows that when acc_fetch_attribute finds the attribute you
request, it returns the attribute’s value as a double-precision floating point number.
The routine first looks for the attribute name that concatenates attribute_string
with the name associated with object_handle. For example, to find an attribute
InputLoad$ for a net n1, acc_fetch_attribute searches for
InputLoad$n1.
If acc_fetch_attribute does not find the attribute associated with the object
you specify with object_handle, the routine then searches for a name that matches
attribute_string. Assume that, in the previous example,
acc_fetch_attribute does not find InputLoad$n1. It then looks for
InputLoad$. Other variants of that name, such as InputLoad$n3 or
InputLoad$n, are not considered matches.
Failing both search attempts, the routine returns a default value. You can control the
default value by using the access routine acc_configure to set or reset the
configuration parameter accDefaultAttr0 as follows:
Usage example
The following example presents a C-language routine,
display_load_capacitance, that uses acc_fetch_attribute to obtain
the load capacitance of all scalar nets connected to the ports in a module.
#include "acc_user.h"
display_load_capacitance()
{
handle module_handle, port_handle, net_handle;
double cap_val;
if (!acc_error_flag)
io_printf("Load capacitance of net #%d = %1f\n",
acc_fetch_index( port_handle ), cap_val );
}
acc_close();
}
Figure 2-22: Obtaining the load capacitance of all scalar nets connected to module ports
2.15.8
acc_fetch_defname
acc_fetch_defname
function returns a pointer to the defining name of a module instance or primitive instance
Usage example
The following example presents a C-language routine,
get_primitive_definitions, that uses acc_fetch_defname to display
the defining names of all primitives in a module.
#include "acc_user.h"
get_primitive_definitions(module_handle)
handle module_handle;
{
handle prim_handle;
2.15.9
acc_fetch_delays
related Use acc_configure( accPathDelayCount... ) to set number of delays for module path
routines Use acc_configure( accMinTypeMaxDelays, "false") for single delays per transition
function when accMinTypMaxDelays is "true", passes back pointer to array of min:typ:max delay values
for primitives, module paths, timing checks, module input ports or inter-module paths
syntax
primitives: acc_fetch_delays( primitive_handle, array_ptr);
related Use acc_configure( accMinTypeMaxDelays, "true") for min:typ:max delays for each transition
routines
In single delay mode, you must supply the correct number of delay arguments to
acc_fetch_delays, as follows:
• MIPDs and Z-state primitives require three delay arguments—
rise_delay_addr, fall_delay_addr and Z_delay_addr.
• Primitives with no Z state require two delay arguments— rise_delay_addr
and fall_delay_addr.
• Module paths require one, two, three or six delay arguments, depending on how
you configure accPathDelayCount.
• Timing checks require one limit argument— limit.
For more information on the configuration parameter accPathDelayCount, refer
to Table 2-39 and Table 2-40.
Table 2-38 shows how acc_fetch_delays reads delays in min:typ:max delay
mode.
module paths reads one, two, three or six sets of three, six, nine or18 values:
min:typ:max delays: (see Table 2-40)
depends on how you configure
accPathDelayCount
(see Table 2-40)
When
accPathDelayCount
is: acc_fetch_delays returns:
1 one delay value,
delay_addr1
(last five delay arguments may be dropped)
Table 2-39: How accPathDelayCount affects module path delays in single delay mode
Table 2-40: The relationship between accPathDelayCount and min:typ:max delays for module paths
Effect of timescales
The routine acc_fetch_delays retrieves delay values in the timescale of the
module that contains object_handle.
#include "acc_user.h"
display_path_delays()
{
handle mod_handle;
handle path_handle;
double rise_delay,fall_delay,toz_delay;
Figure 2-24: Displaying the rise, fall and turn-off delays of all paths through a module
#include "acc_user.h"
fetch_mintypmax_delays( port_output, port_input )
handle port_output, port_input;
{
•
•
•
handle intermod_path;
double delay_array[9]; acc_handle_path
• returns a handle to a wire
path that represents the
• connection from an output
• (or inout) port to an input
acc_configure( accMinTypMaxDelays, "true" ); (or inout) port
•
•
•
intermod_path = acc_handle_path( port_output, port_input);
acc_fetch_delays( intermod_path, delay_array );
•
• acc_fetch_delays places the
• following values in delay_array:
} delay_array[0] =
delay_array[1] = rise
delay
delay_array[2] =
delay_array[3] =
fall
delay_array[4] = delay
delay_array[5] =
delay_array[6] =
delay_array[7] = turn-off
delay
delay_array[8] =
2.15.10
acc_fetch_direction
acc_fetch_direction
returns the direction of a port or terminal as one of three predefined integer constants:
accInput
function accOutput
accInout
Usage example
The following example presents a C-language routine, is_port_input, that uses
acc_fetch_direction to determine whether or not a port is an input.
#include "acc_user.h"
bool is_port_input(port_handle)
handle port_handle;
{
int direction;
direction = acc_fetch_direction(port_handle);
2.15.11
acc_fetch_edge
acc_fetch_edge
returns the edge specifier (type) of a path input or output terminal as one of these predefined integer
constants:
accNoedge accEdge01 accEdgex1
function
accPosedge accEdge10 accEdge1x
accNegedge accEdge0x accEdgex0
Description
The returned value is a masked integer representing the edge specifier for pathio
upon success, or 0 ( accNoedge) upon error or no edge specifier being given.
Table 2-42 lists the predefined edge specifiers in acc_user.h.
The integer mask returned by this routine usually equals either accPosedge or
accNegedge. Occasionally, however, the mask is a hybrid mix of specifiers that is
equal to neither. The example below illustrates how to check for these hybrid edge
specifiers. The value accNoEdge is returned if no edge is found.
Example
The following example takes a path input or output and returns the string corresponding
to its edge specifier. It provides analogous functionality to that of
acc_fetch_type_str in that it returns a string corresponding to an integer value
that represents a type.
This example first checks to see whether the returned mask is equal to accPosedge
or accNegedge, which are the most likely cases. If it does not, the routine does a
bitwise AND with the returned mask and each of the other edge specifiers to find out
which types of edges it contains. If an edge type is encoded in the returned mask, the
corresponding edge type string suffix is appended to the string “accEdge”.
char *acc_fetch_edge_str(pathio)
handle pathio;
{
int edge = acc_fetch_edge(pathio);
static char edge_str[32];
if (! acc_error_flag)
{
if (edge == accNoEdge)
strcpy(edge_str, “accNoEdge”);
return(edge_str);
}
else
return(NULL);
}
Figure 2-27: Using acc_fetch_edge to get the string that corresponds to an edge specifier
2.15.12
acc_fetch_fullname
acc_fetch_fullname
function returns a pointer to the full hierarchical name of any named object or module path
top1
mod3
w4
By default, the path_delimiter is the character $. However, you can override this
default by using the access routine acc_configure to set the delimiter parameter
accPathDelimStr to another character string.
The following examples show names of paths within a top-level module m3, as returned
by acc_fetch_fullname when the path_delimiter is $:
Default names
If a Verilog simulator creates default names for unnamed instances,
acc_fetch_fullname returns the full hierarchical default name. Otherwise, the
routine returns null for unnamed instances.
Usage example
In the example in Figure 2-29, the routine display_if_net uses
acc_fetch_fullname to display the full hierarchical name of an object if the
object is a net.
#include "acc_user.h"
display_if_net(object_handle)
handle object_handle;
{
/*get and display full name if object is a net*/
if (acc_fetch_type(object_handle) == accNet)
io_printf( "Object is a net: %s\n",
acc_fetch_fullname(object_handle) );
else
io_printf( "Object is not a net: %s\n",
acc_fetch_fullname(object_handle) );
}
2.15.13
acc_fetch_fulltype
acc_fetch_fulltype
returns the fulltype of an object as one of these predefined integer constants:
related acc_fetch_type
routines acc_fetch_type_str
Table 2-50: The fulltypes of paths, and task and function definitions
register accRegister
Usage example
The following two C-language routines in Figure 2-30 and Figure 2-31,
display_timing_check_type and display_primitive_type, use
acc_fetch_fulltype to find and display the fulltypes of timing checks and
primitive objects passed as input arguments. These routines are called by a higher-level
routine, display_object_type, presented as the usage example for
acc_fetch_type.
#include "acc_user.h"
display_timing_check_type(tchk_handle)
handle tchk_handle;
{
/*display timing check type*/
io_printf("Timing check is");
switch( acc_fetch_fulltype( tchk_handle ) )
{
case accHold:
io_printf(" hold\n");
break;
case accNochange:
io_printf(" nochange\n");
break;
case accPeriod:
io_printf(" period\n");
break;
case accRecovery:
io_printf(" recovery\n");
break;
case accSetup:
io_printf(" setup\n");
break;
case accSkew:
io_printf(" skew\n");
break;
case accWidth:
io_printf(" width\n");
}
}
#include "acc_user.h"
display_primitive_type(primitive_handle)
handle primitive_handle;
{
/*display primitive type*/
io_printf("Primitive is");
switch( acc_fetch_fulltype( primitive_handle ) )
{
case accAndGate:
io_printf(" and gate\n"); break;
case accBufGate:
io_printf(" buf gate\n"); break;
case accBufif0Gate:case accBufif1Gate:
io_printf(" bufif gate\n"); break;
case accCmosGate:case accNmosGate:case accPmosGate:
case accRcmosGate:case accRnmosGate:case accRpmosGate:
io_printf(" MOS or Cmos gate\n"); break;
case accCombPrim:
io_printf(" combinational UDP\n"); break;
case accSeqPrim:
io_printf(" sequential UDP\n"); break;
case accNotif0Gate:case accNotif1Gate:
io_printf(" notif gate\n"); break;
case accRtranGate:
io_printf(" rtran gate\n"); break;
case accRtranif0Gate:case accRtranif1Gate:
io_printf(" rtranif gate\n"); break;
case accNandGate:
io_printf(" nand gate\n"); break;
case accNorGate:
io_printf(" nor gate\n"); break;
case accNotGate:
io_printf(" not gate\n"); break;
case accOrGate:
io_printf(" or gate\n"); break;
case accPulldownGate:
io_printf(" pulldown gate\n"); break;
case accPullupGate:
io_printf(" pullup gate\n"); break;
case accXnorGate:
io_printf(" xnor gate\n"); break;
case accXorGate:
io_printf(" xor gate\n");
}
}
2.15.14
acc_fetch_index
acc_fetch_index
What is an index?
The index of a port is its position in a module definition in your source description; the
index of a terminal is its position in a gate, switch, or UDP instance. Indexes are
integers that start at zero and increase from left to right. The following table shows how
indexes are derived:
module m1;
explicit_port_mod( q,a,b ); port definition
input a,b;
output q;
nand( q,a,b );
endmodule
Usage example
The following example presents a C-language routine, display_inputs, that uses
acc_fetch_index to find and display the input ports of a module.
#include "acc_user.h"
display_inputs(module_handle)
handle module_handle;
{
handle port_handle;
int direction;
2.15.15
acc_fetch_location
acc_fetch_location
Description
This function returns the file name and line number in the file for the specified object.
The file name and line number are returned in an s_location data structure. This
data structure is defined in Figure 2-33.
The filename field is a character pointer. The line_no field is a nonzero positive
number.
Example
The following example prints the file name and line number for an object.
Figure 2-34: Using acc_fetch_location to find the file name and line number for an object
2.15.16
acc_fetch_name
acc_fetch_name
function returns a pointer to the instance name of any named object or module path
related Use acc_configure( accPathDelimStr...) to set the naming convention for module paths
routines
top1
mod3
w4
By default, the path_delimiter is the character $. However, you can override this
default by using the access routine acc_configure to set the delimiter parameter
accPathDelimStr to some other character string.
Here are some examples of module path names returned by acc_fetch_name when
the path_delimiter is $:
Default names
If the Verilog simulator default names for unnamed instances, acc_fetch_name
returns the default name. Otherwise, the routine returns null for unnamed instances.
Usage example
The following example presents a C-language routine, show_top_modules, that
uses acc_fetch_name to display the names of all top-level modules.
#include "acc_user.h"
show_top_modules()
{
handle module_handle;
acc_close();
}
2.15.17
acc_fetch_paramtype
acc_fetch_paramtype
returns the data type of a parameter as one of three predefined integer constants:
accIntegerParam
function accRealParam
accStringParam
string accStringParam
Usage example
The following example presents a C-language routine,
print_parameter_values, that uses acc_fetch_paramtype to display the
values of all parameters within a module.
#include "acc_user.h"
print_parameter_values()
{
handle module_handle;
handle param_handle;
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*get handle for module*/
module_handle = acc_handle_tfarg( 1 );
/*scan all parameters in the module and display their values*/
/* according to type*/
param_handle = null;
while( param_handle = acc_next_parameter( module_handle,param_handle))
{
io_printf( "Parameter %s has value: ",
acc_fetch_fullname( param_handle ));
switch( acc_fetch_paramtype( param_handle ) )
{
case accRealParam:
io_printf( "%lf\n", acc_fetch_paramval( param_handle) );
break;
case accIntegerParam:
io_printf( "%d\n", (int)acc_fetch_paramval( param_handle) );
break;
case accStringParam:
io_printf("%s\n",(char*)(int)acc_fetch_paramval(param_handle) );
break;
}
}
acc_close(); two-step cast
}
Please note: Most C-language compilers do not allow you to cast a double-
precision value directly to a character pointer. For string parameters in this example,
it is therefore necessary to use a two-step cast, (char*)(int), to first convert the double
value to an integer and then convert the integer to a character pointer.
2.15.18
acc_fetch_paramval
acc_fetch_paramval
Usage example
The following example presents a C-language routine,
print_parameter_values, that uses acc_fetch_paramval to display all
parameter values for a module.
#include "acc_user.h"
print_parameter_values()
{
handle module_handle;
handle param_handle;
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*get handle for module*/
module_handle = acc_handle_tfarg( 1 );
/*scan all parameters in the module and display their values*/
/* according to type*/
param_handle = null;
while( param_handle = acc_next_parameter( module_handle,param_handle))
{
io_printf( "Parameter %s has value: ",
acc_fetch_fullname( param_handle ));
switch( acc_fetch_paramtype( param_handle ) )
{
case accRealParam:
io_printf( "%lf\n", acc_fetch_paramval( param_handle) );
break;
case accIntegerParam:
io_printf( "%d\n", (int)acc_fetch_paramval( param_handle) );
break;
case accStringParam:
io_printf("%s\n",(char*)(int)acc_fetch_paramval(param_handle) );
break;
}
}
acc_close(); two-step cast
}
Please note: Most C-language compilers do not allow you to cast a double-
precision value directly to a character pointer. For string parameters in this example,
it is therefore necessary to use a two-step cast, (char*)(int), to first convert the double
value to an integer and then convert the integer to a character pointer.
2.15.19
acc_fetch_polarity
acc_fetch_polarity
Description
This routine returns the polarity of the specified path. The polarity of a path determines
how a signal transition at its source propagates to its destination in the absence of logic
simulation events. The return value is one of the predefined integer constant polarity
types listed in Table 2-59.
Example
The following example takes a path argument and returns the string corresponding to
its polarity.
char *fetch_polarity_str(path)
{
switch (acc_fetch_polarity(path)) {
case accPositive: return(“accPositive”);
case accNegative: return(“accNegative”);
case accUnknown: return(“accUnkinown”);
default: return(NULL);
}
}
2.15.20
acc_fetch_range
acc_fetch_range
retrieves the most significant bit and least significant bit range values for a vector;
function
returns zero if successful and nozero upon error
Description
The ‘lsb’ will be the right range element, while the ‘msb’ will be the left range element.
Example
This system task takes as its only input a handle to a module instance. It displays the
name and range of each vector net found in the module as: <name>[<msb>:<lsb>].
display_vector_nets()
{
handle mod = acc_handle_tfarg(1);
handle net;
integer msb, lsb;
net = null;
while (net = acc_next_net(mod, net))
if (acc_object_of_type(net, accVector))
{
acc_fetch_range(net, &msb, &lsb);
io_printf(“ %s[%d:%d]\n”,
acc_fetch_name(net), msb, lsb);
}
Figure 2-40: Displaying the name and range for each vector net found in a scope
2.15.21
acc_fetch_size
acc_fetch_size
return value size_in_bits integer number of bits in the net, register, or port
The access routine acc_fetch_size returns the number of bits of a net, register,
or port .
Usage example
In the following example, the routine display_vector_size uses
acc_fetch_size to determine the size of a vector net. The routine then displays
the name of the vector net and its size in bits.
#include "acc_user.h"
void display_vector_size()
{
handle net_handle;
int size_in_bits;
2.15.22
acc_fetch_tfarg
acc_fetch_tfarg
returns value of the specified argument of the system task or function associated (through the PLI
function mechanism) with your C-language routine
Casting values
Values are returned as double-precision floating-point numbers, but they can be cast to
integers and character pointers as well. The following example shows how to use
acc_fetch_tfarg and cast its return values appropriately.
#include "acc_user.h"
#include "veriuser.h"
display_arg_value()
{
int arg_type;
switch( tf_typep( 1 ) )
{
case tf_readonlyreal:case tf_readwritereal: returns value
io_printf("%1f\n", acc_fetch_tfarg(1) ); as double-precision
floating-point
break; number
case tf_readonly:case tf_readwrite:
io_printf("%d\n", (int)acc_fetch_tfarg(1) );
break;
casts value
case tf_string: to integer
io_printf("%s\n", (char*)(int)acc_fetch_tfarg(1) );
break;
default: casts value to
a character pointer
io_printf("Error in argument specification\n");
break;
}
acc_close();
}
2.15.23
acc_fetch_type
acc_fetch_type
function returns the type of an object as one of these predefined integer constants:
accDataPath accPrimPath
accFunction accRealVar
accIntegerVar accRegister
accModule accSpecparam
accNamedEvent accStatement
accNet accTask
accParameter accTchk
accPath accTerminal
accPathTerminal accTimeVar
accPort accWirePath
accPrimitive
related acc_fetch_type_str
routines acc_fetch_fulltype
module accModule
net accNet
parameter accParameter
port accPort
primitive accPrimitive
register accRegister
specparam accSpecparam
terminal accTerminal
Usage example
The following example presents a C-language routine, display_object_type,
that uses acc_fetch_type to identify the type of an object.
#include "acc_user.h"
display_object_type()
{
handle object_handle;
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
object_handle = acc_handle_tfarg(1);
/*display object type*/
switch( acc_fetch_type( object_handle ) )
{
case accModule:
io_printf( "Object is a module\n" );
break;
case accNet:
io_printf( "Object is a net\n" );
break;
case accPath:
io_printf("Object is a module path\n" );
break;
case accPort:
io_printf("Object is a module port\n" );
break;
case accPrimitive:
display_primitive_type( object_handle );
break;
case accTchk:
display_timing_check_type( object_handle );
break;
case accTerminal:
io_printf("Object is a primitive terminal\n" );
break;
}
acc_close();
}
Other routines may be called to identify an object’s fulltype. Two example routines—
display_primitive_type and display_timing_check_type—use the
access routine acc_fetch_fulltype to provide more specific identification of a
primitive or timing check. These are presented in the section on acc_fetch_fulltype.
2.15.24
acc_fetch_type_str
acc_fetch_type_str
function returns a pointer to a string that indicates the type of its argument
related acc_fetch_type
acc_fetch_fulltype
routines
Usage example
In the following example, a handle to an argument is passed to a C routine. The routine
displays the name of the object and the object’s type.
#include "acc_user.h"
void display_object_type(object)
handle object;
{
int type = acc_fetch_type(object);
In Figure 2-44, if you pass a handle to an object named top.param1, the routine
display_object_type produces the following output:
2.15.25
acc_fetch_value
acc_fetch_value
function returns a pointer to a character string indicating the logic or strength value of a net, register or variable
format_string character string pointer: one of the following specifiers for formatting
quoted string literal or the return value:
character pointer variable "%b"
"%d"
"%h"
"%o"
"%v"
"%x"
Size of objects
The access routine acc_fetch_value returns logic simulation values for scalar or
vector nets, registers and variables; it returns strength values for scalar nets and
registers only.
Note that when specified for scalar objects, %v produces the standard Verilog-HDL
strength format. Refer to the Verilog-HDL Reference Manual for information about %v.
Usage example
In the example in Figure 2-45, the routine display_net_values uses
acc_fetch_value to retrieve the logic values of all nets in a module.
#include "acc_user.h"
display_net_values()
{
handle mod_handle, net_handle;
acc_close();
}
2.15.26
acc_free
acc_free
related acc_collect
routines
Usage example
The following example presents a C-language routine, display_nets, that uses
acc_free to deallocate memory used by the array returned by acc_collect.
#include "acc_user.h"
display_nets()
{
handle *list_of_nets, module_handle;
int net_count, i;
acc_close();
}
Figure 2-46: Using acc_collect to gather all nets in a module for display
2.15.27
acc_handle_by_name
acc_handle_by_name
function returns the handle to an object based on its name and scope
Description
This routine returns the handle to a Verilog-HDL object based on the specified name
and scope.
This routine can be used in place of the combination of routines acc_set_scope
and acc_handle_object. While the functionality is the same as calling
acc_set_scope followed by a call to acc_handle_object, this routine makes
the code cleaner and easier to understand and maintain.
Example
The following example shows how a C-language routine, is_net_in_module, uses
acc_handle_by_name to set the scope and get the handle to an object if the object is in
the module.
#include "acc_user.h"
is_net_in_module(module_handle, net_name)
handle module_handle;
char *net_name;
{
handle net_handle;
handle load_handle, load_net_handle;
if (net_handle)
io_printf("Net %s found in module %s\n",
net_name,
acc_fetch_fullname(module_handle) );
else
io_printf("Net %s not found in module %s\n",
net_name,
acc_fetch_fullname(module_handle) );
}
Figure 2-47: Setting a scope and getting a handle
In this example:
net_handle = acc_handle_by_name(net_name, module_handle);
could also have been written as follows:
acc_set_scope(module_handle);
net_handle = acc_handle_object(net_name);
Related routines
acc_set_scope()
acc_handle_object()
Notes
The routines acc_handle_object and acc_set_scope will continue to be
supported.
2.15.28
acc_handle_condition
acc_handle_condition
function returns a handle to the conditional expression for the specified path
Description
The return value is the conditional expression for the specified module or data path. If
there is no condition, null is returned.
Examples
The following routines provide functionality to see if a path is conditional, and, if it is,
whether it is level-sensitive or edge-sensitive. These routines assume that the input is
a valid handle to a module path.
bool is_path_conditional(path)
{
if (acc_handle_condition(path))
return(TRUE);
else
return(FALSE);
}
bool is_level_sensitive(path)
{
bool flag;
handle path_in = acc_next_pathin(path, null);
acc_release_object(path_in);
return (flag);
}
2.15.29
acc_handle_conn
acc_handle_conn
Usage example
The following example presents a C-language routine, display_driven_net, that
displays the net connected to the output terminal of a gate.
#include "acc_user.h"
display_driven_net()
{
handle gate_handle, terminal_handle, net_handle;
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*get handle for the gate*/
gate_handle = acc_handle_tfarg( 1 );
/*get handle for the gate’s output terminal*/
terminal_handle = acc_handle_terminal( gate_handle, 0 );
/*get handle for the net connected to the output terminal*/
net_handle = acc_handle_conn( terminal_handle );
/*display net name*/
io_printf( "Gate %s drives net %s\n",
acc_fetch_fullname( gate_handle ),
acc_fetch_name( net_handle ) );
acc_close();
}
Figure 2-49: Displaying the net connected to the output terminal of a gate
2.15.30
acc_handle_datapath
acc_handle_datapath
function returns a handle to a datapath for a module instance for the specified edge-sensitive module path
Description
The return value is a handle to the data path associated with the module path. If there
is no data path, null is returned.
Example
The following routine finds the data path corresponding to the specified module path
and displays the source and destination port names for the data path. It uses
acc_next_input() and acc_next_output() to get the input and output,
respectively, for a given path. Since a data path has only one input and one output, you
must call acc_release_object to free the memory allocated for the input and
output handles.
display_datapath_terms(modpath)
handle modpath;
{
handle datapath = acc_handle_datapath(modpath);
handle pathin = acc_next_input(datapath, NULL);
handle pathout = acc_next_output(datapath, NULL);
Figure 2-50: Finding the data path that corresponds to a module path
2.15.31
acc_handle_hiconn
acc_handle_hiconn
function returns the hierarchically higher net connection to a scalar module port or a bit of a vector port
Description
The function returns the hierarchically higher net connection for a scalar port or a bit
of one of the following:
• vector port
• part select of a port
• concatenation of any scalar ports, vector ports, part-selects of ports, or other
concatenations
Example
For the indicated port, display the high and low connection(s).
display_port_info(mod, index)
handle mod;
int index;
{
handle port = acc_handle_port (mod, index);
handle hiconn, loconn, port_bit;
if (acc_fetch_size(port) = 1) {
hiconn = acc_handle_hiconn (port);
loconn = acc_handle_loconn (port);
io_printf (“ hi: %s lo: %s\n”,
acc_fetch_fullname(hiconn), acc_fetch_fullname(loconn));
} else {
port_bit = null;
while (port_bit = acc_next_bit (port, port_bit))
{
hiconn = acc_handle_hiconn (port);
loconn = acc_handle_loconn (port);
io_printf (“ hi: %s lo: %s\n”,
acc_fetch_fullname(hiconn), acc_fetch_fullname(loconn));
}
}
2.15.32
acc_handle_loconn
acc_handle_loconn
returns the hierarchically lower net connection to a scalar module port or a bit of a vector port
function
Description
The function returns the hierarchically lower net connection for a scalar port or a bit of
one of the following:
• vector port
• part select of a port
• concatenation of any scalar ports, vector ports, part selects of ports, or other
concatenations
Example
For the indicated port, display the high and low connection(s).
display_port_info(mod, index)
handle mod;
int index;
{
handle port = acc_handle_port (mod, index);
handle hiconn, loconn, port_bit;
if (acc_fetch_size(port) = 1) {
hiconn = acc_handle_hiconn (port);
loconn = acc_handle_loconn (port);
io_printf (“ hi: %s lo: %s\n”,
acc_fetch_fullname(hiconn), acc_fetch_fullname(loconn));
} else {
port_bit = null;
while (port_bit = acc_next_bit (port, port_bit))
{
hiconn = acc_handle_hiconn (port);
loconn = acc_handle_loconn (port);
io_printf (“ hi: %s lo: %s\n”,
acc_fetch_fullname(hiconn), acc_fetch_fullname(loconn));
}
}
2.15.33
acc_handle_modpath
acc_handle_modpath
If: acc_handle_modpath:
you call: uses the associated handle
acc_configure(accEnableArgs, "acc_handle_modpath") argument, source_handle
and or destination_handle, in-
you pass: stead of the name argument
either source_name or destination_name as a null pointer
Optional arguments
When an optional argument is required for a particular call to
acc_handle_modpath, you must set the configuration parameter
accEnableArgs by calling acc_configure as follows:
acc_configure(accEnableArgs, "acc_handle_modpath");
If accEnableArgs is not set for acc_handle_modpath, the routine always
ignores its optional arguments.
When an optional argument is not required for a particular call to
acc_handle_modpath, it can be dropped as long as it does not precede any
required arguments.
However, when an optional argument does precede one or more required arguments, it
must be supplied even if it is ignored by the access routine. In this case, you can specify
the argument as a null value.
Usage example
The following example shows how the C-language routine get_paths uses
acc_handle_modpath to obtain handles for the paths that connect each of the
sources and destinations listed in the file pathconn.dat: The format of
pathconn.dat appears in Figure 2-53; the source code for get_paths appears in
Figure 2-54.
• path source
module name
•
top.mod1 in out
•
• path destination
#include <stdio.h>
#include "acc_user.h"
get_paths()
{
FILE *infile;
char mod_name[NAME_SIZE], src_name[NAME_SIZE], dest_name[NAME_SIZE];
handle path_handle, mod_handle;
The identifier EOF is a predefined constant that stands for end of file. NAME_SIZE is
a user-defined constant that represents the maximum number of characters allowed for
any object name in an input file.
2.15.34
acc_handle_object
acc_handle_object
input: object_instance_name character string pointer: full or relative hierarchical path name of
quoted string literal or the object instance
character pointer variable
related To call acc_handle_object with a simple object instance name, call acc_set_scope first to set scope
routine to the appropriate level in the design hierarchy
Usage example
The following example presents a C-language routine, write_prim_delays, that
uses acc_handle_object to retrieve handles for net names read from a file called
primdelay.dat. The format of the file is shown in Figure 2-55; the example
appears in Figure 2-56.
Note that write_prim_delays assumes that each net is driven by only one
primitive.
rise delay
•
•
top.m1.net7 10.4 8.5
•
name of net • fall delay
#include <stdio.h>
#include "acc_user.h"
write_prim_delays()
{
FILE *infile;
char full_net_name[NAME_SIZE];
double rise,fall;
handle net_handle, driver_handle, prim_handle;
Figure 2-56: Writing new rise and fall delays for primitives
The identifier EOF is a predefined constant that stands for end of file. NAME_SIZE is
a user-defined constant that represents the maximum number of characters allowed for
any object name in an input file.
2.15.35
acc_handle_parent
acc_handle_parent
function returns handle for the parent primitive instance or module instance of an object
What is a parent?
A parent is an object that contains another object. The parent of a terminal is the
primitive object that contains it; the parent of any other object (except a top-level
module) is the module instance that contains argthe object.
Top-level modules do not have parents. Therefore, when you pass a top-level module
handle to acc_handle_parent, it returns null.
Usage example
This example shows the C-language routine get_primitives that uses
acc_handle_parent to determine which primitives’ terminals drive a net.
#include "acc_user.h"
get_primitives(net_handle)
handle net_handle;
{
handle primitive_handle;
handle driver_handle;
/*get primitive that owns each terminal that drives the net*/
driver_handle = null;
while( driver_handle = acc_next_driver( net_handle, driver_handle ) )
{
primitive_handle = acc_handle_parent( driver_handle );
io_printf( "Primitive %s drives net %s\n",
acc_fetch_fullname( primitive_handle ),
acc_fetch_fullname( net_handle ) );
}
}
2.15.36
acc_handle_path
acc_handle_path
function returns a handle to an inter-module path that represents the connection from an output port to an input
port
Arguments
The access routine acc_handle_path takes two arguments. Table 2-64 outlines the
requirements for each argument.
The first argument must be: The second argument must be:
Paths supported
In this release, acc_handle_path returns handles only for wire paths that are inter-
module paths.
Usage example
The following C-language code fragment shows how to fetch min:typ:max delays for
the inter-module path referenced by intermod_path. Assume the Verilog-HDL
source description contains only one delay per transition.
#include "acc_user.h"
fetch_mintypmax_delays( port_output, port_input )
handle port_output, port_input;
{
•
•
•
handle intermod_path;
double delay_array[9]; acc_handle_path
• returns a handle to a wire
path that represents the
• connection from an output
• (or inout) port to an input
acc_configure( accMinTypMaxDelays, "true" ); (or inout) port
•
•
•
intermod_path = acc_handle_path( port_output, port_input );
acc_fetch_delays( intermod_path, delay_array );
•
• acc_fetch_delays places the
• following values in delay_array:
} delay_array[0] =
delay_array[1] = min:typ:max
rise delay
delay_array[2] =
delay_array[3] =
min:typ:max
delay_array[4] = fall delay
delay_array[5] =
delay_array[6] =
delay_array[7] = min:typ:max
turn-off delay
delay_array[8] =
2.15.37
acc_handle_pathin
acc_handle_pathin
function returns handle for the first net connected to a module path source
Usage example
The following example shows how the C-language routine get_path_nets uses
acc_handle_pathin to find the net connected to the input of a path.
#include "acc_user.h"
get_path_nets(path_handle)
handle path_handle;
{
handle pathin_handle, pathout_handle;
2.15.38
acc_handle_pathout
acc_handle_pathout
function returns handle for the first net connected to a module path destination
Usage example
The following example shows how the C-language routine get_path_nets uses
acc_handle_pathout to find the net connected to the output of a path.
#include "acc_user.h"
get_path_nets(path_handle)
handle path_handle;
{
handle pathin_handle, pathout_handle;
2.15.39
acc_handle_port
acc_handle_port
What is an index?
The index of a port is its position in a module definition in your source description.
Indexes are integers that start at zero and increase from left to right. The following
table shows how port indexes are derived:
module m1;
explicit_port_mod( q,a,b );
input a,b;
output q;
nand( q,a,b );
endmodule
Usage example
The following example shows how the C-language routine is_port_output uses
acc_handle_port to identify whether a particular module port is an output.
#include "acc_user.h"
bool is_port_output(module_handle,port_index)
handle module_handle;
int port_index;
{
handle port_handle;
int direction;
2.15.40
acc_handle_scope
acc_handle_scope
Description
This function returns the handle to the scope of an object. The scope can be either a
module, task, function, named parallel block, or named sequential block.
Example
The following example displays the scope which contains an object.
get_scope(obj)
handle obj;
{
handle scope = acc_handle_scope (obj);
2.15.41
acc_handle_simulated_net
acc_handle_simulated_net
function returns the simulated net associated with the collapsed net passed as an argument
Usage example
In the following example, the routine display_simulated_nets uses
acc_handle_simulated_net to find all simulated nets within a particular
scope. The routine then displays each collapsed net, along with the simulated net.
#include "acc_user.h"
void display_simulated_nets()
{
handle mod_handle;
handle simulated_net_handle;
handle net_handle;
2.15.42
acc_handle_tchk
acc_handle_tchk
function returns handle for the specified timing check of a module (or cell)
If: acc_handle_tchk:
tchk_type is accWidth or accPeriod ignores second_arg_conn_name,
second_arg_edge_type and
second_arg_conn_handle
Edge sums
Edge sums are lists of edge specific constants connected by plus (+) signs. They
represent the Verilog-HDL edge control specifiers used by particular timing checks.
Figure 2-64 shows the call to acc_handle_tchk that accesses a $width timing
check containing edge control specifiers.
edge sum
models
edge control specifier
Optional arguments
When an optional argument is required for a particular call to acc_handle_tchk,
you must set the configuration parameter accEnableArgs by calling
acc_configure as follows:
acc_configure(accEnableArgs, "acc_handle_tchk");
If accEnableArgs is not set for acc_handle_tchk, the routine always ignores
its optional arguments.
When an optional argument is not required for a particular call to
acc_handle_tchk, the argument can be dropped as long as it does not precede any
required arguments. However, when an optional argument does precede one or more
required arguments, it must be supplied even if it is ignored by the access routine. In
this case, you can specify the argument as a null value.
Figure 2-65 shows an example in which optional arguments to acc_handle_tchk
can be dropped; Figure 2-66 shows an example in which optional arguments must be
specified.
sample call:
acc_handle_tchk( mod_handle, accPeriod, "clk", accPosedge );
syntax:
acc_handle_tchk(module_handle,
timing_check_type,
first_arg_conn_name,
first_arg_edge_type, not required
second_arg_conn_name, because $period has
only one connection
second_arg_edge_type,
drop
first_arg_conn_handle, because these optional
second_arg_conn_handle); arguments do not precede
any required arguments
not required
because
first_arg_conn_name
is supplied
drop
because this optional
argument does not precede KEY
any required arguments required arguments appear in bold type
optional arguments appear in plain type
Figure 2-65: Example showing optional arguments that may be dropped in acc_handle_tchk
sample call:
acc_handle_tchk( mod_handle,accPeriod,null,accPosedge,null,null,clk_handle)
syntax:
acc_handle_tchk(module_handle,
timing_check_type,
first_arg_conn_name,
first_arg_edge_type,
second_arg_conn_name,
second_arg_edge_type,
first_arg_conn_handle,
second_arg_conn_handle)
KEY
required arguments appear in bold type
optional arguments appear in plain type
Figure 2-66: Example showing optional arguments that may and may not be dropped in
acc_handle_tchk
Usage example
The following example shows how the C-language routine get_ps_tchks uses
acc_handle_tchk to identify all cells in a module that contain either or both of the
following timing checks:
• a period timing check triggered by a positive edge on the clock signal clk
• a setup timing check triggered on signal d by any transition and on signal clk
by either of these clock edge transitions: 1 to 0 or x to 0
#include "acc_user.h"
get_ps_tchks()
{
handle module_handle, port_handle, net_handle, cell_handle;
Figure 2-67: Identifying all cells in a module that contain particular period and setup timing checks
2.15.43
acc_handle_tchkarg1
acc_handle_tchkarg1
function returns handle for the net connected to the first argument of a timing check
first_arg_conn_handle = acc_handle_tchkarg1(tchk_handle);
syntax
Usage example
The following example presents a C-language routine, show_check_nets, that uses
acc_handle_tchkarg1 to obtain the net connected to the first argument of each
setup timing check in each cell under a module.
#include "acc_user.h"
show_check_nets()
{
handle module_handle,cell_handle;
handle tchk_handle,tchkarg1_handle,tchkarg2_handle;
int tchk_type,counter;
/*initialize environment for access routines*/
acc_initialize();
Figure 2-68: Obtaining the nets connected to first arguments of setup timing checks in cells
2.15.44
acc_handle_tchkarg2
acc_handle_tchkarg2
function returns handle for the net connected to the second argument of a timing check
second_arg_conn_handle = acc_handle_tchkarg2(tchk_handle);
syntax
Usage example
The following C-language routine, show_check_nets, uses
acc_handle_tchkarg2 to obtain the net connected to the second argument of
each setup timing check in each cell under a module. Note that
acc_handle_tchkarg2 returns null if you pass it a handle to a timing check that
requires only one net argument.
#include "acc_user.h"
show_check_nets()
{
handle module_handle,cell_handle;
handle tchk_handle,tchkarg1_handle,tchkarg2_handle;
int tchk_type,counter;
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*get handle for module*/
module_handle = acc_handle_tfarg( 1 );
io_printf("module is %s\n", acc_fetch_fullname( module_handle ) );
/*scan all cells in module for timing checks*/
cell_handle = null;
while ( cell_handle = acc_next_cell( module_handle, cell_handle ) )
{
io_printf( "cell is: %s\n", acc_fetch_fullname( cell_handle ) );
counter = 0;
while ( tchk_handle = acc_next_tchk( cell_handle, tchk_handle) )
{
/*get nets connected to timing check arguments*/
tchk_type = acc_fetch_type( tchk_handle );
if ( tchk_type == accSetup )
{
counter++;
io_printf(" for setup check #%d:\n",counter);
tchkarg1_handle = acc_handle_tchkarg1( tchk_handle );
tchkarg2_handle = acc_handle_tchkarg2( tchk_handle );
io_printf(" data net is %s\n reference net is %s\n",
acc_fetch_name( tchkarg1_handle ),
acc_fetch_name( tchkarg2_handle ) );
}
}
}
acc_close();
}
Figure 2-69: Obtaining the nets connected to second arguments of setup timing checks in cells
2.15.45
acc_handle_terminal
acc_handle_terminal
What is an index?
The index of a terminal is its position in a gate, switch, or UDP declaration. Indexes
are integers that start at zero and increase from left to right.
The following table shows how terminal indexes are derived:
Usage example
The following example shows how the C-language routine print_terminal_net
uses acc_handle_terminal to identify the name of a net connected to a primitive
terminal.
#include "acc_user.h"
print_terminal_net(gate_handle, term_index)
handle gate_handle;
int term_index;
{
handle term_handle;
term_handle = acc_handle_terminal( gate_handle, term_index );
io_printf( "%s terminal net #%d is %s\n",
acc_fetch_name(gate_handle),
term_index,
acc_fetch_name( acc_handle_conn(term_handle) ) );
}
2.15.46
acc_handle_tfarg
acc_handle_tfarg
returns handle for the specified argument of the system task or function associated (through the PLI
function mechanism) with your C-language routine
Types of arguments
The routine retrieves handles to the following types of system task or function
arguments:
• nets
• module instances
• primitives
When: acc_handle_tfarg:
the system task or function returns a handle to the net or
argument is a Verilog-HDL module
identifier for a net or module
When Verilog encounters this call, it executes new_timing, which contains the
following code:
#include "acc_user.h"
new_timing()
{
handle gate_handle;
double new_rise, new_fall;
/* report action */
io_printf("Primitive %s has new delays %d %d\n",
acc_fetch_fullname( gate_handle ),
new_rise, new_fall );
acc_close();
}
2.15.47
acc_initialize
acc_initialize
syntax acc_initialize();
arguments none
Usage example
The following example presents a C-language routine, display_inputs, that uses
acc_initialize to initialize the environment for access routines.
#include "acc_user.h"
display_inputs()
{
handle module_handle,port_handle;
int direction;
2.15.48
acc_next
acc_next
function within a scope, returns the next object of each type specified in object_type_array
The access routine acc_next allows you to scan one or more types of objects within
a scope. This routine performs a more general function than the object-specific NEXT
routines—such as acc_next_net and acc_next_primitive —which scan
only one type of object within a scope.
module accModule
net accNet
primitive accPrimitive
register accRegister
Usage example
The C-language routine in the following example uses acc_next to find all nets and
registers in a module. The routine then displays the names of these nets and registers.
#include "acc_user.h"
void display_nets_and_registers()
{
static int net_reg_list[3] = {accNet,accRegister,0};
handle mod_handle, obj_handle;
Figure 2-73: Displaying the names of all nets and registers in a module
2.15.49
acc_next_bit
acc_next_bit
function returns the handles of each bit in an expanded vector port or expanded vector net
The access routine acc_next_bit accesses all of the bits of a vector port or vector
net. This routine retrieves the handles to each bit of a port or net. You can pass these
handles to access routines that insert, replace, or return MIPD values.
Usage examples
The following example C-subroutine, display_port_bits, uses
acc_next_bit to display the low hierarchical connection of each bit of a port.
#include "acc_user.h"
display_port_bits(module_handle, port_number)
handle module_handle;
int port_number;
{
handle port_handle, bit_handle;
Figure 2-74: Displaying the low hierarchical connection of each bit of a port
The following example C subroutine, monitor_bits, requests that VCL monitor the
logic value of each bit of an expanded vector net.
#include "acc_user.h"
void consumer_routine();
void monitor_bits()
{
handle bit_handle, net_handle, mod_handle;
/*reset environment for access routines*/
acc_initialize();
acc_configure( accDevelopmentVersion, "1.5c" );
Figure 2-75: Monitoring the logic value of each bit of an expanded vector net
2.15.50
acc_next_cell
acc_next_cell
function returns the next cell instance within the region that includes the entire hierarchy below a module
Nested cells
The routine acc_next_cell does not find cells that are instantiated inside other
cells.
Usage example
The following C-language routine, list_cells, uses acc_next_cell to find all
cell instances beginning at the level defined by module_handle.
#include "acc_user.h"
list_cells()
{
handle module_handle;
handle cell_handle;
acc_close();
}
2.15.51
acc_next_cell_load
acc_next_cell_load
related acc_next_load
routines
net1
cell1
cell2
cell3
2
3
2
1 1
acc_next_load acc_next_cell_load
returns four primitive returns three primitive
input terminals input terminals
Usage example
The following C-language routine, get_cell_loads, uses
acc_next_cell_load to find all cell loads on a net.
#include "acc_user.h"
get_cell_loads()
{
handle net_handle;
handle load_handle,load_net_handle;
2.15.52
acc_next_child
acc_next_child
What is a child?
A child is a module instance that appears inside another module.
When: acc_next_child:
the first argument, module_handle, works exactly like
is null acc_next_topmod to scan for
top-level modules
Usage example
The following C-language routine, print_children, uses acc_next_child to
display the names of all modules instantiated within the module_handle input
argument.
#include "acc_user.h"
print_children(module_handle)
handle module_handle;
{
handle child_handle;
2.15.53
acc_next_driver
acc_next_driver
Usage example
This example shows the C-language routine print_drivers that uses
acc_next_driver to determine which primitives’ terminals drive a net.
#include "acc_user.h"
print_drivers(net_handle)
handle net_handle;
{
handle primitive_handle;
handle driver_handle;
/*get primitive that owns each terminal that drives the net*/
driver_handle = null;
while( driver_handle = acc_next_driver( net_handle, driver_handle ) )
{
primitive_handle = acc_handle_parent( driver_handle );
io_printf( " %s\n",
acc_fetch_fullname( primitive_handle ) );
}
}
2.15.54
acc_next_hiconn
acc_next_hiconn
function returns the next hierarchically higher net connection to a port of a module
related acc_next_loconn
routines
module
lower higher
Usage example
The following example presents a C-language routine, display_connections,
that uses acc_next_hiconn to find and display the high net connections to a
module port.
#include "acc_user.h"
display_connections(module_handle, port_handle)
handle module_handle, port_handle;
{
handle hiconn_net, loconn_net;
2.15.55
acc_next_input
acc_next_input
function returns a handle to the next input path terminal of the specified module path or datapath
Description
The routine scans the inputs of a module path or sources of a data path and returns
handles to the input path terminals. Routine acc_handle_conn() can then be
applied to this path terminal to derive the net connected to the terminal.
Example
The example on the following page accepts a handle to a scalar net or a net bit-select,
and a module path. The routine returns true if the net is connected to the input of the
path.
Related routines
acc_handle_conn() : returns nets connected to path terminals
acc_release_object() : frees allocated memory
bit = null;
if (acc_object_of_type (port_conn, accExpandedVector))
{
bit = null;
while (bit = acc_next_bit (port_conn, bit))
if (acc_compare_handles (bit, net))
return (true);
}
else
if (acc_compare_handles (bit, net))
return (true);
}
return (false);
}
2.15.56
acc_next_load
acc_next_load
related acc_next_cell_load
routines
net1
cell1
cell2
cell3
2
3
2
1 1
acc_next_load acc_next_cell_load
returns four primitive returns three primitive
input terminals input terminals
Usage example
This example shows how the C-language routine get_loads uses
acc_next_load to find all terminals driven by a net.
#include "acc_user.h"
get_loads()
{
handle net_handle, load_handle, load_net_handle;
2.15.57
acc_next_loconn
acc_next_loconn
function returns the next hierarchically lower net connection to a port of a module
related acc_next_hiconn
routines
module
lower higher
Usage example
The following example presents a C-language routine, display_connections,
that uses acc_next_loconn to find and display the low net connections to a module
port.
#include "acc_user.h"
display_connections(module_handle, port_handle)
handle module_handle, port_handle;
{
handle hiconn_net, loconn_net;
2.15.58
acc_next_modpath
acc_next_modpath
Usage example
The following example shows how the C-language routine get_path_nets uses
acc_next_modpath to find the nets connected to the inputs and outputs of all paths
across a module.
#include "acc_user.h"
get_path_nets(module_handle)
handle module_handle;
{
handle pathin_handle, pathout_handle;
handle path_handle;
/*scan all paths in the module and display nets connected to each*/
/* source and destination*/
io_printf( "For module %s:\n",acc_fetch_fullname( module_handle ) );
path_handle = null;
while( path_handle = acc_next_modpath( module_handle, path_handle) )
{
io_printf(" path %s connections are:\n",
acc_fetch_name( path_handle ) );
pathin_handle = acc_handle_pathin( path_handle );
pathout_handle = acc_handle_pathout( path_handle );
io_printf( "net %s connected to input\n",
acc_fetch_name( pathin_handle ) );
io_printf( "net %s connected to output\n",
acc_fetch_name( pathout_handle ) );
}
}
Figure 2-86: Finding the nets connected to the inputs and outputs of all paths across a module
2.15.59
acc_next_net
acc_next_net
Usage example
The following C-language routine, display_net_names, uses acc_next_net
to display the names of all nets in a module.
#include "acc_user.h"
display_net_names()
{
handle mod_handle, net_handle;
acc_close();
}
2.15.60
acc_next_output
acc_next_output
function returns a handle to the next output path terminal of the specified module path or datapath
Description
The routine scans the outputs of a module path or sources of a data path and returns
handles to the output path terminals. Routine acc_handle_conn() can then be
applied to this path terminal to derive the net connected to the terminal.
Example
The example on the following page accepts a handle to a scalar net or a net bit-select,
and a module path. The routine return true if the net is connected to the output of the
path.
Related routines
acc_handle_conn() : returns nets connected to path terminals
acc_release_object() : frees allocated memory
bit = null;
if (acc_object_of_type (port_conn, accExpandedVector))
{
bit = null;
while (bit = acc_next_bit (port_conn, bit))
if (acc_compare_handles (bit, net))
return (true);
}
else
if (acc_compare_handles (bit, net))
return (true);
}
return (false);
}
Related routines
acc_release_object()
2.15.61
acc_next_parameter
acc_next_parameter
Usage example
The following C-language routine, print_parameter_values, uses
acc_next_parameter to scan all parameters in a module.
#include "acc_user.h"
print_parameter_values(module_handle)
handle module_handle;
{
handle param_handle;
/*scan all parameters in the module and display their values*/
/* according to type*/
param_handle = null;
while( param_handle = acc_next_parameter( module_handle,param_handle))
{
io_printf( "Parameter %s = ",acc_fetch_fullname( param_handle ));
switch( acc_fetch_paramtype( param_handle ) )
{
case accRealParam:
io_printf( "%lf\n", acc_fetch_paramval( param_handle) );
break;
case accIntegerParam:
io_printf( "%d\n", (int)acc_fetch_paramval( param_handle) );
break;
case accStringParam:
io_printf("%s\n",(char*)(int)acc_fetch_paramval(param_handle) );
}
}
}
2.15.62
acc_next_port
acc_next_port
function returns the next input, output or inout port of a module in the order specified by the port list
related acc_next_portout
routines
Usage example
The following example presents a C-language routine, display_inputs, that uses
acc_next_port to find and display the input ports of a module.
#include "acc_user.h"
display_inputs(module_handle)
handle module_handle;
{
handle port_handle;
int direction;
/*get handle for each module port*/
port_handle = null;
while (port_handle = acc_next_port( module_handle, port_handle) )
{
/*give the index of each input port*/
if ( acc_fetch_direction( port_handle ) == accInput )
io_printf( "Port #%d of %s is an input\n",
acc_fetch_index( port_handle ),
acc_fetch_fullname( module_handle ) );
}
}
display_port_connections()
{
handle net = acc_handle_tfarg(1);
handle port, bit;
2.15.63
acc_next_portout
acc_next_portout
function returns the next output or inout port of a module in the order specified by the port list
related acc_next_port
routines
Usage example
The following example presents a C-language routine, display_outputs, that uses
acc_next_portout to find the output and inout ports of a module.
#include "acc_user.h"
display_outputs(module_handle)
handle module_handle;
{
handle port_handle;
/*get handle for each module port*/
port_handle = null;
while (port_handle = acc_next_portout( module_handle, port_handle) )
{
/*give the index of each output or inout port*/
io_printf( "Port #%d of %s is an output or inout\n",
acc_fetch_index( port_handle ),
acc_fetch_fullname( module_handle ) );
}
}
2.15.64
acc_next_primitive
acc_next_primitive
function returns the next gate, switch or user-defined primitive (UDP) within a module
Usage example
The following example presents a C-language routine,
get_primitive_definitions, that uses acc_next_primitive to display
the defining names of all primitives in a module.
#include "acc_user.h"
get_primitive_definitions()
{
handle module_handle, prim_handle;
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*get handle for module*/
module_handle = acc_handle_tfarg( 1 );
io_printf("Module %s contains the following types of primitives:\n",
acc_fetch_fullname( module_handle ) );
/*get and display defining names of all primitives in the module*/
prim_handle = null;
while( prim_handle = acc_next_primitive( module_handle,prim_handle))
io_printf( " %s\n",
acc_fetch_defname( prim_handle ) );
acc_close();
}
2.15.65
acc_next_specparam
acc_next_specparam
Usage example
The following C-language routine, print_specparam_values, uses
acc_next_specparam to scan all specparams in a module.
#include "acc_user.h"
print_specparam_values(module_handle)
handle module_handle;
{
handle sparam_handle;
/*scan all parameters in the module and display their values*/
/* according to type*/
sparam_handle = null;
while(sparam_handle = acc_next_specparam(module_handle,sparam_handle))
{
io_printf( "Specparam %s = ", acc_fetch_fullname( sparam_handle ) );
switch( acc_fetch_paramtype( sparam_handle ) )
{
case accRealParam:
io_printf( "%lf\n", acc_fetch_paramval( sparam_handle) );
break;
case accIntegerParam:
io_printf( "%d\n", (int)acc_fetch_paramval( sparam_handle) );
break;
case accStringParam:
io_printf("%s\n",(char*)(int)acc_fetch_paramval(sparam_handle));
}
}
}
2.15.66
acc_next_tchk
acc_next_tchk
Usage example
The following example presents a C-language routine, show_setup_check_nets,
that uses acc_next_tchk to scan all cells below a module for setup timing checks.
#include "acc_user.h"
show_setup_check_nets()
{
handle mod_handle,cell_handle;
handle tchk_handle,tchkarg1_handle,tchkarg2_handle;
int tchk_type,counter;
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*get handle for module*/
mod_handle = acc_handle_tfarg( 1 );
/*scan all cells in module for timing checks*/
cell_handle = null;
while ( cell_handle = acc_next_cell( mod_handle, cell_handle ) )
{
io_printf( "cell is: %s\n", acc_fetch_name( cell_handle ) );
counter = 0;
tchk_handle = null;
while ( tchk_handle = acc_next_tchk( cell_handle, tchk_handle) )
{
/*get nets connected to timing check arguments*/
tchk_type = acc_fetch_fulltype( tchk_handle );
if ( tchk_type == accSetup )
{
counter++;
io_printf(" for setup check #%d:\n",counter);
tchkarg1_handle = acc_handle_tchkarg1( tchk_handle,mod_handle );
tchkarg2_handle = acc_handle_tchkarg2( tchk_handle,mod_handle );
io_printf(" 1st net is %s\n 2nd net is %s\n",
acc_fetch_name( tchkarg1_handle ),
acc_fetch_name( tchkarg2_handle ) );
}
}
}
acc_close();
}
Figure 2-95: Scanning all cells below a module for setup timing checks
2.15.67
acc_next_terminal
acc_next_terminal
function returns the next terminal of a gate, switch or user-defined primitive (UDP)
Usage example
In the example in Figure 2-96, the routine display_terminals uses
acc_next_terminal to retrieve all nets connected to a primitive.
#include "acc_user.h"
display_terminals()
{
handle prim_handle,term_handle;
2.15.68
acc_next_topmod
acc_next_topmod
related Pass acc_next_child with null module_handle to acc_collect and acc_count to collect or count top-
routines level modules
Usage example
The following example presents a C-language routine, show_top_modules, that
uses acc_next_topmod to display the names of all top-level modules.
#include "acc_user.h"
show_top_modules()
{
handle module_handle;
acc_close();
}
2.15.69
acc_object_in_typelist
acc_object_in_typelist
function determines whether an object fits a type or fulltype—or exhibits a property—specified in an input array
Usage example
In the following example, the C-language routine display_wired_nets uses
acc_object_in_typelist to determine if a net is a wired net. The routine
then displays the name of each wired net found.
#include "acc_user.h"
display_wired_nets()
{
static int wired_nets[5]={accWand,accWor,accTriand,accTrior,0};
handle net_handle;
2.15.70
acc_object_of_type
acc_object_of_type
function determines whether an object fits a specified type or fulltype, or exhibits a specified property
vector accVector
Usage example
In the following example, the routine display_collapsed_nets uses
acc_object_of_type to determine whether nets are collapsed nets. The routine
then displays each collapsed net, along with the simulated net.
#include "acc_user.h"
void display_collapsed_nets()
{
handle mod_handle;
handle net_handle;
handle simulated_net_handle;
2.15.71
acc_product_version
acc_product_version
returns a pointer to a character string that indicates what version of a Verilog simulator is linked to the
function access routines
arguments none
Usage example
The following example presents a C-language routine, show_versions, that uses
acc_product_version to identify the version of the Verilog simulator that is
linked to access routines.
#include "acc_user.h"
show_versions()
{
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*show version of access routines*/
/* and version of Verilog that is linked to access routines*/
io_printf("Running %s with %s\n",acc_version(),acc_product_version() );
acc_close();
}
Figure 2-100: Identifying the version of a Verilog simulator that is linked to access routines
2.15.72
acc_release_object
acc_release_object
Description
This routine deallocates memory for an input or output terminal path handle. You
should call this routine after acc_next_input and acc_next_output under the
following circumstances:
• Y ou have not scanned all inputs or outputs.
• The input or output path had only one terminal.
• An error was returned.
Failure to deallocate memory for input and output handles may result in a significant
waste of memory in a large application.
Examples
The following routine finds the data path corresponding to an input module path, and
displays the source and destination port names for the data path. It uses
acc_next_input and acc_next_output to get the first input and output,
respectively, for a given path. Since it only calls acc_next_input and
acc_next_output once, it must call acc_release_object to free the
memory allocated for the input and output handles.
void display_datapath_terms(modpath)
handle modpath;
{
handle datapath = acc_handle_datapath(modpath);
handle pathin = acc_next_input(datapath, NULL);
handle pathout = acc_next_output(datapath, NULL);
/* there is only one input and output to a datapath */
io_printf(“DATAPATH INPUT: %s\n”, acc_fetch_fullname(pathin));
io_printf(“DATAPATH OUTPUT: %s\n”, acc_fetch_fullname(pathout));
acc_release_object(pathin);
acc_release_object(pathout);
}
Figure 2-101: Releasing the memory for a datapath’s input and output handles
In the following code fragment, there may be more than four inputs, but the code stops
scanning at the fourth input.
pathin = NULL;
for (i = 0; i <= 4; i++)
pathin = acc_next_input(path, pathin);
io_printf(“THE FOURTH INPUT IS: %s\n”,
acc_fetch_name(pathin));
acc_release_object(pathin);
In the following code fragment, there may be more than one input, but only the first
one is accessed.
Related routines
acc_next_input()
acc_next_output()
2.15.73
acc_replace_delays
function when accMinTypMaxDelays is "true", replaces delay values for primitives, module paths, timing
checks, module input ports or inter-module paths with min:typ:max delay values from an array
syntax
primitives: acc_replace_delays( primitive_handle, array_ptr);
related Use acc_configure(accMinTypMaxDelays, "true") for min:typ:max delays for each transition
routines
In single delay mode, it is up to the user to supply the correct number of delay
arguments to acc_replace_delays, as follows:
• MIPDs and Z-state primitives require two delay arguments— rise_delay and
fall_delay—if accToHiZDelay is set to " average", " max" or " min"
• MIPDs and Z-state primitives require three delay arguments— rise_delay,
fall_delay and Z_delay—if accToHiZDelay is set to " from_user"
(the default)
• Primitives with no Z state require two delay arguments— rise_delay and
fall_delay.
• Timing checks require one limit argument— limit.
• Module paths require one, two, three or six delay arguments, depending on how
you configure accPathDelayCount.
For more information on the configuration parameters accToHiZDelay and
accPathDelayCount, refer to Table 2-79, Table 2-80 and Table 2-81.
Table 2-78 shows how acc_replace_delays writes delays in min:typ:max delay
mode.
module paths writes one, two, three or six sets of three, six, nine or18 values:
min:typ:max delays: (see Table 2-80)
depends on how you configure
accPathDelayCount
(see Table 2-80)
When
accPathDelayCount is: acc_replace_delays writes:
1 one delay value, the same for all
transitions: delay1
(last five delay arguments may be dropped)
Table 2-79: How accPathDelayCount affects module path delays in single delay mode
The following rules apply when you modify min:typ:max delays for module paths:
• the number of sets of min:typ:max delays must equal the value of
accPathDelayCount
• the size of the delay array must be three times the value of
accPathDelayCount
Table 2-80 summarizes how accPathDelayCount affects min:typ:max delays for
module paths.
Table 2-80: The relationship between accPathDelayCount and min:typ:max delays for module paths
Effect of timescales
The routine acc_replace_delays writes delay values in the timescale of the
module that contains primitive_handle, path_handle or
timing_check_handle.
#include <stdio.h>
#include "acc_user.h"
write_path_delays()
{
FILE *infile;
char full_module_name[NAME_SIZE];
char pathin_name[NAME_SIZE], pathout_name[NAME_SIZE];
double rise,fall;
handle mod_handle, path_handle;
/*initialize the environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*set accPathDelayCount parameter to return rise and fall delays only*/
acc_configure( accPathDelayCount, "2" );
/*read delays from file - "r" means read only*/
infile = fopen("pathdelay.dat","r");
fscanf(infile, "%s %s %s %lf %lf",
full_module_name,pathin_name,pathout_name,&rise,&fall);
/*get handle for the module and the path*/
mod_handle = acc_handle_object(full_module_name);
path_handle = acc_handle_modpath(mod_handle,pathin_name,pathout_name);
/*replace delays with new values*/
acc_replace_delays( path_handle, rise, fall );
acc_close();
}
Note that the identifier EOF is a predefined constant that stands for end of file.
NAME_SIZE is a user-defined constant that represents the maximum number of
characters allowed for any object name in an input file.
scope
Assume that the Verilog-HDL description contains only one delay per transition—in
this case, the typical delay.
#include "acc_user.h"
#include "veriuser.h"
void scale_prim_delays()
{
handle top, cell, prim;
int i, count;
double min_scale_factor, typ_scale_factor, max_scale_factor;
double da[9]; array must hold three sets
of min:typ:max values for
acc_initialize(); rise, fall and turn-off delays
acc_configure(accDevelopmentVersion,"1.5b.3");
acc_configure(accMinTypMaxDelays,"true");
top = acc_handle_tfarg(1); argument #1: scope
min_scale_factor = acc_fetch_tfarg(2); argument #2: scale factor for minimum delay
typ_scale_factor = acc_fetch_tfarg(3); argument #3: scale factor for typical delay
max_scale_factor = acc_fetch_tfarg(4); argument #4: scale factor for maximum delay
count++;
}
}
io_printf("Completed scale of %d primitives\n", count);
}
2.15.74
acc_set_scope
acc_set_scope
function sets a scope for acc_handle_object to use when searching in the design hierarchy
acc_set_scope(module_handle, module_name);
syntax
related acc_handle_object
routine Use acc_configure(accEnableArgs,"acc_set_scope") to use module_name argument
If: acc_set_scope:
you call: sets scope to the level of module_name
acc_configure(accEnableArgs, "acc_set_scope") in the design hierarchy
and
you pass:
module_handle as a null pointer
you call: sets scope to the level of
acc_configure(accEnableArgs, "acc_set_scope") module_handle in the design hierarchy
and
you pass:
a valid module_handle
you call: sets scope to the top-level module that
acc_configure(accEnableArgs, "acc_set_scope") appears first in the source description
and
you pass:
module_handle and module_name as null pointers
you do not call: always ignores module_name and sets
acc_configure(accEnableArgs, "acc_set_scope") scope to the level of module_handle in
the design hierarchy
if module_handle is null, sets scope to
the top-level module that appears first in
the source description
(you may drop the optional argument
module_name)
Optional arguments
When the optional argument is required for a particular call to acc_set_scope, you
must set the configuration parameter accEnableArgs by calling
acc_configure as follows:
acc_configure(accEnableArgs, "acc_set_scope");
If accEnableArgs is not set for acc_set_scope, the routine always ignores its
optional argument.
When the optional argument is not required for a particular call to acc_set_scope,
you can drop the argument.
However, when an optional argument precedes one or more required arguments, it must
be supplied even if it is ignored by the access routine. In this case, you can specify the
argument as a null value.
Usage example
The following example shows how a C-language routine, is_net_in_module, uses
acc_set_scope to set a scope for acc_handle_object to determine if a net is
in a module.
#include "acc_user.h"
is_net_in_module(module_handle,net_name)
handle module_handle;
char *net_name;
{
handle net_handle;
handle load_handle, load_net_handle;
if (net_handle)
io_printf( "Net %s found in module %s\n",
net_name,
acc_fetch_fullname(module_handle) );
else
io_printf( "Net %s not found in module %s\n",
net_name,
acc_fetch_fullname(module_handle) );
}
2.15.75
acc_set_value
acc_set_value
Description
This routine is used to set and propagate a value on a register or a sequential UDP.
The structure s_setval_value contains the value to be written. A value can be
entered into this structure as a string, scalar, integer, or real. The 'format' field indicates
the value type, while the 'value' union is set to the value to be written. Refer to the
structure definition and associated defined values in file ' acc_user.h' in Appendix
A.
For registers, the structure s_setval_delay indicates if and what delay will take
place before a register value assignment. A delay model is indicated with the 'model'
field. The available delay models are specified using predefined integer constants. The
predefined integer constant for delay models are listed in Table 2-83.
For UDPs, the 'model' field must be accNoDelay, and the new value is assigned with
no delay even if the UDP instance has a delay.
Refer to the file ' acc_user.h' in Appendix A for more information about the
s_setval_delay structure definition and associated defined values.
Example
The following example sets and propagates a value on a register.
int my_set_value()
{
static s_setval_delay delay_s = {{accRealTime},
accInertialDelay};
static s_setval_value value_s = {accBinStrVal};
value_s.value.str = acc_fetch_tfarg_str(2);
delay_s.time.real = acc_fetch_tfarg(3);
2.15.76
acc_vcl_add
acc_vcl_add
tells the Verilog simulator to call a consumer routine with value change information whenever an object
function
changes value
related acc_vcl_delete
routine
The VCL access routine acc_vcl_add tells the Verilog simulator to report logic
value information or logic value and strength information to a consumer routine.
The acc_vcl_add access routine takes the four arguments that are defined in
Table 2-84.
Argument Definition
object_handle The object_handle argument is a handle to the object to
be monitored by an application. You obtain
object_handle by calling PLI access routines.
Please note:
The object_handle passed to
acc_vcl_add is not returned to the
application when the Verilog simulator
reports a value change. Therefore, the
application should use the user_data
argument to save any necessary
information about the object prior to
calling acc_vcl_add. (See the discussion
on user_data below.)
2.15.77
acc_vcl_delete
acc_vcl_delete
tells the Verilog simulator to stop calling a consumer routine with value change information when an object
function changes value
related acc_vcl_add
routine
The VCL access routine acc_vcl_delete tells the Verilog simulator to stop
reporting previously requested information to a consumer routine. The
acc_vcl_delete access routine takes the four arguments that are defined in
Table 2-86.
Argument Definition
object_handle The object_handle argument is a handle to the object to
be monitored by an application. You obtain
object_handle by calling PLI access routines.
Multiple calls
When multiple applications are monitoring the same object, acc_vcl_delete stops
monitoring the object only for the application associated with a specific
consumer_routine and user_data pointer.
Regardless of the number of calls an application makes to acc_vcl_add for the same
object_handle, user_data, and consumer_routine, only one call to
acc_vcl_delete is required to stop the Verilog simulator from notifying the
consumer routine of value changes.
2.15.78
acc_version
acc_version
function returns a pointer to a character string that indicates version number of your access routine software
arguments none
Usage example
The following C-language routine, show_versions, uses acc_version to
identify the current version of access routines.
#include "acc_user.h"
show_versions()
{
handle module_handle;
/*initialize environment for access routines*/
acc_initialize();
/*set development version*/
acc_configure( accDevelopmentVersion, "1.6a" );
/*show version of access routines*/
/* and version of simulator that is linked to access routines*/
io_printf("Running %s with %s\n",acc_version(),acc_product_version() );
acc_close();
}
Figure 3-0
3
Table 3-0
Example 2-0
Interface Mechanism
The interface mechanism works as follows:
The user writes a routine that performs the desired operation, using the routines
described in this manual to get data from the simulation environment and/or send data
back to it. Information about this routine is placed in a table in the file veriuser.c.
This information includes (at a minimum) the name of the user-supplied routine and the
name by which it will be known to Verilog. There is one entry in the table for each task
or function that the user wants to be able to invoke from a Verilog simulator. More than
one task or function can call the same programming language routine, with the
distinction between them made by a data value defined in the table and passed to the
routine automatically by the Verilog simulator.
To invoke the new tasks and functions from the Verilog description, the user references
them just as he would a built-in system task or function, such as $display or $time.
3.1
User-Supplied Routines
As described above, the user provides a routine that will be called when the new task
or function is invoked. This routine is known as the calltf routine.
The user can also provide several other routines, which are described below.
A routine that will be called when the new task or function is encountered during
compilation can be provided; it is optional. This routine will typically check the
correctness of arguments passed from Verilog, but it can also perform other chores.
This routine is known as the checktf routine.
Each routine that will be invoked as a function must have a routine that returns the
width (in bits) of the function return value. This routine is known as the sizetf
routine.
Another routine, known as the misctf routine, is optional. It is called for a variety of
reasons, and a reason flag is passed to it so it can determine why it was called. The
reasons are listed below, under Routine Arguments, and include input argument value
changes and disable. The availability of this routine makes the interface very powerful,
as it allows the user to set up tasks which are called asynchronously (just like
$monitor), and to disable the activity associated with them.
3.2
Routine Arguments
The user-supplied routines are always passed two arguments: ‘data’ and ‘reason’.
These are passed as the first and second arguments, respectively.
3.2.1
Data
The value that is passed as the ‘data’ argument is obtained from the table; it is defined
by the user when the table is filled in. This value can be used to allow several different
tasks and functions to use the same checktf, calltf, or misctf routines. To do
this, the table entries for the various tasks and functions would contain the same routine
names, but would have a different data value for each task or function.
3.2.2
Reason
The value for the ‘reason’ argument is defined as follows:
3.3
Supplied Files
Two files supplied with the Verilog system are used to link user program modules to
the Verilog system:
• veriuser.c
‘C’ code template and examples
• veriuser.h
‘C’ header file
The data associated with the user-supplied routines is inserted into the external table
‘veriusertfs’ normally declared in veriuser.c. This table is an array having the
structure as defined in the header file veriuser.h and described below. Each task
or function that can be invoked in Verilog source description has an entry in the array.
The file veriuser.h is included by veriuser.c and should not be edited by the
user.
3.3.1
Table of Tasks and Functions
A data type called t_tfcell is defined in veriuser.h. The fields of this structure
define a task or function so that the Verilog system knows about it and can call the right
routines upon invocation.
The file veriuser.c creates an array of t_tfcell structures and calls it
veriusertfs. The fields of this array are filled in by editing the file veriuser.c.
WARNING
DO NOT ATTEMPT TO CHANGE THE CONTENTS OF THE DATA
STRUCTURE BY ANY OTHER MEANS!
t_tfcell fields
The meaning of each field is defined below.
type
Defines entry to be a task or function by using the
values of ‘usertask,’ ‘userfunction,’ or
‘userrealfunction’ as defined in veriuser.h.
data
The value given here is passed as the first parameter
to ‘checktf’, ‘sizetf’, ‘calltf’, or ‘misctf’ (defined
below) when each is called. This component can be
useful when several user tasks or functions have just
slightly differing purposes, so that corresponding
routine pointers can point to the same routine
definitions, and the task or function can be
distinguished in the routines by the argument data
value.
checktf
Pointer to the user-supplied routine for checking the
parameters of the task or function statement. This
routine is called once for each task or function
reference in the source description, or in an
interactive command, during the compilation stage. A
value of 0 (null pointer) may be given if no routine is
to be supplied; however, it is recommended that the
parameters be checked for correctness.
sizetf
Pointer to the user-supplied routine that must return
3.4
A Simple Example
The following example illustrates how to use the interface. It is the simplest case
possible: only one routine is associated with the task (the calltf routine) and no data
is passed between Verilog and the routine.
3.4.1
User-Supplied Routine
The routine below is written in the C language. When it is called, it prints the string
“hello world” to the terminal. It is simply a C language routine; nothing special has
been done, and no special routines have been called.
hello()
{
printf(" hello world \n");
}
3.4.2
Table Entry
The entire veriuser.c file for the example is provided below. The text associated
with the examples normally provided with the Verilog system has been deleted for
clarity.
/* Filename: veriuser.c */
/* Verilog user tasks example */
#include "veriuser.h"
hello()
{
printf("hello world \n");
}
/
* Template table for defining user tas
ks and functions.
See file "veriuser.h" for structure definition
*/
s_tfcell veriusertfs[] =
{
{usertask, 0,
0, 0, hello, 0,
"$hello", 0},
/* add extra entries here */
{0} /* this line must always be last */
};
3.4.3
Task Invocation
Invocation of the new task is identical to invocation of any of the built-in system tasks,
such as $stop or $showscopes. When this description is simulated, it will print the
string “hello world”.
module test;
initial $hello;
endmodule
Figure 4-0
4
Table 4-0
Example 3-0
Utility Routines
Interaction between the Verilog system and the user’s routines is handled by a set of
routines that are supplied with the Verilog system. These routines are called in the user-
supplied routines to pass data in both directions across the Verilog/programming
language boundary. The type, arguments, and operation of each routine are detailed
below.
4.1
Call Instances
Most of these routines are in two forms: one dealing with the current call, or “instance,”
and another dealing with an instance other than the current one and referenced by an
instance pointer. The first routine described below gets the instance pointer of the
current instance so that it can be saved for later use. This feature is useful when routines
are related to each other; a typical example is a pair of routines where one is a setup
routine and another is a display routine. This pairing concept has been used extensively
in developing the graphical display mechanisms for Verilog (e.g., $setup_waves,
$display_waves) and it is expected that users will find this very useful. Another
example of the concept is a pair of routines where the first, a setup routine, prints a
header, and the second, a display routine, writes the data. The instance mechanism is
used to associate the list of strings passed to the setup routine with the list of variables
passed to the display routine.
The steps are as follows:
1. In the setup routine, save instance pointer by using the tf_getinstance
routine.
2. In the display routine, use tf_igetcstringp to get the string associated with
each parameter.
3. Use this data just as if it had been passed in to the display routine.
This mechanism eliminates the need to pass the same information to all the routines that
need it—later calls can use the data passed to earlier ones.
4.2
64-Bit Integer and Real Number Values
Some routines are provided in multiple forms:
• one form to deal with 32-bit parameter values that can be passed in one integer
• a second form to deal with 64-bit values, which must be passed in two integers
• and sometimes a third form to deal with real number values, which must be
passed as double-precision floating-point numbers
The routines that deal with 64-bit integer values are named using the name of the
corresponding 32-bit routine with the word long inserted—for example,
tf_gettime and tf_getlongtime. Similarly, routines that deal with real
number values are named using the name of the corresponding 32-bit routine with the
word real inserted—as in tf_setdelay and tf_setrealdelay.
4.3
Effect of Timescales on Utility Routines
By default, each of the following routines expresses its delay or time in the timescale
unit of the system task or function that calls the utility:
tf_setdelay
tf_isetdelay
tf_setlongdelay
tf_isetlongdelay
tf_strdelputp
tf_istrdelputp
tf_strlongdelputp
tf_istrlongdelputp
tf_strrealdelputp
tf_istrrealdelputp
tf_gettime
tf_getlongtime
tf_getnextlongtime
If, for example, a system task in a module with a timescale of nanoseconds calls
tf_setdelay(10), but the simulator is operating in picoseconds, tf_setdelay
automatically scales the delay by 1000 to 10,000 picoseconds.
4.4
Routine Definitions
This section describes each utility routine.
4.4.1
tf_getinstance
Purpose
get current instance pointer
Synopsis
char *tf_getinstance()
This routine returns a pointer that identifies the current instance of the task or function
that is being acted upon by the Verilog simulator. In the following sections, the
argument instance_p will always refer to this instance pointer.
tf_getinstance can be called during any of the reasons, saved by the user, and
used later in other calls to refer to the current instance. Most of the utility routines are
in two forms, one dealing with the current task or function instance, and the other
dealing with information about another instance, where the instance pointer was
obtained during a call to that other task or function. For example, the call
tf_inump(tf_getinstance()) is equivalent to the call tf_nump().
4.4.2
tf_nump
Purpose
get number of task or function parameters
Synopsis
int tf_nump()
int tf_inump(instance_p)
char *instance_p;
The routine tf_nump returns the number of parameters specified in the task or
function statement in the Verilog source description. The number returned is greater
than or equal to zero. tf_inump will return the number of parameters for a given
instance.
4.4.3
tf_typep
Purpose
get parameter type
Synopsis
int tf_typep(nparam)
int nparam;
int tf_itypep(nparam, instance_p)
int nparam;
char *instance_p;
The routine tf_typep is used for determining a given parameter’s type. The value
nparam must be a number specifying the parameter position, with 1 for the first
parameter, 2 for the second, etc. tf_itypep returns a parameter type for a given
instance.
For example, the statement
int itype=tf_typep(3)
examines the third parameter in the argument list, and sets itype to one of the values
shown below, depending on parameter type. If the third argument in the list is an
integer value which cannot be written to, the value tf_readonly is returned. These
return values, shown in the following list, are defined constants.
tf_nullparam
If the parameter is the null expression, i.e., where no
text has been given as the parameter, or if ’ nparam’
is out of range.
tf_string
If the parameter is a literal string.
tf_readonly
If the parameter is a value returning expression that
cannot be written to (i.e., an expression that would be
illegal as a left-hand-side construct in a procedural
assignment).
tf_readwrite
If the parameter is a value returning expression that
can be written to. Writable expressions are the left-
hand-side constructs in procedural assignments.
tf_readonlyreal
Same as tf_readonly except that the specified
parameter is a real value.
tf_readwritereal
Same as tf_readwrite except that the specified
4.4.4
tf_getp/tf_putp
Purpose
get parameter value
put parameter value
Synopsis
int tf_getp(nparam)
int nparam;
int tf_igetp(nparam, instance_p)
int nparam;
char *instance_p;
double tf_getrealp(nparam)
int nparam;
double tf_igetrealp(nparam, instance_p)
int nparam;
char *instance_p;
tf_putp(nparam, value)
int nparam;
int value;
tf_iputp(nparam, value, instance_p)
int nparam;
int value;
char instance_p;
tf_putrealp(nparam, value)
int nparam;
double value;
tf_iputrealp(nparam, value, instance_p)
int nparam;
double value;
char *instance_p;
int tf_getlongp(aof_highvalue, nparam)
int *aof_highvalue;
int nparam;
int tf_igetlongp(aof_highvalue, nparam, instance_p)
int *aof_highvalue;
int nparam;
char *instance_p;
int tf_putlongp(nparam, lowvalue, highvalue)
int nparam;
int lowvalue, highvalue;
int tf_iputlongp(nparam, lowvalue, highvalue, instance_p)
int nparam;
int lowvalue, highvalue;
char *instance_p;
The routines tf_getp and tf_getrealp return a value of the parameter specified
by nparam. The routines tf_igetp and tf_igetrealp return a parameter value
for a given instance. The difference between the real and ‘non-real’ routines is in the
value returned, as shown by the following example.
Assume that the fourth parameter in the argument list has a value of 9.6 (a real value).
Then,
In the first example, note that the int conversion rounds off the value of 9.6 to 10 (rather
than truncates to 9). In the second example, note that the real value must be declared
as a ‘double’ (not as a ‘float’).
If the parameter is a literal string, then the tf_getp routine returns a pointer to the
‘C’ type string (string terminated by a ‘\0’ character). If nparam is out of range or the
parameter is null, zero is returned.
The routine tf_getrealp cannot handle literal strings. Therefore, before calling
tf_getrealp, make sure the argument is not a literal string by calling tf_typep
to check its type.
The routine tf_putp writes the integer value to the parameter specified by nparam.
Similarly, the routine tf_putrealp writes the real value to the parameter specified
by nparam. The routines tf_iputp and tf_iputrealp write a parameter value
for a given instance. The parameter must be one that can be written. To check if it is,
use the tf_typep routine. You can write back the function return value by making
nparam equal to zero. If nparam is out of range or the parameter cannot be written
to, then nothing happens.
The routines tf_getlongp and tf_putlongp operate on 64-bit integer parameter
values. The tf_getlongp() routine returns both the least significant bits of the
value in the parameter lowvalue and the most significant bits in the parameter
highvalue.
Please note: When using the tf_putp and tf_putrealp routines to
write values to parameters, make sure that the data types of the arguments passed are
consistent with the data types required by the function called. There is no inherent data
type checking in C.
4.4.5
tf_strgetp
Purpose
get formatted parameter values
Synopsis
char *tf_strgetp(nparam, format_char)
int nparam;
char format_char;
char *tf_istrgetp(nparam, format_char, instance_p)
int nparam;
char format_char;
char *instance_p;
The string value returned will have the same form as output from the formatted output
task $display in terms of value lengths and value characters used. The length is of
arbitrary size (i.e. not limited to 32 bits as with the tf_getp routine), and unknown
and high-impedance values can be obtained.
The referenced parameter can be a string, in which case a pointer to the string will be
returned ( format_char is ignored in this case). A 0 pointer is returned for errors.
4.4.6
tf_exprinfo / tf_nodeinfo
Purpose
get expression information
get node information
Synopsis
These routines are for obtaining general information about a parameter indicated by
nparam. tf_exprinfo and tf_iexprinfo give information related to the
parameter expression where the information is stored in the C structure
t_tfexprinfo as defined in the file veriuser.h. tf_nodeinfo and
tf_inodeinfo give information related to a node (relevant only when a parameter
is writable), where the information is stored in the t_tfnodeinfo structure.
For all these routines the user must allocate space to hold the information before
making the call. For example the user could allocate the necessary space in the
following way:
{
s_tfexprinfo info;
tf_exprinfo(n, &info);
...
}
All four routines return the second argument, i.e. the pointer to the information
structure. If nparam is out of range, or some other error is found, then 0 is returned.
For every parameter there always exists expression information. For parameters that
are writable, node information also exists. Memory and strength manipulations can be
done only through node information. The following defines the components passed in
the expression information.
expr_type
One of the following values as defined in veriuser.h:
tf_nullparam
tf_string
tf_readonly(for ’int’)
tf_readonlyreal(for ’real’)
tf_readwrite(for ’int’)
tf_readwritereal(for ’real’)
tf_rwbitselect(bit-select)
tf_rwpartselect(part-select)
tf_rwmemselect(memory-select)
expr_value_p
If the expression type is not real, expr_value_p is a pointer to an array of
t_vecval structures that gives the resultant value of the expression. See below for
the definition of this structure.
real_value
If the expression type is real ( tf_readonlyreal or tf_readwritereal),
real_value will contain the value.
expr_string
If the expression is of type tf_string, expr_string points to the string.
expr_ngroups
If the expression type is not real, expr_ngroups indicates the number of groups for
the parameter expression value and determines the array size of the expr_value_p
value structure. If the expression type is real, expr_ngroups is zero.
expr_vec_size
If the expression type is not real, expr_vec_size indicates the total number of bits
in the array of expr_value_p value structures. If the expression type is real,
expr_vec_size is zero.
expr_sign
The sign of the expression: zero for unsigned, non-zero for signed.
node_type
A node_type is one of the following values as defined in veriuser.h:
tf_null_node - not a writable parameter
tf_reg_node - parameter references a register variable
tf_integer_node - parameter references an integer variable
tf_real_node - parameter references a real variable
tf_time_node - parameter references a time variable
tf_netvector_node - parameter references a vector net
tf_netscalar_node - parameter references a scalar net
tf_memory_node - parameter references a memory
node_value
A node_value is a union of pointers to value structures defining the current value
on the node referenced by the parameter. The union member accessed depends on
node_type. The union members are:
vecval_p - for tf_reg_node, tf_integer_node,tf_time_node,
and tf_netvector_node.
real_value_p - for tf_real_node
strengthval_p - for tf_netscalar_node
memoryval_p - for tf_memory_node
node_symbol
A node_symbol is a string pointer to the parameter’s identifier.
node_ngroups
If the node type is not real, node_ngroups indicates the number of groups for the
parameter nodevalue and is used to determine the array size of the
node_value.vecval_p value structure. If the node type is real, node_ngroups
is zero.
node_vec_size
If the node type is not real, node_vec_size indicates the total number of bits in the
array of node_value.vecval_p structure. If the expression type is real,
node_vec_size is zero.
node_sign
The sign of the node: zero for unsigned, non-zero for signed.
node_mem_size
Number of elements in node_value.memoryval_p structure.
The usual data structure for representing vector values is an array of the following
structure.
If the number of bits in the vector (defined by expr_vec_size or
node_vec_size) is less than or equal to 32, then there is only one group in the
array. For 33 to 64 bits, two groups are in the array, and so on. The number of groups
is also given by the value of expr_ngroups and node_ngroups. The components
avalbits and bvalbits hold the bit patterns making up the parameter’s value.
The least significant bit in the value is represented by the least significant bits in the
avalbits and bvalbits components, and so on up. The bit coding is as follows:
ab value
00 logic 0
10 logic 1
11 unknown
01 high impedance
Where strength0 gives the 0-strength bit pattern for the value, and strength1
gives the 1-strength bit pattern. See the section on logic strength modeling in the
reference manual for details about these bit patterns.
For node information only, when node_type is tf_memory_node then
node_value.memoryval_p points to a structure giving the total contents of the
memory. The structure is organized as follows
struct
{
char avalbits[node_ngroups];
char bvalbits[node_ngroups];
} memval[node_mem_size];
4.4.7
tf_asynchon / tf_asynchoff
Purpose
enable asynchronous calling
disable asynchronous calling
Synopsis
tf_asyncon()
tf_iasynchon(instance_p)
char *instance_p;
tf_asynchoff()
tf_iasynchoff(instance_p)
char *instance_p;
4.4.8
tf_synchronize
Purpose
synchronize to end of simulation time unit
Synopsis
tf_synchronize()
tf_isynchronize(instance_p)
char *instance_p;
4.4.9
tf_rosynchronize
Purpose
synchronize to end of simulation time slot
Synopsis
tf_rosynchronize()
tf_irosynchronize(instance_p)
char *instance_p;
These routines allow certain processing to be delayed until the end of the current
simulation time. The routine specified by misctf in the veriusertfs table is called with
a reason of reason_rosynch at the end of the current simulation time.
These routines are very similar to the tf_synchronize and tf_isynchronize
calls. The difference is that these calls guarantee that no new events at the current
simulation time will be created after processing routines called due to reason
reason_rosynch. Consequently, it is not possible to write output values or
generate new events during the misctf call with reason reason_rosynch. This
means that calls to routines such as tf_strdelputp and tf_setdelay are illegal
during processing of the misctf routine with reason reason_rosynch.
Please note: It is essential that these routines be used instead of the
tf_synchronize and tf_isynchronize calls when the
tf_getnextlongtime routine is being used.
4.4.10
tf_gettime
Purpose
get current simulation time
Synopsis
int tf_gettime()
int tf_getlongtime(aof_hightime)
int *aof_hightime;
4.4.11
tf_strgettime
Purpose
get current simulation time as a string
Synopsis
char *tf_strgettime()
Returns a pointer to a string which is the ASCII representation of the current simulation
time.
4.4.12
tf_gettimeunit
Purpose
get the timescale units of a module
Synopsis
int tf_gettimeunit()
int tf_igettimeunit(instance_p)
char *instance_p;
4.4.13
tf_gettimeprecision
Purpose
get the timescale precision of a module
Synopsis
int tf_gettimeprecision()
int tf_igettimeprecision(instance_p)
char *instance_p;
4.4.14
io_printf
Purpose
formatted print to standard output and log file
Synopsis
io_printf(format, arg1, ...)
char *format;
The routine io_printf places output to the standard output stream and to log file
output. It works in the same way as the standard C routine printf, except that a
maximum of 12 arguments are allowed.
4.4.15
tf_error
Purpose
report error
Synopsis
tf_error(format, arg1, ...)
4.4.16
tf_warning
Purpose
report warning
Synopsis
tf_warning(format, arg1, ...)
tf_warning gives a warning message compatible with the Verilog compiler. The
arguments work in the same way as with the io_printf routine, except that a
maximum of five arguments are allowed. Statement location information (file name and
line number of source statement) and the text “warning!” are appended to the message.
4.4.17
tf_message
Purpose
report error
Synopsis
tf_message(level, facility, code, message,
arg1,...arg5)
The tf_message utility routine allows an application to tell the Verilog simulator
to display error message information. This utility routine contains the following
required message string arguments: level, facility, code, and message.
The level field gives the class of information. There are five classes: ERR_ERROR,
ERR_MESSAGE, ERR_INTERNAL, ERR_SYSTEM, and ERR_WARNING.
Facility and code are string arguments that you specify. These string arguments
are printed in the Verilog simulator message syntax and should be kept to 6-10
characters in length. Message is the PLI message you want to display.
Your application can use up to a maximum of five variable arguments. These variable
arguments display information such as the variable name, file name, or operating
system name to the software tool that issues the message. There is no limit to the length
of the variable argument.
Whenever possible, the Verilog simulator displays the file name and line number of the
statement that triggers the error along with the statement itself before it displays the
information contained in these arguments.
If your application calls tf_message during an execution of the checktf routine
with the level set to ERR_ERROR, ERR_SYSTEM, or ERR_INTERNAL, the Verilog
simulator stops compiling your source description.
If you interactively enter a user-defined system task that invokes this routine with the
level set to ERR_ERROR, ERR_SYSTEM, or ERR_INTERNAL, the Verilog simulator
terminates that system task.
You do not need to include formatting characters such as \n, \t, \b, \f, or \r when
creating a message. The error handling unit automatically formats each message.
An example of tf_message follows in Section 4.4.18, tf_text.
4.4.18
tf_text
Purpose
stores error information
Synopsis
tf_text(message, arg1,...arg5)
The tf_text utility routine stores information about an error in a buffer. It allows
your application to store information about an error before it calls the tf_message
utility routine. Your application can call tf_text any number of times before it calls
tf_message .
When your application calls tf_message , the Verilog simulator displays the
information stored by tf_text before it displays the information in an application’s
call to tf_message . Each call to tf_message clears the buffer where
tf_text stores its information.
Your application can use a single message string argument and up to a maximum of five
variable arguments to store error information. These arguments can be any kind of
information you want to display in your message, such as the variable name, file name,
or operating system name. An example of this is argnum in Example 4-1. There is no
limit to the length of a message argument.
The error message created by the code in Example 4-1 is shown in Example 4-2.
Example 4-2: The printed message for the example in Example 4-1
4.4.19
tf_dostop
Purpose
enable interactive mode
Synopsis
tf_dostop()
The routine tf_dostop stops the simulation and puts the Verilog simulator into the
interactive mode exactly as if a $stop was encountered in a Verilog source
description.
4.4.20
tf_dofinish
Purpose
finish simulation
Synopsis
tf_dofinish()
4.4.21
tf_getcstringp
Purpose
get parameter value as a pointer to a C language string
Synopsis
char *tf_getcstringp(nparam)
int nparam;
4.4.22
tf_setdelay
Purpose
activate the misctf routine for the user task at a particular simulation time
Synopsis
int tf_setdelay(delay)
int delay;
int tf_setrealdelay(realdelay)
double realdelay;
4.4.23
tf_clearalldelays
Purpose
clear all scheduled reactivations
Synopsis
tf_clearalldelays()
tf_iclearalldelays(instance_p)
char *instance_p;
Clear all reactivation delays. Remove the effect of all previous tf_setdelay calls
for the given instance.
4.4.24
tf_strdelputp
Purpose
write value to parameter from string value specification
Synopsis
int tf_strdelputp(nparam, bitlength, format_char, value_p,
delay, delaytype)
int nparam;
int bitlength;
int format_char;
char *value_p;
int delay;
int delaytype;
Write a string value to the specified parameter with delay. Schedules an event on the
parameter in the Verilog model at a future simulation time. Both single and double
integer and real forms are available. The parameter bitlength defines the value size
in bits. Format_char defines the format of the value specified by value_p and
must be one of:
Delay must be greater than or equal to 0. The delaytype parameter is one of:
Inertial delays cause all scheduled events on the output parameter in the Verilog model
to be removed before scheduling a new event. Transport delays cause removal of events
that are scheduled for times later than the new event. Pure transport delays do not cause
any events to be removed before the new event is scheduled. Caution should be used
when using pure delays because the last event to be scheduled is not necessarily the last
one to occur.
Each delay assumes the timescale units specified for the module containing the current
system task call or the call referenced by the instance pointer (see Section 4.3).
Returns 0 if an error is detected, 1 if not.
4.4.25
tf_scale_longdelay / tf_scale_realdelay
Purpose
convert a long integer delay or double-precision floating-point delay to
internal simulation time units
Synopsis
void tf_scale_longdelay(instance_p, delay_lo,
delay_hi, aof_delay_lo, aof_delay_hi)
char *instance_p;
int delay_lo;
int delay_hi;
int *aof_delay_lo;
int *aof_delay_hi;
4.4.26
tf_unscale_longdelay / tf_unscale_realdelay
Purpose
convert a delay expressed in internal simulation time units to the timescale of
a particular module
Synopsis
void tf_unscale_longdelay(instance_p, delay_lo,
delay_hi, aof_delay_lo, aof_delay_hi)
char *instance_p;
int delay_lo;
int delay_hi;
int *aof_delay_lo;
int *aof_delay_hi;
These two routines take a long integer delay or a double-precision floating-point delay
expressed in internal simulation time units and convert it into the timescale units of the
module that contains the system task or function referenced by the instance pointer. The
parameters beginning with aof contain the address of the converted delay returned by
the routine; that is, integer parameters should be passed to this routine using ‘&’.
4.4.27
Parameter Value Change Flags
Parameter Value Change (pvc) flags are used to indicate whether a particular parameter
has changed value. Each parameter has two pvc flags: an old pvc flag which is set by
Verilog when the change occurs, and a saved pvc flag which is controlled by the user.
Typical usage of these flags is for the user to move the old flags to the saved flags by
the call tf_movepvc_flag(-1), before anything else is done. The saved flags are
then available for later use.
Routines that use the pvc flags are:
tf_copypvc_flag(), tf_icopypvc_flag()
tf_movepvc_flag(), tf_imovepvc_flag()
tf_testpvc_flag(), tf_itestpvc_flag()
tf_getpchange(), tf_igetpchange()
Please note: pvc flags will not be set until tf_asynchon is called.
4.4.28
tf_copypvc_flag
Purpose
copy parameter value change flag
Synopsis
int tf_copypvc_flag(nparam)
int nparam;
Copy pvc flag to saved flag. Returns flag that was copied. If nparam is -1, then all
parameters are copied and the logical OR of all saved flags is returned.
4.4.29
tf_movepvc_flag
Purpose
move parameter value change flag
Synopsis
int tf_movepvc_flag(nparam)
int nparam;
Moves pvc flag to saved flag and clears old flag. Returns flag that was moved. If
nparam is -1, then all parameters are moved and the logical OR of all moved flags is
returned.
4.4.30
tf_testpvc_flag
Purpose
test parameter value change flag
Synopsis
int tf_testpvc_flag(nparam)
int nparam;
Returns saved pvc flag for a given instance. If nparam is -1, then all parameters are
tested and the logical OR of all saved flags is returned.
4.4.31
tf_getpchange
Purpose
get number of parameter that changed value
Synopsis
int tf_getpchange(nparam)
int nparam;
Gets the number of the next parameter, with number greater than nparam, that
changed value. The nparam argument must be 0 the first time this routine is called
within a given user routine invocation. Returns the parameter number if there is a
change in a parameter with a number greater than nparam. Returns 0 if there are no
changes in parameters greater than nparam or if an error is detected. This routine uses
the saved pvc flags, so it is necessary to execute tf_movepvc_flag(-1) first.
4.4.32
Work Areas
Work areas allow storage of data associated with specific instances of user task
invocations. Routines are provided to store and retrieve pointers. These pointers should
point to the data structures which represent data associated with the user task. It is up
to the user to allocate the memory required and save the pointers from one invocation
to the next.
4.4.33
tf_setworkarea
Purpose
store work area pointer
Synopsis
void tf_setworkarea(workarea)
char *workarea;
Store a given work area pointer into cell. The parameter workarea_p is any memory
pointer.
4.4.34
tf_getworkarea
Purpose
get work area pointer
Synopsis
char *tf_getworkarea()
char *tf_igetworkarea(instance_p)
char *instance_p;
4.4.35
tf_setroutine
Purpose
store routine pointer
Synopsis
tf_setroutine(routine)
char (*routine)();
tf_isetroutine(routine, instance_p)
char (*routine)();
char *instance_p;
4.4.36
tf_getroutine
Purpose
get routine pointer
Synopsis
char *tf_getroutine()
char *tf_igetroutine(instance_p)
char *instance_p;
4.4.37
tf_settflist
Purpose
store user task/function instance pointer
Synopsis
tf_settflist(tflist)
char *tflist;
tf_isettflist(other_instance_p, instance_p)
char *other_instance_p;
char *instance_p;
4.4.38
tf_gettflist
Purpose
get user task/function instance pointer
Synopsis
char *tf_gettflist()
char *tf_igettflist(instance_p)
char *instance_p;
Get a task or function instance pointer that was stored using tf_settflist.
4.4.39
tf_mipname
Purpose
get module instance path name as a string
Synopsis
char *tf_mipname()
char *tf_imipname(instance_p)
char *instance_p;
Gets a module instance path name. Returns a string that is the Verilog-HDL
hierarchical path name to the module containing the call to the user task or function.
Please note: If this string is needed across multiple calls to the user task, the
string value should be stored or tf_mipname should be called in each invocation.
4.4.40
tf_ispname
Purpose
get scope path name as a string
Synopsis
char *tf_spname()
char *tf_ispname(instance_p)
char *instance_p;
Gets a scope path name. Returns a string which is the Verilog-HDL hierarchical path
name to the scope containing the call to the user task or function.
4.4.41
tf_sizep
Purpose
get bit length of a parameter
Synopsis
int tf_sizep(nparam)
int nparam;
If the parameter is not real, tf_sizep (or tf_isizep) returns the value size of the
parameter. The return value is an integer which indicates the length of the parameter
value in bits.
If the parameter is a literal string, tf_sizep returns the string length.
If the parameter is real or if an error is detected, tf_sizep (or tf_isizep) returns
a zero.
4.4.42
io_mcdprintf
Purpose
write to multiple-channel descriptor files
Synopsis
io_mcdprintf(multi_chann_desc, format, arg1, ...)
int multi_chann_desc;
char *format;
Similar to io_printf but writes to the files opened using $fopen. The files must
have been previously opened from a Verilog description. The parameter
multi_chann_desc is an integer with the same meaning as the multi-channel
descriptor used with $fdisplay and related system tasks.
4.4.43
mc_scan_plusargs
Purpose
scan command line plus (+) options
Synopsis
char *mc_scan_plusargs(startarg)
char *startarg;
Scans all command arguments and matches given string to a plus argument. Returns
null if startarg is not found. If startarg is found, then returns remaining part of
command argument (e.g., if the argument string is “ +siz64”, and startarg is
“ siz”, then “ 64” is returned). If there is no remaining part of a found plus argument,
then a pointer to the C string null terminator is returned. The match is case sensitive.
4.4.44
tf_getnextlongtime
Purpose
get next time at which a simulation event is scheduled
Synopsis
int tf_getnextlongtime(aof_lowtime, aof_hightime)
int *aof_lowtime, *aof_hightime;
Assigns the double time of the next simulation event to aof_lowtime and
aof_hightime. If not called in read-only synchronize mode ( misctf call with
reason_rosynch), then the current time is always assigned. The time is expressed
in the timescale units of the system task or function that calls the utility (see
Section 4.3).
The routine returns one of the following:
0 for ok
1 for no more future events to execute - assigning 0 time.
2 for not in read-only synchronize mode - assigning current time.
Appendix A
The Contents of acc_user.h
/*** File acc_user.c ***/
/*** This file is to be included in files which call access routines ***/
#define ACCUSERH 1
/**********************************************************************/
/*** General constant definitions ***/
#ifndef ACCH
#endif
/**********************************************************************/
/*** Type and configuration constant definitions ***/
#define accModule 20
#define accScope 21
#define accNet 25
#define accReg 30
#define accRegister 30
#define accPort 35
#define accTerminal 45
#define accInputTerminal 46
#define accOutputTerminal 47
#define accInoutTerminal 48
#define accCombPrim 140
#define accSeqPrim 142
/* acc_configure() parameters */
#define accPathDelayCount 1
#define accPathDelimStr 2
#define accDisplayErrors 3
#define accDefaultAttr0 4
#define accToHiZDelay 5
#define accEnableArgs 6
#define accSpecitemScope 7
#define accDisplayWarnings 8
#define accWarnNestedLoconn 9
#define accWarnNestedHiconn 10
#define accDevelopmentVersion 11
#define accMinMultiplier 12
#define accTypMultiplier 13
#define accMaxMultiplier 14
#define accAttrDelimStr 15
#define accDelayCount 16
#define accMapToMipd 17
#define accDelayArrays 18
#define accMinTypMaxDelays 19
#define accUserErrorString 20
/* Product types */
#define accVerilog 1
/* Version defines */
#define accVersion15Beta 1
#define accVersion15a 2
#define accVersion15b 3
#define accVersion15b1 4
#define accVersion15b2Beta 5
#define accVersion15b2 6
#define accVersion15b3 7
#define accVersion15b4 8
#define accVersion15b5 9
#define accVersion15cBeta 12
#define accVersion15c 16
#define accVersion15c03 20
#define accVersion15c04 21
#define accVersion15c10 24
#define accVersion15c30 28
#define accVersion15c40 32
#define accVersion15c41 33
#define accVersion16Beta 36
#define accVersion16Beta2 37
#define accVersion16Beta3 38
#define accVersion16Beta4 39
#define accVersion16 40
#define accVersion161 41
#define accVersion16aBeta 42
#define accVersion16a 44
#define accVersion16b 48
#define accVersionLatest accVersion16aBeta
/* Delay modes */
#define accDelayModeNone 0
#define accDelayModePath 1
#define accDelayModeDistrib 2
#define accDelayModeUnit 3
#define accDelayModeZero 4
/*****************************
** typedefs for time structure*/
/* t_acc_time types */
#define accTime 1 /* timescaled time */
#define accSimTime 2 /* internal simulation time */
#define accRealTime 3 /* timescaled real time */
/******************************************
** typedefs and defines for acc_set_value()*/
/* t_setval_delay types */
#define accNoDelay 0
#define accInertialDelay 1
#define accTransportDelay 2
#define accPureTransportDelay 3
/* t_setval_value fromats */
#define accBinStrVal 1
#define accOctStrVal 2
#define accDecStrVal 3
#define accHexStrVal 4
#define accScalarVal 5
#define accIntVal 6
#define accRealVal 7
#define accStringVal 8
#define accCompactVal 9
/* scalar values */
#define acc0 0
#define acc1 1
#define accX 2
#define accZ 3
/**********************************************************************/
/*
* includes for Value Change Link
*/
#define logic_value_change 1
#define strength_value_change 2
#define real_value_change 3
#define vector_value_change 4
#define event_value_change 5
#define integer_value_change 6
#define time_value_change 7
#define sregister_value_change 8
#define vregister_value_change 9
#define realtime_value_change 10
#define compact_value_change 11
/* logic values */
#define vcl0 acc0
#define vcl1 acc1
#define vclX accX
#define vclZ accZ
/**********************************************************************/
/*** includes for the location structure ***/
/* structure that stores location */
typedef struct t_location {
int line_no;
char *filename;
} s_location, *p_location;
/**********************************************************************/
/*** includes for the time callbacks ***/
#define reason_begin_of_simtime 1
#define reason_end_of_simtime 2
/**********************************************************************/
/*
* include information for stability checks
*/
/**********************************************************************/
/*** Routine declarations ***/
#ifndef ACCH
/* Handle routines */
handle acc_handle_object();
handle acc_handle_port();
handle acc_handle_terminal();
handle acc_handle_parent();
handle acc_handle_conn();
handle acc_handle_tchk();
handle acc_handle_pathout();
handle acc_handle_pathin();
handle acc_handle_tchkarg1();
handle acc_handle_tchkarg2();
handle acc_handle_modpath();
handle acc_handle_path();
handle acc_handle_loconn();
handle acc_handle_hiconn();
handle acc_handle_datapath();
handle acc_handle_condition();
handle acc_handle_by_name();
handle acc_handle_scope();
/* Nexts routines */
handle acc_next_terminal();
handle acc_next_port();
handle acc_next_child();
handle acc_next_driver();
handle acc_next_load();
handle acc_next_primitive();
handle acc_next_net();
handle acc_next_topmod();
handle acc_next_loconn();
handle acc_next_hiconn();
handle acc_next_modpath();
handle acc_next_path(); /* alias for acc_next_modpath */
handle acc_next_cell();
handle acc_next_cell_load();
handle acc_next_tchk();
handle acc_next_parameter();
handle acc_next_specparam();
handle acc_next_portout();
handle acc_next_bit();
handle acc_next();
handle acc_next_input();
handle acc_next_output();
/* Fetch routines */
char *acc_fetch_value();
char *acc_fetch_name();
char *acc_fetch_fullname();
char *acc_fetch_defname();
int acc_fetch_type();
int acc_fetch_fulltype();
char *acc_fetch_type_str();
int acc_fetch_index();
int acc_fetch_direction();
bool acc_fetch_delays();
double acc_fetch_paramval();
double acc_fetch_attribute();
int acc_fetch_polarity();
int acc_fetch_paramtype();
int acc_fetch_size();
int acc_fetch_range();
int acc_fetch_edge();
void acc_fetch_location();
/* Modify routines */
bool acc_replace_delays();
bool acc_append_delays();
/* Utility routines */
bool acc_initialize();
void acc_close();
bool acc_configure();
int acc_count();
handle *acc_collect();
char *acc_version();
void acc_free();
handle acc_handle_tfarg();
double acc_fetch_tfarg();
bool acc_compare_handles();
char *acc_set_scope();
int acc_release_object();
bool acc_object_of_type();
bool acc_object_in_typelist();
int acc_set_value();
#endif
/**********************************************************************/
acc_fetch_defname 2-5, 2-10, 2-76 acc_fetch_value 2-12, 2-13, 2-15, 2-131 to 2-133
syntax 2-76 formatting logic and strength values 2-131 to 2-
132
acc_fetch_delays 2-7, 2-8, 2-9, 2-10, 2-14, 2-77 to 2- logic values 2-131
87 scalar or vector nets 2-131
effect of timescales 2-84 syntax 2-131
fetching delays for inter-module paths 2-84
fetching delays for module paths 2-81 to 2-83 acc_free 2-134 to 2-135
fetching MIPDs 2-84 compared to acc_close 2-134
syntax 2-77 syntax 2-134
accPathDelayCount 2-59 D
accPathDelimStr 2-60, 2-71 data argument 3-2
bits of a port
access routines for 2-7
E
buffer reset 2-22 to 2-23 edge group constants 2-163
retrieving net connected to cell’s second setup fetching delays for inter-module paths 2-84
check argument 2-172
retrieving rise, fall, turn-off delays of module fetching delays for MIPDs 2-84
paths 2-85 fetching delays for module paths 2-81 to 2-83
scanning all cells below a module for setup
timing checks 2-217 format specifications for tf_strgetp/tf_istrgetp 4-10
scanning all nets in a module 2-183, 2-206, 2-
222 full hierarchical name 2-93
scanning all parameters in a module 2-210 fulltype
scanning all specparams in a module 2-215 compared to type 2-95 to 2-102, 2-124 to 2-127
setting a scope and getting a handle 2-137
setting accDefaultAttr0 2-61
setting accDevelopmentVersion 2-62
H
setting accDisplayErrors 2-63 handle routines 2-3, 2-27 to 2-28
setting accDisplayWarnings 2-64
setting accEnableArgs 2-65 handles 2-3
setting accPathDelayCount 2-66 declaring variables for 2-3
setting accToHiZDelay 2-67
setting scope for acc_handle_object 2-243, 2- header files
245 acc_user.h 2-16
using acc_compare_handles to compare two hierarchically higher connection 2-195
handles 2-54
using acc_fetch_edge to get the string that hierarchically lower connection 2-202
corresponds to an edge specifier 2-91
using acc_fetch_location to find the file name I
and line number for an object 2-108
using acc_fetch_polarity to get the polarity of a index 2-105, 2-157, 2-173
path 2-118
using acc_fetch_tfarg to return the value of initializing access routines 2-16
arguments 2-123 instance pointer 4-3
using strcpy with access routines 2-24
using the Programming Language Interface inter-module paths
mechanism 3-5 to 3-6 access routines for 2-9
validating system task argument 2-64 fetching delays for 2-84
replacing delays for 2-236
exiting access routines 2-16
io_mcdprintf 4-51
expr_ngroups 4-12
io_printf 4-22
expr_sign 4-12
expr_string 4-12 M
expr_type 4-12 mc_scan_plusargs 4-52
nets S
access routines for 2-12
setting default value for acc_fetch_attribute 2-61
next routines 2-3, 2-30 to 2-33
compared to acc_collect 2-51 setting delays for module paths 2-41 to 2-43
node_vec_size 4-13 T
t_tfcell data structure 3-3 to 3-5
P 0 value in field 3-5
parameter value change flags 4-36 calltf field 3-4
checktf field 3-4
parameters data field 3-3
access routines for 2-13 forwref field 3-4
data types 2-112, 2-114 misctf field 3-4
sizetf field 3-4
tf_setlongdelay 4-30
U 16
to test parameter value change flags 4-39
using access routines 2-16 to 2-17 to write string value specifications to parameters
4-32 to 4-33
utility routines 2-34, 4-1
to "get" a parameter value 4-7 to 4-9
to "get" module instance path names 4-48
V
to "get" routine pointers 4-45 Value Change Link (VCL) 2-35, 2-176, 2-186, 2-
to "get" system task/function instance pointers 247 to 2-252
4-47 VCL access routines 2-35, 2-247 to 2-252
to "get" work area pointers 4-43
to "put" a parameter value 4-7 to 4-9 veriuser.c 2-17, 3-1, 3-3, 3-5
to clear scheduled reactivations 4-31
to convert delays to a module’s timescale 4-35 veriuser.h 3-2, 3-3
to convert delays to simulation time units 4-34 veriusertfs data structure 3-3, 3-3 to 3-5
to copy parameter value change flags 4-37 0 value in field 3-5
to disable asynchronous calling 4-15 calltf field 3-4
to enable asynchronous calling 4-15 checktf field 3-4
to enter interactive mode 4-27 data field 3-3
to finish simulation 4-28 forwref field 3-4
to get a module’s timescale precision 4-21 misctf field 3-4
to get a module’s timescale units 4-20 sizetf field 3-4
to get bit length of a parameter 4-50 tfname field 3-4
to get current simulation time 4-18
to get current simulation time as a string 4-19
to get next time of scheduled simulation events
W
4-53 work areas 4-41
to get number of parameter that changed value
4-40
to get pointers to C language strings 4-29
to get scope path names 4-49
to get the type of a parameter 4-5 to 4-6
to identify the current instance of a task or
function 4-3
to obtain formatted parameter values 4-10
to obtain information about parameters 4-
12 to 4-14
to obtain the number of task or function
parameters 4-4
to print formatted data to standard output and log
file 4-22
to reactivate user tasks 4-30
to report errors 4-23, 4-25
to report warnings 4-24
to scan command line plus options 4-52
to store error information 4-26
to store routine pointers 4-44
to store system task/function instance pointers 4-
46
to store work area pointers 4-42
to synchronize to end of simulation time slot 4-
17
to synchronize to end of simulation time unit 4-