summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/registre/registre.vhd
blob: 219e1f1bf6fbde01f8706a4209d835badd2bf88b (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
-- txserie.vhd
-- Eurobot 2004 : APB Team
-- Auteur : Pierre Prot
-- registre IO adressable sur bus ISA

-- MARCHE 

-- -------------------------------------------
-- Registre g�n�rique � brancher sur un bus
-- -------------------------------------------
-- 
-- * on peut �crire ou lire dans le registre depuis le bus :
--   . Positionner l'adresse
--   . Mettre 'rw' � 1=>read 0=>write
--   . Front montant sur 'ck'
--   Remarque : on ne peut pas �crire via le bus si 'load' est activ�
-- * on peut lire la valeur en permanence sur 'output'
-- * on peut �crire dans le registre en permanence gr�ce � 'load'. Cette
--   action est prioritaire sur l'�criture via le bus
--   . Mettre 'load' � 1
--   . Ecrire dans 'input' (actualisation imm�diate)
--   . Mettre 'load' � 0 pour latcher


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 regIO is
    port(
	cs: in std_logic;
	bus_data: inout T_DATA:=(others => 'Z');
	input: 	in  T_DATA;
	output: out T_DATA;
	rw:	in std_logic;
	load:	in std_logic;
	ck:	in std_logic;
	rst:	in std_logic
	);
end entity;


architecture rtl of regIO is
signal REG : T_DATA :=(others => '0');

begin
  p_w:process(ck,load,input,rst)
  begin
    if(rst='1') then
	   REG<=(others => '0');
    elsif(ck'event and ck='1') then
	   if(cs='1') then
	     if(rw='0' and load='0') then
		    REG<=bus_data;
        end if;
      end if;
    end if;

    -- chargement : prioritaire sur l'�criture via le bus
--    if(load='1' and not(ck='1' and rw='1')) then
    if(load='1') then
      REG<=input;
    end if;
  end process;

  bus_data<=REG when (rw='1' and cs='1' and rst='0') else (others => 'Z');

  output<=REG;
end rtl;