OpenCores
URL https://opencores.org/ocsvn/System09/System09/trunk

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [XilinxRAMs/] [block_spram.vhd] - Blame information for rev 217

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 203 davidgb
--===========================================================================--
2
--                                                                           --
3
--            Generic Single-Port Block RAM for Xilinx                       --
4
--                                                                           --
5
--===========================================================================--
6
--
7
--  File name      : block_spram.vhd
8
--
9
--  Entity name    : block_spram
10
--
11
--  Purpose        : Implements generic block memory of arbitrary size
12
--
13
--  Dependencies   : ieee.std_logic_1164
14
--                   ieee.std_logic_arith
15
--
16
--  Uses           : infers family-specific block memory as required
17
--
18
--  Author         : David Burnette
19
--
20
--  Email          :       
21
--
22
--  Web            : 
23
--
24
--  Description    : Generic Block RAM 
25
--
26
--
27
--  This program is free software: you can redistribute it and/or modify
28
--  it under the terms of the GNU General Public License as published by
29
--  the Free Software Foundation, either version 3 of the License, or
30
--  (at your option) any later version.
31
--
32
--  This program is distributed in the hope that it will be useful,
33
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
34
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
35
--  GNU General Public License for more details.
36
--
37
--  You should have received a copy of the GNU General Public License
38
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
39
--
40
--===========================================================================--
41
--                                                                           --
42
--                              Revision  History                            --
43
--                                                                           --
44
--===========================================================================--
45
--
46
-- Version Date        Author     Changes
47
--
48
-- 0.1     2021-02-19  David Burnette  Initial verison 
49
--
50
library IEEE;
51
  use IEEE.STD_LOGIC_1164.ALL;
52
  use IEEE.Numeric_Std.ALL;
53
library unisim;
54
        use unisim.vcomponents.all;
55
 
56
entity block_spram is
57
  generic (
58
    dwidth : integer := 8;     -- parameterized data width
59
         awidth : integer := 16     -- parameterized address width
60
         );
61
  port (
62
    clk         : in std_logic;
63
         cs          : in std_logic; -- chip-select/enable
64
         addr        : in std_logic_vector(awidth-1 downto 0);
65
         rw          : in std_logic;
66
         data_in     : in std_logic_vector(dwidth-1 downto 0);
67
         data_out    : out std_logic_vector(dwidth-1 downto 0)
68
         );
69
end block_spram;
70
 
71
architecture rtl of block_spram is
72
  type ram_t is array ( (2**awidth)-1 downto 0) of std_logic_vector(dwidth-1 downto 0);
73
  signal ram_data : ram_t := (others => (others => '0')); -- ram storage, initialized to zero
74
 
75
  attribute ram_style : string;
76
  attribute ram_style of ram_data : signal is "BLOCK"; -- direct ISE/Vivado to target block memory
77
  signal we : std_logic;
78
begin
79
  we <= not rw;
80
  process ( clk )
81
  begin
82
    if (rising_edge(clk)) then
83
           if (cs = '1') then
84
                  data_out <= ram_data(to_integer(unsigned(addr))); -- read port
85
                  if (we = '1') then
86
                    ram_data(to_integer(unsigned(addr))) <= data_in; -- write port
87
        end if;
88
      end if;
89
    end if;
90
  end process;
91
end architecture rtl;
92
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.