[sv-cc] Multidimensional dynamic array in DPI-C

From: Radoslaw Nawrot <Radoslaw.Nawrot@aldec.com.pl>
Date: Wed Apr 04 2012 - 23:30:53 PDT

Hello,
 
I have two interpretation problems:
 
1.) array querying functions for multidimensional dynamic array
 
Example code:
module top;
import "DPI-C" function a(int i [][]);
int y [][];
 initial
 begin
 y=new[4];
 y[0] = new[1];
 y[1] = new[2];
 y[2] = new[3];
 y[3] = new[4];
 a(y);
 end
 initial #1000 $finish;
endmodule

 
What should be returned on c side by svSize:
extern "C" int a(svOpenArrayHandle hnd) {

file<<"Size d2: "<<svSize(hnd,2)<<std::endl;

return 0;

}

?

Should be 0 ($high - $low + 1)? Or maybe simulation error would be better in
that case?

 

LRM says:

$left shall return the left bound of the dimension. For a packed dimension,
this is the index of the

most significant element. For a queue or dynamic array dimension, $left
shall return 0.

- $right shall return the right bound of the dimension. For a packed
dimension, this is the index of

the least significant element. For a queue or dynamic array dimension whose
current size is zero,

$right shall return -1.

- For a fixed-size dimension, $increment shall return 1 if $left is greater
than or equal to $right

and -1 if $left is less than $right. For a queue or dynamic array dimension,
$increment shall

return -1.

- $low shall return the same value as $left if $increment returns -1, and
the same value as

$right if $increment returns 1.

- $high shall return the same value as $right if $increment returns -1, and
the same value as

$left if $increment returns 1.

 

So all dynamic arrays should have size =0 ??

 If yes than how user can get information to hull data by index if he(she)
doesn't know how many index;es array have?

 

2.) If I use svGetArrElemPtr1(hnd, 0) should it return another
svOpenArrayHandle ?

    If not then how user can get number of second dimension elements to use
svGetArrElemPtr2 ??

    The same question about svGetArrayPtr

Thanks in advance ,

 

Radek

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Apr 4 23:31:53 2012

This archive was generated by hypermail 2.1.8 : Wed Apr 04 2012 - 23:32:08 PDT