Home > Community > Forums > Functional Verification > Importing C Function into System Verilog using DPI with 3-step process

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: *

 Importing C Function into System Verilog using DPI with 3-step process 

Last post Thu, Oct 31 2013 2:17 AM by 0725. 2 replies.
Started by 0725 31 Oct 2013 01:38 AM. Topic has 2 replies and 4086 views
Page 1 of 1 (3 items)
Sort Posts:
  • Thu, Oct 31 2013 1:38 AM

    • 0725
    • Not Ranked
    • Joined on Wed, Jul 3 2013
    • Posts 2
    • Points 25
    Importing C Function into System Verilog using DPI with 3-step process Reply

    Hi all,

    I want to import some C math function such as the sin and atan into my testbench using the DPI. It works fine when I use the "irum" command, the code should be right. But when I use the 3-step process it doesn't work. From the referrence manual I know that the c file should be first complied to the libdpi.so, but since I use the standare C function, which file should I compile? And I try to skip the compilation step and add the -sv_lib libm.so argument, it also doesn't work.

    I greatly appreciate any help.

     

    • Post Points: 20
  • Thu, Oct 31 2013 1:54 AM

    • muffi
    • Top 500 Contributor
    • Joined on Tue, Aug 4 2009
    • Bangalore, Karnataka
    • Posts 22
    • Points 305
    Re: Importing C Function into System Verilog using DPI with 3-step process Reply

     Here is an example which works:

    % gcc my_c_funcs.c -fpic -shared -o libdpi.so

    % ncvlog -sv my_test.sv -mess
    % ncelab -access +c worklib.my_test
    % ncsim worklib.my_test -sv_lib libdpi.so

     

    I hope this helps.

    • Post Points: 20
  • Thu, Oct 31 2013 2:17 AM

    • 0725
    • Not Ranked
    • Joined on Wed, Jul 3 2013
    • Posts 2
    • Points 25
    Re: Importing C Function into System Verilog using DPI with 3-step process Reply

     Hi muffi, thank you for your reply.

    The problem is I don't have the my_c_funcs.c file, because I just use the standare "sin" and "atan" math functions in my code. Do you have any idea about that?  

    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by 0725 at 31 Oct 2013 01:38 AM. Topic has 2 replies.