quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif 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. Library functions defined in PLI 1.0 perform a wide variety of operations on the parameters passed. The system call is used to do a simulation synchronization or to implement conditional program breakpoints.

   

space.gif

These routines are also called Utility routines. Most of them are in two forms: one dealing with the current call, or instance; another dealing with an instance other than the current one and referenced by an instance pointer.

   

space.gif

  ../images/main/bullet_star_pink.gif Classification of Utility Routines
   

space.gif

Routine

Description

tf_getp()

Get integer value of a task or function argument (parameter) for the current instance.

tf_putp()

Passes a 32-bit integer value to an argument of the current task or function.

tf_getrealp()

Get real value of a task or function argument for the current instance.

tf_putrealp()

Passes a 64-bit floating point value to an argument of the current task or function.

tf_getlongp()

Get long argument value (64 bits) for the current instance.

tf_putlongp()

Passes a 64-bit integer argument value to the current instance of a task or function.

tf_strgetp()

Get formatted argument values.

tf_getcstringp()

Get a parameter value as a character string.

tf_strdelputp()

Write a value to an argument with the specified delay, where the write value is specified as a character string.

tf_strlongdelputp()

Write value to an argument with specified long (64-bit) delay, where the write value is specified as a character string.

tf_strrealdelputp()

Write value to an argument with specified real value delay, where the write value is specified as a character string.

tf_copypvc_flag()

Copy parameter value change flag

tf_movepvc_flag()

Move argument value change flag.

tf_testpvc_flag()

Test argument value change flag for the current task/function instance.

tf_getpchange()

Get number of the next argument that changed value in the current task or function instance.

tf_gettime()

Get the current simulation time.

tf_getlongtime()

Gets current simulation time as a 64-bit integer value, in the timescale of the calling task or function.

tf_getrealtime()

Get the current simulation time scaled to the calling module's timescale.

tf_strgettime()

Get current simulation time as a character string.

tf_gettimeunit()

Get the timescale units for the module that contains the current task call.

tf_gettimeprecision()

Get the timescale precision of the module that contains the current task call.

tf_synchronize()

Synchronize processing of the current system task or function arguments.

tf_rosynchronize()

Synchronize processing of the current system task or function arguments to the end of the current time slot with event generation suppressed.

tf_getnextlongtime()

Get the time of the next scheduled simulation event.

tf_setdelay()

Reactivate a user task at a particular integer simulation time.

tf_setlongdelay()

Reactivate a user task at a particular simulation time specified by a 64-bit integer.

tf_setrealdelay()

Activate a user task at a particular simulation time.

tf_clearalldelays()

Clear all scheduled reactivation delays.

io_printf

Print a formatted message to the output channel of the software product that invoked the PLI application and to a log file.

io_mcdprintf()

Write a formatted message to one or more files.

tf_warning()

Report a warning.

tf_error()

Report an error.

tf_text()

Stores error information for later display by tf_message.

tf_message()

Reports user-generated error message in standard error-message syntax.

tf_getinstance()

Get current instance pointer.

tf_mipname()

Get hierarchical path name of the current module instance.

tf_spname()

Get a scope's hierarchical path name as a string.

tf_setworkarea()

Store a work area pointer for the current user task/function instance in a cell.

tf_getworkarea()

Get the work area pointer stored by the routine tf_setworkarea().

tf_nump()

Get number of arguments in the argument list of the current task or function instance.

tf_typep()

Get data type of an argument of the current task or function.

tf_sizep()

Get size of an argument of the current task/function instance.

tf_dostop()

Enable interactive mode.

tf_dofinish()

Finish simulation.

mc_scan_plusargs()

Get command line plus (+) options.

tf_compare_long()

Compare two 64-bit integer values.

tf_add_long()

Add two 64-bit integer values.

tf_subtract_long()

Subtract one 64-bit integer value from another.

tf_multiply_long()

Multiply two 64 bit integer values.

tf_divide_long()

Divide two 64-bit integer values.

tf_long_to_real()

Convert a long integer to a real (double-precision floating point) number.

tf_longtime_tostr()

Convert 64-bit integer time value to string.

tf_real_tf_long()

Convert a real (double precision floating point) number to a long (64-bit) integer.

tf_write_save()

Append a block of data to the save file.

tf_read_restart()

Get a block of data from a previously written save file.

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Other Useful functions

Other than acc_* and tf_* routines, simulators provide functions as listed below.

   

space.gif

  • veriusertfs
  • endofcompile_routines
  • err_intercept
   

space.gif

  ../images/main/bullet_star_pink.gif veriusertfs

For all simulators other than VCS, veriusertfs should be provided. The veriusertfs array is a table that the PLI uses to associate Verilog Simulator system tasks or functions with user-written applications. The table below shows the fields in the array that you fill in for each new system task or function you wish to create. The fields appear in the array in the order shown.

   

space.gif

Field

Description

type

Keyword that indicates whether the routine is a system task or function; usertask defines a system task or userfunction defines a system function that can return a user-defined value or userrealfunction defines a system function that returns a real value

data

Data argument (0 means do not pass a data argument).

checktf

Pointer to an optional user-supplied routine that checks parameters of the system task or function (0 means no checktf routine).

sizetf

Pointer to an user-supplied routine that returns the size in bits of the value returned by a system function (0 means no sizetf routine).

calltf

Pointer to an user-supplied application -- the main routine that is called when the Veritool executes the system task or function during simulation (0 means no calltf routine).

misctf

Pointer to optional miscellaneous routine (0 means no misctf routine).

$tfname

Quoted literal string defining the name of the system task or function; $ must be the first character, followed by any combination of letters, numbers and underscore (_) characters.

   

space.gif

  ../images/main/bullet_star_pink.gif endofcompile_routines

This data structure, as the name suggests, can be used for declaring functions that will be invoked at the end of the simulation. The present example does not need it. Nonetheless there has to be a default definition as shown below.

   

space.gif

int (*endofcompile_routines[])() ={0};

   

space.gif

  ../images/main/bullet_star_pink.gif err_intercept

This function, which returns either true or false (i.e. a boolean type), can be used to enhance the error detection mechanism of the code and can be ignored for small applications. A typical example of this routine would be as shown below.

   

space.gif

bool err_intercept(level, facility,code)

int level; char * facility; char *code;

{ return (true); }

   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com