summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/registre/reg_rw.vhd
blob: 25d645f7abf68ed2cf0b0e1567cd062d0c748f8d (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
-- reg_rw.vhd
-- Eurobot 2004 : APB Team
-- Auteur : Pierre-Andr� Galmes
-- Registre dont la valeur est accessible en lecture.

-- Principe :
-- Si (write et enable) alors sauvegarde entr�e et copie entr�e sur sortie.
-- Si (read  et enable) alors copie derni�re valeur sauvegard�e sur entr�e.
-- Si (pas enable)      alors copie derni�re valeur sauvegard�e sur sortie et
--			entr�e en haute imp�dance.

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_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 entity;

architecture RTL of reg_rw is
    -- signal interne
    signal REG : T_DATA;
begin
    -- partie s�quentielle.
    process (rst, clk)
    begin
	-- reset
	if (rst = '1') then
	    REG <= (others => '0');
		 data <= (others => 'Z');
	-- �criture des donn�es.
	elsif (clk'event and clk = '1') then
		if (enable = '1' and rw = ISA_WRITE) then
				REG <= data;
		end if;
	end if;
   end process;

    -- partie combinatoire.
    data <= REG when (enable = '1' and rw = ISA_READ) else (others => 'Z');
    data_out <= REG;
	
end RTL;