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

Subversion Repositories ddr3_synthesizable_bfm

[/] [ddr3_synthesizable_bfm/] [trunk/] [rtl/] [dport_ram.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 slai
/*single clock dual port ram
2
2010-2011 sclai <laikos@yahoo.com>
3
 
4
This library is free software; you can redistribute it and/or modify it
5
 under the terms of the GNU Lesser General Public License as published by
6
 the Free Software Foundation; either version 2.1 of the License,
7
 or (at your option) any later version.
8
 
9
 This library is distributed in the hope that it will be useful, but
10
 WITHOUT ANY WARRANTY; without even the implied warranty of
11
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
 Lesser General Public License for more details.
13
 
14
 You should have received a copy of the GNU Lesser General Public
15
 License along with this library; if not, write to the Free Software
16
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17
 USA
18
 
19
 
20
Example:
21
Desity     Bank     Row    Col
22
-----------------------------
23
   64MB    2:0      12:0   9:0
24
  128MB    2:0      13:0   9:0
25
  512MB    2:0      13:0  10:0
26
    1GB    2:0      15:0  10:0
27
*/
28
 
29
module dport_ram
30
#(
31
        parameter DATA_WIDTH=8,
32
        parameter ADDR_WIDTH=36
33
)(
34
        input                                            clk,
35
        input [(DATA_WIDTH-1):0] di,
36
        input [(ADDR_WIDTH-1):0] read_addr,
37
        input [(ADDR_WIDTH-1):0] write_addr,
38
        input                                            we,
39
        output reg [(DATA_WIDTH-1):0] do
40
);
41 4 slai
localparam ACTUAL_ADDR_WIDTH=16; //due to small size of internal memory
42
//localparam ACTUAL_ADDR_WIDTH=26; //due to small size of internal memory
43 2 slai
wire [ACTUAL_ADDR_WIDTH-1:0]ACTUAL_WRITE_ADDR;
44
wire [ACTUAL_ADDR_WIDTH-1:0]ACTUAL_READ_ADDR;
45
                                                                                                //bank            row               col
46
//assign ACTUAL_WRITE_ADDR={write_addr[34:32],write_addr[25:16],write_addr[7:0]};
47
//assign ACTUAL_READ_ADDR ={ read_addr[34:32], read_addr[25:16], read_addr[7:0]};
48
assign ACTUAL_WRITE_ADDR={write_addr[34:32],write_addr[28:16],write_addr[9:0]};
49
assign ACTUAL_READ_ADDR ={ read_addr[34:32], read_addr[28:16], read_addr[9:0]};
50
//8196Kbytes RAM
51
reg [DATA_WIDTH-1:0] ram[2**ACTUAL_ADDR_WIDTH-1:0];
52
 
53
        always @ (posedge clk)
54
        begin
55
                if (we==1'b1)
56
                        begin
57
                                ram[ACTUAL_WRITE_ADDR] <= di;
58
                        end
59
                else
60
                        begin
61
                                do <= ram[ACTUAL_READ_ADDR];
62
                        end
63
        end
64
endmodule

powered by: WebSVN 2.1.0

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