阅读(1044) (17)

Verilog TF子程序列表

2022-05-20 11:59:25 更新

建议使用时再仔细研究对应类型的子程序。这里也没有对所有的子程序都进行验证,由于版本或抄写问题,可能会有所疏漏,欢迎指正。

TF 子程序常用于 Verilog 和用户 C 子程序之间的双向数据传输。当以 ​tf_​ 为前缀的子程序有一个以 ​tf_i​ 为前缀的子程序与之对应时,这个以 ​tf_i​ 为前缀的对应子程序中发生操作的实例指针必须被当做变量列表最后的附加变量加以传递。

TF 子程序在命名形式上没有明确的分类标志,简单做如下总结。

取任务、函数信息

返回类型 调用格式及说明
char * ◆tf_getinstance()
  获取指向用户定义的系统任务或函数的当前实例的指针。
char * ◆tf_mipname()
◆tf_imipname(char *instance_p)
  以字符串形式获取分层模块实例路径名。
char * ◆tf_spname()
◆tf_ispname(char *instance_p)
  以字符串形式获取范围分层路径名。

取变量列表信息

返回类型 调用格式及说明
int ◆tf_nump()
◆tf_inump(char *instance_p)
  获取任务或函数参数的数量。
int ◆tf_typep(int narg)
◆tf_itypep(int narg, char *instance_p)
  获取系统任务/函数参数类型。
int ◆tf_sizep(narg)
◆tf_isizep(int narg, char *instance_p)
  获取系统任务/函数参数的位长。
t_tfexprinfo * ◆tf_exprinfo(int narg, t_tfexprinfo *exprinfo_p)
◆tf_iexprinfo(int narg, t_tfexprinfo *exprinfo_p, char *instance_p)
  获取系统任务/函数参数表达式信息。
t_tfexprinfo 是一个数据结构,在 veriuser.h 中定义。
t_tfnodeinfo * ◆tf_nodeinfo(int narg, t_tfnodeinfo *nodeinfo_p)
◆tf_inodeinfo(int narg, t_tfnodeinfo *nodeinfo_p, char *instance_p)
  获取系统任务/函数参数节点信息。
t_tfnodeinfo 是一个数据结构,在 veriuser.h 中定义。

取参数值

返回类型 调用格式及说明
int ◆tf_getp(int narg)
◆tf_igetp(int narg, char *instance_p)
  获取系统任务/函数参数值作为整数或字符串指针
double ◆tf_getrealp(int narg)
◆tf_igetrealp(int narg, char *instance_p)
  获取系统任务/函数参数值作为双精度值。
int ◆tf_getlongp(int *aof_highvalue, int narg)
◆tf_igetlongp(int *aof_highvalue, int narg, char *instance_p)
  以 64 位整数形式获取系统任务/函数参数值。
char * ◆tf_strgetp(int narg, int format)
◆tf_istrgetp(int narg, int format, char *instance_p)
  获取格式化的系统任务/函数参数值。
char * ◆tf_getcstringp(int narg)
◆tf_igetcstringp(int narg, char *instance_p)
  以字符串形式获取系统任务/函数参数值。
int ◆tf_evaluatep(int narg)
◆tf_ievaluatep(int narg, char *instance_p)
  评估系统任务/函数参数表达式。

置参数值

返回类型 调用格式及说明
int ◆tf_putp(int narg, int value)
◆tf_iputp(int narg, int value, char *instance_p)
  将整数值放入系统任务/函数参数或函数返回。
int ◆tf_putrealp(int narg, double value)
◆tf_iputrealp(int narg, double value, char *instance_p)
  将实际值写入系统任务/函数参数或函数返回。
int ◆tf_putlongp(int narg, int lowvalue, int highvalue)
◆tf_iputlongp(int narg, int lowvalue, int highvalue, char *instance_p)
  将 64 位整数值写入系统任务/函数参数或函数返回。
int ◆tf_propagatep(int narg)
◆tf_ipropagatep(int narg, char *instance_p)
  传播系统任务/函数参数值。
int ◆tf_strdelputp(int narg, int bitlength, char format, char *value_p, int delay, int delaytype)
◆tf_istrdelputp(int narg, int bitlength, char format, char *value_p, int delay, int delaytype, char *instance_p)
  使用 32 位整数延迟将值从字符串值规范写入系统任务/函数参数。
int ◆tf_strrealdelputp(int narg, int bitlength, char format, char *value_p, double realdelay, int delaytype)
◆tf_istrrealdelputp(int narg, int bitlength, char format, char *value_p, double realdelay, int delaytype, char *instance_p)
  使用实数延迟将值从字符串值规范写入系统任务/函数参数。
int ◆tf_strlongdelputp(int narg, int bitlength, char format, char *value_p, int lowdelay, int highdelay, int delaytype)
◆tf_istrlongdelputp(int narg, int bitlength, char format, char *value_p, int lowdelay, int highdelay, int delaytype, char *instance_p)
  使用 64 位整数延迟将值从字符串值规范写入系统任务/函数参数。

监视参数值变化

返回类型 调用格式及说明
int ◆tf_asynchon()
◆tf_iasynchon(char *instance_p)
  为系统任务/函数参数值更改启用 misctf 应用程序的异步调用。
int
(always 0)
◆tf_asynchoff()
◆tf_iasynchoff(char *instance_p)
  禁用 misctf 应用程序的异步调用。
int ◆tf_synchronize()
◆tf_isynchronize(char *instance_p)
  同步到仿真时间步的结束。
int ◆tf_rosynchronize()
◆tf_irosynchronize(char *instance_p)
  同步到仿真时间步的结束。
int ◆tf_getpchange(int narg)
◆tf_igetpchange(int narg, char *instance_p)
  获取下一个更改值的系统任务/函数参数的索引号。
int ◆tf_copypvc_flag(int narg)
◆tf_icopypvc_flag(int narg, char *instance_p)
  复制系统任务/函数参数值更改标志。
int ◆tf_movepvc_flag(int narg)
◆tf_imovepvc_flag(int narg, char *instance_p)
  移动系统任务/函数参数值更改标志。
int ◆tf_testpvc_flag(int narg)
◆tf_itestpvc_flag(int narg, char *instance_p)
  测试系统任务/函数参数值更改标志。

任务同步

返回类型 调用格式及说明
int ◆tf_gettime()
◆tf_igettime(char *instance_p)
  以 32 位整数形式获取当前仿真时间。
double ◆tf_getrealtime()
◆tf_igetrealtime(char *instance_p)
  以双精度格式获取当前仿真时间。
int ◆tf_getlongtime(int *aof_hightime)
◆tf_igetlongtime(int *aof_hightime, char *instance_p)
  以 64 位整数形式获取当前仿真时间。
返回最低有效(最右边)32 位仿真时间
char * ◆tf_strgettime()
  以字符串形式获取当前模拟时间。
int ◆tf_getnextlongtime(int *aof_lowtime, int *aof_hightime)
  获取下一次安排模拟事件的时间
int ◆tf_gettimeprecision()
◆tf_igettimeprecision(char *instance_p)
  获取模块或模拟的时间刻度精度。
int ◆tf_gettimeunit()
◆tf_igettimeunit(char *instance_p)
  获取模块或模拟的时间刻度单位。
int ◆tf_setdelay(int delay)
◆tf_isetdelay(int delay, char *instance_p)
  在特定的模拟时间激活 misctf 应用程序。
int ◆tf_setlongdelay(int lowdelay, int highdelay)
◆tf_isetlongdelay(int lowdelay, int highdelay, char *instance_p)
  在特定的模拟时间激活 misctf 应用程序。
int ◆tf_setrealdelay(double realdelay)
◆tf_isetrealdelay(double realdelay, char *instance_p)
  在特定的模拟时间激活 misctf 应用程序。
void ◆tf_scale_longdelay(char *instance_p, int delay_lo, int delay_hi, int *aof_delay_lo, int *aof_delay_hi)
  将 64 位整数延迟转换为模块实例的时间刻度。
void ◆tf_scale_realdelay(char *instance_p, double realdelay, double *aof_realdelay)
  将双精度浮点延迟转换为模块实例的时间刻度。
void ◆tf_unscale_longdelay(char *instance_p, int delay_lo, int delay_hi, int *aof_delay_lo, int *aof_delay_hi)
  将内部仿真时间单位的延迟转换为特定模块的时间尺度。
void ◆tf_unscale_realdelay(char *instance_p, double realdelay, double *aof_realdelay)
  将以内部仿真时间单位表示的延迟转换为特定模块的时间尺度。
int ◆tf_clearalldelays()
◆tf_iclearalldelays(char *instance_p)
  通过 tf_setdelay() 或 tf_isetdelay() 清除所有计划的重新激活。

算术运算

返回类型 调用格式及说明
int
(always 0)
◆tf_add_long(int *aof_low1, int *aof_high1, int low2, int high2)
  添加两个 64 位整数。
int
(always 0)
◆tf_subtract_long(int *aof_low1, int *aof_high1, int low2, int high2)
  减去两个 64 位整数。
void ◆tf_multiply_long(int *aof_low1, int *aof_high1, int low2, int high2)
  将两个 64 位整数相乘。
void ◆tf_divide_long(int *aof_low1, int *aof_high1, int low2, int high2)
  将两个 64 位整数相除。
int ◆tf_compare_long(int low1, int high1, int low2, int high2)
  比较两个 64 位整数值。
char * ◆tf_longtime_tostr(int lowtime, int hightime)
  将 64 位整数时间值转换为字符串。
void ◆tf_real_to_long(double realvalue, int *aof_low, int *aof_high)
  将实数转换为 64 位整数。
void ◆tf_long_to_real(int low, int high, double *aof_real)
  将 64 位整数转换为实数。

显示信息

返回类型 调用格式及说明
void ◆io_printf(char *format, arg1, ..., arg12)
  将格式化消息打印到调用 PLI 应用程序的软件产品的输出通道和产品的日志文件。
void ◆io_mcdprintf(int mcd, char *format, arg1, ..., arg12)
  将格式化的消息写入一个或多个文件。
int
(always 0)
◆tf_error(char *format, arg1,..., arg5)
  报告错误消息。
int
(always 0)
◆tf_warning(char *format, arg1, ..., arg5)
  报告警告消息。
int
(always 0)
◆tf_message(int level, char *facility, char *code, char *message, arg1,..., arg5)
  使用软件产品中断控制报告错误或警告消息。
int
(always 0)
◆tf_text(char *message, arg1,..., arg5)
  存储错误消息信息。

内部任务维护

返回类型 调用格式及说明
int
(always 0)
◆tf_setworkarea(char *workarea)
◆tf_isetworkarea(char *workarea, char *instance_p)
  将用户数据指针存储在工作区中。
char * ◆tf_getworkarea()
◆tf_igetworkarea(char *instance_p)
  获取工作区指针。

其他子程序

返回类型 调用格式及说明
int
(always 0)
◆tf_dostop()
  使软件产品进入交互模式。
int
(always 0)
◆tf_dofinish()
  退出软件产品执行。
char * ◆mc_scan_plusargs(char *startarg)
  扫描软件产品调用命令行以获取加号 (+) 选项。
int ◆tf_write_save(char *blockptr, int blocklen)
  将数据块附加到保存文件。
int ◆tf_read_restart(char *blockptr, int blocklen)
  从先前写入的保存文件中获取数据块。