/
s8_nov.vhd
59 lines (59 loc) · 2.55 KB
/
s8_nov.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
library ieee;
use ieee.numeric_std.all;
use ieee.std_logic_1164.all;
entity s8_nov is
port(
clock: in std_logic;
input: in std_logic_vector(3 downto 0);
output: out std_logic_vector(0 downto 0)
);
end s8_nov;
architecture behaviour of s8_nov is
constant s1: std_logic_vector(2 downto 0) := "001";
constant s2: std_logic_vector(2 downto 0) := "000";
constant s3: std_logic_vector(2 downto 0) := "110";
constant s4: std_logic_vector(2 downto 0) := "111";
constant s5: std_logic_vector(2 downto 0) := "010";
signal current_state, next_state: std_logic_vector(2 downto 0);
begin
process(clock) begin
if rising_edge(clock) then current_state <= next_state;
end if;
end process;
process(input, current_state) begin
next_state <= "---"; output <= "-";
case current_state is
when s1 =>
if std_match(input, "1000") then next_state <= s1; output <= "1";
elsif std_match(input, "0100") then next_state <= s1; output <= "1";
elsif std_match(input, "0010") then next_state <= s2; output <= "1";
elsif std_match(input, "0001") then next_state <= s2; output <= "1";
end if;
when s2 =>
if std_match(input, "1000") then next_state <= s2; output <= "1";
elsif std_match(input, "0100") then next_state <= s3; output <= "1";
elsif std_match(input, "0010") then next_state <= s2; output <= "1";
elsif std_match(input, "0001") then next_state <= s1; output <= "1";
end if;
when s3 =>
if std_match(input, "1000") then next_state <= s3; output <= "1";
elsif std_match(input, "0100") then next_state <= s5; output <= "1";
elsif std_match(input, "0010") then next_state <= s3; output <= "1";
elsif std_match(input, "0001") then next_state <= s5; output <= "1";
end if;
when s4 =>
if std_match(input, "1000") then next_state <= s4; output <= "1";
elsif std_match(input, "0100") then next_state <= s2; output <= "1";
elsif std_match(input, "0010") then next_state <= s3; output <= "1";
elsif std_match(input, "0001") then next_state <= s3; output <= "1";
end if;
when s5 =>
if std_match(input, "1000") then next_state <= s5; output <= "1";
elsif std_match(input, "0100") then next_state <= s5; output <= "1";
elsif std_match(input, "0010") then next_state <= s1; output <= "1";
elsif std_match(input, "0001") then next_state <= s4; output <= "1";
end if;
when others => next_state <= "---"; output <= "-";
end case;
end process;
end behaviour;