EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: jeremy on February 14, 2014, 10:56:49 am

Title: Translating C code to Verilog
Post by: jeremy on February 14, 2014, 10:56:49 am
Hi all,

Does anyone have any good resources on taking algorithms implemented in C and translating them to HDL? I know there are lots of tools out there which offer various degrees of automated translation, but I am interested in doing it myself.
Title: Re: Translating C code to Verilog
Post by: AlfBaz on February 14, 2014, 11:08:13 am
I'm by no means a vhdl expert but I suggest you just take it on. I managed to implement bresenham's line drawing algorithm from C code without to much trouble
Title: Re: Translating C code to Verilog
Post by: dannyf on February 14, 2014, 02:57:14 pm
I usually do two things:

1) Understand what the original code was doing, and how it did it. Then replicate the approach and structure in the target language; This works better if the original code is well designed and documented.
2) Write you own. Essentially replicating the functionality of the original code without replicating the code itself. This works better if you find it unproductive trying to understand a poorly written and documented piece of code.
Title: Re: Translating C code to Verilog
Post by: NANDBlog on February 14, 2014, 04:32:36 pm
You put a soft processor on your FPGA, then you run the code on that.
C code is sequential, HDL is concurrent. They are the least alike.