Table of Contents
VERILOG PLI REFERENCE GUIDE ..............................................................6
TF utility routines ................................................................................................................ 6
ACC access routines .......................................................................................................... 6
USING THE VERILOG PLI .............................................................................8
Registering PLI applications.............................................................................................. 8
Building and linking PLI applications to Active-HDL Simulator..................................... 8
TF UTILITY ROUTINES................................................................................10
io_printf()............................................................................................................10
mc_scan_plusargs()...........................................................................................11
io_mcdprintf().....................................................................................................12
tf_add_long()......................................................................................................13
tf_asynchoff(); tf_iasynchoff().............................................................................15
tf_asynchon(); tf_iasynchon().............................................................................16
tf_clearalldelays(); tf_iclearalldelays() ................................................................17
tf_compare_long()..............................................................................................18
tf_copypvc_flag(); tf_icopypvc_flag()..................................................................20
tf_divide_long() ..................................................................................................21
tf_dofinish()........................................................................................................22
tf_dostop()..........................................................................................................23
tf_error().............................................................................................................24
tf_evaluatep(); tf_ievaluatep().............................................................................25
tf_exprinfo(); tf_iexprinfo() ..................................................................................26
tf_getcstringp(); tf_igetcstringp();........................................................................27
tf_getinstance() ..................................................................................................28
tf_getlongp(); tf_igetlongp() ................................................................................29
tf_getlongtime(); tf_igetlongtime();......................................................................31
tf_getnextlongtime() ...........................................................................................32
tf_getp(); tf_igetp() .............................................................................................33
tf_getpchange(); tf_igetpchange() ......................................................................34
tf_getrealp(); tf_igetrealp()..................................................................................36
tf_getrealtime(); tf_igetrealtime(); .......................................................................37
tf_gettime(); tf_igettime()....................................................................................38
tf_gettimeprecision(); tf_igettimeprecision()........................................................39
tf_gettimeunit(); tf_igettimeunit().........................................................................41
1
tf_getworkarea(); tf_igetworkarea() ....................................................................43
tf_long_to_real().................................................................................................45
tf_longtime_tostr()..............................................................................................46
tf_message()......................................................................................................47
tf_mipname(); tf_imipname() ..............................................................................48
tf_movepvc_flag(); tf_imovepvc_flag()................................................................49
tf_multiply_long()................................................................................................50
tf_nodeinfo(); tf_inodeinfo() ................................................................................51
tf_nump(); tf_inump() .........................................................................................52
tf_propagatep(); tf_ipropagatep() .......................................................................53
tf_putlongp(); tf_iputlongp() ................................................................................54
tf_putp(); tf_iputp() .............................................................................................55
tf_putrealp(); tf_iputrealp()..................................................................................56
tf_read_restart() .................................................................................................57
tf_real_to_long().................................................................................................58
tf_rosynchronize(); tf_irosynchronize() ...............................................................59
tf_scale_longdelay()...........................................................................................60
tf_scale_realdelay()............................................................................................61
tf_setdelay(); tf_isetdelay().................................................................................62
tf_setlongdelay(); tf_isetlongdelay()....................................................................64
tf_setrealdelay(); tf_isetrealdelay() .....................................................................65
tf_setworkarea(); tf_isetworkarea().....................................................................66
tf_sizep(); tf_isizep()...........................................................................................67
tf_spname(); tf_ispname() ..................................................................................68
tf_strdelputp(); tf_istrdelputp() ............................................................................69
tf_strgetp(); tf_istrgetp()......................................................................................71
tf_strgettime().....................................................................................................73
tf_strlongdelputp(); tf_istrlongdelputp()...............................................................74
tf_strrealdelputp(); tf_istrrealdelputp() ................................................................76
tf_subtract_long()...............................................................................................78
tf_synchronize(); tf_isynchronize()......................................................................79
tf_testpvc_flag(); tf_itestpvc_flag() .....................................................................80
tf_text() ..............................................................................................................81
tf_typep(); tf_itypep()..........................................................................................82
tf_unscale_longdelay().......................................................................................84
tf_unscale_realdelay()........................................................................................85
tf_warning()........................................................................................................86
2
tf_write_save() ...................................................................................................87
ACC ACCESS ROUTINES...........................................................................88
acc_append_delays().........................................................................................88
acc_append_pulsere() .......................................................................................89
acc_close() ........................................................................................................90
acc_collect().......................................................................................................91
acc_compare_handles().....................................................................................92
acc_configure() ..................................................................................................93
acc_count()........................................................................................................94
acc_fetch_argc() ................................................................................................95
acc_fetch_argv() ................................................................................................96
acc_fetch_attribute() ..........................................................................................97
acc_fetch_attribute_int().....................................................................................98
acc_fetch_attribute_str() ....................................................................................99
acc_fetch_defname() .......................................................................................100
acc_fetch_delay_mode()..................................................................................101
acc_fetch_delays()...........................................................................................102
acc_fetch_direction()........................................................................................103
acc_fetch_edge() .............................................................................................104
acc_fetch_fullname()........................................................................................105
acc_fetch_fulltype()..........................................................................................106
acc_fetch_index().............................................................................................107
acc_fetch_location().........................................................................................108
acc_fetch_name() ............................................................................................109
acc_fetch_paramtype() ....................................................................................110
acc_fetch_paramval().......................................................................................111
acc_fetch_polarity()..........................................................................................112
acc_fetch_precision().......................................................................................113
acc_fetch_pulsere() .........................................................................................114
acc_fetch_range()............................................................................................115
acc_fetch_size()...............................................................................................116
acc_fetch_tfarg()..............................................................................................117
acc_fetch_itfarg() .............................................................................................118
acc_fetch_tfarg_int() ........................................................................................119
acc_fetch_itfarg_int() .......................................................................................120
acc_fetch_tfarg_str() ........................................................................................121
acc_fetch_itfarg_str() .......................................................................................122
3
acc_fetch_timescale_info() ..............................................................................123
acc_fetch_type() ..............................................................................................124
acc_fetch_type_str() ........................................................................................125
acc_fetch_value().............................................................................................126
acc_free().........................................................................................................127
acc_handle_by_name()....................................................................................128
acc_handle_calling_mod_m() ..........................................................................130
acc_handle_condition()....................................................................................131
acc_handle_conn() ..........................................................................................132
acc_handle_datapath() ....................................................................................133
acc_handle_hiconn()........................................................................................134
acc_handle_interactive_scope().......................................................................135
acc_handle_itfarg() ..........................................................................................136
acc_handle_loconn()........................................................................................137
acc_handle_modpath() ....................................................................................138
acc_handle_notifier() .......................................................................................139
acc_handle_object().........................................................................................140
acc_handle_parent() ........................................................................................142
acc_handle_path() ...........................................................................................143
acc_handle_pathin() ........................................................................................144
acc_handle_pathout() ......................................................................................145
acc_handle_port()............................................................................................146
acc_handle_scope().........................................................................................147
acc_handle_simulated_net() ............................................................................148
acc_handle_tchk()............................................................................................149
acc_handle_tchkarg1().....................................................................................150
acc_handle_tchkarg2().....................................................................................151
acc_handle_terminal()......................................................................................152
acc_handle_tfarg() ...........................................................................................153
acc_handle_tfinst()...........................................................................................154
acc_initialize() ..................................................................................................155
acc_next()........................................................................................................156
acc_next_bit() ..................................................................................................157
acc_next_cell().................................................................................................158
acc_next_cell_load() ........................................................................................159
acc_next_child()...............................................................................................160
acc_next_driver() .............................................................................................161
4
acc_next_hiconn()............................................................................................162
acc_next_input() ..............................................................................................163
acc_next_load() ...............................................................................................164
acc_next_loconn()............................................................................................165
acc_next_modpath() ........................................................................................166
acc_next_net() .................................................................................................167
acc_next_output() ............................................................................................168
acc_next_parameter()......................................................................................169
acc_next_port()................................................................................................170
acc_next_portout() ...........................................................................................171
acc_next_primitive().........................................................................................172
acc_next_scope().............................................................................................173
acc_next_specparam().....................................................................................174
acc_next_tchk()................................................................................................175
acc_next_terminal() .........................................................................................176
acc_next_topmod() ..........................................................................................177
acc_object_in_typelist()....................................................................................178
acc_object_of_type()........................................................................................179
acc_product_type() ..........................................................................................180
acc_product_version()......................................................................................181
acc_release_object()........................................................................................182
acc_replace_delays().......................................................................................183
acc_replace_pulsere()......................................................................................184
acc_reset_buffer()............................................................................................185
acc_set_interactive_scope().............................................................................186
acc_set_pulsere() ............................................................................................187
acc_set_scope()...............................................................................................188
acc_set_value()................................................................................................189
acc_vcl_add() ..................................................................................................191
acc_vcl_delete()...............................................................................................192
acc_version() ...................................................................................................193
5
Verilog PLI Reference Guide
TF utility routines
io_mcdprintf()
io_printf()
mc_scan_plusargs()
tf_add_long()
tf_asynchoff()
tf_iasynchoff()
tf_asynchon()
tf_iasynchon()
tf_clearalldelays()
tf_iclearalldelays()
tf_compare_long()
tf_copypvc_flag()
tf_icopypvc_flag()
tf_divide_long()
tf_dofinish()
tf_dostop()
tf_error()
tf_evaluatep()
tf_ievaluatep()
tf_exprinfo()
tf_iexprinfo()
tf_getcstringp()
tf_igetcstringp()
tf_getinstance()
tf_getlongp()
tf_igetlongp()
tf_getlongtime()
tf_igetlongtime()
tf_getnextlongtime()
tf_getp()
tf_igetp()
tf_getpchange()
tf_igetpchange()
tf_getrealp()
tf_igetrealp()
tf_getrealtime()
tf_igetrealtime()
tf_gettime()
tf_igettime()
tf_gettimeprecision()
tf_igettimeprecision()
tf_gettimeunit()
tf_igettimeunit()
tf_getworkarea()
tf_igetworkarea()
tf_long_to_real()
tf_longtime_tostr()
tf_message()
tf_mipname()
tf_imipname()
tf_movepvc_flag()
tf_imovepvc_flag()
tf_multiply_long()
tf_nodeinfo()
tf_inodeinfo()
tf_nump()
tf_inump()
tf_propagatep()
tf_ipropagatep()
tf_putlongp()
tf_iputlongp()
tf_putp()
tf_iputp()
tf_putrealp()
tf_iputrealp()
tf_read_restart()
tf_real_to_long()
tf_rosynchronize()
tf_irosynchronize()
tf_scale_longdelay()
tf_scale_realdelay()
tf_setdelay()
tf_isetdelay()
tf_setlongdelay()
tf_isetlongdelay()
tf_setrealdelay()
tf_isetrealdelay()
tf_setworkarea()
tf_isetworkarea()
tf_sizep()
tf_isizep()
tf_spname()
tf_ispname()
tf_strdelputp()
tf_istrdelputp()
tf_strgetp()
tf_istrgetp()
tf_strgettime()
tf_strlongdelputp()
tf_istrlongdelputp()
tf_strrealdelputp()
tf_istrrealdelputp()
tf_subtract_long()
tf_synchronize()
tf_isynchronize()
tf_testpvc_flag()
tf_itestpvc_flag()
tf_text()
tf_typep()
tf_itypep()
tf_unscale_longdelay()
tf_unscale_realdelay()
tf_warning()
tf_write_save()
ACC access routines
acc_append_delays()
acc_append_pulsere()
acc_close()
acc_collect()
acc_compare_handles()
acc_configure()
acc_count()
acc_fetch_argc()
acc_fetch_argv()
acc_fetch_attribute()
acc_fetch_attribute_int()
acc_fetch_attribute_str()
acc_fetch_defname()
acc_fetch_delay_mode()
acc_fetch_delays()
acc_fetch_direction()
acc_fetch_edge()
acc_fetch_fullname()
acc_fetch_fulltype()
acc_fetch_index()
acc_fetch_location()
6
acc_fetch_pulsere()
acc_fetch_range()
acc_fetch_size()
acc_fetch_tfarg()
acc_fetch_itfarg()
acc_fetch_tfarg_int()
acc_fetch_itfarg_int()
acc_fetch_tfarg_str()
acc_fetch_itfarg_str()
acc_fetch_timescale_info()
acc_fetch_type()
acc_fetch_type_str()
acc_fetch_value()
acc_free()
acc_handle_by_name()
acc_handle_calling_mod_m()
acc_handle_condition()
acc_handle_conn()
acc_handle_datapath()
acc_handle_hiconn()
acc_handle_interactive_scope(
acc_handle_path()
acc_handle_pathin()
acc_handle_pathout()
acc_handle_port()
acc_handle_scope()
acc_handle_simulated_net()
acc_handle_tchk()
acc_handle_tchkarg1()
acc_handle_tchkarg2()
acc_handle_terminal()
acc_handle_tfarg()
acc_handle_itfarg()
acc_handle_tfinst()
acc_initialize()
acc_next()
acc_next_bit()
acc_next_cell()
acc_next_cell_load()
acc_next_child()
acc_next_driver()
acc_next_hiconn()
acc_next_output()
acc_next_parameter()
acc_next_port()
acc_next_portout()
acc_next_primitive()
acc_next_scope()
acc_next_specparam()
acc_next_tchk()
acc_next_terminal()
acc_next_topmod()
acc_object_in_typelist()
acc_object_of_type()
acc_product_type()
acc_product_version()
acc_release_object()
acc_replace_delays()
acc_replace_pulsere()
acc_reset_buffer()
acc_set_interactive_scope()
acc_set_pulsere()
acc_set_scope()
acc_fetch_name()
acc_fetch_paramtype()
acc_fetch_paramval()
acc_fetch_polarity()
acc_fetch_precision()
)
acc_handle_loconn()
acc_handle_modpath()
acc_handle_notifier()
acc_handle_object()
acc_handle_parent()
acc_next_input()
acc_next_load()
acc_next_loconn()
acc_next_modpath()
acc_next_net()
acc_set_value()
acc_vcl_add()
acc_vcl_delete()
acc_version()
7
Using the Verilog PLI
The Verilog PLI provides a mechanism for defining user tasks and functions by using a C-language interface covering
Verilog simulation. The Active-HDL supports Verilog PLI that you can replace Verilog system tasks and functions with
own code written in C. In addition, you may write your own PLI applications (i.e. user task and function). There are many
third party applications available that interface to Verilog simulators through the PLI interface.
The IEEE Std 1364 is the reference that defines the usage of the PLI interface and routines. This page describes details
of using the PLI routines in the Active-HDL environment.
Registering PLI applications
Each PLI application must register its system tasks and functions with the simulator, providing the name of each system
task and function and the associated callback routines. Since many PLI applications already interface to Cadence Verilog-
XLTM, MTI ModelSimTM, the Active-HDL Verilog PLI applications make use of the same mechanism to register information
about each system task and function in an array of veriusertfs. This table looks like :
s_tfcell veriusertfs[] =
{
{usertask | userfunction | userrealfunction,data;
checktf;
sizetf;
calltf;
misctf;
"$tfname"
},
{0}
}
The various callback functions (checktf, sizetf, calltf, and misctf) are described in detail in Section 17 of the IEEE Std
1364-1995. The simulator calls these functions for various reasons. All callback functions are optional, but most
applications contain at least the calltf function, which is called when the system task or function is executed in the Verilog
code. The first field defines the entry either as a system task (USERTASK) or a system function that returns either a
register (USERFUNCTION) or a real (USERREALFUNCTION). The "$tfname" field is the system task or function name (it
must begin with $).
Each user task or function has one own entry in veriusertfs. The last entry of the table is a mandatory {0} for setting its
end.
Building and linking PLI applications to Active-HDL Simulator
On loading a library for each PLI application, the simulator looks for an exported veriusertfs array. If this table is found, the
simulator calls desirable user task or function defined in it. The following example is a typical registration of user task and
function to veriusertfs array.
s_tfcell veriusertfs[] = {
{usertask, 0, 0, 0, welcome_task_calltf, 0, "$welcome_task"},
{userfunction, 0, 0, 0, function_calltf, 0, "$my_function"},
{0} /* last entry must be 0 */
};
The above table and definitions of welcome_task_calltf and function_calltf user has to write in C source file (in present
case it can be PliApp.c). Because of Microsoft Windows version of Active-HDL, the PLI application project must be
compiled and built into 32-bit dynamically linked library (DLL). It can be done by using Microsoft Visual C/C++ compiler or
similar programs. For making veriusertf array exportable, user has to write definition of Windows function DllMain() in the
same C source file, as follows:
BOOL WINAPI DllMain(HINSTANCE hInstance,DWORD dwReason,LPVOID lpReserved)
{
return TRUE;
}
and user has to add Definition File (PliApp.def) to MS Visual C++ project of PliApp. This file should contain such entry:
EXPORTS
veriusertfs DATA
The final version of C source file (in present case, PliApp.c) with foregoing definitions should look like:
8