------------------------------------------------------------------------

-- File: push_to_set.vhd

--

-- Group: Korrey Scott 237118

-- Milton Mah 341428

-- Mike Holden 346386

--

-- Course: EE 552

-- Project: ASM

-- Instructor: Dr. Duncan Elliott

-- Completed: Apr. 3, 1998

------------------------------------------------------------------------

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_arith.all;

use ieee.std_logic_unsigned.all;

------------------------------------------------------------------------

-- Entity: push_to_set

--

-- Inputs: hour_button: external push button used to increment hours

--

-- minute_button: external push button used to increment minutes

--

-- clkpulse: externally generated pulse at 1kHz

--

-- reset: master reset of the system

--

-- Outputs: set_hour: a signal sent to clock.vhd that is set high for one

--clkpulse

--

--set_minute: a signal sent to clock.vhd that is set high for one

-- clkpulse

------------------------------------------------------------------------

entity push_to_set is

port (hour_button,minute_button, clkpulse, reset : in std_logic;

set_hour, set_minute : buffer std_logic);

end push_to_set;

------------------------------------------------------------------------

-- Architecture: behaviour of push_to_set

--

-- Description: This architecture was taken from lab #5 solutions by Dr. Elliott.

-- Only the names of the signals have been changed.

-- The purpose of this module is to detect a button push and

-- set its associated signal high for a duration of one clkpulse.

------------------------------------------------------------------------

architecture behaviour of push_to_set is

-- latched but not synchronized

signal set_hour_latched, set_hour_latched2 : std_logic;

signal set_min_latched, set_min_latched2 : std_logic;

begin

--SR latch built with AND and OR gates

set_hour_latched2 <= set_hour_latched or hour_button;

set_hour_latched <= set_hour_latched2 and (not reset and hour_button);

set_min_latched2 <= set_min_latched or minute_button;

set_min_latched <= set_min_latched2 and (not reset and minute_button);

--this synchronizer (D-flip-flop) reduces the probablitlity of

--the asynchronous push button causing metastability

d_flipflop : process(clkpulse)

begin

if rising_edge(clkpulse) then

set_hour <= set_hour_latched;

set_minute <= set_min_latched;

end if;

end process d_flipflop;

end behaviour;