VHDL 中的 FSM 是 Moore 还是 Mealy?

FSM in VHDL is Moore or Mealy?

我正在用 VHDL 编写 FSM。特别是,它是一个同步序列检测器,输入一个 8 位数字和一个 "first",仅在序列的第一个数字期间必须为“1”。输出由解锁和警告组成:如果序列 (36, ...) 正确,则解锁 = '1',如果序列错误,则警告 = '1' 或 first = '1' 不是第一个数字顺序。

在 VHDL 中,我使用两个进程,一个同步,一个不同步。第二个的简化版是:

state_register_p : process(clk)
    begin 
        if (clk'EVENT and clk = '1') then
            if(rst = '0') then
                current_state <= S0;

                errors_num <= "00";
                five_cycles <= "000";
                first_error <= '1';
            else
                current_state <= next_state;

                if correct = '0' then
                    errors_num <= errors_num + "01";
                else
                    errors_num <= "00";
                end if;

            end if;

        end if;

end process state_register_p;

combinatorial_logic_p : process(current_state, num_in, first)

    begin       
        unlock <= '0';
        warning <= '0';

        case (current_state) is             
            when S0 =>
                if (to_integer(unsigned(num_in)) = 36) and (first = '1') then
                    next_state <= S1;
                else
                    next_state <= S0;
           when S1 =>
                correct <= '0';
                if (to_integer(unsigned(num_in)) = 19) and (first = '0') and errors_num /= "11" then
                    next_state <= S2;
                elsif first = '1' or errors_num = "11" then
                    next_state <= S6;
                else
                    next_state <= S0;
                end if;

            when S2 =>
                correct <= '0';
                if (to_integer(unsigned(num_in)) = 56)  and (first = '0') then
                    next_state <= S3;
                elsif first = '1' then
                    next_state <= S6;
                else
                    next_state <= S0;
                end if;

            when S3 =>
                correct <= '0';
                if (to_integer(unsigned(num_in)) = 101) and (first = '0') then
                    next_state <= S4;
                elsif first = '1' then
                    next_state <= S6;
                else
                    next_state <= S0;
                end if;

            when S4 =>
                correct <= '0';
                if (to_integer(unsigned(num_in)) = 73) and (first = '0') and (to_integer(unsigned(five_cycles)) = 5) then
                    next_state <= S5;
                    correct <= '1';
                elsif first = '1' then
                    next_state <= S6;
                else
                    next_state <= S0;
                end if;

            when S5 =>
                correct <= '1';
                if to_integer(unsigned(num_in)) = 36 and (first = '1') then
                    next_state <= S1;
                else
                    next_state <= S0;
                end if;

                unlock <= '1';

            when S6 =>
                correct <= '0';
                next_state <= S6; -- default, hold in current state
                warning <= '1';

        end case;               
end process combinatorial_logic_p;

通过在线阅读,我知道在 Moore 机器中,下一个状态仅取决于当前状态,因此输出仅在时钟边沿发生变化,而在 Mealy 中,它还取决于输入,因此其输出可能会在输入时发生变化变化(即,不一定在时钟边沿)。 .

在我的敏感性列表中,我使用了 current_state 和 2 个输入(num_in 和第一个),所以可以说我描述的是 Mealy 机器还是它仍然是 Moore 机器,因为我在等待下一个上升沿来更新输出吗?

我仍然认为是摩尔,但我不确定。谢谢

它是摩尔状态机,因为输出 unlockwarning 仅取决于 combinatorial_logic_p 过程中的 current_state

注意信号errors_numfive_cyclescombinatorial_logic_p过程中使用,但在敏感列表中被遗忘。所以添加它们,或者如果使用 VHDL-2008 则更改为 (all)