• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. SV DPI: veriusertfs

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 66
  • Views 18411
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SV DPI: veriusertfs

archive
archive over 18 years ago

Hi,

I'm trying to compile C file that contain the following:

#include
#include
#include
#include "veriuser.h"
#include "acc_user.h"
....
....

s_tfcell veriusertfs[] = {
//{userfunction, 0, 0, fio_size32, myfclose, 0, "$myfclose"},
{usertask, 0, 0, 0, myfopen, 0, "$myfopen"},
{usertask, 0, 0, 0, myfclose, 0, "$myfclose"},
...
...
{0} //
};

the problem is that the compiler (gcc c-file.c -c -I /include -o c-file.o) didn't recognize s_tfcell veriusertfs[], I have get the following message:

//372: parse error before "veriusertfs"
//374: warning: braces around scalar initializer
//374: warning: (near initialization for `veriusertfs[0]')
//374: `usertask' undeclared here (not in a function)
//374: initializer element is not constant
//374: (near initialization for `veriusertfs[0]')
//374: warning: excess elements in scalar initializer
//374: warning: (near initialization for `veriusertfs[0]')
//374: warning: excess elements in scalar initializer
...
...

All the include files are exist, what I'm missing?? are the include files too old??

Thanks, Benni.


Originally posted in cdnusers.org by bennik
  • Cancel
  • archive
    archive over 18 years ago

    Hi Benni.

    Two points I noticed, though maybe you found these already...

    1) You should probably include "vxl_veriuser.h" which defines the s_tfcell struct.
    2) On you gcc line, make sure you have "-I `ncroot`/tools/include" in order to search the IUS include directory.

    If you want to test the sanity of your Unix environment, you could also try compiling one of the example PLI applications that come with IUS. Look in the `ncroot`/tools/examples/pli directory and follow the README files there.

    Steve.


    Originally posted in cdnusers.org by stephenh
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 18 years ago

    Thank you I forgot to inclode "vxl_veriuser.h".
    Now the C file is compiled but I don't know how to do the link to C function, my C file is:

    int myfopen()
    //myfopen("./filename",FILE *stream),return 0;
    {
    char *filename;
    FILE *fp;

    acc_initialize();
    //filename = (char*)(int)acc_fetch_tfarg(1);
    filename = tf_getcstringp(1);
    fp = fopen(filename, "r" );
    if(fp)
    {
    tf_putp(2, (int)(fp));//return the fp
    acc_close();
    if(DEBUG) io_printf("open the %s success!\n",filename);
    tf_putp(ARG_RET, true); //return the true
    }
    else
    {
    acc_close();
    if(DEBUG) io_printf("open the %s fail!\n",filename);
    tf_putp(ARG_RET, false);
    }
    return 0;
    }

    my SV code for using the C file is:
    initial
    begin
    integer fp;
    $myfopen("./script.txt",fp);
    ....
    end

    I tried to use the DPI-C declaration as the followin:
    import "DPI-C" function myfopen(input char filename, output integer FILE);
    import "DPI-C" function myfopen(input char "./script.txt", output integer FILE);
    import "DPI-C" context function myfopen(input char "./script.txt", output integer FILE);
    import "DPI-C" function int myfopen();

    and more but I have some cpmpilation error.
    Do you have any idea what I should do?

    Thanks in advanced, Benni.


    Originally posted in cdnusers.org by bennik
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 18 years ago

    sorry, "myopen(...)" is task and I changed the import accordingly but it still not work

    import "DPI-C" context task myfopen(input string "./script.txt", output FILE fp);
    |
    ncvlog: *E,EXPIDN (../monitor/mon_top.sv,48|65): expecting an identifier [3.2][3.8][3.9(IEEE)].
    import "DPI-C" context task myfopen(input string "./script.txt", output FILE fp);
    |
    ncvlog: *E,EXP1RD (../monitor/mon_top.sv,48|73): expecting at least one register variable [3.2.2(IEEE)].
    import "DPI-C" context task myfopen(input string "./script.txt", output FILE fp);
    |
    ncvlog: *E,SVNOTY (../monitor/mon_top.sv,48|78): Syntactically this identifier appears to begin a datatype but it does not refer to a visible datatype in the current scope.
    import "DPI-C" context task myfopen(input string "./script.txt", output FILE fp);
    |
    ncvlog: *E,EXPCORP (../monitor/mon_top.sv,48|81): Expecting a ',' or ')' [A.1.4(IEEE-2001)].
    import "DPI-C" context task myfopen(input string "./script.txt", output FILE fp);
    |
    ncvlog: *E,EXPRPA (../monitor/mon_top.sv,48|81): expecting a right parenthesis (')') [A.2.6(IEEE)].
    import "DPI-C" context task myfopen(input string "./script.txt", output FILE fp);
    |
    ncvlog: *E,EXPENM (../monitor/mon_top.sv,48|82): expecting the keyword 'endmodule' [12.1(IEEE)].


    Originally posted in cdnusers.org by bennik
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 18 years ago

    HI Benni

    It is not clear to me whether you are trying to use PLI or DPI. If you want to use DPI, you do not need to include any vxl_veriuser.h files and do not need to code it like a PLI method. While using DPI, simply code up your C function as you would as if you were calling that function from within C. Then you put your import DPI-C calls in the verilog/system verilog code and use as if they are verilog/system verilog task. You do not need to use $myopenfunc instead use myopenfunc.

    Also while using DPI, use the following declaration:
    import "DPI-C" function int myfopen (string filename); (I am not sure if NC supports string as argument presently)


    Nitin


    Originally posted in cdnusers.org by nitin_sharma
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 18 years ago

    Sorry it's my mistake I confused between PLI and DPI. of course I want to use PLI.
    I compiled the C file by:
           gcc open_cmd.c -c -I/include -o open_cmd.o
           ld -G open_cmd.o -o libpli.so

    and I get the following errors

            Elaborating the design hierarchy:
    $myfopen("./script.txt",fp);
           |
    ncelab: *W,MISSYST (../monitor/mon_top.sv,51|7): Unrecognized system task or function (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
    If item was defined in a shared-object library, the problem could be:
    ld.so.1: ncelab: fatal: libvpi.so: open failed: No such file or directory
    ld.so.1: ncelab: fatal: libpli.so: open failed: No such file or directory.
    while (!$myfeof(fp))
                  |
    ncelab: *W,MISSYST (../monitor/mon_top.sv,52|14): Unrecognized system task or function (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
     $myfgets(inline_vari,LINE_SIZE,fp);
            |
    ncelab: *W,MISSYST (../monitor/mon_top.sv,54|8): Unrecognized system task or function (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
     $mystokstr(inline_vari,cmd_str);
              |
    ncelab: *W,MISSYST (../monitor/mon_top.sv,55|10): Unrecognized system task or function (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
        $mystokdec(inline_vari,int_int);     
                 |
    ncelab: *W,MISSYST (../monitor/mon_top.sv,59|13): Unrecognized system task or function (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
        $mystokint(inline_vari,int_int);     
                 |
    ncelab: *W,MISSYST (../monitor/mon_top.sv,64|13): Unrecognized system task or function (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
           $mystokhex(inline_vari,hex1,hex2);      
                    |
    ncelab: *W,MISSYST (../monitor/mon_top.sv,69|16): Unrecognized system task or function (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
    $myfclose(fp);
            |
    ncelab: *W,MISSYST (../monitor/mon_top.sv,94|8): Unrecognized system task or function (did not match built-in or user-defined names) [2.7.4(IEEE Std 1364-2001)].
    ...
    ...
            Writing initial simulation snapshot: worklib.sv_utils:sv
    ncverilog: *E,SIMERR: Error during Simulation (status 1), exiting.


    Originally posted in cdnusers.org by bennik
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • JMGGL
    JMGGL over 16 years ago

    Did you finally find a solution for that? I've the same kind of issue.

    Thanks 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information