I do not understand why my state machine does absolutely nothing. Can anyone identify why? It seems simple enough to me, 4 states that have three possibilities based on two inputs (2 state changes and 1 no state change), and upon changing states increment or decrement one of 8 counters (variables) then assign these variables to out ports. The simulation outputs nothing. This is the first state machine I have written.
Thanks so much!
Thanks so much!
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
entity pmodcounter is
Port (Ain, Bin : in STD_LOGIC;
reset : in STD_LOGIC;
out12, out23, out34, out41, out43, out32, out21, out 14 : out unsigned(25 downto 0));
end pmodcounter;
architecture Behavioral of pmodcounter is
type states is (st1, st2, st3, st4);
signal present_state, next_state: states;
begin
process (reset,clk)
begin
if (reset='1') then
present_state <= st1;
elsif rising_edge(clk) then
present_state <= next_state;
end if;
end process;
process (Ain, Bin, present_state)
-- Counting variables
variable c12, c23, c34, c41, c43, c32, c21, c14: unsigned(25 downto 0):="01000000000000000000000000";
begin
case present_state is
when st1=>
if (Ain='0' and Bin='1') then
c12:=c12+1;
next_state <= st2;
elsif (Ain='1' and Bin='0') then
c14:=c14-1;
next_state <= st4;
else
end if;
when st2=>
if (Ain='1' and Bin='1') then
c23:=c23+1;
next_state <= st3;
elsif (Ain='0' and Bin='0') then
c21:=c21-1;
next_state <= st1;
else
end if;
when st3=>
if (Ain='1' and Bin='0') then
c34:=c34+1;
next_state <= st4;
elsif (Ain='0' and Bin='1') then
c32:=c32-1;
next_state <= st2;
else
end if;
when st4=>
if (Ain='0' and Bin='0') then
c41:=c41+1;
next_state <= st1;
elsif (Ain='1' and Bin='1') then
c43:=c43-1;
next_state <= st3;
else
end if;
end case;
out12<=c12;
out23<=c23;
out34<=c34;
out41<=c41;
out43<=c43;
out32<=c32;
out21<=c21;
out14<=c14;
end process;
end behavioral;