--************************************************************************* -- HDL Model : ALARM_STATE_MACHINE.vhd -- Original HDL Model : /tnfs/v3/amoor/hw1/behv/alarm_state_machine.vhd --************************************************************************* -- Authors and Owners : Synopsys -- Functional Description : This is a state machine that controls setting the alarm time. -- Like a typical digital alarm clock, a few buttons must be held down in combination in order -- to set the alarm. This block sends a pulse out when the correct combination is pressed. -- Application Intent : Alarm Clock -- Interface Specifications : 4 single-bit inputs, 2 single-bit outputs. -- Tools and Versions Used/Needed : ---- Altera Version 9.4 Synthesized: Yes ---- Altera Version number Simulated: No ---- Viewlogic Synthesized : Yes ---- FPGA Express Synthesized : No -- Size : ---- Altera : Logic Cells= 6 ---- Input Lines= 4 ---- Output Lines= 2 ---- Viewlogic : Cell Count= ---- Gate Equivalent= ---- Number of Nets= --************************************************************************* --************************************************************************* entity ALARM_STATE_MACHINE is port (ALARM_BUTTON, HOURS_BUTTON, MINUTES_BUTTON, CLK: in BIT; HOURS, MINS: out BIT); end; architecture BEHAVIOR of ALARM_STATE_MACHINE is type STATE_TYPE is (IDLE,SET_HOURS,SET_MINUTES); signal CURRENT_STATE, NEXT_STATE: STATE_TYPE; begin COMBIN: process(CURRENT_STATE, ALARM_BUTTON, HOURS_BUTTON, MINUTES_BUTTON) begin NEXT_STATE <= CURRENT_STATE; HOURS <= '0'; MINS <= '0'; case CURRENT_STATE is when IDLE => if (ALARM_BUTTON = '1' and HOURS_BUTTON = '1' and MINUTES_BUTTON = '0') then NEXT_STATE <= SET_HOURS; HOURS <= '1'; elsif (ALARM_BUTTON = '1' and MINUTES_BUTTON = '1' and HOURS_BUTTON = '0') then NEXT_STATE <= SET_MINUTES; MINS <= '1'; else NEXT_STATE <= IDLE; end if; when SET_HOURS => if (ALARM_BUTTON = '1' and HOURS_BUTTON = '1' and MINUTES_BUTTON = '0')then NEXT_STATE <= SET_HOURS; HOURS <= '0'; else NEXT_STATE <= IDLE; end if; when SET_MINUTES => if (ALARM_BUTTON = '1' and MINUTES_BUTTON = '1' and HOURS_BUTTON = '0') then NEXT_STATE <= SET_MINUTES; MINS <= '0'; else NEXT_STATE <= IDLE; end if; end case; end process; SYNCH: process begin wait until CLK'event and CLK = '1'; CURRENT_STATE <= NEXT_STATE; end process; end BEHAVIOR;