summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/gpio/gpio.vhd
blob: b85d5da9dc323b53829b717ea4e130312837669f (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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
-- gpio.vhd
-- Eurobot 2004 : APB Team
-- Auteur : Pierre-Andr� Galmes
-- Fichier mod�le pour la d�claration de module.

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

use	work.nono_const.all;

entity gpio is
    port(
	rst : in std_logic;
	clk_i : in std_logic;	-- clock du bus isa
	clk_m : in std_logic;	-- master clock
	rw  : in std_logic; -- read (0) / write (1) TODO ??
	interrupt : out std_logic;
	bus_data : inout T_DATA;
	io_output : inout T_DATA;
	-- chip select
	cs_reg_data : in std_logic;
	cs_reg_direction : in std_logic;
	cs_reg_it_mask : in std_logic;
	cs_read_output : in std_logic
    );
end entity;

architecture RTL of gpio is

-- D�finition des composants utilis�s.

-- Registre.
component reg_rw is
    port (
        clk : in std_logic;
        rst : in std_logic;
        rw  : in std_logic; -- read (ISA_READ) / write (ISA_WRITE)
        enable  : in std_logic;
        data : inout T_DATA;
        data_out : out T_DATA -- data courant
    );
end component;

-- ET bit � bit  � sortie trhee state.
component gpio_direction is
    port (
        direction_mask : in T_DATA;
        data_in : in T_DATA;
        data_out : out T_DATA
    );
end component;

-- d�tecteur d'interruption 8 bits.
component gpio_it_detect 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 component;

-- Composant three-state.
component tristate is
    port (
        enable  : in std_logic;
        data_in : in T_DATA;
        data_out : out T_DATA
    );
end component;

-- d�finition des signaux.
-- clk, rst... sont d�finis dans l'entity du GPIO.
--
signal bus_direction_mask : T_DATA;
signal bus_it_mask : T_DATA;
signal bus_reg_data : T_DATA;

begin

-- Mapping des composants.
	
--
Reg_direction_mask : reg_rw 
port map (
    clk_i, 
    rst, 
    rw, 
    cs_reg_direction, 
    bus_data, 
    bus_direction_mask
);
  
--  
Reg_data : reg_rw 
port map (
    clk_i, 
    rst, 
    rw, 
    cs_reg_data, 
    bus_data, 
    bus_reg_data
);

--
Reg_it_mask : reg_rw 
port map (
    clk_i, 
    rst, 
    rw, 
    cs_reg_it_mask, 
    bus_data, 
    bus_it_mask
);

--
read_output : tristate 
port map (
    cs_read_output, 
    io_output, 
    bus_data
);

--
gest_direction : gpio_direction 
port map (
    bus_direction_mask, 
    bus_reg_data, 
    io_output
);

--
it_detector : gpio_it_detect 
port map (
    clk_m, 
    rst, 
    io_output, 
    bus_it_mask, 
    interrupt
);

end RTL;