• 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 27599
  • 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
Parents
  • 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
Reply
  • 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
Children
No Data

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