-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFSMctrl.vhd
111 lines (89 loc) · 1.68 KB
/
FSMctrl.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
library IEEE;
use ieee.std_logic_1164.all;
-- ENTITY
entity FSMctrl is
port(
CLK, RST, ENTER: in std_logic;
Operacao: in std_logic_vector(1 downto 0);
Selecao: out std_logic_vector(1 downto 0);
Enable_1, Enable_2: out std_logic
);
end FSMctrl;
--ARCHITECTURE
architecture FSM_beh of FSMctrl is
type states is(S0,S1,S2,S3,S4,S5,S6,S7);
signal EA, PE: states;
signal clock: std_logic;
signal reset: std_logic;
begin
clock <= CLK;
P1: process(clock, reset)
begin
if reset = '0' then
EA <= S0;
elsif clock'event and clock = '1' then
EA <= PE;
end if;
end process;
P2: process(EA, ENTER, Operacao)
begin
case EA is
when S0 =>
if Enter = '1' then
PE <= S0;
else
PE <= S1;
end if;
Enable_1 <= '0';
Enable_2 <= '0';
when S1 =>
if Enter = '0' then
PE <= S1;
else
PE <= S2;
end if;
Enable_1 <= '1';
Enable_2 <= '0';
when S2 =>
Enable_1 <= '0';
Enable_2 <= '0';
if Operacao = "00" then
PE <= S3;
elsif Operacao = "01" then
PE <= S4;
elsif Operacao = "10" then
PE <= S5;
elsif Operacao = "11" then
PE <= S6;
end if;
when S3 =>
Selecao <= "00";
if Enter = '1' then
PE <= S3;
else
PE <= S7;
end if;
when S4 =>
Selecao <= "01";
if Enter = '1' then
PE <= S4;
else
PE <= S7;
end if;
when S5 =>
Enable_1 <= '1';
Enable_2 <= '1';
Selecao <= "10";
PE <= S0;
when S6 =>
Enable_1 <= '1';
Enable_2 <= '1';
Selecao <= "11";
PE <= S0;
when S7 =>
Enable_1 <= '0';
Enable_2 <= '1';
PE <= S0;
end case;
end process;
end FSM_beh;