(SV DPI-C/C)How to manipulate an svOpenArrayHandle in C?

16 Views Asked by At

I'm trying to write a C function for a verification tool, one of its purposes is to manipulate an OpenArrayHandle, this is done by taking a character array and converting it into the bit vector. I am trying to use the function svPutBitselBit but that isn't working as it only works for svBitVecVal. I've been trying to find other ways to do this but it isn't working. Here are the variables the function takes in:

void function(const svBitVecVal *inputBlock, int blockSize, svOpenArrayHandle expectedCiphertext) This are the lines where it generates the character array(buffer size is determined beforehand:

char *ciphertextBuffer = malloc(BUFFER_SIZE);
    if (ciphertextBuffer == NULL) {
        printf("Error: Memory allocation failed.\n");
        pclose(fp);
        return;
    }
    fgets(ciphertextBuffer, BUFFER_SIZE, fp);
    pclose(fp);

This is where it attempts the conversion:

 // Convert the ciphertext (string) to a bit vector
    for (int i = 0; i < blockSize * 8; i++) {
        svPutBitselBit(&expectedCiphertext, i, ciphertextBuffer[i] - '0');
    }

    free(ciphertextBuffer);

The error I am given is that svPutBitselBit doesn't accept the conversion from ciphertextBuffer to expectedCiphertext. Does anyone know any fixes?

I've tried to use different accesses and a different implementation using two svBitVecVal vectors but neither of those worked.

0

There are 0 best solutions below