16

In light of this question, I was wondering if there was a fairly standard process for turning a software solution into a hardware implemention. Forgive me and my imagination, but would there be a compiler that could take a C program and compile it in terms of a schematic of transistors, resistors, etc. or maybe even well-known PCBs?

I realize that I could be looking at this scenario from the wrong perspective. Historically from my own experience, typically you have some piece of hardware that somebody has implemented as a software solution (think hardware emulation). Does this concept in reverse even exist? How do these bigger companies do it such as software vs hardware IP routing?

Chad Harrison
  • 383
  • 1
  • 8
  • See also "why can't I automatically make my singletheaded C program multithreaded?" – pjc50 Mar 28 '13 at 20:53
  • @pjc50 : Where can I see "why can't I automatically make my singletheaded C program multithreaded?" ? – davidcary Apr 01 '13 at 07:54
  • I don't have a specific example in mind, but it's a question I've seen people asking before. It's also related in that hardware is intrinsically parallel while software is "naturally" sequential in terms of the way people think about it and write programs. – pjc50 Apr 01 '13 at 12:21

4 Answers4

11

No, there is no standard solution for turning software into hardware. Generally speaking, taking software that was not written with a hardware implementation in mind cannot be easily converted into hardware without huge waste and inefficiencies. Usually, the best thing to do is just make a chip that has a CPU and ROM-- and put the software in the ROM.

Over the years there has been compilers that would take "C-Like" code and compile it into hardware-- much in the same way that VHDL or Verilog can be compiled into hardware. But the key thing is that it is "C-Like", and not C. You still cannot take, for example, a C/C++ program that calculates PI and magically convert it into hardware that calculates PI. Most of these C-Line languages have gone away, or is not used in any numbers. One of the more popular versions of this is SystemC, but it is important to note that it is not C/C++ and is not useful for generic "let's write software and then compile it into hardware". You still need to "write some hardware, that also might be compiled into software".

Switches and routers typically have hardware the does most of the commonly used and speed critical router functions (Looking up stuff in routing tables, managing queues, etc.) in hardware and then use a CPU to do all of the not-so-common functions (handling exceptions, errors, routing table updates, etc). In many ways this is similar to how modern CPU's work, where the most common opcodes are done in hardware and occasionally some opcodes are actually implemented in software (for example, floating point instructions when an FPU is not present).

  • Not only is SystemC actual C++, it's just a C++ library. You can use any ordinary C++ code you like with SystemC. That said, SystemC doesn't have much to do with automatically generating hardware. It's more oriented towards simulating systems, helping to make architectural decisions, and allowing software teams to get started before hardware is available. – Theran Mar 28 '13 at 22:37
  • This really helps me understand why there's specific hardware that perform specific tasks. – Chad Harrison Mar 29 '13 at 12:31
  • There are many other C to HDL compilers that were designed for this purpose. – Anderson Green Nov 02 '18 at 19:13
5

The closest thing would be Altera's C-to-Hardware (C2H) Compiler. It can do some of what you're suggesting. But there are defiantly caveats. You can't turn just any C code into hardware, nor would you want to. But specific functions work rather well and you can see a dramatic increase in performance.

Typically you would implement a NIOS II softcore processor into an Altera FPGA. You would then write some ANSI C code for it like you would any other processor. Then say one of the C functions you've written involves some heavy math that would benefit performance-wise from some parallel execution. You invoke the C2H compiler, say "Implement in Hardware" and it essentially turns that function into a peripheral of the NIOS II softcore processor.

Here's an example of coding a Mandelbrot computation in ANSI C and then implementing it in hardware:

The C2H compiler-accelerated Mandelbrot algorithm results in a speed improvement of at least 60x compared to the same algorithm running on the fastest Nios II processor using compiler optimization level 2 (-O2). This speed increase is because of the parallelism and fast iteration speeds that hardware can provide, which are not possible from a general-purpose processing unit.

Going back to your example, the NIOS II processor can run Linux. And certain functions that would be necessary to perform routing tasks could benefit from hardware acceleration. It would most likely perform better than a pure software router. But it will never approach the performance of specially designed dedicated ASICs.

embedded.kyle
  • 8,511
  • 2
  • 26
  • 45
  • 1
    Xilinx has a comparable tool called Vivado HLS (High-level synthesis), formerly known as AutoESL. Similar caveats apply: it does a good job converting code to RTL if it's the kind of code that's easy to automatically convert to RTL. – Theran Mar 28 '13 at 22:11
  • @Theran I was unaware that Xilinx had a competing product. I'll have to check that out. Thanks! – embedded.kyle Mar 29 '13 at 12:13
2

You mention "C to Silicon" in your title and mention board level products in the body. I'll just focus on the part of that equation that does exist -> "C to Silicon" design flows. C in itself is not a natural fit for the description of hardware as it lacks some fundamental support for the inherent parallelism of hardware, the need to prevent race conditions and other issues, and it's not notably expressive in being able to represent these concepts. Or not nearly as much as Verilog and VHDL are.

C code that is synthesizable (i.e. can be rendered to a hardware description) and here hardware = digital logic, wouldn't win any coding contests judged by software developers.

Here is a list of some notable vendors supply C -> Silicon tools for the ASIC flow crowd.

  • Forte Cynthesizer

  • Mentor Catapult

  • BlueSpec C

  • Synopsys Synphony (ex- Synfora)

  • Cadence C-to-Silicon

placeholder
  • 30,170
  • 10
  • 63
  • 110
1

Turning software into hardware is not a completely trivial task if you expect reasonable hardware. Hardware tends to need more architecting to carefully manage resource usage which relates to area/cost. Having said that, there are a number of tools that take C in some form, allow you to add hardware specific information (for instance, what is the hardware interface?), and generate optimized hardware. Proficient users can easily get better results in less time than hand coded RTL.

embedded.kyle
  • 8,511
  • 2
  • 26
  • 45