summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/interrupt/conserv1.vhd
blob: 8afffe71d4dfffbd5b5b1ce99bb3c4e7ae736a5c (plain)
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
-- conserv1.vhd
-- Eurobot 2004 : APB Team
-- Auteur : Pierre-Andr� Galmes
-- Lors de la d�tection d'un front, garde un �tat haut durant 2 cycles
-- d'horloge. Marche sur une patte.


library ieee;
use	ieee.std_logic_1164.all;
--use     ieee.std_logic_arith.all;
use     ieee.std_logic_unsigned.all;

use	work.isa_const.all;
use	work.nono_const.all;


entity conserv1 is
    port (
	clk : in std_logic;
	rst : in std_logic;
	pin_in : in std_logic;
	pin_out : out std_logic
    );
end entity;

architecture RTL of conserv1 is
    
    -- Signal interne
    signal cycle : std_logic_vector (1 downto 0);

begin
    -- process s�quentiel
    process (rst, clk)
    begin
	if (rst = '1') then
	    pin_out <= '0';
	    cycle <= "00";
	elsif (clk'event and clk = '1') then
	    if (cycle = "10") then
		pin_out <= '0';
		cycle <= "00";
	    end if;
	    --
	    if (pin_in /= '0' or cycle = "01") then
		cycle <= cycle + "01"; 
		pin_out <= '1';
	    end if;
	
	end if;
    end process;

    -- process combinatoire.

end RTL;