在Mealy有限状态机中重置

时间:2018-05-08 09:04:01

标签: vhdl fsm

我在VHDL的Mealy有限状态机中遇到了复位信号的一些问题。我创建了一个非常简单的Mealy FSM,以便于理解。 FSM有两个过程,一个用于计算状态,一个用于计算输出和下一个状态。我遇到的问题是,当reset ='1'且input1 =“11”时,输出1 =“11”时应输出1 =“00”

这可以通过以下方式解决:将复位输入包括在组合块的灵敏度列表中。 或者通过评估状态s0处的复位信号(例如if input1="11" and rst = '0'then)。然而,我没有在任何文献中看到这些“解决方案”,所以我怀疑的是。 以下是源代码。

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.ALL;

entity fsmtest is

  port (
    clk  : in  std_logic;
    rst : in std_logic;
    input1  : in std_logic_vector(1 downto 0);
    output1  : out std_logic_vector(1 downto 0));


end fsmtest;

architecture rtl of fsmtest is

  type state is (s0, s1);
  signal st, next_state : state := s0;


begin  -- rtl

  process (clk, rst)
  begin --process
    if rst = '1' then
      st <= s0;
      --next_state <= s0;
    elsif clk'event and clk = '1' then  -- rising clock edge
      st <= next_state;
    end if;
  end process;

  process(st, input1)
    begin  -- process

      case (st) is
        when (s0) => --initial state
          if input1 = "11" then
          next_state <= s1;
          output1 <= "11";
          else
          next_state <= s0;
          output1 <= "00";
        end if;

        when (s1) => --wait10
          if input1 = "00" then
            next_state <= s0;
            output1 <= "00";
            else
              output1 <= input1;
              next_state <= s1;
          end if;     
      end case;
  end process;
end rtl;

先谢谢

1 个答案:

答案 0 :(得分:0)

rst = '1'input1= "11"然后output1="11"时。这就是你在代码中写的内容。你写了:

  process (clk, rst)
  begin --process
    if rst = '1' then
      st <= s0;

st s0 rst '1' process(st, input1) begin -- process case (st) is when (s0) => --initial state if input1 = "11" then output1 <= "11"; 然后你写了

output1

"11" st s0input1"11"heroku-18时,heroku-16heroku stack:set heroku-18 -a <app name>