-
Notifications
You must be signed in to change notification settings - Fork 0
/
headControle.vhd
63 lines (51 loc) · 1.25 KB
/
headControle.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
library ieee;
use ieee.std_logic_1164.all;
entity headControle is
port(
l,r,u,d: in std_logic;
clk,raza: in std_logic;
Haut,Gauche,Droite,Bas: out std_logic
);
end entity;
architecture stateMachine of headControle is
type state is (pUp, pDown, pLeft, pRight);
signal present, futur: state;
begin
evolution:
process (present, l,r,u,d)
begin
futur <= present;
case present is
when pDown => if r = '1' then futur <= pRight;
elsif l = '1' then futur <= pLeft; end if;
when pUp => if r = '1' then futur <= pRight;
elsif l = '1' then futur <= pLeft; end if;
when pRight => if u = '1' then futur <= pUp;
elsif d = '1' then futur <= pDown; end if;
when pLeft => if u = '1' then futur <= pUp;
elsif d = '1' then futur <= pDown; end if;
end case;
end process;
synchronisation:
process (clk,raza)
begin
if raza = '0' then present <= pRight;
elsif rising_edge(clk) then present <= futur;
end if;
end process;
actions:
process (present)
begin
Haut <= '0';
Bas <= '0';
Gauche <= '0';
Droite <= '0';
case present is
when pUp => Haut <= '1';
when pDown => Bas <= '1';
when pLeft => Gauche <= '1';
when pRight => Droite <= '1';
when others => null;
end case;
end process;
end architecture;