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

Subversion Repositories t80

[/] [t80/] [trunk/] [rtl/] [vhdl/] [SSRAM.vhd] - Blame information for rev 2

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

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

powered by: WebSVN 2.1.0

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