63 lines
2.9 KiB
VHDL
63 lines
2.9 KiB
VHDL
----------------------------------------------------------------------------------
|
|
-- Company: INSA-Toulouse
|
|
-- Engineer: Paul Faure
|
|
--
|
|
-- Create Date: 15.04.2021 08:23:48
|
|
-- Module Name: BancRegistres - Behavioral
|
|
-- Project Name: Processeur sécurisé
|
|
-- Target Devices: Basys 3 ARTIX7
|
|
-- Tool Versions: Vivado 2016.4
|
|
-- Description: Banc de registre
|
|
--
|
|
-- Dependencies: None
|
|
--
|
|
-- Comments :
|
|
-- - Il est possible de lire 3 registres en simultané
|
|
-- - Si on souhaite lire et ecrire dans un même registre, l'écriture est prioritaire
|
|
----------------------------------------------------------------------------------
|
|
|
|
|
|
library IEEE;
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
|
use IEEE.NUMERIC_STD.ALL;
|
|
|
|
entity BancRegistres is
|
|
Generic (Nb_bits : Natural; -- Taille d'un mot dans un registre
|
|
Addr_size : Natural; -- Nombres de bits nécessaires pour adresser les registres
|
|
Nb_regs : Natural); -- Nombre de registre
|
|
Port ( AddrA : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre A à lire
|
|
AddrB : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre B à lire
|
|
AddrC : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre C à lire
|
|
AddrW : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre W où ecrire
|
|
W : in STD_LOGIC; -- Flag d'écriture ('1' -> écriture)
|
|
DATA : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Donnée a écrire
|
|
RST : in STD_LOGIC; -- Reset
|
|
CLK : in STD_LOGIC; -- Clock
|
|
QA : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Sortie : Valeur contenue dans le registre AddrA
|
|
QB : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Sortie : Valeur contenue dans le registre AddrB
|
|
QC : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0));-- Sortie : Valeur contenue dans le registre AddrC
|
|
end BancRegistres;
|
|
|
|
|
|
architecture Behavioral of BancRegistres is
|
|
signal REGISTRES : STD_LOGIC_VECTOR ((Nb_regs * Nb_bits)-1 downto 0) := (others => '0'); -- Buffer (registres)
|
|
begin
|
|
process
|
|
begin
|
|
-- Synchronisation
|
|
wait until CLK'event and CLK = '1';
|
|
if (RST = '0') then
|
|
REGISTRES <= (others => '0');
|
|
else
|
|
-- Ecriture
|
|
if (W = '1') then
|
|
REGISTRES (((to_integer(unsigned(AddrW)) + 1) * Nb_bits - 1) downto Nb_bits * to_integer(unsigned(AddrW))) <= DATA;
|
|
end if;
|
|
end if;
|
|
end process;
|
|
|
|
-- Lecture en Assynchrone (donc écriture prioritaire)
|
|
QA <= REGISTRES (((to_integer(unsigned(AddrA)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrA)));
|
|
QB <= REGISTRES (((to_integer(unsigned(AddrB)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrB)));
|
|
QC <= REGISTRES (((to_integer(unsigned(AddrC)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrC)));
|
|
end Behavioral;
|