Verilog FOR loop. Can it be used to design hardware?
Following example shows the declaration of Verilog FOR loop.
initial begin
for (i=0; i < 4; i=i+1)
$display("%d:%h", i, data[i]);
end
Commonly asked questions for Verilog and SystemVerilog are listed below.
Question. Can we synthesize FOR loops to
replicate
hardware or fpga ?Question. Is it valid or smart coding style to freely use FOR loops in RTL? Can we do increment using for loops? (yes)
Answer to above questions is elaborated below:
First of all
FOR loop
is completely synthesizable
construct. These are used when speed of digital hardware is critical and there is not much limitation
on hardware utilization. With FOR loops we are basically instantiating same hardware circuit multiple times.
Digital design always involves trade- off between speed and area. In case of FPGA’s the resources are limited and its recommended to carefully evaluate the use of FOR loops. Alternate approach is to
pipeline
design, its discussed on FCD at link. Complete usage is discussed is complete rtl example.Hope you liked! this page. Don't forgot to access relevant previous and next sections
with links below.