vhdl mem_type dual port
----------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Titre : ram synthétisable
-- Projet :
-------------------------------------------------------------------------------
-- Fichier : ram_simple.vhd
-------------------------------------------------------------------------------
-- Description : RAM avec une seule adresse mais deux horloges
-- description conforme a la doc leo_tech.pdf page 292
-- surface occupee : 16 function generators
-------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY ram_simple IS
PORT (
SIGNAL data : IN std_logic_vector(7 DOWNTO 0);
SIGNAL address : IN std_logic_vector(4 DOWNTO 0);
SIGNAL we, inclock, outclock : IN std_logic;
SIGNAL q : OUT std_logic_vector(7 DOWNTO 0));
END ram_simple;
ARCHITECTURE fe2 OF ram_simple IS
TYPE mem_type IS ARRAY ( 31 DOWNTO 0) OF std_logic_vector (7 DOWNTO 0);
SIGNAL mem : mem_type;
SIGNAL address_int : unsigned(4 DOWNTO 0);
BEGIN -- ex2
l0 : PROCESS (inclock,outclock, we, address)
BEGIN -- PROCESS
IF (inclock = '1' AND inclock'event) THEN
address_int <= unsigned(address);
IF we = '1' THEN
mem(To_integer(unsigned(address))) <= data;
END IF;
END IF;
IF (outclock = '1' AND outclock'event) THEN
q <= mem(to_integer(address_int));
END IF;
END PROCESS;
END fe2;