-- ------------------------------------------- -- 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; library ieee.std_logic_1164.all; entity registre is generic(adr : integer); constant adr_w : integer :=10; constant data_w : integer :=8; port( adrbus: in std_logic_vector((adr_w - 1) downto 0); databus: inout std_logic_vector((data_w - 1) downto 0); input: in std_logic_vector((data_w - 1) downto 0); output: out std_logic_vector((data_w - 1) downto 0); rw: in std_logic; load: in std_logic; ck: in std_logic; rst: in std_logic ); end registre; architecture rtl of registre is signal REG : std_logic_vector((data_w - 1) downto 0); begin p_w:process(ck) begin if(ck'event and ck='1') then if(bvtoi(To_bitvector(adrbus))=adr) then if(rw='0') then if(load='0') then REG<=databus; end if; end if; end if; end if; end process p_w; p_r : process(adr,rw) begin if(bvtoi(To_bitvector(adrbus))=adr and rw='1') then databus<=REG; else databus<='ZZZZZZZZ'; end if; end process p_r; p_load : process(load,input) begin if(load='1') then REG<=input; end if; end process p_load; p_reset : process(rst) begin if(rst'event and rst='1') then REG='00000000'; databus='ZZZZZZZZ'; end if; output<=REG; end rtl;