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

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

$
0
0

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


Viewing all articles
Browse latest Browse all 1074

Trending Articles



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