tags:

views:

577

answers:

10

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?

+9  A: 

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.

Nils Pipenbrinck
I can say that all the FPGA work I have done was in Verilog
GrayWizardx
I did some in AHDL (http://en.wikipedia.org/wiki/Altera_Hardware_Description_Language) - but that's a similar language to VHDL.
Tobias Langner
+6  A: 

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.

SiegeX
+1  A: 

Two that I can think of off the top of my head: C++ is much more complicated to write compilers (in this case HDL translators) for and has too many features that just would not be useful in such low level programming as fpga programming calls for.

Ichorus
+2  A: 

They're probably using C to interface with the FPGA. When working with one in a design class, we used Verilog to program the FPGA and C in the attached Linux board. In that case, they're likely using C as it's easier to bang out a small program in C than in C++.

CajunLuke
+1  A: 

Like others have said most FPGA's are designed using VHDL or Verilog. I have also seen PALASM used several years ago for small designs. The design is a logic description that is converted to settings that configure the FPGA. Verilog is based on c so knowing c will help with learning verilog however FPGAs are by nature parallel so even though the syntax might look similar not much else translates.

Rex Logan
A: 

You usually get a larger standard library with C++ and with C, and C is closer to the way that the hardware operates, i.e. easier for electrical engineers.

e8johan
+4  A: 

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.

sellibitze
+1  A: 

You're probably talking about SystemC, which is a set of C++ classes and macros used mainly for (transaction-level) modeling, not for synthesis. The high-level model can then be used as a golden reference to verifiy the register transfer level (RTL) description, which is typically coded in VHDL or Verilog.

geschema
However, using SystemC requires that you use some fairly expensive synthesis tools - at least in the tens of thousands of dollars. Definitely can't use the free FPGA vendor tools.
aneccodeal
+1  A: 

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.

aneccodeal
There's CtoVerilog: http://www.c-to-verilog.com/
aneccodeal