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.

MemoireDonnees.vhd 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 16.04.2021 14:35:04
  6. -- Design Name:
  7. -- Module Name: MemoireDonnees - 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. -- Uncomment the following library declaration if using
  23. -- arithmetic functions with Signed or Unsigned values
  24. use IEEE.NUMERIC_STD.ALL;
  25. -- Uncomment the following library declaration if instantiating
  26. -- any Xilinx leaf cells in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29. entity MemoireDonnees is
  30. Generic (Nb_bits : Natural;
  31. Addr_size : Natural;
  32. Mem_size : Natural);
  33. Port ( Addr : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
  34. RW : in STD_LOGIC;
  35. D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
  36. RST : in STD_LOGIC;
  37. CLK : in STD_LOGIC;
  38. D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0'));
  39. end MemoireDonnees;
  40. architecture Behavioral of MemoireDonnees is
  41. signal MEMORY : STD_LOGIC_VECTOR ((Mem_Size * Nb_bits)-1 downto 0) := (others => '0');
  42. begin
  43. process
  44. begin
  45. wait until CLK'event and CLK = '1';
  46. if (RST = '0') then
  47. MEMORY <= (others => '0');
  48. else
  49. if (RW = '0') then
  50. MEMORY (((to_integer(unsigned(Addr)) + 1) * Nb_bits - 1) downto Nb_bits * to_integer(unsigned(Addr))) <= D_IN;
  51. else
  52. D_OUT <= MEMORY (((to_integer(unsigned(Addr)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(Addr)));
  53. end if;
  54. end if;
  55. end process;
  56. end Behavioral;