Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

For loop timing query

Status
Not open for further replies.

nesta

Junior Member level 2
Joined
Feb 19, 2010
Messages
20
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,466
Hi VhdlExperts,

I would like to understand about how the timing is decided.

For example if i have a for loop inside a process which runs on every rising edge of the clock signal, Is it guaranteed that the for loop will complete within one clock cycle.

eg:
test: process(clk)
begin
if(clk ='1' and clk'event) then
for i in 0 to 100 loop
--- do somematrix multiplication.
end loop;

for i in 0 to 100 loop
--- do somematrix addition.
end loop;

end if;
end process;

Is the forloop guaranteed to complete within 1 clk cycle. Please explain.

Thanks.
 

Is it guaranteed that the for loop will complete within one clock cycle.
Yes, a HDL loop statement hasn't to do with sequence in time. It instructs to do something parallel.
 
Is the forloop guaranteed to complete within 1 clk cycle. Please explain.
Thanks.
Yes, but there is no guarantee for the clock frequency you can use if you try to run it in real hardware. The synthesis tool will tell you the maximum frequency.

If the result from one iteration in the loop is used in the next iteration, the resulting hardware will be a long chain of matrix hardware, and the maximum frequency will be very low.

In that case it is probably better to create a pipeline by putting registers between each stage. This means that the clock frequency can be higher. A new result will still be produced every clock cycle, but in the example there will be a delay of 101 clock cycles.

VHDL is not a programming language. It describes what the hardware does, but not how it is done. The synthesized hardware for the example will be completely different if the input data for one iteration does not depend on the previous iteration. It will be a parallel structure instead of a chain.

It is easy to write a few lines of code that will synthesize to hardware that will not fit even in the biggest FPGA.
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top