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.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 15.04.2021 08:23:48
  6. -- Design Name:
  7. -- Module Name: BancRegistres - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool Versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. --use IEEE.STD_LOGIC_UNSIGNED.ALL;
  23. --use IEEE.STD_LOGIC_ARITH.ALL;
  24. -- Uncomment the following library declaration if using
  25. -- arithmetic functions with Signed or Unsigned values
  26. use IEEE.NUMERIC_STD.ALL;
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx leaf cells in this code.
  29. --library UNISIM;
  30. --use UNISIM.VComponents.all;
  31. entity BancRegistres is
  32. Generic (Nb_bits : Natural;
  33. Addr_size : Natural;
  34. Nb_regs : Natural);
  35. Port ( AddrA : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  36. AddrB : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  37. AddrW : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  38. W : in STD_LOGIC;
  39. DATA : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  40. RST : in STD_LOGIC;
  41. CLK : in STD_LOGIC;
  42. QA : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  43. QB : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0));
  44. end BancRegistres;
  45. -- ASK MEILLEURE IDEE UN TABLEAU
  46. architecture Behavioral of BancRegistres is
  47. signal REGISTRES : STD_LOGIC_VECTOR ((Nb_regs * Nb_bits)-1 downto 0) := (others => '0');
  48. begin
  49. process
  50. begin
  51. wait until CLK'event and CLK = '1';
  52. if (RST = '0') then
  53. REGISTRES <= (others => '0');
  54. else
  55. if (W = '1') then
  56. REGISTRES (((to_integer(unsigned(AddrW)) + 1) * Nb_bits - 1) downto Nb_bits * to_integer(unsigned(AddrW))) <= DATA;
  57. end if;
  58. end if;
  59. end process;
  60. QA <= REGISTRES (((to_integer(unsigned(AddrA)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrA)));
  61. QB <= REGISTRES (((to_integer(unsigned(AddrB)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrB)));
  62. end Behavioral;