First try at the Verilog VPI
This commit is contained in:
parent
9b350ec117
commit
a0c2413b85
15
verilog_iverilog/VPI_example/Makefile
Normal file
15
verilog_iverilog/VPI_example/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
OBJECTS= hello.vvp hello.o
|
||||
CFLAGS = -Wall -O $(CFLAGS_$@)
|
||||
|
||||
|
||||
simulate: ${OBJECTS}
|
||||
vvp -M. -mhello hello.vvp
|
||||
|
||||
%.o:%.c
|
||||
iverilog-vpi $< --name $(subst .o,,$@)
|
||||
|
||||
%.vvp:%.v
|
||||
iverilog $^ -o $@
|
||||
|
||||
clean:
|
||||
rm ${OBJECTS} -f
|
41
verilog_iverilog/VPI_example/hello.c
Normal file
41
verilog_iverilog/VPI_example/hello.c
Normal file
@ -0,0 +1,41 @@
|
||||
#include <vpi_user.h>
|
||||
|
||||
static int hello_compiletf(char* user_data){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hello_calltf(char* user_data){
|
||||
vpiHandle systfref, args_iter, argh;
|
||||
struct t_vpi_value argval;
|
||||
int value;
|
||||
|
||||
// Obtain a handle to the argument list
|
||||
systfref = vpi_handle(vpiSysTfCall, NULL);
|
||||
args_iter = vpi_iterate(vpiArgument, systfref);
|
||||
|
||||
// Grab the value of the first argument
|
||||
argh = vpi_scan(args_iter);
|
||||
argval.format = vpiIntVal;
|
||||
vpi_get_value(argh, &argval);
|
||||
value = argval.value.integer;
|
||||
vpi_printf("Hello World!\nVPI routine received %d\n", value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hello_register(){
|
||||
s_vpi_systf_data tf_data;
|
||||
|
||||
tf_data.type = vpiSysTask;
|
||||
tf_data.tfname = "$hello";
|
||||
tf_data.calltf = hello_calltf;
|
||||
tf_data.compiletf = hello_compiletf;
|
||||
tf_data.sizetf = 0;
|
||||
tf_data.user_data = 0;
|
||||
vpi_register_systf(&tf_data);
|
||||
}
|
||||
|
||||
void (*vlog_startup_routines[])() = {
|
||||
hello_register,
|
||||
0
|
||||
};
|
BIN
verilog_iverilog/VPI_example/hello.o
Normal file
BIN
verilog_iverilog/VPI_example/hello.o
Normal file
Binary file not shown.
9
verilog_iverilog/VPI_example/hello.v
Normal file
9
verilog_iverilog/VPI_example/hello.v
Normal file
@ -0,0 +1,9 @@
|
||||
module main;
|
||||
integer val;
|
||||
|
||||
initial begin
|
||||
val = 41;
|
||||
$hello(val);
|
||||
end
|
||||
|
||||
endmodule
|
BIN
verilog_iverilog/VPI_example/hello.vpi
Executable file
BIN
verilog_iverilog/VPI_example/hello.vpi
Executable file
Binary file not shown.
24
verilog_iverilog/VPI_example/hello.vvp
Executable file
24
verilog_iverilog/VPI_example/hello.vvp
Executable file
@ -0,0 +1,24 @@
|
||||
#! /usr/bin/vvp
|
||||
:ivl_version "11.0 (stable)";
|
||||
:ivl_delay_selection "TYPICAL";
|
||||
:vpi_time_precision + 0;
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/system.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/vhdl_sys.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/vhdl_textio.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2005_math.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/va_math.vpi";
|
||||
S_0x561f1548f320 .scope module, "main" "main" 2 1;
|
||||
.timescale 0 0;
|
||||
v0x561f15457770_0 .var/i "val", 31 0;
|
||||
.scope S_0x561f1548f320;
|
||||
T_0 ;
|
||||
%pushi/vec4 41, 0, 32;
|
||||
%store/vec4 v0x561f15457770_0, 0, 32;
|
||||
%vpi_call 2 6 "$hello", v0x561f15457770_0 {0 0 0};
|
||||
%end;
|
||||
.thread T_0;
|
||||
# The file index is used to find the file name in the following table.
|
||||
:file_names 3;
|
||||
"N/A";
|
||||
"<interactive>";
|
||||
"hello.v";
|
Loading…
Reference in New Issue
Block a user