Efficient C code for hardware implementation in Verilog

I have a simple C code for an image codec. My goal is to develop an efficient C model that will be taken and implemented in hardware using Verilog or some such hardware description language. What I am trying to figure out is:

1.) What changes need to be made when creating the structures of the C code to make it efficient with hardware.

2.) Whether it is necessary to modify the data structures. Are there any restrictions related to arrays / buffers (how should they be declared with the storage class register.

3.) I heard that the H / W model should have no conditions or as little as possible. What is it about?

(Consider a generic hardware implementation using some FPGAs, Verilog without details on bus, clock, etc.)

-AD

0


source to share


1 answer


  • It depends on how serial or parallel you want to implement the hardware implementation of your algorithm.

In an always block, there is a distinction between "<=" (non-blocking) and "=" blocking assignment. The lock assignment is similar to what you have in software, everything is evaluated on a row-by-row basis, which tends to be synthesized to reduce sequential logic with a performance priority priority. With a non-blocking operator, all assignments in a block are always processed at the same time, which tends to create more concurrent structures. This will probably be the part you need to focus on the most when porting software to hardware.

  1. In RTL-friendly Verilog, you have combinational logic (continuous logic equation assignment) and memory assignment (registers and latches) to persist state over time. Your RTL-encoded data structures are likely to output registers and latches during logical synthesis. Your data structures will probably work if coded correctly in Verilog, but what makes sense on a microprocessor may not be the best way to build it in hardware. Again it depends.

  2. "if" can be used for both combinational logic and memory logic (hold state) "if" when written as a ternary operator (Verilog has the same syntax as C for this) is synthesized into a multiplexer (multiplexer). The "if" can also be used in the boolean description for a register to see if the reset pin was specified after the block's always event list was fired (this is just one example). Be careful with the "If": when you are going to create combinational logic with always block (event list has no posedge clk or negedge clk, posedge reset, negedge reset, etc.) And does the assignment to the combinational logic variable as part of the "if statement ", but then forget about the else statement, the latch will be pulled out during synthesis.Not having a corresponding "else" statement in an "if" expression means doing nothing (hold the value).

The "reg" type is used to describe both combinational logic and memory logic; what logic is synthesized depends on always the list of block events and the availability of complete code. C code is usually translated into a style that's always used in blocks.



The wire type is used for continuous assignment (combinational logic).

ImpulseC is a software compiler that looks intriguing. HDL Coder is a MATLAB / Simulink companion to automatically generate a description of your hardware.

Even if you use these software tools to create a hardware description for you, you still want to understand what they created.

+2


source







All Articles