VHDL的序列检测器设计 20
VHDL的序列检测器设计,源程序如下,仿真结果如图所示
LIBRARY ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
--*----------------------------------------------------------------
entity seq_detector is
port(clk : in std_logic;
X : in std_logic;
Z : out std_logic);
end seq_detector;
--*-----------------------------------------------------------------------------------
architecture arch of seq_detector is
signal shift_L : std_logic_vector(4 downto 0);
begin
P1 : process(clk)
begin
if clk'event and clk = '1' then
shift_L <= shift_L(3 downto 0)&X;
if shift_L="10010"then
Z <= '1';
else
Z <= '0';
end if;
end if;
end process P1;
end arch;
--*--------------------------------------------------------------------