Forum Discussion

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

please help me.

I'm a newbie in this field, i have a problem and i hope that you all can help me.

i wanted to add in countdown timer into the music box that shown at fpga4fun but i have no idea on how to do the coding for the countdown timer, so i need your help. :(

i hope that the countdown timer is in VHDL code or you all can give me the VHDL coding and i'll try to change the music box verilog code so that i can add in the VHDL code.

The countdown timer that i want is when i turn on the music box it will countdown 5 second, after countdown it will start to play music.

thanks you very much for your help :)

1 Reply

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

    Are you using a dev. board? What is the frequency of the fpga clock? The timer is based on the clock period. The code looks like:

    entity....

    architecture arch of ent_name is

    begin

    process(rst, clk)

    begin

    if(rst='1') then

    cont_reg <= ( others=>'0');

    elsif(clk'event and clk='1') else

    cont_reg <= cont_prox;

    end if;

    end process;

    cont_prox <= cont_reg + 1 when ( cont_reg < timeout ) else

    cont_reg;

    start <= '0' when ( cont_reg < timeout ) else

    '1';

    end architecture arch;

    The signal "start" goes up to '1' when expires the timer. you enable the circuit with this signal. The constant timeout depends of clock period.