我想對狀態機進行VHDL編程。在這個狀態機中,一個狀態本身就是另一個狀態機。我怎樣才能從主狀態機調用這個狀態機?什麼其實我想要做的 示例如下:如何從另一個狀態機調用一個狀態機並以VHDL得到響應
主要的狀態機(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;
子狀態機(sm_execute.vhd): -
的執行上述狀態機的狀態本身就是另一個狀態機程序。
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;
我想要的是在sm_main.vhd的執行狀態下調用此sm_execute.vhd。作爲結果的sm_execute的輸出將被用作確定在sm_main.vhd中執行後的下一個狀態的輸入。這意味着我想調用子狀態機程序,並且一旦子狀態機程序完成它的執行,該值也會返回到主狀態機程序。
在此先感謝 Sruthi拉詹
請張貼您當前的代碼顯示有問題的問題。 – 2015-04-06 05:31:15