- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello,
I have been trying to import and export functions and task through DPI between system verilog and C. I have managed to import functions and task from C to SV:) but can't really figure out how to export SV functions and tasks to C:confused:. I tried an example code given in the modelsim manual but i just doesn't work :( this is how the code looks like; sv file: module helloc(); int ret; export "DPI-C" task verilog_task; task verilog_task (input i, output int o); # 10; $display ("hello from sv"); endtask import "DPI-C" context task c_task (input int i, output int o); initial begin c_task(1,ret); end endmodule C file :# include <stdio.h># include <svdpi.h># include <conio.h># include <dpiheader.h> int c_task(int i, int*o) { printf("hello from c"); verilog_task(i, o); *o = i; return 0; } the dpiheader.h file was generated by Modelsim when given the command vlog -sv -dpiheader dpiheader.h helloc.sv this is the error i get when trying to compile the C file: # In file included from helloc.c:4:0:# c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/dpiheader.h:26:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int' the error is in the dpiheader file!!! and if i remove this header file then the compiler doesn't consider the verilog_task as a task. it gives an error again. I will obliged if someone can help me out with this prob:oops: really gotta figure this prob out asap... pls reply asapLink Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Most likely you are using an unsupported gcc version. Check the compatibility of gcc versions with your version of modelsim.
If you have ModelSim 10.1 or later, you can put your C file on the vlog command line and it will compile the C file for you vlog -dpiheader dpiheader.h helloc.sv helloc.c (Do not use the -sv switch if your SV files already have a .sv extension, otherwise all files including .v will be treated as SystemVerilog)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have a ModelSim-Altera 6.5b starter edition and 4.6.2 version of mingw in windows 7 pc...
any idea if the gcc version is the right one? :$- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MinGW gcc 3.2.3 was the recommended version at the time Modelsim 6.5b was released in 2009. You either need to downgrade your gcc or upgrade your Modelsim.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
which version of ModelSim is compatible with 4.6.2 gcc? :| will try to upgrade ModelSim that particular version..
btw thanks a lot for the replies... i am literally running out of time for this project of mine.. :(- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It worked for me with 4.2.1 and that is the minimum version supported in Modelsim 10.2.
You should install the version of gcc that the version of Modelsim recommends. You can have multiple versions on your system if you need them.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page