• 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. How to make verilog function calls from non-DPI C model...

Stats

  • Locked Locked
  • Replies 0
  • Subscribers 65
  • Views 14497
  • 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

How to make verilog function calls from non-DPI C model ?

YHLiu
YHLiu over 9 years ago

Hello all,

I am a software developer and new to design function verification.

Currently I am designing C test program model to test hardware design via DPI. And we wish the test program be stopped until hardware interrupt is handled. Hence we create one dedicated thread (called interrupt thread later) to handle interrupts. 

Whenever interrupt asserted, design calls import "DPI-C" task to notify C test program wakes interrupt thread up to handle asserted interrupt. Later interrupt thread get execution, it suspends the thread involved with test program to make sure all tests are stopped before handling interrupt. Certainly it needs to call export tasks to read/write design register and these calls are from non-DPI C function.

So ... Is there any simple method to make export tasks can be called from non-DPI C model like DpiOutOfTheBlue feature in ModelSim. Or SystemC is necessary to support the test scenario above ?

Besides we got some interesting results from experiment below.

1. Test 1: Calling export task in interrupt thread's routine, it showed error message below during simulation. 

ncsim: *E,NONCONG: The C identifier "ncs_read_register" representing an export task/function cannot be executed from a non-context area .

2. Test 2: Using svSetScope function to set context explicitly before call export task. Fail, it showed error message below. 

ncsim: *E,NOCONTG: DPI Scope function call allowed only from context function.

3. Test 3: Using atomic functions, __sync_lock_test_and_set/__sync_lock_release to sync. export task access in the C test program (between interrupt thread and main test thread). OK, the export task can be called and svGetScope can work!! I don't know why but it seems to exist a way which can make sure export task can be called from non-DPI C function. So the question is how to make sure it works always.

Thanks,

-YH

  • 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