大家好,小弟刚在学习状态机的VHDL建模,看到一例子,其VHDL的描述如下:
type state is (step1, step2, step3);
signal current_state, next_state : state;
STATE_REG : process(clk) is
begin
if rising_edge(clk) then
if reset = '1' then
current_state <= step1;
else
current_state <= next_state;
end if;
end if;
end process STATE_REG;
NEXT_STATE_REG : process (start) is
begin
case current_state is
when step1 =>
if start = '0' then
next_state <= step1;
else
next_state <= step2;
end if;
when step2 =>
next_state <= step3;
when step3 =>
next_State <= step1;
end case;
end process NEXT_STATE_REG;
NEXT_STATE_REG : process (start) is
begin
case current_state is
when step1 =>
if start = '0' then
next_state <= step1;
else
next_state <= step2;
end if;
when step2 =>
next_state <= step3;
when step3 =>
next_State <= step1;
end case;
end process NEXT_STATE_REG;