我正在尝试编写一些 vhdl 来检测一串位中的给定模式。当电路在输入流中找到模式“110”时,它应该输出 1。我的输入是“X”,我的输出是“Z”。
我不确定如何检查“110”的输入模式。
这是我到目前为止所拥有的:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity checker is
Port ( clk : in STD_LOGIC;
x : in STD_LOGIC;
z : out STD_LOGIC);
end checker;
architecture Behavioral of checker is
type state_type is (S0, S1, S2);
signal pr_state: state_type := S0;
signal nx_state: state_type := S0;
begin
process(clk) begin
if (rising_edge(clk)) then
pr_state <= nx_state;
end if;
end process;
process(pr_state, nx_state) begin
case (pr_state) is
when S0 =>
z <= '0';
nx_state <= S1;
when S1 =>
z <= '0';
nx_state <= S2;
when S2 =>
z <= '1';
nx_state <= S0;
end case;
end process;
end Behavioral;
有什么想法吗?感谢您的反馈。