Questions tagged [system-verilog-dpi]

Direct Programming Interface (DPI) from SystemVerilog. This interface allows direct communication between SystemVerilog simulation and foreign programming languages.

Direct Programming Interface (DPI) from . This interface allows direct communication between SystemVerilog simulation and foreign programming languages. Different programming languages can be used to intact with SystemVerilog; however, the SystemVerilog LRM (IEEE Std 1800-2017) only defines the C programming language as a foreign language layer.

Full details can be found in IEEE Std 1800-2017 § 35 Direct programming interface

55 questions
7
votes
2 answers

Detect timescale in System Verilog

How do I detect the timescale precision used in a simulation from the source code ?. Consider I have a configuration parameter(cfg_delay_i) of some delay value given by user in timeunits as fs .If the user gives 1000 , my code has to wait 1000fs or…
Sreejin TJ
  • 177
  • 12
6
votes
2 answers

Exporting tasks to 'C using DPI

I have an verilog based test-bench, interfaced to 'C source using DPI. Now using DPI I am planning to write my whole firmware. To do this I need 3 things Register Read Register Write Interrupt handler As I understand, register reads and writes are…
Alphaneo
  • 12,079
  • 22
  • 71
  • 89
5
votes
1 answer

How can I pass data between SV and C++ bidirectionally via open array with DPI import function

My goal is to fill an open array by C++. The stage is as follows. 1. SV: Define a sized unpacked array and send it via open array in the import function. 2. C++: Fill the open array. 3. SV: Use the array. For the sized unpacked array, there is no…
gnoejh
  • 325
  • 4
  • 16
4
votes
1 answer

How to compile and run a verilog program which calls C function?

I am not trying to use a DPI call, but a simple Verilog program which internally uses its PLI to call a function written in C language. I don't know about static linking. I am using edaplayground. Can anyone tell me which simulator should I use and…
4
votes
4 answers

SystemVerilog: How to connect C function using DPI call in VCS simulator?

I have the following files: C file with functions: // funcs.c #include void something() { printf("something\n"); sayHello(); } System verilog file: // hello_world.v module kuku; export "DPI-C" function sayHello; import…
SomethingSomething
  • 11,491
  • 17
  • 68
  • 126
4
votes
2 answers

Ruby and SystemVerilog DPI

The DPI functionality in System Verilog always mentions that you can interface it with any language, the most common one being C/C++. I want to interface my system Verilog code with Ruby. Is there any documentation or support for this functionality?…
noobuntu
  • 903
  • 1
  • 18
  • 42
3
votes
1 answer

How do I execute SystemVerilog code at garbage collection?

I have a SystemVerilog class that encapsulates a C++ class using a chandle and the DPI. I want to be sure that the C++ class’s destructor is called when the SystemVerilog object is destroyed. As far as I can tell, this is not being done…
coderoo
  • 65
  • 5
3
votes
1 answer

Output open array as a formal argument in DPI-C

I have C code (predictor model) that can generate an array of variable length as its result. It is unknown before calling the C code what the size of this array is, and there is some amount of randomization involved (noise modelling) I need to call…
noobuntu
  • 903
  • 1
  • 18
  • 42
3
votes
0 answers

Unsupported element in unpacked struct datatype in formal argument

I'm having trouble passing a structure object from SV to C through SV-C DPI. The code: SV side: /*svFile.sv*/ typedef struct { int a; int b; } struct_sv; import "DPI-C" function void reciever(input struct_sv a); and on the C…
Anand PA
  • 31
  • 3
3
votes
2 answers

Integrating fftw C function calls inside system verilog code

I have installed fftw C library succefully on my linux system. Here is more info about fftw c => http://www.fftw.org/ I have a sample C code which can call fftw C functions successfully. Below is a C ccode and command to run the C…
sanforyou
  • 455
  • 2
  • 8
  • 22
2
votes
1 answer

UVM DPI-C function import

Can somebody please educate me why we need DPI-C function import to do UVM specific functions like uvm_hdl_force or uvm_hdl_deposit even when force and deposit system verilog constructs exist? What extra flexibility does the C functions give with…
user1978273
  • 484
  • 10
  • 24
2
votes
1 answer

Is it possible to use packed structs with DPI

Suppose I have a packed struct: typedef struct packed { logic a; logic [7:0] b; bit [7:0] c; logic [7:0] [31:0] d; } my_struct; And I want to pass it into a C function: import "DPI" context function int my_dpi_function (input my_struct…
random
  • 3,868
  • 3
  • 22
  • 39
2
votes
1 answer

Implementing System verilog’s $value$plusargs() system function in Specman E

What is the equivalent syntax or implementation for System verilog‘s $value$plusargs option in Specman E ? I am working in converting a source code from System verilog to Specman E, I am stuck with implementing $value$plusargs() system function in…
Sreejin TJ
  • 177
  • 12
2
votes
1 answer

Passing C structs through SystemVerilog DPI-C layer

SystemVerilog LRM has some examples that show how to pass structs in SystemVerilog to\from C through DPI-C layer. However when I try my own example it seems to not work at all in Incisive or Vivado simulator (it does work in ModelSim). I wanted to…
2
votes
3 answers

How do I stack trace info in the case of SystemVerilog+C DPI calls?

I have a situation where I have 2 C functions. These C functions have many error checking scenarios where I use a exit(1) to cop out. A million places in system verilog code calls these 2 C functions via DPI calls. I used execinfo.h and backtrace()…
1
2 3 4