Write a test bench for the sequence detector given below lib
Solution
The Sequece Detector Detect the sequence of 1101 and when this sequence is detected the output z becomes 1
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
entity tb_sequence_detector is
end tb_sequence_detector;
architecture behavior of tb_sequence_detector is
signal clk,rst,x,z : std_logic := \'0\';
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: entity work.sequence_detector PORT MAP (
clk => clk,
rst => rst,
x => x,
z => z
);
-- Clock process definitions
clk_process :process
begin
clk <= \'0\';
wait for clk_period/2;
clk <= \'1\';
wait for clk_period/2;
end process;
stim_proc: process
begin
x <= \'1\'; --1
wait for clk_period;
x <= \'1\'; --11
wait for clk_period;
x <= \'0\'; --110
wait for clk_period;
x <= \'1\'; --1101
wait for clk_period;
x <= \'1\'; --11011
wait for clk_period;
x <= \'1\'; --110111
wait for clk_period;
x <= \'0\'; --1101110
wait for clk_period;
x <= \'1\'; --11011101
wait for clk_period;
x <= \'0\'; --110111010
wait for clk_period;
x <= \'1\'; --1101110101
wait for clk_period;
x<=\'1\' --11011101011
wait for clk_period;
x<=\'0\' --110111010110
wait for clk_period;
x<=\'1\' --1101110101101
rst<=\'1\' --reset the sequence
wait for clk_period;
x <= \'1\'; --1
wait for clk_period;
x <= \'1\'; --11
wait for clk_period;
x <= \'0\'; --110
wait for clk_period;
x <= \'1\'; --1101
wait;
end process;
END;

