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

Subversion Repositories the_wizardry_project

[/] [the_wizardry_project/] [trunk/] [Wizardry/] [VHDL/] [Wizardry Top Level/] [Address Generation/] [JOP/] [sdpram.vhd] - Blame information for rev 22

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 mcwaccent
--
2
--
3
--  This file is a part of JOP, the Java Optimized Processor
4
--
5
--  Copyright (C) 2006, Martin Schoeberl (martin@jopdesign.com)
6
--
7
--  This program is free software: you can redistribute it and/or modify
8
--  it under the terms of the GNU General Public License as published by
9
--  the Free Software Foundation, either version 3 of the License, or
10
--  (at your option) any later version.
11
--
12
--  This program is distributed in the hope that it will be useful,
13
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
--  GNU General Public License for more details.
16
--
17
--  You should have received a copy of the GNU General Public License
18
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
 
21
--
22
--      sdpram.vhd
23
--
24
--      Simple dual port ram with read and write port
25
--              and independent clocks
26
--      Read and write address, write data is registered. Output is not
27
--      registered. Read enable gates the read address. Is compatible
28
--      with SimpCon.
29
--
30
--      When using different clocks following warning is generated:
31
--              Functionality differs from the original design.
32
--      Read during write at the same address is undefined.
33
--
34
--      If read enable is used a discrete output register is synthesized.
35
--      Without read enable the 
36
--
37
--      Author: Martin Schoeberl (martin@jopdesign.com)
38
--
39
--      2006-08-03      adapted from simulation only version
40
--      2008-03-02      added read enable
41
--
42
 
43
library ieee;
44
use ieee.std_logic_1164.all;
45
use ieee.numeric_std.all;
46
 
47
entity sdpram is
48
generic (width : integer := 32; addr_width : integer := 7);
49
port (
50
        wrclk           : in std_logic;
51
        data            : in std_logic_vector(width-1 downto 0);
52
        wraddress       : in std_logic_vector(addr_width-1 downto 0);
53
        wren            : in std_logic;
54
 
55
        rdclk           : in std_logic;
56
        rdaddress       : in std_logic_vector(addr_width-1 downto 0);
57
        rden            : in std_logic;
58
        dout            : out std_logic_vector(width-1 downto 0)
59
);
60
end sdpram ;
61
 
62
architecture rtl of sdpram is
63
 
64
        signal reg_dout                 : std_logic_vector(width-1 downto 0);
65
 
66
        subtype word is std_logic_vector(width-1 downto 0);
67
        constant nwords : integer := 2 ** addr_width;
68
        type ram_type is array(0 to nwords-1) of word;
69
 
70
        signal ram : ram_type;
71
 
72
begin
73
 
74
process (wrclk)
75
begin
76
        if rising_edge(wrclk) then
77
                if wren='1' then
78
                        ram(to_integer(unsigned(wraddress))) <= data;
79
                end if;
80
        end if;
81
end process;
82
 
83
process (rdclk)
84
begin
85
        if rising_edge(rdclk) then
86
                if rden='1' then
87
                        reg_dout <= ram(to_integer(unsigned(rdaddress)));
88
                end if;
89
        end if;
90
end process;
91
 
92
        dout <= reg_dout;
93
 
94
end rtl;

powered by: WebSVN 2.1.0

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