add me241101_dpi
This commit is contained in:
parent
a421c93452
commit
ec527508ff
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,5 +1,3 @@
|
||||
2_dpi
|
||||
3_python_learn
|
||||
4_c_re
|
||||
5_vpi
|
||||
sv_lab
|
||||
@ -16,3 +14,15 @@ me241100_svExample/simv
|
||||
me241100_svExample/ucli.key
|
||||
me241100_svExample/vc_hdrs.h
|
||||
me241100_svExample/wave.fsdb
|
||||
|
||||
me241101_dpi/csrc/
|
||||
me241101_dpi/simv.daidir/
|
||||
me241101_dpi/verdiLog/
|
||||
me241101_dpi/*.log
|
||||
me241101_dpi/novas.*
|
||||
me241101_dpi/simv
|
||||
me241101_dpi/ucli.key
|
||||
me241101_dpi/vc_hdrs.h
|
||||
me241101_dpi/wave.fsdb
|
||||
me241101_dpi/*.o
|
||||
me241101_dpi/*.so
|
12
me241101_dpi/Makefile
Normal file
12
me241101_dpi/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
sv_main.so: sv_main.c
|
||||
- gcc -fPIC -c sv_main.c -I ${VCS_HOME}/include
|
||||
- gcc -shared -o sv_main.so sv_main.o
|
||||
#sv_main.so: sv_main.c
|
||||
# - gcc -fPIC -shared -o sv_main.so -c sv_main.c -I ${VCS_HOME}/include
|
||||
comp:
|
||||
- vcs -full64 +v2k -sverilog -LDFLAGS -Wl,--no-as-needed -debug_access+all -top testbench -l compile.log \
|
||||
testbench.sv
|
||||
sim: sv_main.so
|
||||
- ./simv -l sim.log -sv_root . -sv_lib sv_main
|
||||
clean:
|
||||
- \rm -rf *.log simv simv.daidir *.a *.o *.so csrc *.key
|
31
me241101_dpi/ReadMe.md
Normal file
31
me241101_dpi/ReadMe.md
Normal file
@ -0,0 +1,31 @@
|
||||
# dpi
|
||||
|
||||
## 概述
|
||||
|
||||
使用vcs编译dpi的简单例子
|
||||
|
||||
> 需要准备好vcs+verdi的仿真环境。
|
||||
|
||||
### 特性
|
||||
|
||||
- 动态调用
|
||||
- Makefile 管理
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 一、仿真
|
||||
|
||||
```bash
|
||||
make clean comp sim
|
||||
```
|
||||
|
||||
### 二、检查log
|
||||
|
||||
查看log,检查是否正确调用dpi。
|
||||
|
||||
## 更多
|
||||
|
||||
[PLI 学习 - 博涵 - 博客园](https://www.cnblogs.com/fengbohan/p/18595069/pli-learning-zx6kpe)
|
||||
|
||||
|
||||
|
10
me241101_dpi/sv_main.c
Normal file
10
me241101_dpi/sv_main.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <svdpi.h>
|
||||
#include <vpi_user.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern void sv_hello();
|
||||
int c_hello(const char *name, int age) {
|
||||
vpi_printf("c_hello: %s, %d\n", name, age);
|
||||
sv_hello();
|
||||
return 0;
|
||||
}
|
29
me241101_dpi/testbench.sv
Normal file
29
me241101_dpi/testbench.sv
Normal file
@ -0,0 +1,29 @@
|
||||
//===========================================================================
|
||||
// Organization : Individual Developer
|
||||
// Filename : testbench.sv
|
||||
// Author : Feng Bohan
|
||||
// Create Time : 16:17:37 2024-11-22
|
||||
// Last Modified: 16:20:09 2024-11-22
|
||||
// Abstract :
|
||||
//--------------------------------------------------------------------------
|
||||
// Description:
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
// Modification History:
|
||||
//--------------------------------------------------------------------------
|
||||
// Rev Date Who Description
|
||||
// --- ---- --- -----------
|
||||
// 0.0.01 2024-11-22 Feng Bohan initial version
|
||||
//===========================================================================
|
||||
module testbench;
|
||||
import "DPI-C" context function int c_hello(input string name, input int age);
|
||||
export "DPI-C" function sv_hello;
|
||||
function void sv_hello();
|
||||
$display("sv_hello");
|
||||
endfunction
|
||||
|
||||
initial begin
|
||||
c_hello("testbench", 18);
|
||||
end
|
||||
endmodule
|
||||
|
Loading…
x
Reference in New Issue
Block a user