LIBRARY IEEE;
USE IEEE. STD_LOGIC_1164. ALL;
ENTITY oneprocess_fsm1 IS
PORT ( ip,reset,clk : IN BIT; --DECLARES THE INPUTS
op : OUT BIT ); --DECLARES THE OUTPUT
END oneprocess_fsm1;
ARCHITECTURE operation_oneprocess_fsm OF oneprocess_fsm1 IS
TYPE statetype IS (S0, S1 ,S2 ,S3 ,S4 ,S5); --ENUMERATED DATA TYPE
SIGNAL state: statetype;
BEGIN
PROCESS( ip, reset, clk ) --BEGINING OF PROCESS WITH SENSITIVITY LIST
BEGIN
IF(reset='1') THEN
state<= S0;
ELSIF(clk'event and clk='1') THEN --ON CLK EVENT STATE IS LOADED
CASE state IS --CASE CHECKS FOR VARIOUS CONDITIONS DEPENDING ON THE STATES
WHEN S0 =>
IF(ip='1') THEN
state <= S1;
ELSE
state <= S0;
END IF;
op <= '0' ;
WHEN S1 =>
IF(ip='0') THEN
state <= S2;
ELSE
state <= S1;
END IF;
op <= '0' ;
WHEN S2 =>
IF(ip='0') THEN
state <= S3;
ELSE
state <= S1;
END IF;
op <= '0' ;
WHEN S3 =>
IF(ip='1') THEN
state <= S4;
ELSE
state <= S0;
END IF;
op <= '0' ;
WHEN S4 =>
IF(ip='1') THEN
state <= S5;
ELSE
state <= S2;
END IF;
op <= '0' ;
WHEN S5 =>
IF(ip='1') THEN
state <= S1;
ELSE
state <= S2;
END IF;
op <= '1' ;
END CASE; --END CASE
END IF;
END PROCESS;
-- WITH state SELECT --USE OF WITH SELECT TO GIVE OUPUT BASED ON STATE CONDITION
-- op <= '0' WHEN S0,
-- '0' WHEN S1,
-- '0' WHEN S2,
-- '0' WHEN S3,
-- '0' WHEN S4,
-- '1' WHEN S5,
-- '0' WHEN OTHERS;
--
END operation_oneprocess_fsm;