A
Andreas Ehliar
Guest
On 2008-05-20, Kolja Sulimma <ksulimma@googlemail.com> wrote:
loop will simply be unrolled. My example was merely meant to
illustrate that it is very easy to write a for loop which will
be extremely expensive in hardware even though it is only a couple
of lines of code. This is why we recommend students to avoid
for-loops in our introductory courses, it is too easy to try to
program instead of designing hardware. If you don't use a for loop
you will immediately figure out that something is not right with
your design as you are going to write 512 individual additions...
However, since you seem to have some experience with synthesizers
that support wait statements I have a question for you: How should
you implement a synchronous reset if you have a process like the
following?
always begin
always @(posedge clk);
// This is the state I want to end up with at reset time
bar <= 0;
always @(posedge clk);
bar <= bar + 1;
always @(posedge clk);
bar <= bar + 1;
always @(posedge clk);
bar <= bar + 1;
end
/Andreas
Of course, and I believe I wrote in my original post that a forDon't confuse architecture and coding.
The parallel linear adder chain will cost exactly the same hardware
when coded with or without the for loop.
loop will simply be unrolled. My example was merely meant to
illustrate that it is very easy to write a for loop which will
be extremely expensive in hardware even though it is only a couple
of lines of code. This is why we recommend students to avoid
for-loops in our introductory courses, it is too easy to try to
program instead of designing hardware. If you don't use a for loop
you will immediately figure out that something is not right with
your design as you are going to write 512 individual additions...
However, since you seem to have some experience with synthesizers
that support wait statements I have a question for you: How should
you implement a synchronous reset if you have a process like the
following?
always begin
always @(posedge clk);
// This is the state I want to end up with at reset time
bar <= 0;
always @(posedge clk);
bar <= bar + 1;
always @(posedge clk);
bar <= bar + 1;
always @(posedge clk);
bar <= bar + 1;
end
/Andreas