Quantcast
Channel: Cadence Functional Verification Forum
Viewing all articles
Browse latest Browse all 1074

get an error using 3 steps DPI C to simulate systemverilog

$
0
0

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.

 
 

 


Viewing all articles
Browse latest Browse all 1074

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>