I want to do VHDL programming of a state machine. In this state machine one state is itself another state machine. how can i call this state machine from the main state machine? Example of what i actually want to do is as follows:
main state machine (sm_main.vhd) :-
clk_process : process (clk, reset)
begin
if(reset = '1') then
state_reg <= start;
elsif (clk'event and clk =' 1' ) then
state_reg <= state_next;
end if;
end process;
state_process : process (state_reg,input,enable)
begin
case state_reg is
when start =>
if (input =1) then
state_next <= wait;
else
state_next <= start;
end if;
when wait =>
if (enable =1) then
output <= '1';
state_next <= execute;
else
output <='0';
state_next <= wait;
end if ;
when execute =>
if (enable =1) then
state_next <= done;
else
state_next <= start;
end if;
when done =>
if(result = 1) then
state_next <= execute;
else
state_next <= start;
end if;
end case;
end process;
sub state machine (sm_execute.vhd):-
The execute state of the above state machine is itself another state machine program.
state_process : process (state_reg,a,b)
begin
case state_reg is
when start =>
if (a=1) then
state_next <= s1;
else
state_next <= s2;
end if;
when s1 =>
if (b =1) then
state_next <= s3;
else
state_next <= s3;
end if ;
when s3=>
if(c=1) then
result <= '1';
state_next <= s3
else
result <='0';
state_next <= start
end case;
end process;
What i want is to call this sm_execute.vhd in the execute state of sm_main.vhd. The output from the sm_execute which is result, is to be used as an input to determine the next state after execute in sm_main.vhd. That means i want to call the sub state machine program and also return the value to main state machine program once the sub state machine program finishes its execution.
thanks in advance Sruthi Rajan