source: PROJECT_CORE_MPI/CORE_MPI/BRANCHES/v1.00/RAM_32_32.vhd @ 78

Last change on this file since 78 was 70, checked in by rolagamo, 11 years ago
File size: 2.5 KB
Line 
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----------------------------------------------------------------------------------
20library IEEE;
21use IEEE.STD_LOGIC_1164.ALL;
22use IEEE.STD_LOGIC_ARITH.ALL;
23use 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
33entity RAM_v is
34generic(width : positive:=32; Size:positive:=16);
35Port ( 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));
41end RAM_v;
42
43architecture 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-3)-1 downto 0) of std_logic_vector (width-1 downto 0);
48        signal RAM: ram_type;
49begin
50 process (clka)
51        begin
52                if clka'event and clka = '1' then
53                        if ena = '1' then
54                                if wea = '1' then
55                                  if conv_integer(addra)>8191 then
56                                      report  "Erreur d'adresse";
57                                  else
58                                                RAM(conv_integer(addra)) <= dia;
59                                        end if;
60                                end if;
61                                if conv_integer(addrb)>8191 then
62                                      report  "Erreur d'adresse";
63                                  else 
64                                doa<=RAM(conv_integer(addrb));
65                           end if;
66                                Lra<='1';
67                        else 
68                                if lrb='1' then
69                                                Lra<='0';
70                                end if;
71                        end if;
72                 end if;
73 end process;
74
75 
76 process (clkb) 
77 begin
78                if clkb'event and clkb = '1' then
79                        if enb = '1' then
80                                Lrb<='1';       
81                                if conv_integer(addrb)>8191 then
82                                      report  "Erreur d'adresse";
83                                  else 
84                                  dout <= RAM(conv_integer(addrb)) ;
85                                end if;
86                        else
87                                if Lra='1' then
88                                        Lrb<='0';
89                                end if;
90                        end if;
91                end if;
92 end process;
93 
94 sel<=(Lra,Lrb);
95 With  sel select
96 dob <=dout when "11",
97      doa  when "10",
98                dout when "01",
99                dout when "00",
100                dout when others;
101               
102end Behavioral;
103
Note: See TracBrowser for help on using the repository browser.