Forum Discussion

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

Vhdl codes for counter to start and purse

Hi,

I need urgent help on how to design a stopwatch that can stop/purse using vhdl code. I will really appreciate any urgent reply to this.

Thanks.

Waiting for your replies.

14 Replies

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

    how can i design the clock such that if i press pause at intial state, there should be something to remember that state so that Wwhen i do that, the button will change to the next state i.e 1 to 0.

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

    is majoprly on the start./stop and nothint else. thats all i need for now.

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

    anybody with idea on how to implement this. I need it urgent.

    or If you know how to apply flip flop, logic gate to manipulate the start and stop button, I will appreciate it. Thanks

    one switch represent start and stop. All I want is that instead of holding the switch down to stop counting, I want it to stop counting if I also remove my hand. and again If I do same thing, i want it to start counting....

    Please If you know what I mean, kindly help me out.

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

    The best way to achieve what you are asking is to draw yourself a flow chart. If you are looking for an on/off button with just one push then you would have something like this.

    
    process(clk) begin
      if(rising_edge(clk)) then
         button_prev <= button_curr;
         button_curr <= button;
      end if;
    end process
    Button_pulse <= button_curr AND (NOT button_prev);
    
    Now, you can register the pulse, add debounce, ect. It is up to you.

    Next, you need to create a state machine to handle the enable to your counter. From what you've described you have 2 states, on and off. you start in the off state, if the button_pulse = 1 then you go to the on state and again if the button pulse is 1 you go back to the off state. Then you describe your counter enable as 1 when in the on state and 0 when in the off. I recommend drawing this out and then creating your state machine to match your diagram.