Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
8 years ago

HLS Best Practices for Parameter Passing

Hello, I am new to using HLS and I am used to the object oriented programming that can be done in C++.

What is the closest analog to making class or a struct so that many parameters can be passed into a component without cluttering the component function's definition?

I have many different components that require similar, but not exactly the same inputs. Would I be losing efficiency if I pass in a single, overarching struct that includes all of these parameters?

Thanks for the input!

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    You can use structs to group together parameters to pass into a component.

    However, there are sometimes area penalties. if you have a struct containing members of different widths, the smaller members may be padded.

    Note that there is ultimately very little change in the overall design. In fact, if you ground the extra ‘padding’ bits when integrating your component with a full system, Quartus should optimize away the extra bits.

    Let me know if this has helped resolve the issue you are facing or if you need any further assistance.

    Best Regards,

    Anand Raj Shankar

    (This message was posted on behalf of Intel Corporation)