3

I'm trying to make a state machine that is synthesizable into a hardware description through Vitis HLS. I'm getting the error ERROR: [HLS 214-134] in function 'kernel1(char*, int)': Pointer to pointer is not supported for variable ''. This is happening in:

  • Transition transitions[] = {a, b};, where I'm trying to create an array of Transition structs
  • transitions_occurred += testTransition(&transitions[i], stream, &stream_index);, where I'm trying to call a function with members of the previous array

I don't get why that specific error pops up in these situations. I get no error when trying to do it 'manually' (without the array), like in:

transitions_occurred += testTransition(&a, stream, &stream_index);
transitions_occurred += testTransition(&b, stream, &stream_index);

Here's the full code:

#include <stdio.h>
#include <stdbool.h>
#include <string.h>

typedef struct {
    bool active;
} State;

typedef struct {
    char token;
    State *current;
    State *next;
    int stream_increment;
} Transition;

bool testTransition(Transition *t, char* stream, int *stream_index)
{
    if (!t->current->active)
        return false;
    
    if (t->token == stream[*stream_index])
    {
        t->next->active = true;
        *stream_index += t->stream_increment;
        return true;
    }

    return false;
}

#define STATE_NO 3
#define START_STATE 0
#define END_STATE 2

bool kernel1(char stream[], int stream_size)
{
    State current[STATE_NO] = {0};
    State next[STATE_NO] = {0};
    current[START_STATE].active = true;

    Transition a = {'a', &current[0], &next[1], 1};
    Transition b = {'b', &current[1], &next[2], 1};
    Transition transitions[] = {a, b};
    size_t transition_no = sizeof(transitions) / sizeof(Transition);

    int stream_index = 0;
    int transitions_occurred;

    do {
        transitions_occurred = 0;
        for (int i = 0; i < transition_no; i++)
            transitions_occurred += testTransition(&transitions[i], stream, &stream_index);

        memcpy(current, next, STATE_NO * sizeof(State));
        memset(next, 0, STATE_NO * sizeof(State));
    } while (stream_index != stream_size && transitions_occurred);

    return current[END_STATE].active;
}
8
  • What version of C used to compile? Commented Sep 29, 2023 at 17:24
  • Where can I see that? I'm new to Vitis HLS Commented Sep 29, 2023 at 17:41
  • @chux-ReinstateMonica I've tried running it with -std=c99/11/14/17 in the CFLAGS and the error persists Commented Sep 29, 2023 at 17:58
  • Sorry I am not familiar enough then for Vitis HLS. Good luck. Commented Sep 29, 2023 at 18:06
  • 1
    "It has to do with the notion that in HLS, C is being used to define hardware, not write software. So HLS must know the size at compile time, which it cannot do here. You might be able to get away with a char x[ARRAY_LEN] array in the struct, but you would have to try it and see." - Why Pointer to pointer is not supported? Commented Oct 2, 2023 at 21:54

1 Answer 1

1
+100

I don't get why that specific error pops up in these situations.

transitions is a pointer to Transition objects which contain pointers.

I get no error when trying to do it 'manually' (without the array)

Vivado-HLS will inline function calls with pointer-to-pointer. That is why a direct call with the reference to the object works as no pointer to that object is ever created.

Pointer to pointer support is limited. Please check the Pointer sections in the user guides UG902 / UG1399.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.