【发布时间】:2018-12-31 18:36:56
【问题描述】:
我有一个可以正常工作的特定 FSM。但是我想从 FSM 中的特定状态开始,我想知道我是否可以使用仅在电路中发生一次但我不能这样做的事件来做到这一点,因为我想到的所有事件都使电路保持在相同的状态
library ieee;
use ieee.std_logic_1164.all;
use work.all;
entity ELEVAR is
port(
clk, rst: in std_logic;
NF,status : in std_logic_vector(2 downto 0);
output: out std_logic_vector(2 downto 0));
end ELEVAR;
architecture struct of ELEVAR is
type state is(S,S0,S1,S2,S3,S4,S5,S6,S7,S8,HI);
signal current_state, next_state:state;
signal output22 : std_logic_vector(2 downto 0);
begin
process(clk, rst)
begin
if(rst='1')then
current_state<=S0;
elsif(rising_edge(clk))then
else
null;
end if;
end process;
process(current_state)
begin
case current_state is
when S8=>next_state<=S7;
output<="111";
output22<="111";
if (NF=output22) then
next_state<=HI;
output<="111";
end if;
when S7=>next_state<=S6;
output<="110";
output22<="110";
if (NF=output22) then
next_state<=HI;
output<="110";
end if;
when S6=>next_state<=S5;
output<="101";
output22<="101";
if (NF=output22) then
next_state<=HI;
output<="101";
end if;
when S5=>next_state<=S4;
output<="100";
output22<="100";
if (NF=output22) then
next_state<=HI;
output<="100";
end if;
when S4=>next_state<=S3;
output<="011";
output22<="011";
if (NF=output22) then
next_state<=HI;
output<="011";
end if;
when S3=>next_state<=S2;
output<="010";
output22<="010";
if (NF=output22) then
next_state<=HI;
output<="010";
end if;
when S2=>next_state<=S1;
output<="001";
output22<="001";
if (NF=output22) then
next_state<=HI;
output<="001";
end if;
when S1=>next_state<=S0;
output<="000";
output22<="000";
if (NF=output22) then
next_state<=HI;
output<="000";
end if;
when others => next_state<=HI;
null;
end case;
end process;
end struct;
-- 此代码选择我想开始但我不知道的状态 --- 我应该把它放在我的代码中的什么地方。
current_state<=next_state;
elsif status = "000" then
current_state<=S0;
elsif
status = "001" then
current_state<=S1;
elsif
status = "010" then
current_state<=S2;
elsif
status = "011" then
current_state<=S3;
elsif
status = "100" then
current_state<=S4;
elsif
status = "101" then
current_state<=S5;
elsif
status = "110" then
current_state<=S6;
elsif
status = "111" then
current_state<=S7;
【问题讨论】:
-
可怕的格式,我不会修复它。只需在重置期间分配不同的状态 if (rst = '1') then current_state ;否则...
-
@damage 不能解决我的问题!!,你认为这将如何使它从特定状态开始!!
-
如果您想从 SO 社区获得快速且良好的解决方案,您应该使用得到的代码格式(例如缩进)。如果没有做好充分的准备,没有人会花几分钟来理解你的代码。接下来,您应该阅读状态机模式。
标签: vhdl state modelsim fsm quartus