add me241102_vpi
This commit is contained in:
parent
2f0ad27f4a
commit
53a59a5f61
14
.gitignore
vendored
14
.gitignore
vendored
@ -25,4 +25,16 @@ me241101_dpi/ucli.key
|
||||
me241101_dpi/vc_hdrs.h
|
||||
me241101_dpi/wave.fsdb
|
||||
me241101_dpi/*.o
|
||||
me241101_dpi/*.so
|
||||
me241101_dpi/*.so
|
||||
|
||||
me241102_vpi/csrc/
|
||||
me241102_vpi/simv.daidir/
|
||||
me241102_vpi/verdiLog/
|
||||
me241102_vpi/*.log
|
||||
me241102_vpi/novas.*
|
||||
me241102_vpi/simv
|
||||
me241102_vpi/ucli.key
|
||||
me241102_vpi/vc_hdrs.h
|
||||
me241102_vpi/wave.fsdb
|
||||
me241102_vpi/*.o
|
||||
me241102_vpi/*.so
|
18
me241102_vpi/Makefile
Normal file
18
me241102_vpi/Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
comp_c:
|
||||
- gcc -fPIC -shared -o libfunc.so func.c -I ${VCS_HOME}/include
|
||||
comp:
|
||||
- vcs -full64 +v2k -sverilog -LDFLAGS -Wl,--no-as-needed \
|
||||
-P ${VERDI_HOME}/share/PLI/VCS/LINUX64/novas.tab ${VERDI_HOME}/share/PLI/VCS/LINUX64/pli.a \
|
||||
-P ./func.tab \
|
||||
+vcs+fsdbon -debug_access+all \
|
||||
-top testbench -l compile.log -timescale=1ns/1ps\
|
||||
testbench.sv
|
||||
|
||||
sim:
|
||||
- ./simv -l sim.log +fsdbfile+wave.fsdb +fsdb+no_msg+Flush +fsdb+delta +fsdb+sva_sucess +fsdb+glitch=0 +fsdb+sequential -load ./libfunc.so
|
||||
|
||||
verdi:
|
||||
- verdi -sverilog +v2k testbench.sv -ssf wave.fsdb -sswr signal.rc &
|
||||
|
||||
clean:
|
||||
- \rm -rf *.log *.fsdb simv.daidir
|
31
me241102_vpi/ReadMe.md
Normal file
31
me241102_vpi/ReadMe.md
Normal file
@ -0,0 +1,31 @@
|
||||
# vpi
|
||||
|
||||
## 概述
|
||||
|
||||
使用vcs编译vpi的简单例子
|
||||
|
||||
> 需要准备好vcs+verdi的仿真环境。
|
||||
|
||||
### 特性
|
||||
|
||||
- 动态调用
|
||||
- Makefile 管理
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 一、仿真
|
||||
|
||||
```bash
|
||||
make clean comp_c comp sim
|
||||
```
|
||||
|
||||
### 二、检查log
|
||||
|
||||
查看log,检查是否正确调用vpi。
|
||||
|
||||
## 更多
|
||||
|
||||
[PLI 学习 - 博涵 - 博客园](https://www.cnblogs.com/fengbohan/p/18595069/pli-learning-zx6kpe)
|
||||
|
||||
|
||||
|
30
me241102_vpi/func.c
Normal file
30
me241102_vpi/func.c
Normal file
@ -0,0 +1,30 @@
|
||||
#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);
|
||||
}
|
1
me241102_vpi/func.tab
Normal file
1
me241102_vpi/func.tab
Normal file
@ -0,0 +1 @@
|
||||
$get_arg call=get_arg
|
5
me241102_vpi/testbench.sv
Normal file
5
me241102_vpi/testbench.sv
Normal file
@ -0,0 +1,5 @@
|
||||
module testbench;
|
||||
initial begin
|
||||
$get_arg("Hello world");
|
||||
end
|
||||
endmodule
|
Loading…
x
Reference in New Issue
Block a user