csystem-verilogsystem-verilog-dpi

How to manually compile shared dpi lib?


I try to import some C-function that generates an array in SystemVerilog.
Here is code:

#include "svdpi.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void getPacket(int packetSize, svOpenArrayHandle fpSig, svOpenArrayHandle err)
{
    int* cfpSig = (int*) calloc(packetSize, sizeof(int));
    double* cerr = (double*)calloc(packetSize, sizeof(double));

    for(int i = 0; i < packetSize; ++i)
    {
        cfpSig[i] = i;
        cerr[i] = 1.1*i;
        printf("%d %f\n",cfpSig[i],cerr[i]);
    }
    printf("----------");
    memcpy((int*) svGetArrayPtr(fpSig),cfpSig,packetSize);
    memcpy((int*) svGetArrayPtr(err),cerr,packetSize);
    free(cfpSig);
    free(cerr);
}
import "DPI-C" function void getPacket(input int packetSize,
                                    output int fpSig[], output real err[]);
module top();
    initial begin
        parameter int packetSize =  4;
        int fpSig[packetSize];
        real    err[packetSize];
        getPacket(packetSize,fpSig,err);
        for(int i = 0; i < packetSize; ++i) begin
            $display("fpSig: %d\nerr  : %f",fpSig[i],err[i]);
        end
    end

endmodule

But when I compile the c-code manually, an error is generated at the linking stage: undefined reference to 'svGetArrayPtr'.
I have not previously worked with svOpenArrayHandle and it was enough to connect the header file "svdpi.h". I tried to look for some svdpi.dll lib in the questa install folder, but didn't find it.

If I compile c-file by vlog it's working fine, but I want to compile it manually because I plan to include matlab libs and compiling via vlog will become uncomfortable.


Solution

  • In Questasim simulator, the library containing the svGetArrayPtr symbol is mtipli.dll