| 1 | ----------------------------------------------------------------------------------
|
|---|
| 2 | -- Company:
|
|---|
| 3 | -- Engineer: GAMOM NGOUNOU
|
|---|
| 4 | --
|
|---|
| 5 | -- Create Date: 18:33:31 03/05/2012
|
|---|
| 6 | -- Design Name:
|
|---|
| 7 | -- Module Name: RAM_32_32 - Behavioral
|
|---|
| 8 | -- Project Name: MPI_Core
|
|---|
| 9 | -- Target Devices:
|
|---|
| 10 | -- Tool versions:
|
|---|
| 11 | -- Description: permet de stocker les données locales de la librairie MPI
|
|---|
| 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_ARITH.ALL;
|
|---|
| 23 | use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
|---|
| 24 | -- Uncomment the following library declaration if using
|
|---|
| 25 | -- arithmetic functions with Signed or Unsigned values
|
|---|
| 26 | --use IEEE.NUMERIC_STD.ALL;
|
|---|
| 27 |
|
|---|
| 28 | -- Uncomment the following library declaration if instantiating
|
|---|
| 29 | -- any Xilinx primitives in this code.
|
|---|
| 30 | --library UNISIM;
|
|---|
| 31 | --use UNISIM.VComponents.all;
|
|---|
| 32 |
|
|---|
| 33 | entity RAM_v is
|
|---|
| 34 | generic(width : positive:=32; Size:positive:=16);
|
|---|
| 35 | Port ( clka, clkb : in std_logic;
|
|---|
| 36 | wea : in std_logic;
|
|---|
| 37 | ena, enb : in std_logic;
|
|---|
| 38 | addra, addrb : in std_logic_vector(size-1 downto 0); --cinq lignes d'adresse
|
|---|
| 39 | dia : in std_logic_vector(width-1 downto 0);
|
|---|
| 40 | dob : out std_logic_vector(width-1 downto 0));
|
|---|
| 41 | end RAM_v;
|
|---|
| 42 |
|
|---|
| 43 | architecture Behavioral of RAM_v is
|
|---|
| 44 | signal Lra,Lrb :std_logic:='0';
|
|---|
| 45 | signal sel : std_logic_vector(1 downto 0);
|
|---|
| 46 | signal doa,dout : std_logic_vector(width-1 downto 0);
|
|---|
| 47 | type ram_type is array (2**size-1 downto 0) of std_logic_vector (width-1 downto 0);
|
|---|
| 48 | signal RAM: ram_type;
|
|---|
| 49 | begin
|
|---|
| 50 | process (clka)
|
|---|
| 51 | begin
|
|---|
| 52 | if clka'event and clka = '1' then
|
|---|
| 53 | if ena = '1' then
|
|---|
| 54 | if wea = '1' then
|
|---|
| 55 | RAM(conv_integer(addra)) <= dia;
|
|---|
| 56 | end if;
|
|---|
| 57 |
|
|---|
| 58 | doa<=RAM(conv_integer(addrb));
|
|---|
| 59 | Lra<='1';
|
|---|
| 60 | else
|
|---|
| 61 | if lrb='1' then
|
|---|
| 62 | Lra<='0';
|
|---|
| 63 | end if;
|
|---|
| 64 | end if;
|
|---|
| 65 | end if;
|
|---|
| 66 | end process;
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | process (clkb)
|
|---|
| 70 | begin
|
|---|
| 71 | if clkb'event and clkb = '1' then
|
|---|
| 72 | if enb = '1' then
|
|---|
| 73 | Lrb<='1';
|
|---|
| 74 | dout <= RAM(conv_integer(addrb)) ;
|
|---|
| 75 | else
|
|---|
| 76 | if Lra='1' then
|
|---|
| 77 | Lrb<='0';
|
|---|
| 78 | end if;
|
|---|
| 79 | end if;
|
|---|
| 80 | end if;
|
|---|
| 81 | end process;
|
|---|
| 82 |
|
|---|
| 83 | sel<=(Lra,Lrb);
|
|---|
| 84 | With sel select
|
|---|
| 85 | dob <=dout when "11",
|
|---|
| 86 | doa when "10",
|
|---|
| 87 | dout when "01",
|
|---|
| 88 | dout when "00",
|
|---|
| 89 | dout when others;
|
|---|
| 90 |
|
|---|
| 91 | end Behavioral;
|
|---|
| 92 |
|
|---|