Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fpga: choosing c++ to program fpga

Tags:

c++

c

fpga

I keep hearing mostly from electrical engineers that C is used for fpga work.

What about C++? Are there any disadvantages to using C++? I would think that the parallelism desired when programming for hardware would be better served by C++ more than C, no?

Also what do I use after that to make compatible c++ with the hardware?

like image 715
harry Avatar asked Dec 21 '09 02:12

harry


4 Answers

I'm pretty sure that FPGAs are programmed either in VHDL or Verilog.

http://en.wikipedia.org/wiki/Vhdl

http://en.wikipedia.org/wiki/Verilog

I know that Altera also offers some C to HDL translators. I doubt that they are usable for anything but tiny designs though.

like image 130
Nils Pipenbrinck Avatar answered Oct 28 '22 18:10

Nils Pipenbrinck


By far and away the easiest way to program an FPGA is via LabView's FPGA module. However this also ties you into their hardware and software. Not a cheap solution, but certainly the fastest way to get your program in hardware without having to learn anything but LabVIEW.

like image 32
SiegeX Avatar answered Oct 28 '22 18:10

SiegeX


You can use C or C++ to program FPGAs but it requires some very expensive Highlevel Synthesis software. CatapultC is a product from Mentor Graphics which allows you to write your algorithm in untimed C++. It then synthesizes that C++ into RTL VHDL or Verilog. But CatapultC sells for well over $100,000 so it's definitely not for hobbyists. There's another product called ImpulseC which allows you to write C code which then gets synthesized into RTL, but I'm pretty sure that it only handles C not C++. ImpulseC is about $2000.

For hobbyists, you're probably best off sticking with VHDL or Verilog to describe your design and then using the free tools from Xilinx or Altera to synthesize that code and program the FPGA.

like image 24
aneccodeal Avatar answered Oct 28 '22 18:10

aneccodeal


There is a big difference between compiling for CPUs and compiling for FPGAs. "Normal" compilers generate binary program code. The special FPGA compilers generate "hardware". There are compilers out there that turn some C-like code into "hardware". But it's not exactly C. It may be a C derivative extented with integer types of arbitrary bit lengths and is probably restricted to iteration and non-recursive function calls.

I am a big fan of C++ but even I see that many parts of it are just not appropriate for FPGAs: virtual functions, RTTI, exceptions. At least that's my impression. I didn't test those C-like FPGA compilers myself but a buddy of mine worked with them and it's supposedly a PITA.

like image 35
sellibitze Avatar answered Oct 28 '22 16:10

sellibitze