123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- ----------------------------------------------------------------------------------
- -- Company: INSA-Toulouse
- -- Engineer: Paul Faure
- --
- -- Create Date: 16.04.2021 14:35:04
- -- Module Name: MemoireDonnees - Behavioral
- -- Project Name: Processeur sécurisé
- -- Target Devices: Basys 3 ARTIX7
- -- Tool Versions: Vivado 2016.4
- -- Description: Memoire des donnees utilisateur
- --
- -- Dependencies: None
- ----------------------------------------------------------------------------------
-
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use IEEE.NUMERIC_STD.ALL;
-
- entity MemoireDonnees is
- Generic (Nb_bits : Natural; -- Taille d'un mot en mémoire
- Addr_size : Natural; -- Nombre de bits nécessaires a l'adressage de la mémoire
- Mem_size : Natural); -- Nombre de mot stockables
- Port ( Addr : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- L'adresse a laquelle il faut agir
- RW : in STD_LOGIC; -- Ce qu'il faut faire ('1' -> Read, '0' -> Write)
- D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Data a ecrire (si RW = 0)
- RST : in STD_LOGIC; -- Reset
- CLK : in STD_LOGIC; -- Clock
- D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0')); -- Sortie de la mémoire
- end MemoireDonnees;
-
- architecture Behavioral of MemoireDonnees is
- signal MEMORY : STD_LOGIC_VECTOR ((Mem_Size * Nb_bits)-1 downto 0) := (others => '0'); -- Buffer pour la mémoire
- begin
- process
- begin
- wait until CLK'event and CLK = '1';
- if (RST = '0') then
- MEMORY <= (others => '0');
- else
- if (RW = '0') then
- MEMORY (((to_integer(unsigned(Addr)) + 1) * Nb_bits - 1) downto Nb_bits * to_integer(unsigned(Addr))) <= D_IN;
- end if;
- end if;
- end process;
-
- -- Lecture assynchrone et en permanence
- D_OUT <= MEMORY (((to_integer(unsigned(Addr)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(Addr)));
- end Behavioral;
|