System Verilog DPI - unknown array size

1.4k Views Asked by At

I have the following code:

file.sv

module svtest();

    import "DPI-C" function void my_func(output bit [31:0] id, input bit [31:0] size);

    bit [31:0] my_id;
    bit [31:0] my_size;

    initial
    begin
        my_size = 1 << 30;
        my_func(my_id, my_size);
        $finish();
    end

endmodule

filc.c

void my_func(svBitVecVal* id, svBitVecVal* size)
{
 . . . . .
}

The problam i have: I want to bit vector of "size" not to be a const length (32 bit), i want an undefined bit vector to be passed to c file. I saw the type "svOpenArrayHandle" - looks good, but i cant figure out how to declare it on the DPI import:

import "DPI-C" function void my_func(output bit [31:0] id, input bit size[]) -> raise error :-(

Any advice ?

Thanks.

1

There are 1 best solutions below

0
On

An un-sized array cannot be passed to a C function that takes us a pointer. You are going to synthesize the hardware and it cannot be variable. It cannot grow or shrink in size as per your requirements.