• 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. C++ code through DPI simulation error?

Stats

  • Locked Locked
  • Replies 18
  • Subscribers 64
  • Views 27586
  • 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

C++ code through DPI simulation error?

archive
archive over 18 years ago

Hi Cadence,

I have write a simple C code through DPI example, it work OK.

Then, I write a simple C++ code through DPI example. And found C++ compile and SV compile/elaboration pass. But  DPI link error? I guess its not DPI cannot found the lib as show in the ncsim log. Because the C code through DPI use the same configuration.
My friend tried the same example in Synopsys VCS and work OK.


//--- adder.cpp---
#include
#include "svdpi.h"
extern "C"{
    int sum(int a, int b);
    }

class CADD
{
    private:
        int a;
        int b;
   
    public:
        CADD();
        ~CADD();
        int add(int a, int b);

};

CADD::CADD()
{
}

CADD::~CADD()
{
}

int CADD::add(int a, int b)
{
    int c = a +b;
    return c;
       
}

int sum(int a, int b)
{
    CADD add1;
    int result = add1.add(a,b);
    printf("the result is %d\n",result);
}
//------------

//-- C++ compile makefile
#!/bin/sh
g++ adder.cpp -fPIC -shared -o libdpi.so -I $CDS_INST_DIR/tools/inca/include
//-------------

//-- switch add to ncsim
-sv_lib ./src/test_sv/libdpi.so
//------------

Run simulation and output:
ncsim: 05.83-s003: (c) Copyright 1995-2007 Cadence Design Systems, Inc.
snapshot worklib.top:module (SSS) is up to date (no update required).
Loading snapshot worklib.top:module .................... Done
ncsim: *W,NOLDPI: Unable to load ./src/test_sv/libdpi.so.
OSDLERROR: /cad/cadence/IUS583-s003-linux/tools.lnx86/lib/libgcc_s.so.1: version cannot open shared object file: No such file or directory or file is not valid ELFCLASS32 library..
ncsim: *F,NOFDPI: Function sum not found in any of the shared object specified with -SV_LIB switch.
ncsim: Memory Usage - 17.9M program + 10.4M data = 28.3M total
ncsim: CPU Usage - 0.0s system + 0.1s user = 0.2s total (1.0s, 15.8% cpu)

Best regards,
Davy


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

    Davy,

    Try the following in any of your environment.

    setenv LD_LIBRARY_PATH /cad/cadence/IUS61/lnx86/tools.lnx86/systemc/gcc/3.2.3/install/lib

    Put the above statement in your .cshrc file and save and exit. Source the .cshrc file from the terminal from where you are going to invoke the simulation and finally run the simulation.

    If this doesn't work, send me the output of the following command: gcc -v

    -Vivek






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

    Hi Vivek,

    Continue the last post,

    I have check the shared lib file.
    IUS on SunOS:
    libstdc++.so.2.10.0 CANNOT found on SunOS /usr/lib

    IUS on Linux:
    Both /cad/cadence/IUS61/lnx86/tools.lnx86/lib/libgcc_s.so.1 and /usr/lib/libstdc++.so.5 CAN be found
    But what's "version `GCC_3.3' not found " mean?
    Shall the lib/libgcc_s.so.1 be compiled with GCC_3.3?

    Any Cadence engineer can show me the right direction?

    Best regards,
    Davy


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

    Hi Vivek,

    I add
    setenv LD_LIBRARY_PATH /cad/cadence/IUS61/lnx86/tools.lnx86/systemc/gcc/3.2.3/install/lib:{$LD_LIBRARY_PATH}

    When I compile the c++ file on Linux machine, g++ give out errors:
    g++: Internal error: Segmentation fault (program as)
    Please submit a full bug report.
    See for instructions.

    >> gcc -v
    Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
    Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
    Thread model: posix
    gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-52)

    Best regards,
    Davy


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

    Davy,

    Would it be possible to zip and send the programs so that i can try those out? Kindly send it to prasad_vc@yahoo.com

    GCC_3.3 means to me, the tool has used the gcc version 3.3 to build and now we are using the gcc 3.2.3 version. I guess you are right that the libgcc_s.so.1 should be compiled with GCC_3.3.

    -Vivek.


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

    Hi Vivek,

    I have send a email (all the related files are attached) to you, thanks!

    Best regards,
    Davy


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

    Hi Vivek,

    I found there is a gcc3.4.6 under IUS,
    /cad/cadence/IUS61/lnx86/tools.lnx86/systemc/gcc/3.4.6

    I have added
    setenv LD_LIBRARY_PATH /cad/cadence/IUS61/lnx86/tools.lnx86/systemc/gcc/3.4.6/install/lib:{$LD_LIBRARY_PATH}

    But when I type
    >> gcc -v
    echo always gcc 3.2.3.

    What environment parameter shall I change to force system use gcc3.4.6?

    Best regards,
    Davy


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

    Hi Davy.

    You probably want to set your PATH variable too:
    setenv PATH /cad/cadence/IUS61/lnx86/tools.lnx86/systemc/gcc/3.4.6/install/bin:${PATH}

    Cheers.
    Steve.


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

    Hi Vivek, Steve and all,

    The C++ by DPI testbench worked finally :)
    There is one hint for others who want to use it.
    Try to make sure the compiler PATH and the library LD_LIBRARY_PATH are the same version (for example, both 3.4.6).
    >> gcc -v
    find the gcc compiler version
    >> echo $LD_LIBRARY_PATH
    find the library version

    Best regards,
    Davy


    Originally posted in cdnusers.org by davyzhu
    • 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