Over the past few weeks, I've been thinking about reconfigurable computing. More specifically, I've been wondering whether it would be possible to convert C code into a useful hardware description. I really like the idea that it may be possible to take a program and produce a circuit diagram full of thousands of 74xxx logic parts.
I'm aware of tools that already do this, but what I propose is a system that is, first and foremost, open source and that will transform unadulterated C into a form that could be built as a circuit.
Is a restricted subset enough? Well, no. I know that the features you are left with are more than enough for any program you may want to write, but think of all the great libraries out there that you can't use simply because they use language features that are outside of your compiler's scope of reasoning.
In order to do this, I think the first step is to convert the C program to SSA form. How exactly? LLVM is a compiler infrastructure that can compile and optimize programs, it is open source and written in a modular way. It has an internal representation (IR) which is in SSA form that it needs in order to do optimizations. If LLVM was used to compile the C code into LLVM's IR, half of the task would already be completed.
The second part of the process is to transform this SSA form into hardware. Much of the SSA has a direct mapping to hardware, but some parts require careful consideration, loops are one such example. I'm convinced, however, that by introducing some clever asynchronous glue logic that such things can be worked around.
Rather than starting to write the hardware synthesiser to begin with, I think the first step is to create a hardware simulation program in C that can later be synthesised into a FPGA. This would allow you to easily test the code that a hardware synthesiser could produce. It also lowers the cost of contributing; the only tool you would need to contribute would be the computer you are sitting at now. Open source software is a proven development model. Hopefully this methodology will provide the open source community with a plethora of tools to create hardware with in an open source software-ish kind of way.
Why not use C++ (to create the simulator)? C++ is object oriented and relies heavily on dynamic memory allocation. This is something to be avoided in hardware. LLVM supports C++ through clang so it would be possible to use C++ in the project, it's just not advised.
Why not Python, Ruby, Tcl, or any other interpreted language you can think of? Dynamic Types can't be compiled well into regular machine code. Logical synthesis only causes more problems.
Why not Java? I hope you're kidding. If you're not... good luck with that.
The only real contender I see to C is that maybe someone could create a language that could be efficeintly compiled into software or into a hardware description. The more I think about this the more I realise that a language like this could be really useful in the future.
In the future I see FPGAs overthrowing processors, making crazy things like Just In Time Hardware Synthesis possible. Programs will be faster and more efficient. This is the next quantum leap in processor design!
Very nice crisp article. Indeed a great vista to dive into.