Saturday, July 05, 2008     Register | Login | Search | Contact Us
     
Home
Forums
Subject: unpacked structure in DPI
Posting to forums is available to community members only.
Login or Register
Rate this topic:
   
Author Messages
zqlsi
Posts: 5
Online: User is Offline
5/10/2008 2:45 AM  
Hi,

Does anyone know whether the SV unpacked structure can be passed to a C function through DPI?

I tried this in LDV6.2 but was told that this data type is unsupported as a formal augment.

Thanks!
Daniel
prasad_vc
Posts: 12
Online: User is Offline
5/11/2008 9:47 PM  
Check this out.

http://www.cdnusers.org/Forums/tabid/52/forumid/66/postid/2261/view/topic/Default.aspx

-Vivek

-Vivek C. Prasad
zqlsi
Posts: 5
Online: User is Offline
5/11/2008 10:18 PM  

Vivek,

Thanks for your reply! The example showes a packed structure while what I want is an unpacked structure with real type members. Do you have examples for unpacked structure in DPI?

Regards,
Daniel

prasad_vc
Posts: 12
Online: User is Offline
5/11/2008 11:10 PM  

Daniel,

Do you have any example code, which you can share?

-Vivek

-Vivek C. Prasad
tmackett
Posts: 34
Online: User is Offline
5/12/2008 9:06 AM  

I wrote two examples, one using packed structures, and another using unpacked structures.  The unpacked example is here:

The title is: Manipulating Unpacked Arrays using DPI

http://www.cdnusers.org/Forums/tabid/52/view/topic/forumid/66/postid/3123/Default.aspx


Todd Mackett
Cadence Incisive
zqlsi
Posts: 5
Online: User is Offline
5/12/2008 7:24 PM  
Hi Todd,

The example is helpful. Thanks! How about the unpacked STRUCT (with integer and real members)? Can I use this as arguments in an imported C function? 

Regards,
Daniel
tmackett
Posts: 34
Online: User is Offline
5/14/2008 11:25 AM  

I don't believe you can make reals part of a packed structure or put them into a unpacked array.

Here's another example showing how to use reals and DPI

http://www.cdnusers.org/Forums/tabid/52/view/topic/forumid/66/postid/2841/Default.aspx


Todd Mackett
Cadence Incisive
shalom
Posts: 13
Online: User is Offline
5/14/2008 11:53 AM  
You can have an unpacked array of reals.

Shalom.Bresticker@intel.com
tmackett
Posts: 34
Online: User is Offline
5/14/2008 1:30 PM  
I'll clarify that by saying, I don't think you can have a packed structure of reals (somehow) or an upacked array of reals AND put them over a DPI interface.

Todd Mackett
Cadence Incisive
zqlsi
Posts: 5
Online: User is Offline
5/14/2008 7:48 PM  
Thanks Todd!

I can use unpacked array of integer to exchange data in DPI now.  However, what I really need is to use an unpacked structure which has both real and integer data members in DPI. Will Cadence support this kind of thing in future release of LDV?

Regards,
Daniel
tmackett
Posts: 34
Online: User is Offline
5/15/2008 9:31 AM  
The spec basically says that class cannot be put across the DPI interface - only packed structures of bits and logic. This restriction basically leaves out classes and packed/unpacked reals (reals by themselves are fine). I'm not the one to comment on if Cadence will support that - but if any supplier does, it will be a non-standard implementation.

I have one thought...this might work...never tried it. If someone can code this up - please post it:
from SV:
a) create a SV real. Use realtobits() to convert it to a vector, pack the converted real into a packed structure.
b) send that structure across the DPI interface

DPI C code:
a) recieve packed structure containing encoded real per usual DPI transfer
b) decode it back to a C double using some function call <-- is there such a function call??

Todd Mackett
Cadence Incisive
zqlsi
Posts: 5
Online: User is Offline
5/15/2008 7:26 PM  
Hi Todd,

Thanks a lot for the answer! It's very helpful to me.

Regards,
Daniel
prasad_vc
Posts: 12
Online: User is Offline
5/15/2008 8:58 PM  
Daniel,

As suggested by Todd, you can use the "integer" for float and "longint" for double to create a struct and pass this struct to "C".

-Vivek C. Prasad
Posting to forums is available to community members only.
Login or Register

Forums > Functional Verification > SystemVerilog > unpacked structure in DPI


ActiveForums 3.6
     
Copyright 2006 Cadence Design Systems, Inc.