• 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. get an error using 3 steps DPI C to simulate systemveri...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 66
  • Views 16810
  • 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

get an error using 3 steps DPI C to simulate systemverilog

jbriquet
jbriquet over 11 years ago

Hello all, 

I want to call a C function within my systemverilog file using DPI C. I have tried the one step (irun -sv hello.c hello.sv )and it worked very well. But the thing I want to do is to create my own shared object .so, to do this I have tried a 3 steps methodology (ncvlog ,ncelab and ncsim) but it failed when I want to simulate it.

I got this message : ncsim: *F,NOLWSV: Searching for import subroutine "print" in default library libdpi. Unable to load the default library libdpi.OSDLERROR: ./libdpi.so: only ET_DYN and ET_EXEC can be loaded.

Please find in this following paragraph all my files and script to do this. 

Thank you by advance,

 Jean-Pierre

 

 /////// top.sv
module top;
bit clk,rst;


helloworld U0(.clk(clk),.rst(rst));
////// reset

/*
initial begin

rst=1;
#15;
rst=0;

end


///// clock
initial begin

clk=0;
#5;
forever begin
#5 clk=~clk;
end

end
*/

endmodule

module helloworld(clk,rst) ;

input clk;
input rst;

bit clk, rst;

import "DPI-C" context function void print();

always @( posedge clk ) begin

$display("hello world");
        print();
end

endmodule

/////// hello.c 

#include <stdio.h>
//#include <vpi_user.h>
//#include "svdpi.h"

void print()
 { printf("helloworld from C \n");}


/////// cds.lib 

DEFINE lib ./lib1

/////// run using irun ( This solution works !!! ) But I want to create manually my shared object 

irun -cdslib cds.lib -sv test.c test.sv

//////// run using NC-Verilog ( This solution doesn't work )

ncvlog -cdslib cds.lib -messages -sv top.sv -work lib

ncelab -messages -access +RWC lib.top

gcc -fPIC -shared -o libdpi.so test.c -I/pkg/cadence-incisiv-/13.20.003/i686-linux/tools/inca/include/ -m32 -c  

ncsim -messages lib.top

///////  script report
...helloworld_verilated/test 600$ ncvlog -cdslib cds.lib -messages -sv top.sv -work lib

ncvlog: 13.20-s003: (c) Copyright 1995-2014 Cadence Design Systems, Inc.
file: top.sv
        module lib.top
                errors: 0, warnings: 0
        module lib.helloworld
                errors: 0, warnings: 0
...helloworld_verilated/test 601$ ncelab -messages -access +RWC lib.top
ncelab: 13.20-s003: (c) Copyright 1995-2014 Cadence Design Systems, Inc.
        Elaborating the design hierarchy:
                Caching library 'lib' ....... Done
        Building instance overlay tables: .................... Done
        Generating native compiled code:
                lib.helloworld:module <0x7028777f>
                        streams:   1, words:  1182
                lib.top:module <0x77267332>
                        streams:   2, words:   196
        Building instance specific data structures.
        Loading native compiled code:     .................... Done
        Design hierarchy summary:
                             Instances  Unique
                Modules:             2       2
                Registers:           2       2
                Scalar wires:        2       -
                Always blocks:       1       1
                Pseudo assignments:  2       2
        Writing initial simulation snapshot: lib.top:module

...helloworld_verilated/test 602$ gcc -fPIC -shared -o libdpi.so test.c -I/pkg/cadence-incisiv-/13.20.003/i686-linux/tools/inca/include/ -m32 -c  

...helloworld_verilated/test 603$ ncsim -messages lib.top

ncsim: 13.20-s003: (c) Copyright 1995-2014 Cadence Design Systems, Inc.
Loading snapshot lib.top:module .................... Done
ncsim: *F,NOLWSV: Searching for import subroutine "print" in default library libdpi. Unable to load the default library libdpi.
OSDLERROR: ./libdpi.so: only ET_DYN and ET_EXEC can be loaded.

 
 

 

  • Cancel
  • FlyingHeart
    FlyingHeart over 11 years ago

     You need to use ncsim -svlib lib_name to load the dpi library generated by gcc, otherwise, the link process will report error

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • jbriquet
    jbriquet over 11 years ago

    Thank you, but i have used the simple way to do it using irun . But i have a question, is it possible to load several shared object and not only using the default "libdpi.so" ? because i have several shared object corresponding to a function, and i want to call several function from different shared object ... 

    Is it possible to do this ?

    thank you by advance,

    Sincerely,

     Jean-Pierre 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • FlyingHeart
    FlyingHeart over 11 years ago

    In fact, you can generate multiple librires and use multiple -svlib lib_name to load multiple libraries and use different functions in irunto realize your idea.

    • 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