UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Teacher xilinxacct
Teacher
506 Views
Registered: ‎10-23-2018

HLS: C or C++ for new designs?

Jump to solution

Reading through the HLS manual, it appears the C++ may be ‘slightly’ better supported (e.g. possible larger limits for arbitrary_precision, less gotchas for casting, better floating point simulation, …)

Are there any cases where the C version can do things that C++ version can’t? (e.g. any downside to using the C++ in HLS?) Any runtime (e.g. final implementation, not compile time) overhead for using C++ or C?

Assuming someone knows both C & C++, would you suggest C++ be used for new designs?

0 Kudos
1 Solution

Accepted Solutions
Scholar u4223374
Scholar
442 Views
Registered: ‎04-26-2015

Re: HLS: C or C++ for new designs?

Jump to solution

In my opinion, the preferred option is to use C++, but try to keep the code as close to C as is reasonably possible.

 

The key advantages for C++ in HLS are:

- Fixed-point (not supported in C)

- Arbitrary-precision integers (and fixed-points) can have their length defined by macros.

- Function templates - which are very, very useful when working with arbitrary-precision integers and fixed-point

- Libraries that are only supported in C++ (Streams, Video, etc).

 

I prefer not to use "full" C++ (primarily creating objects) because I find that HLS doesn't really make good use of them. The big advantage of having a class is that you can just make an object of that type when you need it - but HLS can't because it doesn't support dynamic memory allocation.

2 Replies
Adventurer
Adventurer
454 Views
Registered: ‎04-19-2018

Re: HLS: C or C++ for new designs?

Jump to solution

With HLS, you implement hardware, don't forget this. HLS is a C-like abstraction that helps writing otherwise complex designs in VHDL or Verilog. HLS deviates from C and C++ in many aspects. And, above all, keep always in mind you are not writing any program in HLS.

If what you like is software, there are lots of processors.

Scholar u4223374
Scholar
443 Views
Registered: ‎04-26-2015

Re: HLS: C or C++ for new designs?

Jump to solution

In my opinion, the preferred option is to use C++, but try to keep the code as close to C as is reasonably possible.

 

The key advantages for C++ in HLS are:

- Fixed-point (not supported in C)

- Arbitrary-precision integers (and fixed-points) can have their length defined by macros.

- Function templates - which are very, very useful when working with arbitrary-precision integers and fixed-point

- Libraries that are only supported in C++ (Streams, Video, etc).

 

I prefer not to use "full" C++ (primarily creating objects) because I find that HLS doesn't really make good use of them. The big advantage of having a class is that you can just make an object of that type when you need it - but HLS can't because it doesn't support dynamic memory allocation.