Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

What does the c2h do?

Altera_Forum
Honored Contributor II
1,277 Views

Does the c2h actually convert a C code ,supposed to run on NiosII, into a VHDL code? If not, is there a way it can be done?

0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
503 Views

C2H is an ESL (electrical system level) design tool. It takes a software function and maps it into dedicated hardware as a component in SOPC Builder. At a high level what it does is form DMAs and data transforms and provides statemachines that controls all that stuff. For example if you used it on a 'for' loop that copied data from one memory to another one element at a time you would end up with an accelerator that acts like a DMA engine. 

 

There are other ESL tools out there that vary in input language, output files, and complexity. If you have ever heard of Handle-C that's a language that is specifically used for this purpose. C2H uses ANSI-C as an input language which makes things easier on software developers but there are sometimes optimizations you have to perform to your code to make it more efficient for C2H. For example C2H works well on code that is rolled up which is the opposite of how you typically optimize code for a general purpose CPU. 

 

Here is some additional info: http://www.altera.com/products/ip/processors/nios2/tools/c2h/ni2-c2h.html?gsa_pos=3&wt.oss_r=1&wt.oss=c2h 

 

http://www.alteraforum.com/forum/showthread.php?t=12696
0 Kudos
Altera_Forum
Honored Contributor II
503 Views

I have a question regarding the concurrency of a C2H accelerated function. If a function is basically doing just a memory transfer and C2H acceleration is performed on it, will the hardware version of the function still block code execution while the memory transfer is occurring? I would think it would have to since in sequential C code there may be subsequent functions which expect the transfer to be complete. Where as if the code was written to use DMA, the subsequent functions would wait until the DMA done flag was set. So can C2H be used to improve memory transfer functions, or is DMA required since the rest of the code must be aware of transfer completion?

0 Kudos
Altera_Forum
Honored Contributor II
503 Views

That's correct, by default the function you accelerate will become blocking when called as to not break sequential code. There are pragmas you can add to the function to instruct the compiler to generate a non-blocking wrapper which you would then either implement polling or use an interrupt to let your application know when the accelerated function is complete. 

 

What C2H does is generate a wrapper file that gets linked in, instead of the actual C code. This wrapper file optionally flushes the data cache, it writes the parameters of the function to the hardware accelerator, and by default polls the accelerator waiting for it to complete. Once the polling is done the wrapper exits and you continue running the application on the CPU.
0 Kudos
Reply