Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clock made by a push button, glitch free

Status
Not open for further replies.

Gauss1777

Technical User
Oct 26, 2004
2
MX
I'm doing many projects that are simulated very well. I'm using MAX Plus II, but my projects need to be tested by a push button by my teacher, where the push button gives the clock signal to the circuit. I know it's easy to make such a clock with an external circuit, but's that not the solution. I need to implement the clock inside the FPGA I'm using, also a push button that is already in the training board by Altera should be used.

I have implemented such type of clock in many ways, but always give glitches, causing the circuit to jump to a wrong state. That's the problem, how to program such a clock so I can add it to my projects? I made a succesful clock with 2 push buttons, to make the low and the high signal that worked great but my teacher didn't like it, he wants a clock made with one push button.

Thanks for any help.
 
You need a button debouncer
here is an example of one using a 100hz clk
Code:
library IEEE;
use  IEEE.STD_LOGIC_1164.all;
use  IEEE.STD_LOGIC_ARITH.all;
use  IEEE.STD_LOGIC_UNSIGNED.all;
ENTITY debounce IS
	PORT(pb, clock_100Hz : IN	STD_LOGIC;
		 pb_debounced	 : OUT	STD_LOGIC);
END debounce;

ARCHITECTURE a OF debounce IS
	SIGNAL SHIFT_PB : STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN

-- Debounce Button: Filters out mechanical switch bounce for around 40Ms.
-- Debounce clock should be approximately 10ms
process 
begin
  wait until (clock_100Hz'EVENT) AND (clock_100Hz = '1');
  	SHIFT_PB(2 Downto 0) <= SHIFT_PB(3 Downto 1);
  	SHIFT_PB(3) <= NOT PB;
  	If SHIFT_PB(3 Downto 0)="0000" THEN
   	 PB_DEBOUNCED <= '1';
  	ELSE 
   	 PB_DEBOUNCED <= '0';
  	End if;
end process;
end a;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top