Forum Discussion

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

wait statement inside process

Hi all,

I faced some problem when I trying to compile my following code. The error replied was only one wait statement is allowed in the process. I have tried putting IF statement but it took 10,000 iterations. May I know how can i change my code?

Main : process

variable counter : counter_type := 0;

begin

-- HWY green, SRD red

wait on (CLOCK until CLOCK = '1' and SRDcar = '1');

if (HWYcar = '1') then

Counter := 0;

loop

wait until CLOCK = '1';

exit when (HWYcar = '0' or Counter = long_cycle);

Counter := Counter + 1;

end loop;

end if ;

Thank you so much

7 Replies

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

    Main : process

    variable counter : counter_type := 0;

    begin

    if rising_edge(CLOCK) then

    if SRDcar = '1' then

    if HWYcar = '1' then

    counter := 0;

    elsif counter = long_cycle then

    null;

    else

    counter := counter + 1;

    end if;

    end if;

    end if;

    end process;

    I think this should be something like what you want.

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

    thank you ben. but the error return now is rising_edge is used but not declared. sorry for bothering. I'm very very new this software.

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

    Have you included the std_logic_1164 library because that is where the rising_edge function is declared.

    use ieee.std_logic_1164.all;
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    yup... i included that...

    library ieee;

    use ieee.std_logic_1164.all;

    was trying to figure this out for the past 2 days...
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can replace "if rising_edge(CLOCK) then" with "if CLOCK'event and CLOCK = '1' then" or you open the std_logic_1164 library and check that the rising_edge function is in there.