2011年5月6日 星期五

DPI再了解(八)

DPI long  常數資料的傳送
從VCS的example整理出來的

module main();
    longint i1;
   
    import "DPI" function void mydisplay(inout longint i1);
    initial begin
        i1=64'h1234_5678_9000;
        $display("SV: i1 is %0h",i1);
        mydisplay(i1);
        $display("SV(after DPI call): i1 is %0h",i1);
    end

endmodule

#include "svdpi.h"
//#include "vcsuser.h"

#include <stdlib.h>
#include <stdio.h>

extern "C" {
    void mydisplay(long long *i1) {
        printf("C: size of long long is %0d bytes\n",sizeof(long long));
        printf("C: i1 is %llx\n",*i1);
        (*i1) = (*i1) * 2;   
        printf("C: change i1 to %llx\n",*i1);
       
    }
}

沒有留言: