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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_dpram_256x32.v] - Blame information for rev 10

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

Line No. Rev Author Line
1 10 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Double-Port Synchronous RAM                         ////
4
////                                                              ////
5
////  This file is part of memory library available from          ////
6
////  http://www.opencores.org/cvsweb.shtml/generic_memories/     ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  This block is a wrapper with common double-port             ////
10
////  synchronous memory interface for different                  ////
11
////  types of ASIC and FPGA RAMs. Beside universal memory        ////
12
////  interface it also provides behavioral model of generic      ////
13
////  double-port synchronous RAM.                                ////
14
////  It should be used in all OPENCORES designs that want to be  ////
15
////  portable accross different target technologies and          ////
16
////  independent of target memory.                               ////
17
////                                                              ////
18
////  Supported ASIC RAMs are:                                    ////
19
////                                                              ////
20
////  Supported FPGA RAMs are:                                    ////
21
////  - Xilinx Virtex RAMB16                                      ////
22
////  - Xilinx Virtex RAMB4                                       ////
23
////                                                              ////
24
////  To Do:                                                      ////
25
////   - add additional RAMs                                      ////
26
////   - xilinx rams need external tri-state logic                ////
27
////                                                              ////
28
////  Author(s):                                                  ////
29
////      - Nir  Mor, nirm@opencores.org                          ////
30
////                                                              ////
31
//////////////////////////////////////////////////////////////////////
32
////                                                              ////
33
//// Copyright (C) 2005 Authors and OPENCORES.ORG                 ////
34
////                                                              ////
35
//// This source file may be used and distributed without         ////
36
//// restriction provided that this copyright statement is not    ////
37
//// removed from the file and that any derivative work contains  ////
38
//// the original copyright notice and the associated disclaimer. ////
39
////                                                              ////
40
//// This source file is free software; you can redistribute it   ////
41
//// and/or modify it under the terms of the GNU Lesser General   ////
42
//// Public License as published by the Free Software Foundation; ////
43
//// either version 2.1 of the License, or (at your option) any   ////
44
//// later version.                                               ////
45
////                                                              ////
46
//// This source is distributed in the hope that it will be       ////
47
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
48
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
49
//// PURPOSE.  See the GNU Lesser General Public License for more ////
50
//// details.                                                     ////
51
////                                                              ////
52
//// You should have received a copy of the GNU Lesser General    ////
53
//// Public License along with this source; if not, download it   ////
54
//// from http://www.opencores.org/lgpl.shtml                     ////
55
////                                                              ////
56
//////////////////////////////////////////////////////////////////////
57
//
58
// CVS Revision History
59
//
60
 
61
// synopsys translate_off
62
`include "timescale.v"
63
// synopsys translate_on
64
`include "or1200_defines.v"
65
 
66
module or1200_dpram_256x32(
67
        // Generic synchronous double-port RAM interface
68
        clk_a, rst_a, ce_a, oe_a, addr_a, do_a,
69
        clk_b, rst_b, ce_b, we_b, addr_b, di_b
70
);
71
 
72
//
73
// Default address and data buses width
74
//
75
parameter aw = 8;
76
parameter dw = 32;
77
 
78
//
79
// Generic synchronous double-port RAM interface
80
//
81
input                   clk_a;  // Clock
82
input                   rst_a;  // Reset
83
input                   ce_a;   // Chip enable input
84
input                   oe_a;   // Output enable input
85
input   [aw-1:0] addr_a; // address bus inputs
86
output  [dw-1:0] do_a;   // output data bus
87
input                   clk_b;  // Clock
88
input                   rst_b;  // Reset
89
input                   ce_b;   // Chip enable input
90
input                   we_b;   // Write enable input
91
input   [aw-1:0] addr_b; // address bus inputs
92
input   [dw-1:0] di_b;   // input data bus
93
 
94
 
95
`ifdef OR1200_XILINX_RAMB4
96
 
97
//
98
// Instantiation of FPGA memory:
99
//
100
// Virtex/Spartan2
101
//
102
 
103
//
104
// Block 0
105
//
106
RAMB4_S16_S16 ramb4_s16_0(
107
        .CLKA(clk_a),
108
        .RSTA(rst_a),
109
        .ADDRA(addr_a),
110
        .DIA(16'h0000),
111
        .ENA(ce_a),
112
        .WEA(1'b0),
113
        .DOA(do_a[15:0]),
114
 
115
        .CLKB(clk_b),
116
        .RSTB(rst_b),
117
        .ADDRB(addr_b),
118
        .DIB(di_b[15:0]),
119
        .ENB(ce_b),
120
        .WEB(we_b),
121
        .DOB()
122
);
123
 
124
//
125
// Block 1
126
//
127
RAMB4_S16_S16 ramb4_s16_1(
128
        .CLKA(clk_a),
129
        .RSTA(rst_a),
130
        .ADDRA(addr_a),
131
        .DIA(16'h0000),
132
        .ENA(ce_a),
133
        .WEA(1'b0),
134
        .DOA(do_a[31:16]),
135
 
136
        .CLKB(clk_b),
137
        .RSTB(rst_b),
138
        .ADDRB(addr_b),
139
        .DIB(di_b[31:16]),
140
        .ENB(ce_b),
141
        .WEB(we_b),
142
        .DOB()
143
);
144
 
145
`else
146
 
147
`ifdef OR1200_XILINX_RAMB16
148
 
149
//
150
// Instantiation of FPGA memory:
151
//
152
// Virtex4/Spartan3E
153
//
154
// Added By Nir Mor
155
//
156
 
157
RAMB16_S36_S36 ramb16_s36_s36(
158
        .CLKA(clk_a),
159
        .SSRA(rst_a),
160
        .ADDRA({1'b0, addr_a}),
161
        .DIA(32'h00000000),
162
        .DIPA(4'h0),
163
        .ENA(ce_a),
164
        .WEA(1'b0),
165
        .DOA(do_a),
166
        .DOPA(),
167
 
168
        .CLKB(clk_b),
169
        .SSRB(rst_b),
170
        .ADDRB({1'b0, addr_b}),
171
        .DIB(di_b),
172
        .DIPB(4'h0),
173
        .ENB(ce_b),
174
        .WEB(we_b),
175
        .DOB(),
176
        .DOPB()
177
);
178
 
179
`else
180
 
181
//
182
// Generic double-port synchronous RAM model
183
//
184
 
185
//
186
// Generic RAM's registers and wires
187
//
188
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
189
reg     [aw-1:0] addr_a_reg;             // RAM address registered
190
 
191
//
192
// Data output drivers
193
//
194
assign do_a = (oe_a) ? mem[addr_a_reg] : {dw{1'b0}};
195
 
196
//
197
// RAM read
198
//
199
always @(posedge clk_a or posedge rst_a)
200
        if (rst_a)
201
                addr_a_reg <= #1 {aw{1'b0}};
202
        else if (ce_a)
203
                addr_a_reg <= #1 addr_a;
204
 
205
//
206
// RAM write
207
//
208
always @(posedge clk_b)
209
        if (ce_b && we_b)
210
                mem[addr_b] <= #1 di_b;
211
 
212
`endif  // !OR1200_XILINX_RAMB16
213
`endif  // !OR1200_XILINX_RAMB4
214
endmodule

powered by: WebSVN 2.1.0

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