-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseq_det.vhd
90 lines (86 loc) · 1.74 KB
/
seq_det.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 08:24:04 04/27/23
-- Design Name:
-- Module Name: seq_det - Behavioral
-- Project Name:
-- Target Device:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
--------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
--Mealy Sequence detector for detecting the sequence "11011".
--2 bit overlapping.
entity seq_det is
port( clk : in std_logic;
reset : in std_logic;
input : in std_logic;
output : out std_logic);
end seq_det;
architecture Behavioural of seq_det is
type state_type is (s0,s1,s2,s3,s4);
signal state : state_type := s0;
begin
process(clk, reset)
begin
if( reset = '1' ) then
output <= '0';
state <= s0;
elsif ( rising_edge(clk) ) then
case state is
when s0 =>
output <= '0';
if ( input = '0' ) then
state <= s0;
else
state <= s1;
end if;
when s1 =>
if ( input = '0' ) then
state <= s0;
output<='0';
else
state <= s2;
output<='0';
end if;
when s2 =>
if ( input = '0' ) then
state <= s3;
output<='0';
else
state <= s2;
output<='0';
end if;
when s3 =>
if ( input = '0' ) then
state <= s0;
output<='0';
else
state <= s4;
output<='0';
end if;
when s4 =>
if ( input = '0' ) then
state <= s0;
output<='0';
else
state <= s2;
output <= '1';
end if;
when others => NULL;
end case;
end if;
end process;
end Behavioural;