summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/gpio/reg_io.vhd
blob: 951c56d348c075ee4260eecf8c981bf88aac6386 (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
-- reg_io.vhd
-- Eurobot 2004 : APB Team
-- Auteur : Pierre-Andr� Galmes
-- Registre dont on peut lire les valeurs sur data_out.
-- 

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 reg_io is
    port (
	rst : in std_logic;
	
	-- XXX : savoir si read = 0 ou 1 !!
	rw  : in std_logic; -- read (0) / write (1)
	enable  : in std_logic;
	data_in : inout T_DATA;
	data_out : inout T_DATA
	--data_direction : in T_DATA
    );
end entity;

architecture BEHAV of reg_io is
    -- signal interne
    signal REG : T_DATA;
begin
    -- process 
    process (rst, rw, enable, data_in)
    begin
	if (rst = '1') then
	    REG <= x"00";
	    -- data_in <= "ZZZZZZZZ";
	else
	    if (enable = '1') then
		if (rw = ISA_WRITE) then
		    REG <= data_in;
		    -- data_out <= REG;
		elsif (rw = ISA_READ) then
		    data_in <= data_out;
		    -- data_in  <= REG;
		end if;
	    else 
		data_in <= "ZZZZZZZZ";
		-- data_out <= REG;
	    end if;
	end if;
    end process;

    data_out <= "ZZZZZZZZ" when (rw = ISA_READ and enable = '1') else REG;
end BEHAV;