Verification Academy

Search form

My Account Menu

  • Register
  • Log In
  • Topics
  • Courses
  • Forums
  • Patterns Library
  • Cookbooks
  • Events
  • More
  • All Topics
    The Verification Academy offers users multiple entry points to find the information they need. One of these entry points is through Topic collections. These topics are industry standards that all design and verification engineers should recognize. While we continue to add new topics, users are encourage to further refine collection information to meet their specific interests.
    • Languages & Standards

      • Portable Test and Stimulus
      • Functional Safety
      • Design & Verification Languages
    • Methodologies

      • UVM - Universal Verification Methodology
      • UVM Framework
      • UVM Connect
      • FPGA Verification
      • Coverage
    • Techniques & Tools

      • Verification IP
      • Simulation-Based Techniques
      • Planning, Measurement, and Analysis
      • Formal-Based Techniques
      • Debug
      • Clock-Domain Crossing
      • Acceleration
  • All Courses
    The Verification Academy is organized into a collection of free online courses, focusing on various key aspects of advanced functional verification. Each course consists of multiple sessions—allowing the participant to pick and choose specific topics of interest, as well as revisit any specific topics for future reference. After completing a specific course, the participant should be armed with enough knowledge to then understand the necessary steps required for maturing their own organization’s skills and infrastructure on the specific topic of interest. The Verification Academy will provide you with a unique opportunity to develop an understanding of how to mature your organization’s processes so that you can then reap the benefits that advanced functional verification offers.
    • Universal Verification Methodology (UVM)

      • Advanced UVM
      • Basic UVM
      • Introduction to UVM
      • UVM Connect
      • UVM Debug
      • UVMF - One Bite at a Time
    • Featured Courses

      • Introduction to ISO 26262
      • Introduction to DO-254
      • Clock-Domain Crossing Verification
      • Portable Stimulus Basics
      • Power Aware CDC Verification
      • Power Aware Verification
      • SystemVerilog OOP for UVM Verification
    • Additional Courses

      • Assertion-Based Verification
      • An Introduction to Unit Testing with SVUnit
      • Evolving FPGA Verification Capabilities
      • Metrics in SoC Verification
      • SystemVerilog Testbench Acceleration
      • Testbench Co-Emulation: SystemC & TLM-2.0
      • Verification Planning and Management
      • VHDL-2008 Why It Matters
    • Formal-Based Techniques

      • Formal Assertion-Based Verification
      • Formal-Based Technology: Automatic Formal Solutions
      • Formal Coverage
      • Getting Started with Formal-Based Technology
      • Handling Inconclusive Assertions in Formal Verification
      • Sequential Logic Equivalence Checking
    • Analog/Mixed Signal

      • AMS Design Configuration Schemes
      • Improve AMS Verification Performance
      • Improve AMS Verification Quality
  • All Forum Topics
    The Verification Community is eager to answer your UVM, SystemVerilog and Coverage related questions. We encourage you to take an active role in the Forums by answering and commenting to any questions that you are able to.
    • UVM Forum

      • Active Questions
      • Solutions
      • Replies
      • No Replies
      • Search
      • UVM Forum
    • SystemVerilog Forum

      • Active Questions
      • Solutions
      • Replies
      • No Replies
      • Search
      • SystemVerilog Forum
    • Coverage Forum

      • Active Questions
      • Solutions
      • Replies
      • No Replies
      • Search
      • Coverage Forum
    • Additional Forums

      • Announcements
      • Downloads
      • OVM Forum
  • Patterns Library
    The Verification Academy Patterns Library contains a collection of solutions to many of today's verification problems. The patterns contained in the library span across the entire domain of verification (i.e., from specification to methodology to implementation—and across multiple verification engines such as formal, simulation, and emulation).
    • Implementation Patterns

      • Environment Patterns
      • Stimulus Patterns
      • Analysis Patterns
      • All Implementation Patterns
    • Specification Patterns

      • Occurrence Property Patterns
      • Order Property Patterns
      • All Specification Patterns
    • Pattern Resources

      • Start Here - Patterns Library Overview
      • Whitepaper - Taking Reuse to the Next Level
      • Verification Horizons - The Verification Academy Patterns Library
      • Contribute a Pattern to the Library
  • All Cookbooks
    Find all the methodology you need in this comprehensive and vast collection. The UVM and Coverage Cookbooks contain dozens of informative, executable articles covering all aspects of UVM and Coverage.
    • UVM Cookbook

      • UVM Basics
      • Testbench Architecture
      • DUT-Testbench Connections
      • Configuring a Test Environment
      • Analysis Components & Techniques
      • End Of Test Mechanisms
      • Sequences
      • The UVM Messaging System
      • Other Stimulus Techniques
      • Register Abstraction Layer
      • Testbench Acceleration through Co-Emulation
      • Debug of SV and UVM
      • UVM Connect - SV-SystemC interoperability
      • UVM Versions and Compatibility
      • UVM Cookbook
    • Coding Guidelines & Deployment

      • Code Examples
      • UVM Verification Component
      • Package/Organization
      • Questa/Compiling UVM
      • SystemVerilog Guidelines
      • SystemVerilog Performance Guidelines
      • UVM Guidelines
      • UVM Performance Guidelines
    • Coverage Cookbook

      • Introduction
      • What is Coverage?
      • Kinds of Coverage
      • Specification to Testplan
      • Testplan to Functional Coverage
      • Bus Protocol Coverage
      • Block Level Coverage
      • Datapath Coverage
      • SoC Coverage Example
      • Requirements Writing Guidelines
      • Coverage Cookbook
  • All Events
    No one argues that the challenges of verification are growing exponentially. What is needed to meet these challenges are tools, methodologies and processes that can help you transform your verification environment. These recorded seminars from Verification Academy trainers and users provide examples for adoption of new technologies and how to evolve your verification process.
    • Upcoming & Featured Events

      • The Digital Twin: An Aerospace and Defense Revolution - March 9th
      • VIP solutions for Protocol and Memory Verification  - March 11th
      • Advance your Designs with Advances in CDC and RDC - March 23rd
      • Webinar Calendar
    • On Demand Seminars

      • The ABC of Formal Verification
      • I'm Excited About Formal...
      • 2020 Functional Verification Study
      • All On-Demand Seminars
    • Recording Archive

      • Improving Your SystemVerilog & UVM Skills
      • Should I Kill My Formal Run?
      • Visualizer Debug Environment
      • All Recordings
    • Conferences

      • DVCon 2020
      • DAC 2019
      • All Conferences
    • Mentor Learning Center

      • SystemVerilog Fundamentals
      • SystemVerilog UVM
      • View all Learning Paths
  • About Verification Academy
    The Verification Academy will provide you with a unique opportunity to develop an understanding of how to mature your organization's processes so that you can then reap the benefits that advanced functional verification offers.
    • Blog & News

      • Verification Horizons Blog
      • Academy News
      • Academy Newsletter
      • Technical Resources
    • Verification Horizons Publication

      • Verification Horizons - November 2020
      • Verification Horizons - July 2020
      • Verification Horizons - March 2020
      • Issue Archive
    • About Us

      • Verification Academy Overview
      • Subject Matter Experts
      • Contact Us
    • Training

      • Questa® & ModelSim®
      • Questa® inFact
      • Functional Verification Library
Ask a Question
UVM
  • Home
  • Forums
  • UVM
  • DPI import function not found

DPI import function not found

UVM 5582
DPI 9 #uvm 239
zz8318
zz8318
Full Access
132 posts
July 25, 2018 at 9:20 am

I created a cpp file named get_reg_name.cpp as shown below.

extern "C" {

uint32 get_reg_addr_dpi(const char* reg_name) {
    uint32 reg_addr;
    ...
    return reg_addr;
}
}

and in my global file (my_globals.svh) I import it as shown below.

import "DPI-C" function uint32 get_reg_addr_dpi(string reg_name);

when I use it, I hit the error that the DPI import function not found. No idea what code I missed ?

Thank you !

Replies

Log In to Reply
cuonghle
cuonghle
Full Access
308 posts
July 25, 2018 at 9:46 am

In reply to zz8318:

Please change:
- "uint32" in SV to "int unsigned". SV doesn't understand "uint32" type.
- "uint32" in C to "unsigned int" (or keep it if you have this type in C)

I create an example for you, it works:
https://www.edaplayground.com/x/4gdC

Chris Le

dave_59
dave_59
Forum Moderator
8586 posts
July 25, 2018 at 9:53 am

In reply to zz8318:

Please check the user manual of your tool for running DPI code. This forum is not for tool specific issues.

— Dave Rich, Verification Architect, Siemens EDA

zz8318
zz8318
Full Access
132 posts
July 25, 2018 at 9:55 am

In reply to chris_le:

forget to mentioned that I already typedef it in the my_globals.svh file

typedef int unsigned uint32;

zz8318
zz8318
Full Access
132 posts
January 16, 2019 at 2:48 pm

In reply to dave_59:

I have a further question that whether the import/export function declaration must be inside a module ? The error information is shown below.

Error-[DPI-DXFNF] DPI export function not found
Please check the called DPI export function/task is defined in the mentioned
module, or check if the DPI declaration of the DPI import function/task
which invokes that DPI export function/task is made with 'context'. Another
work-around is using svGetScopeFromName/svSetScope to explicitly set the
scope to the module which contains the definition of the DPI export
function/task.

dave_59
dave_59
Forum Moderator
8586 posts
January 16, 2019 at 3:57 pm

In reply to zz8318:

DPI imports/exports do not need to be in a module.

Did you follow all the advice given by the error message? Did you package import the DPI exported function into the module where you called the DPI imported function?

A complete skeletal example that reproduces the problem would really help.

— Dave Rich, Verification Architect, Siemens EDA

zz8318
zz8318
Full Access
132 posts
January 16, 2019 at 4:17 pm

In reply to dave_59:

Hi Dave,
Do you mean the DPI imports/exports function needs to be inside a module, right ?
I am sorry the example I currently have is a bit complicated and I have little idea how to express it here...

dave_59
dave_59
Forum Moderator
8586 posts
January 16, 2019 at 4:28 pm

In reply to zz8318:

DPI imports/exports do not need to be in a module.

I cannot help you any further without some idea of where you are declaring the DPI in/exports, and where you are calling them from.

— Dave Rich, Verification Architect, Siemens EDA

zz8318
zz8318
Full Access
132 posts
January 16, 2019 at 5:01 pm

In reply to dave_59:

I see. Thanks a lot anyway. I will try to figure it out myself. :)

zz8318
zz8318
Full Access
132 posts
January 18, 2019 at 7:06 am

In reply to dave_59:

Now I fixed the "DPI not found" issue but encountered next error which is Segmentation Fault.
May I know how to debug this kind of error ? It looks like too little error information in the logfile.

Here is my code:
C file:

struct reg_t {
  unsigned int addr;
  unsigned int data;
}
 
extern "C" void exported_sv_function(reg_t a);
extern "C" void get_all_reg() {
  reg_t tmp;
  unsigned int total = 500;
  unsigned int idx;
  for (idx = 0; idx < total; idx++) {
    tmp.addr = idx;
    tmp.data = idx;
    exported_sv_function(tmp);
}

and in my sv file :

typedef struct {
  logic [31:0] addr;
  logic [31:0] data;
} reg_t;
reg_t my_reg_array[$];
 
export"DPI-C" function exported_sv_function;
function void exported_sv_function(input reg_t x);
    my_reg_array.push_back(x);
endfunction
 
import "DPI-C" context function void get_all_reg();

and in my test (my_test.sv file)

...
task my_test::run_phase(uvm_phase phase);
    get_all_reg();         // The Segmentation fault is happened here
endtask
...

And the whole error information is shown below.

An unexpected termination has occurred in /proj/out/.../sim/exec/vcs_sim_exe due to a signal: Segmentation fault

Dumping VCS Annotated Stack:
#0 0x00000033dda0b63c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00002aaad1154240 in ndpBIMT_popElem () from /tool/cbar/apps/verdi/2017.03-SP2-11/share/PLI/lib/LINUXAMD64/libsscore_vcs201703.so
#2 0x00002aaad115482e in ndpBIMT_ConsumerMain () from /tool/cbar/apps/verdi/2017.03-SP2-11/share/PLI/lib/LINUXAMD64/libsscore_vcs201703.so
#3 0x00000033dda07a51 in start_thread () from /lib64/libpthread.so.0
#4 0x00000033dd2e896d in clone () from /lib64/libc.so.6
#0 0x00000033dd2ac6cd in waitpid () from /lib64/libc.so.6
#1 0x00000033dd23e609 in do_system () from /lib64/libc.so.6
#2 0x00000033dd23e940 in system () from /lib64/libc.so.6
#3 0x00002aaab41f71bb in SNPSle_10ee25eff68cd8461c9146fa1d0b35e87067f3c8015b313e639d2928478c79b3f673f99203bcf8be64600612100082236bffb2007f1e0ef9 () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/liberrorinf.so
#4 0x00002aaab41f8bc6 in SNPSle_10ee25eff68cd8461c9146fa1d0b35e87067f3c8015b313efba706aab251478fa49e66610e453774633a6c152e7ef778f2202cda681f3d4e () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/liberrorinf.so
#5 0x00002aaab41f1c95 in SNPSle_d35ca1ff70d465c2b9b1a72eee90a506fdd009d3de3db1de () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/liberrorinf.so
#6 0x00002aaab733ce68 in SNPSle_64133461705005bb725549e2e6fa1b3f () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#7 0x00002aaab719e43e in SNPSle_82244d58c54c18c70d63edc9becab634 () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#9 0x00000033dd283900 in memmove () from /lib64/libc.so.6
#10 0x00002aaab84715c4 in SNPSle_2681ff91466c07ba85e55d8e718f74c7f0dd524361188f7def6afc2d54b39315 () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#11 0x00002aaab847442f in SNPSle_64cf966be35473e7c27d42cab9451f7c620b2a08eac4939b () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#12 0x00002aaaac929ba9 in F_VCSgd_EaWgM_166_0 () from /proj/.../pub/sim/exec/vcs_sim_exe.daidir/_29753_archive_1.so
#13 0x00002aaaaf36b5b2 in exported_sv_function () from /proj/.../pub/sim/exec/vcs_sim_exe.daidir/_prev_archive_1.so
#14 0x0000000000427655 in rlc_get_all_reg ()
#15 0x00002aaaac913059 in U_VCSgd_EaWgM_136 () from /proj/.../pub/sim/exec/vcs_sim_exe.daidir/_29753_archive_1.so
#16 0x00002aaab73ba864 in SNPSle_ba9d6ef1a21efcfe () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#17 0x00002aaaac8fc15f in U_VCSgd_EaWgM_16 () from /proj/.../pub/sim/exec/vcs_sim_exe.daidir/_29753_archive_1.so
#18 0x00002aaab73ba864 in SNPSle_ba9d6ef1a21efcfe () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#19 0x00002aaab73ba864 in SNPSle_ba9d6ef1a21efcfe () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#20 0x00002aaab73ba864 in SNPSle_ba9d6ef1a21efcfe () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#21 0x00002aaaafb7e629 in U_VCSgd_hEeZs_211 () from /proj/.../pub/sim/exec/vcs_sim_exe.daidir/_prev_archive_1.so
#22 0x00002aaaafb7f11d in F_VCSgd_hEeZs_13328_0 () from /proj/.../pub/sim/exec/vcs_sim_exe.daidir/_prev_archive_1.so
#23 0x00002aaaafb7e97a in U_VCSgd_hEeZs_212 () from /proj/.../pub/sim/exec/vcs_sim_exe.daidir/_prev_archive_1.so
#24 0x00002aaaaf634f83 in N_VCSgd_irqrb () from /proj/.../pub/sim/exec/vcs_sim_exe.daidir/_prev_archive_1.so
#25 0x00002aaab72ed620 in SNPSle_63c7abb936d47b07d29d61775f9dbe8c () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#26 0x00002aaab7351f2f in SNPSle_490598bfebcc8e81efcf3d1815066cc9 () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#27 0x00002aaab7367178 in SNPSle_490598bfebcc8e81 () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so
#28 0x00002aaab3814717 in main () from /proj/.../pub/sim/exec/vcs_sim_exe.daidir/_csrc0.so
#29 0x00000033dd21ed5d in __libc_start_main () from /lib64/libc.so.6
#30 0x0000000000426289 in _start ()

Thanks for your great help in advance.

dave_59
dave_59
Forum Moderator
8586 posts
January 18, 2019 at 9:15 am

In reply to zz8318:

Debugging DPI code requires tool specific help, and this Mentor sponsored public forum is not for tool specific issues. Please contact your vendor directly.

— Dave Rich, Verification Architect, Siemens EDA

cgales
cgales
Forum Moderator
1577 posts
January 18, 2019 at 9:29 am

In reply to zz8318:

As a follow-up to Dave's comment, you should read Appendix H of the LRM regarding the DPI C layer and how data types are mapped. A logic[31:0] is not compatible with unsigned int.

zz8318
zz8318
Full Access
132 posts
January 18, 2019 at 9:33 am

In reply to cgales:

I tried other type actually but met the same issue.

rashi_bhardwaj
rashi_bhardwaj
Full Access
1 post
January 08, 2021 at 12:36 am

In reply to zz8318:

Hi, How did you rsolve the DPI not found error. I am facing the same issue after folllowing all steps diligently

Siemens Digital Industries Software

Siemens Digital Industries Software

##TodayMeetsTomorrow

Solutions

  • Cloud
  • Mendix
  • Siemens EDA
  • MindSphere
  • Siemens PLM
  • View all portfolio

Explore

  • Digital Journeys
  • Community
  • Blog
  • Online Store

Siemens

  • About Us
  • Careers
  • Events
  • News and Press
  • Newsletter
  • Customer Stories

Contact Us

USA:

phone-office +1 800 547 3000

See our Worldwide Directory

  • Contact Us
  • Support Center
  • Give us Feedback
©2021 Siemens Digital Industries Software. All Rights Reserved.
Terms of Use Privacy Cookie Policy