System Verilog DPI Example

Refer to the previous post for introduction.

System Verilog DPI NCVerilog

The above example gives a demo with NCVerilog.

Here is the run script for running the same example with Modelsim under windows.

Download here. system-verilog-dpi-modelsim.pdf

#File name run.tcl

# Author: A.G.Raja

# Website:

# License: GPL

#Type at Transcript terminal: source run.tcl

vlib work

vlog -sv -dpiheader dpiheader.h dpi_top.v

exec gcc -c -g -IE:/modelsim/include dpi_main.c -o dpi_main.obj

exec gcc -shared -o dpi_main.dll dpi_main.obj -LE:/modelsim/win32

vsim -novopt top -sv_lib dpi_main


# EOF run.tcl

Replace “E:/modelsim” with “modelsim installation path”

1) Don’t create a new project while starting Modelsim

2) Open and proceed directly to Modelsim.

3) At the transcript terminal change to the working directory

4) No need to create a folder named work.

5) The run script given above does it.

Download here. system-verilog-dpi-modelsim.pdf

Download NCVerilog demo here.


C++ struct vs class

This is an example to show the similarity between a struct and a class

  #include <iostream>using namespace std;

int main()


struct employee

{char *name;

int age;

double salary;


employee e257 = {”raja“,25,23519.78};


<<”\t”<<e257.salary <<endl;

class Employee { public:      char *name;
     int age;double salary; };

Employee E257 = {”raja”,25,23519.78};


<<”\t”<<E257.salary <<endl;

1) All members of a struct are public by default 
2) All members of a class are private by default 
3) For a class member to be public, it has be 
declared public with the keyword "public".  
Advantage of using classes 
1) Member variables are private and protected. 
2) Constructors functions(declared public) can be 
used  to initialize and modify values of that private variables. 
See this page for Constructors:  Constructors & Destructors </pre
 Download here.struct.doc