gpt4 book ai didi

vhdl - VHDL 中的 FSM 机器,每个状态都在执行某些操作

转载 作者:行者123 更新时间:2023-12-02 22:03:00 24 4
gpt4 key购买 nike

我有一个具有五个状态(s1、s2、s3、s4、s5)的 FSM。

但是,对于每个状态,应该执行一系列操作。例如,在 s2 中,计数器应该从 1 计数到 10。

我的问题来了:FSM怎么知道“我应该从s2换成s3”?或者换句话说,s2如何通知FSM“我完成了”,并根据一个LookUpTable开始新的状态?

最佳答案

如果您以合适的风格编写 FSM,这实际上不是问题。示例:

architecture RTL of dut is
type state_t is (s1, s2, s3, s4, s5);
signal state : state_t;
signal counter : integer;
signal condition : boolean;
begin
fsm : process is
begin
if rising_edge(clk) then
case state is
when s1 =>
-- do stuff
when s2 =>
if condition then
counter <= 0;
state <= s3;
end if;
when s3 =>
if counter = 10 then
state <= s4;
else
counter <= counter + 1;
end if;
when s4 =>
null;
when s5 =>
null;
end case;
end if;
end process fsm;

end architecture RTL;

关于vhdl - VHDL 中的 FSM 机器,每个状态都在执行某些操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16573754/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com