File tree 3 files changed +36
-0
lines changed
3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ #+title: Nim/SystemVerilog VPI Example
2
+
3
+ This directory contains the "Hello" example from [[https://www.asic-world.com/verilog/pli6.html][this asic-world PLI
4
+ tutorial]] translated from C to Nim.
5
+
6
+ - To run the Nim code with SystemVerilog, run ~make~ in this
7
+ directory.
8
+ - To run the original C code from the tutorial, cd to the ~orig/~
9
+ directory in here, and run ~make~ there.
Original file line number Diff line number Diff line change
1
+ // https://www.asic-world.com/verilog/pli6.html
2
+
3
+ #include "vpi_user.h"
4
+
5
+ void hello () {
6
+ vpi_printf ("\n\nHello!!\n\n" );
7
+ }
8
+
9
+ // Associate C Function with a New System Task
10
+ void registerHelloSystfs () {
11
+ s_vpi_systf_data task_data_s ;
12
+ p_vpi_systf_data task_data_p = & task_data_s ;
13
+ task_data_p -> type = vpiSysTask ;
14
+ task_data_p -> tfname = "$hello" ;
15
+ task_data_p -> calltf = hello ;
16
+ task_data_p -> compiletf = 0 ;
17
+
18
+ vpi_register_systf (task_data_p );
19
+ }
20
+
21
+ // Register the new system task here
22
+ // https://cdecl.org/?q=void+%28*vlog_startup_routines%5B+%5D+%29+%28%29
23
+ void (* vlog_startup_routines [ ] ) () = {
24
+ registerHelloSystfs ,
25
+ 0 // last entry must be 0
26
+ };
Original file line number Diff line number Diff line change
1
+ ../ tb.sv
You can’t perform that action at this time.
0 commit comments