C/C++ to Verilog/VHDL

Posts: 14
Joined: July 20th, 2014, 8:57 pm

C/C++ to Verilog/VHDL

Postby abalducci » October 12th, 2014, 1:13 pm

Of course there are the HLS (High Level Synthesis) C/C++ compilers found in professional (i.e. expen$ive) packaged such as Xilinx Vivado, and Altium Designer, but for our design set I myself was looking for some other alternatives and thought I'd share what I found.

Possibility the most comprehensive subset I've seen so far is provided by the LegUp Program, run open source out of the University of Toronto http://legup.eecg.utoronto.ca/. The program automatically takes in high level C++ code and spits out the required Verilog files in only a few steps, plus includes built in analysis features. Further, standard optimizations such as loop pipe-lining are quiet easily edited by a few simple flag additions to the source code.

In one example on the site they show the translation from C++ of the Mandelbrot set equation to VHDL (minus graphics implementation of course, though once the outputs are calculated you can simply route the data into whatever standard [VGA, HDMI, etc] fairly regularly]) which I think is pretty cool.


A couple exceptions to all this-- for one, if I read correctly this implementation occurs, in part, by wrapping a type of soft-processor around the VHDL translation, so in this case this is probably not the best setup to use if your goal is to translate from C to VHDL for the purpose of 'learning' what the opposite translation looks like. The resulting code, while highly optimized, is also rather complicated. Second, the licensing agreement stipulates that it is not to be used for commercial purposes.

However, I still think this would be great, especially in a pinch where you have a really difficult implementation you can work out in C, but would find it hard to code in verilog, especially if your FPGA is simply a means towards getting 'somewhere else'/attached to other devices in the chain.

The second example I found was the browser based site http://www.c-to-verilog.com/, which seems to produce much cleaner Verilog output, though I haven't tested it all that extensively at this point/tried any really hard algorithms with it. One also has to think for a minute before putting any 'important' data up on the web as well. Still, possibly a better translation/learning tool.

There still is one item however that I am not quite sure how it would be translated from C to VHDL-- Particularly the case where you have some sort of I/O, or are 'pulling' in data from somewhere else. For example, loading a file into an array. Yes, you could explicitly declare the data as a static variable in your C program, or otherwise later specify/load it as block ram in ISE, though these are both rather limited case uses...

My best guess is to write a parallel shift input register into the block diagram in ISE itself preceding the input variables for your code-- Though I am not sure if anyone else has any other/better ideas?

Also, if you find more resources on this topic, feel free to add to the list.

I hope this is of use/interest to someone.

Posts: 1
Joined: March 10th, 2017, 5:06 am

Re: C/C++ to Verilog/VHDL

Postby ShraddhaKapoor » March 10th, 2017, 5:07 am

C was initially created by Dennis Ritchie in the vicinity of 1969 and 1973 at Bell Labs and used to re-actualize the Unix working framework. It has since turned out to be a standout amongst the most broadly utilized programming dialects ever with C compilers from different merchants accessible for the lion's share of existing PC structures and working frameworks. c programming pdf C has been institutionalized by the American National Standards Institute (ANSI) since 1989 (see ANSI C) and consequently by the International Organization for Standardization (ISO).

Notwithstanding its low-level abilities, the dialect was intended to support cross-stage programming. A norms consistent and movably composed C program can be accumulated for a wide assortment of PC stages and working frameworks with few changes to its source code. The dialect has turned out to be accessible on an extensive variety of stages, from implanted microcontrollers to supercomputers. Unix was one of the principal working framework portions actualized in a dialect other than gathering. Prior occasions incorporate the Multics framework which was composed in and Master Control Program for the Burroughs B5000 written in ALGOL in 1961. In around 1977, Ritchie and Stephen C. Johnson rolled out further improvements to the dialect to encourage conveyability of the Unix working framework. Johnson's Portable C Compiler filled in as the reason for a few usage of C on new stages.

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 1 guest