No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BancRegistres.vhd 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ----------------------------------------------------------------------------------
  2. -- Company: INSA-Toulouse
  3. -- Engineer: Paul Faure
  4. --
  5. -- Create Date: 15.04.2021 08:23:48
  6. -- Module Name: BancRegistres - Behavioral
  7. -- Project Name: Processeur sécurisé
  8. -- Target Devices: Basys 3 ARTIX7
  9. -- Tool Versions: Vivado 2016.4
  10. -- Description: Banc de registre
  11. --
  12. -- Dependencies: None
  13. --
  14. -- Comments :
  15. -- - Il est possible de lire 3 registres en simultané
  16. -- - Si on souhaite lire et ecrire dans un même registre, l'écriture est prioritaire
  17. ----------------------------------------------------------------------------------
  18. library IEEE;
  19. use IEEE.STD_LOGIC_1164.ALL;
  20. use IEEE.NUMERIC_STD.ALL;
  21. entity BancRegistres is
  22. Generic (Nb_bits : Natural; -- Taille d'un mot dans un registre
  23. Addr_size : Natural; -- Nombres de bits nécessaires pour adresser les registres
  24. Nb_regs : Natural); -- Nombre de registre
  25. Port ( AddrA : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre A à lire
  26. AddrB : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre B à lire
  27. AddrC : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre C à lire
  28. AddrW : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre W où ecrire
  29. W : in STD_LOGIC; -- Flag d'écriture ('1' -> écriture)
  30. DATA : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Donnée a écrire
  31. RST : in STD_LOGIC; -- Reset
  32. CLK : in STD_LOGIC; -- Clock
  33. QA : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Sortie : Valeur contenue dans le registre AddrA
  34. QB : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Sortie : Valeur contenue dans le registre AddrB
  35. QC : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0));-- Sortie : Valeur contenue dans le registre AddrC
  36. end BancRegistres;
  37. architecture Behavioral of BancRegistres is
  38. signal REGISTRES : STD_LOGIC_VECTOR ((Nb_regs * Nb_bits)-1 downto 0) := (others => '0'); -- Buffer (registres)
  39. begin
  40. process
  41. begin
  42. -- Synchronisation
  43. wait until CLK'event and CLK = '1';
  44. if (RST = '0') then
  45. REGISTRES <= (others => '0');
  46. else
  47. -- Ecriture
  48. if (W = '1') then
  49. REGISTRES (((to_integer(unsigned(AddrW)) + 1) * Nb_bits - 1) downto Nb_bits * to_integer(unsigned(AddrW))) <= DATA;
  50. end if;
  51. end if;
  52. end process;
  53. -- Lecture en Assynchrone (donc écriture prioritaire)
  54. QA <= REGISTRES (((to_integer(unsigned(AddrA)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrA)));
  55. QB <= REGISTRES (((to_integer(unsigned(AddrB)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrB)));
  56. QC <= REGISTRES (((to_integer(unsigned(AddrC)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrC)));
  57. end Behavioral;