jiten said:
hi the code is like this
process(cnt,tmp,rst)
begin
if rst='1' then
cnt <= "0000";
tmp <= "000";
i <= 0;
else
w : while i< 8 loop
tmp <= tmp+1;
cnt <= cnt+1;
i <= i + 1;
end loop w;
end if;
end process;
Yeeesh! Where are people learning how to write such crappy code? Let
me guess: you're a software guy?
Anyways, you don't want a while loop, or a for loop, or in fact any
loop at all. You need to THINK HARDWARE. What sort of hardware do you
think your synthesize will do with your code? First of all, you
probably want to use a clock to synchronize everything; as it is now,
you have a big combinatorial mess.
Maybe something like:
mycnt : process (clk, rst) is
begin
if (rst = '1') then
cnt <= "0000";
tmp <= "000";
i <= 0;
elsif rising_edge(clk) then
if i < 8 then
cnt <= cnt + 1;
tmp <= tmp + 1;
i <= i + 1;
end if;
end if;
end process mycnt;
It's left as an exercise for the reader to choose the proper type for
cnt, tmp and i, as well as to figure out how to clear the counter once
i is 8.
-a