Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

Use loop for with if

In my architecture I put a loop for, and I want when my index = 1, switch on my led 1,

but for others switch them off, maybe this is a stupid error, but myfollowing code is

wrong the error comes from line : if (i = 1) then, please anyone could help me ?

gene_led: for i in 4 downto 1 generate

process(init,opg_clk)

begin

if (i = 1) then

led(i) <= '0';

else

led(i) <= '1';

end if;

end process;

end gene_led;

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    please be so kind to say something more about the error and what you intend to do...

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I didn't defined led as a signal but as a variable that's why it couldn't work :p

    thanks to have answered me