struct在DPI上的使用例
從VCS上改過來的例子
module main();
typedef struct {
int a;
int b;
} mystruct;
import "DPI" function void mydisplay(inout mystruct s1);
mystruct s1;
initial begin
s1.a =10;
s1.b =20;
$display("SV: s1.a=%0d,s1.b=%0d",s1.a,s1.b);
mydisplay(s1);
$display("SV after DPI call: s1.a=%0d,s1.b=%0d",s1.a,s1.b);
end
endmodule
#include "svdpi.h"
//#include "vcsuser.h"
#include <stdlib.h>
#include <stdio.h>
extern "C" {
typedef struct {
int a;
int b;
} mystruct;
void mydisplay(mystruct *s1) {
int s2;
printf("C: gets values from SV, s1.a=%d, s1.b=%d\n",s1->a,s1->b);
s1->a = 100;
s1->b = 200;
printf("C: set values, s1.a=%d, s1.b=%d\n",s1->a,s1->b);
}
}
沒有留言:
張貼留言