Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 81 additions and 0 deletions.
  1. +18 −0 button.vhd
  2. +63 −0 headControle.vhd
View
18 button.vhd
@@ -0,0 +1,18 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+entity button is
+ port(
+ button, clk: in std_logic;
+ trigger: out std_logic
+ );
+end entity;
+
+architecture Behavioral of button is
+ signal buttonCliked, resync: std_logic;
+begin
+ buttonCliked <= '0' when resync = '1' else '1' when falling_edge(button);
+ resync <= buttonCliked when rising_edge(clk);
+ trigger <= resync;
+end Behavioral;
View
63 headControle.vhd
@@ -0,0 +1,63 @@
+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 = '1' 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;
+
+

No commit comments for this range

Something went wrong with that request. Please try again.