我正在上一门关于嵌入式系统设计的课程,我的一个同学已经上了另一门课程,声称另一门课程的讲师不会让他们实现这样的状态机:
architecture behavioral of sm is
type state_t is (s1, s2, s3);
signal state : state_t;
begin
oneproc: process(Rst, Clk)
begin
if (Rst = '1') then
-- Reset
elsif (rising_edge(Clk)) then
case state is
when s1 =>
if (input = '1') then
state <= s2;
else
state <= s1;
end if;
...
...
...
end case;
end if;
end process;
end architecture;
但他们不得不这样做:
architecture behavioral of sm is
type state_t is (s1, s2, s3);
signal state, next_state : state_t;
begin
syncproc: process(Rst, Clk)
begin
if (Rst = '1') then
--Reset
elsif (rising_edge(Clk)) then
state <= next_state;
end if;
end process;
combproc: process(state)
begin
case state is
when s1 =>
if (input = '1') then
next_state <= s2;
else
next_state <= s1;
end if;
...
...
...
end case;
end process;
end architecture;
对我来说,非常缺乏经验,第一种方法看起来更简单,因为一切都是计时的,并且引入闩锁的风险更小(不是?)。
我的同学不能给我任何理由说明他的讲师为什么不让他们使用其他方式来实现它,所以我试图找出每种方式的优缺点。他们中的任何一个在行业中是首选吗?为什么我要避免其中一个?