-
Notifications
You must be signed in to change notification settings - Fork 0
/
boothFSM.vhd
97 lines (94 loc) · 2.9 KB
/
boothFSM.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
--MAquina de estados
---------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity boothFSM is
port (
I: in std_logic;
V: in std_logic_vector(1 downto 0);
S: in std_logic;
clk : in std_logic;
reset : in std_logic;
ResetOut: out std_logic;
AorS: out std_logic;
Somar: out std_logic;
Shift: out std_logic
);
end entity;
architecture behav of boothFSM is
begin
process(I, V, S, Clk, Reset)
variable state : integer := 0;
begin
if (clk = '1' and clk'event) then
if (Reset = '1') then
state := 0;
ResetOut <= '0';
AorS <= '0';
Somar <= '0';
Shift <= '0';
elsif (state = 0 and S ='0') then
state := 0;
ResetOut <= '0';
AorS <= '0';
Somar <= '0';
Shift <= '0';
elsif (state = 0 and S ='1') then
state := 1;
ResetOut <= '1';
AorS <= '0';
Somar <= '0';
Shift <= '0';
elsif (state = 1) then
state := 2;
ResetOut <= '0';
AorS <= '0';
Somar <= '0';
Shift <= '0';
elsif (state = 2 and I ='1') then
state := 0;
ResetOut <= '0';
AorS <= '0';
Somar <= '0';
Shift <= '0';
elsif (state = 2 and I = '0' and V(1)='1' and v(0)='0') then
state := 4;
ResetOut <= '0';
AorS <= '1';
Somar <= '1';
Shift <= '0';
elsif (state = 2 and I = '0' and V(1)='0' and v(0)='1') then
state := 3;
ResetOut <= '0';
AorS <= '0';
Somar <= '1';
Shift <= '0';
elsif (state = 2 and I = '0' and (V ="00" or V = "11")) then
state := 5;
ResetOut <= '0';
AorS <= '0';
Somar <= '0';
Shift <= '1';
elsif (state = 3) then
state := 5;
ResetOut <= '0';
AorS <= '0';
Somar <= '0';
Shift <= '1';
elsif (state = 4) then
state := 5;
ResetOut <= '0';
AorS <= '0';
Somar <= '0';
Shift <= '1';
elsif (state = 5) then
state := 2;
ResetOut <= '0';
AorS <= '0';
Somar <= '0';
Shift <= '0';
end if;
end if;
end process;
end architecture;
---------------------------------------------------