Home > Community > Forums > Functional Verification > C DPI compilation error

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 C DPI compilation error 

Last post Mon, Nov 16 2009 2:55 AM by StephenH. 3 replies.
Started by abhingp01 13 Nov 2009 04:10 AM. Topic has 3 replies and 4391 views
Page 1 of 1 (4 items)
Sort Posts:
  • Fri, Nov 13 2009 4:10 AM

    • abhingp01
    • Not Ranked
    • Joined on Thu, Aug 6 2009
    • Posts 14
    • Points 295
    C DPI compilation error Reply

    Hi all,

     I am checking my OVC against existing eVC. My OVC has some DPI interfaces with C-code.

     C-Code is as follows:

    #include<math.h>
    #include"svdpi.h"

    int ilog2_inC(int val)
    {
       return (log2(val));
    }


    int ipow_inC(int val)
    {
       return(pow(2,val));
    }

    I am using it in my monitor class of OVC.

    Following statements imports it:

    import "DPI-C" pure function int ilog2_inC(int logchk);
    import "DPI-C" pure function int ipow_inC(int logchk);

     But on compiling I am getting following error:

    ncsim: *F,NOLWSV: Unable to load the default library libdpi.
    OSDLERROR: ./libdpi.so: cannot open shared object file: No such file or directory or file is not valid ELFCLASS32 library..

     

    Kindly help for same.

     

    Regards

    Abhishek

    Filed under:
    • Post Points: 20
  • Fri, Nov 13 2009 4:33 AM

    • StephenH
    • Top 25 Contributor
    • Joined on Tue, Sep 2 2008
    • Bristol, Avon
    • Posts 278
    • Points 4,450
    Re: C DPI compilation error Reply

    Hi Abhishek.

    You haven't said how you compiling the C code, or how you're using irun or ncsim, so it's hard to see the exact problem.

    At a guess though, you're running on a 64-bit CPU; but using the standard 32-bit ncsim process. That's fine, and performance will be better than 64-bit simulation, but it does mean that you need to take care to compile your C code with gcc's "-m32" flag to get 32-bit object files. By default on a 64-bit CPU, gcc will build a 64-bit binary, which is not what you wantfor ncsim.

    Post your exact gcc and ncsim / irun commands and we'll have a bit more to go on.

    Oh, and either way, let us know if the gcc option helps!

    Steve.

    Steve Hobbs / Applications Engineer / Cadence Functional Verification
    • Post Points: 20
  • Sun, Nov 15 2009 8:37 PM

    • abhingp01
    • Not Ranked
    • Joined on Thu, Aug 6 2009
    • Posts 14
    • Points 295
    Re: C DPI compilation error Reply

    Hi steve,

    Here is the irun command.

    irun +access+rwc  +tcl+sim.tcl -ovm  -snvlog  -snpath /home/abhishek/project_mmbd/specman/phil_lib/phil_dtl/e  -snload /home/abhishek/project_mmbd/specman/phil_lib/dtl_mmbd_config.e  -incdir /home/abhishek/project_mmbd/dtl_param_saved/examples -incdir /home/abhishek/project_mmbd/dtl_param_saved/sv  /home/abhishek/project_mmbd/dtl_param_saved/sv/cprog.c  /home/abhishek/project_mmbd/dtl_param_saved/examples/dtl_mmbd_tb_top.sv +OVM_TESTNAME=test_read_modify_write -snprerun "set message FULL;test" +TEST_RUN_TIME=2000000

    Regards

    Abhishek

    • Post Points: 20
  • Mon, Nov 16 2009 2:55 AM

    • StephenH
    • Top 25 Contributor
    • Joined on Tue, Sep 2 2008
    • Bristol, Avon
    • Posts 278
    • Points 4,450
    Re: C DPI compilation error Reply

    Hi Abhishek.

    From the paths in the file names, I think I recognise the company you work for, and I recall that all the tools are heavily wrapped by your CAD team, so the "irun" command that you run is not the exact irun that Cadence supplies. Thus there  may be some issue in the wrapper.

    When I debug something like this, I always start with a known-good example and make sure that works on the local IT setup.
    For DPI code, you should try running one of the DPI examples that come with Incisive.
    Can you try the following commands, and if they don't work, please talk to your IT support to see what's wrong in your IT setup?

    cp -r `ncroot`/doc/dpiEngrNtbk/fourbit_ctr $HOME
    cd $HOME/fourbit_ctr
    irun -sv top.v t_counter.v t_ff.v counter.c

    Note: the ncroot command is enclosed in back-ticks (like the Verilog `include tick), this executes the ncroot command to return the path to the tool installation.

    Regards,

    Steve.

    Steve Hobbs / Applications Engineer / Cadence Functional Verification
    Filed under:
    • Post Points: 5
Page 1 of 1 (4 items)
Sort Posts:
Started by abhingp01 at 13 Nov 2009 04:10 AM. Topic has 3 replies.