summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/gpio/gpio_it_detect_up.vhd
blob: 382533aaf83804f925ed02e2182ac71b70f14c60 (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
55
56
57
58
-- gpio_it_detect_up.vhd
-- Eurobot 2004 : APB Team
-- Auteur : Pierre-Andr� Galmes
-- detecteur de changement d'�tat (front montant) avec masque.

-- Remarque : 
-- masque : si bit � 1 => g�n�rer une interruption.
-- 	    si bit � 0 => ne pas g�n�rer d'interruption.

library ieee;
use	ieee.std_logic_1164.all;

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


entity gpio_it_detect_up is
    port (
	clk : in std_logic;
	rst : in std_logic;
	data_in : in T_DATA;
	it_mask : in T_DATA;
	it_detected : out std_logic
    );
end entity;

architecture RTL of gpio_it_detect_up is
    -- Signal interne
    signal state_p : T_DATA;	-- �tat pass�
	 
begin

    -- process s�quentiel
    process (rst, clk, data_in)
    begin
	if (rst = '1') then
	    -- ne pas d�clencher d'it apr�s rst.
	    state_p <= data_in; 
	    it_detected <= '0';
	elsif (clk'event and clk = '1') then	
	    -- d�tection d'un front descendant.
	    if ((state_p(0) = '0' and data_in(0) = '1' and it_mask(0) = '1')
	     or (state_p(1) = '0' and data_in(1) = '1' and it_mask(1) = '1')
	     or (state_p(2) = '0' and data_in(2) = '1' and it_mask(2) = '1')
	     or (state_p(3) = '0' and data_in(3) = '1' and it_mask(3) = '1')
	     or (state_p(4) = '0' and data_in(4) = '1' and it_mask(4) = '1')
	     or (state_p(5) = '0' and data_in(5) = '1' and it_mask(5) = '1')
	     or (state_p(6) = '0' and data_in(6) = '1' and it_mask(6) = '1')
	     or (state_p(7) = '0' and data_in(7) = '1' and it_mask(7) = '1'))
		then
		-- on �met le signal d'interruption.
		it_detected <= '1';
	    end if;
	    state_p <= data_in;
	end if;
   end process;

end RTL;