1 |
106 |
arniml |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- Parametrizable, generic RAM with enable.
|
4 |
|
|
--
|
5 |
179 |
arniml |
-- $Id: generic_ram_ena.vhd 179 2009-04-01 19:48:38Z arniml $
|
6 |
106 |
arniml |
--
|
7 |
|
|
-- Copyright (c) 2006 Arnim Laeuger (arniml@opencores.org)
|
8 |
|
|
--
|
9 |
|
|
-- All rights reserved
|
10 |
|
|
--
|
11 |
|
|
-- Redistribution and use in source and synthezised forms, with or without
|
12 |
|
|
-- modification, are permitted provided that the following conditions are met:
|
13 |
|
|
--
|
14 |
|
|
-- Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
-- this list of conditions and the following disclaimer.
|
16 |
|
|
--
|
17 |
|
|
-- Redistributions in synthesized form must reproduce the above copyright
|
18 |
|
|
-- notice, this list of conditions and the following disclaimer in the
|
19 |
|
|
-- documentation and/or other materials provided with the distribution.
|
20 |
|
|
--
|
21 |
|
|
-- Neither the name of the author nor the names of other contributors may
|
22 |
|
|
-- be used to endorse or promote products derived from this software without
|
23 |
|
|
-- specific prior written permission.
|
24 |
|
|
--
|
25 |
|
|
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
26 |
|
|
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
27 |
|
|
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
28 |
|
|
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
|
29 |
|
|
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
30 |
|
|
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
31 |
|
|
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
32 |
|
|
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
33 |
|
|
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
34 |
|
|
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
35 |
|
|
-- POSSIBILITY OF SUCH DAMAGE.
|
36 |
|
|
--
|
37 |
|
|
-- Please report bugs to the author, but before you do so, please
|
38 |
|
|
-- make sure that this is not a derivative work and that
|
39 |
|
|
-- you have the latest version of this file.
|
40 |
|
|
--
|
41 |
|
|
-- The latest version of this file can be found at:
|
42 |
|
|
-- http://www.opencores.org/cvsweb.shtml/t400/
|
43 |
|
|
--
|
44 |
|
|
-------------------------------------------------------------------------------
|
45 |
|
|
|
46 |
|
|
library ieee;
|
47 |
|
|
use ieee.std_logic_1164.all;
|
48 |
|
|
|
49 |
|
|
entity generic_ram_ena is
|
50 |
|
|
|
51 |
|
|
generic (
|
52 |
|
|
addr_width_g : integer := 10;
|
53 |
|
|
data_width_g : integer := 8
|
54 |
|
|
);
|
55 |
|
|
port (
|
56 |
|
|
clk_i : in std_logic;
|
57 |
|
|
a_i : in std_logic_vector(addr_width_g-1 downto 0);
|
58 |
|
|
we_i : in std_logic;
|
59 |
|
|
ena_i : in std_logic;
|
60 |
|
|
d_i : in std_logic_vector(data_width_g-1 downto 0);
|
61 |
|
|
d_o : out std_logic_vector(data_width_g-1 downto 0)
|
62 |
|
|
);
|
63 |
|
|
|
64 |
|
|
end generic_ram_ena;
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
library ieee;
|
68 |
|
|
use ieee.numeric_std.all;
|
69 |
|
|
|
70 |
|
|
architecture rtl of generic_ram_ena is
|
71 |
|
|
|
72 |
|
|
type mem_t is array (natural range 0 to 2**addr_width_g-1) of
|
73 |
|
|
std_logic_vector(d_i'range);
|
74 |
|
|
signal mem_q : mem_t
|
75 |
|
|
-- pragma translate_off
|
76 |
|
|
:= (others => (others => '0'))
|
77 |
|
|
-- pragma translate_on
|
78 |
|
|
;
|
79 |
|
|
|
80 |
|
|
begin
|
81 |
|
|
|
82 |
|
|
mem: process (clk_i)
|
83 |
|
|
begin
|
84 |
|
|
|
85 |
|
|
if clk_i'event and clk_i = '1' then
|
86 |
|
|
if ena_i = '1' then
|
87 |
|
|
if we_i = '1' then
|
88 |
|
|
mem_q(to_integer(unsigned(a_i))) <= d_i;
|
89 |
|
|
end if;
|
90 |
|
|
|
91 |
162 |
arniml |
d_o <= mem_q(to_integer(unsigned(a_i)));
|
92 |
106 |
arniml |
end if;
|
93 |
|
|
|
94 |
|
|
end if;
|
95 |
|
|
end process mem;
|
96 |
|
|
|
97 |
|
|
end rtl;
|