RE: [sv-cc] example code errors in I.12.9 ?

From: Warmke, Doug <doug_warmke_at_.....>
Date: Sun Mar 01 2009 - 22:09:33 PST
Hi Shalom,

 

The example has a couple of problems that make it unable to compile,

but not in the code related to DPI.  The … in the struct declarations, for example.

Another problem is that the import function “foo” is called in the middle of nowhere

in $unit, which isn’t allowed.

 

I got the example working fine in the simulator available to me by correcting

those MyType declarations and the other minor syntax errors.

 

No LRM-related changes appear necessary.

 

Regards,

Doug

 

test.c:

#include "svdpi.h"

typedef struct { int x; } MyType;

void foo(const svOpenArrayHandle hin, const svOpenArrayHandle hout)

{ 

int count = svSize(hin, 1);

  MyType *s = (MyType *)svGetArrayPtr(hin);

  MyType *d = (MyType *)svGetArrayPtr(hout);

  if (s && d) { 

  /* both arrays have C layout */

  /* an efficient solution using pointer arithmetic */

  while (count--) 

  *d++ = *s++; 

 

} else   {   /* less efficient yet implementation independent */ 

   int i = svLow(hin, 1);

   int j = svLow(hout, 1);

   while (i <= svHigh(hin, 1)) { 

   *(MyType *)svGetArrElemPtr1(hout, j++) = 

   *(MyType *)svGetArrElemPtr1(hin, i++); 

   } 

 } 

}

 

test.sv:

typedef struct {

    int x;

} MyType; 

import "DPI-C" function void foo(input MyType i [], output MyType o []);

MyType source [11:20];  

MyType target [11:20]; 

module top; 

    initial begin

        source[11].x = 123;

        source[20].x = 999;

        foo(source, target);

        $display("source[11].x=%0d, source[12].x=%0d, source[20].x=%0d, target[11].x=%0d, target[12].x=%0d, target[20].x=%0d",

            source[11].x, source[12].x, source[20].x, target[11].x, target[12].x, target[20].x);

    end

endmodule

 

Regards,

Doug

 

From: owner-sv-cc@server.eda.org [mailto:owner-sv-cc@server.eda.org] On Behalf Of Bresticker, Shalom
Sent: Sunday, March 01, 2009 9:44 PM
To: SV-CC
Subject: [sv-cc] example code errors in I.12.9 ?

 

Hi, SV-CC.

 

Please see the discussion in http://verificationguild.com/modules.php?name=Forums&file=viewtopic&p=14513 on the example code in I.12.9 and comment on whether changes are needed.

 

Thanks,

Shalom

 

Shalom Bresticker

Intel Jerusalem LAD DA

+972 2 589-6582

+972 54 721-1033

 

 

---------------------------------------------------------------------
Intel Israel (74) Limited
 
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


-- 
This message has been scanned for viruses and 
dangerous content by MailScanner <http://www.mailscanner.info/> , and is 
believed to be clean. 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Sun Mar 1 22:10:34 2009

This archive was generated by hypermail 2.1.8 : Sun Mar 01 2009 - 22:10:38 PST