-
Notifications
You must be signed in to change notification settings - Fork 0
/
Maquina_Sensores.vhd
126 lines (115 loc) · 2.41 KB
/
Maquina_Sensores.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity Maquina_Sensores is
port(
clk,reset : in std_logic;
a,b: in std_logic;
inc,dec: out std_logic
);
end Maquina_Sensores;
architecture Behavioral of Maquina_Sensores is
type estado_sensores is (quieto,ent_10,ent_11,ent_01,sal_01,sal_11,sal_10,entro,salio);
signal r_reg,r_next : estado_sensores;
begin
--Estado
process(clk,reset)
begin
if(reset='1') then
r_reg <= quieto;
elsif(clk'event and clk='1') then
r_reg <= r_next;
end if;
end process;
--Logica del estado siguiente
process(r_reg,a,b)
begin
--Proceso de entrada
case r_reg is
when quieto =>
if a = '1' and b = '0' then
r_next <= ent_01;
elsif(a='0' and b='1')then
r_next <= sal_10;
else
r_next <= r_reg;
end if;
when ent_01 =>
if ( a='1' and b='1') then
r_next <= ent_11;
elsif (a='1' and b='0') then
r_next <= r_reg;
else
r_next <= quieto;
end if;
when ent_11 =>
if(a='0' and b='1') then
r_next <= ent_10;
elsif (a='1' and b='1') then
r_next <= r_reg;
elsif (a='1' and b='0') then
r_next <= ent_01;
else
r_next <= quieto;
end if;
when ent_10 =>
if(a='0' and b='0') then
r_next <= entro;
elsif(a='1' and b='1') then
r_next <= ent_11;
elsif(a='0' and b='1') then
r_next <= r_reg;
else
r_next <= quieto;
end if;
--Proceso de salida
when sal_10 =>
if(a='1' and b='1') then
r_next <= sal_11;
elsif (a='0' and b='1') then
r_next <= r_reg;
else
r_next <= quieto;
end if;
when sal_11 =>
if (a='1' and b='0') then
r_next <= sal_01;
elsif (a='1' and b='1') then
r_next <= r_reg;
elsif (a='0' and b='1') then
r_next <= sal_10;
else
r_next <= quieto;
end if;
when sal_01 =>
if(a='0' and b='0') then
r_next <= salio;
elsif (a='1' and b='1') then
r_next <= sal_11;
elsif (a='1' and b='0') then
r_next <= r_reg;
else
r_next <= quieto;
end if;
when entro =>
r_next <= quieto;
when salio =>
r_next <= quieto;
when others =>
r_next <= r_reg;
end case;
end process;
--Logica de salida
process(r_reg)
begin
case r_reg is
when entro =>
inc<= '1';
when salio =>
dec <= '1';
when others =>
dec <= '0';
inc <= '0';
end case;
end process;
end Behavioral;