30 lines
844 B
C
30 lines
844 B
C
#include <stdio.h>
|
|
#include <vpi_user.h>
|
|
|
|
void get_arg(PLI_BYTE8 *user_data)
|
|
{
|
|
// 变量定义
|
|
s_vpi_value value_s;
|
|
vpiHandle systf_handle, arg_iter, arg_handle;
|
|
|
|
// 获取函数调用的句柄
|
|
systf_handle = vpi_handle(vpiSysTfCall, NULL);
|
|
// 从句柄中获取参数迭代器
|
|
arg_iter = vpi_iterate(vpiArgument, systf_handle);
|
|
if(arg_iter == NULL){
|
|
vpi_printf("ERROR: failed to obtain systf arg handles\n");
|
|
vpi_control(vpiFinish, 1); /* abort simulation */
|
|
return;
|
|
}
|
|
|
|
// 迭代获取第一个参数
|
|
arg_handle = vpi_scan(arg_iter);
|
|
value_s.format = vpiStringVal;
|
|
vpi_get_value(arg_handle, &value_s);
|
|
PLI_BYTE8 *arg1 = value_s.value.str;
|
|
|
|
// 释放迭代器
|
|
vpi_free_object(arg_iter); /* because not scanning until null */
|
|
|
|
vpi_printf("arg[1] = %s", arg1);
|
|
} |