1
votes

I come from a programming background and not messed around too much with hardware or firmware (at most a bit electronics and Arduino).

What is the motivation in using hardware description languages (HDL) such as Verilog and VHDL over programming languages like C or some Assembly?

Is this issue at all a matter of choice?

I read that hardware, which its firmware is written in an HDL, has a clear advantage in running instructions in parallel. However, I was surprised to see discussions expressing doubts whether to write firmware in C or Assembly (how is Assembly appropriate if you don't necessarily have a CPU?) but I concluded it's also an option.

Therefore, I have a few questions (don't hesitate to explain anything):

  1. A firmware really can be written either in HDL or in a software programming language, or it's just another way to perform the same mission? I'd love to real-world examples. What constraints resulting from each option?

  2. I know that a common use of firmware over software is in hardware accelerators (such as GPUs, network adapters, SSL accelerators, etc). As I understand it, this acceleration is not always necessary, but only recommended (for example, in the case of SSL and acceleration of complex algorithms). Can one choose between firmware and software in all cases? If not, I'd be happy to cases in which firmware is clearly and unequivocally appropriate.

  3. I've read that the firmware mostly burned on ROM or flash. How it is represented in there? In bits, like software? If so, what's the profound difference? Is it the availability of adapted circuits in the case of firmware?

I guess I made a mistake here and there in some assumptions, please forgive me. Thank you!

2
While there is some overlap (state machines, etc), HDL languages are usually used to describe the structure (ultimately, "wiring") of a computing device, while languages such as C are used to give it a list of tasks to perform in sequential-with-branches order. "firmware" usually refers to the latter (basically, "software" stored in a chip vs. "disk") - the HDL equivalent would be a "design file" either loaded into an FPGA or used to guide the physical production of a custom IC. It's not uncommon for a project to have both - HDL to describe a custom processor, and firmware to run on it.Chris Stratton

2 Answers

3
votes

The term "firmware" is at best ill defined, and I believe that is probably the cause of your confusion.

Historicallym - before the availability of programmable logic devices - the term "firmware" has been used to refer to code stored-in and executed-from read-only memory (ROM). At a time when the only available ROM technology was mask-ROM where the code was burned into the device at manufacture of the silicon and therefore unchangeable without replacing the chip - that was pretty "firm". Even with later programmable read-only memory (PROM), which could be programmed post-manufacture, because it was one-time programmable (OTP), the term still applied.

With the introduction of UV erasable EEPROM, firmware became perhaps less "firm", but the lack of in-circuit programmability and the need to expose the device to UV to erase it still made replacement of the embedded software a chore - normally requiring removal of the chip, placing it in the eraser for an hour or so, then programming it in a dedicated programmer.

The advent of NOR Flash memory, where code could be stored and executed directly from the device, but also readily changed in-circuit, the term firmware in this context has become less common. However it is still used (perhaps mainly by older practitioners) to refer to embedded software stored and executed from a random-access, read-only memory device as opposed to loaded into RAM from a file system.

The use for the term firmware to refer to programmable logic configuration is newer and has probably come about simply because it is hardware, but the configuration is written much like software using a high-level language.

The upshot of this is that you do not choose

"Verilog and VHDL over programming languages like C or some Assembly"

because in each context the term firmware simply refers to a different concept.

It would be best to avoid the term firmware altogether as it means different things to different people or in different contexts.

There is perhaps some further confusion form the fact that some hardware description languages are based on software development languages - such as Handle C, which is a C-like hardware description language.

0
votes

This question would not have much arise some time ago, but with current platforms you can now translate between C and HDL languages (instead of using Handel-C extension of C, from the 90's), mainly between C and behavioral VHDL. And a lot of newer tools provided by enterprises, like Xilinx Electronic System Level Design Ecosystem, or Impulse-C (http://www.impulseaccelerated.com/products_universal.htm)

It is important to know though that as C is a middle level language, and VHDL is, as stated a Hrdware Description Language. C can only handle sequential instructions while VHDL allows both sequential and concurrent executions.

And even though a C program can be successfully written with pure logical or algorithmic thinking, a successful VHDL programmer needs thorough working knowledge of the hardware circuits. being able to predict how a given code will be implemented in hardware.

In both languages you care about the resource usage, but in a different way (Unless you are programming for resource-constrained devices). But when it comes to VHDL, apart from the memory, other logic elements are limited in a FPGA (where you normally put the VHDL code in).