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 588

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 141 marcus.erl
// $Log: or1200_dpram_256x32.v,v $
61
// Revision 2.0  2010/06/30 11:00:00  ORSoC
62
// New
63
//
64 10 unneback
 
65
// synopsys translate_off
66
`include "timescale.v"
67
// synopsys translate_on
68
`include "or1200_defines.v"
69
 
70
module or1200_dpram_256x32(
71
        // Generic synchronous double-port RAM interface
72
        clk_a, rst_a, ce_a, oe_a, addr_a, do_a,
73
        clk_b, rst_b, ce_b, we_b, addr_b, di_b
74
);
75
 
76
//
77
// Default address and data buses width
78
//
79
parameter aw = 8;
80
parameter dw = 32;
81
 
82
//
83
// Generic synchronous double-port RAM interface
84
//
85
input                   clk_a;  // Clock
86
input                   rst_a;  // Reset
87
input                   ce_a;   // Chip enable input
88
input                   oe_a;   // Output enable input
89
input   [aw-1:0] addr_a; // address bus inputs
90
output  [dw-1:0] do_a;   // output data bus
91
input                   clk_b;  // Clock
92
input                   rst_b;  // Reset
93
input                   ce_b;   // Chip enable input
94
input                   we_b;   // Write enable input
95
input   [aw-1:0] addr_b; // address bus inputs
96
input   [dw-1:0] di_b;   // input data bus
97
 
98
 
99
`ifdef OR1200_XILINX_RAMB4
100
 
101
//
102
// Instantiation of FPGA memory:
103
//
104
// Virtex/Spartan2
105
//
106
 
107
//
108
// Block 0
109
//
110
RAMB4_S16_S16 ramb4_s16_0(
111
        .CLKA(clk_a),
112
        .RSTA(rst_a),
113
        .ADDRA(addr_a),
114
        .DIA(16'h0000),
115
        .ENA(ce_a),
116
        .WEA(1'b0),
117
        .DOA(do_a[15:0]),
118
 
119
        .CLKB(clk_b),
120
        .RSTB(rst_b),
121
        .ADDRB(addr_b),
122
        .DIB(di_b[15:0]),
123
        .ENB(ce_b),
124
        .WEB(we_b),
125
        .DOB()
126
);
127
 
128
//
129
// Block 1
130
//
131
RAMB4_S16_S16 ramb4_s16_1(
132
        .CLKA(clk_a),
133
        .RSTA(rst_a),
134
        .ADDRA(addr_a),
135
        .DIA(16'h0000),
136
        .ENA(ce_a),
137
        .WEA(1'b0),
138
        .DOA(do_a[31:16]),
139
 
140
        .CLKB(clk_b),
141
        .RSTB(rst_b),
142
        .ADDRB(addr_b),
143
        .DIB(di_b[31:16]),
144
        .ENB(ce_b),
145
        .WEB(we_b),
146
        .DOB()
147
);
148
 
149
`else
150
 
151
`ifdef OR1200_XILINX_RAMB16
152
 
153
//
154
// Instantiation of FPGA memory:
155
//
156
// Virtex4/Spartan3E
157
//
158
// Added By Nir Mor
159
//
160
 
161
RAMB16_S36_S36 ramb16_s36_s36(
162
        .CLKA(clk_a),
163
        .SSRA(rst_a),
164
        .ADDRA({1'b0, addr_a}),
165
        .DIA(32'h00000000),
166
        .DIPA(4'h0),
167
        .ENA(ce_a),
168
        .WEA(1'b0),
169
        .DOA(do_a),
170
        .DOPA(),
171
 
172
        .CLKB(clk_b),
173
        .SSRB(rst_b),
174
        .ADDRB({1'b0, addr_b}),
175
        .DIB(di_b),
176
        .DIPB(4'h0),
177
        .ENB(ce_b),
178
        .WEB(we_b),
179
        .DOB(),
180
        .DOPB()
181
);
182
 
183
`else
184
 
185
//
186
// Generic double-port synchronous RAM model
187
//
188
 
189
//
190
// Generic RAM's registers and wires
191
//
192
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
193
reg     [aw-1:0] addr_a_reg;             // RAM address registered
194
 
195
//
196
// Data output drivers
197
//
198
assign do_a = (oe_a) ? mem[addr_a_reg] : {dw{1'b0}};
199
 
200
//
201
// RAM read
202
//
203 358 julius
always @(posedge clk_a or `OR1200_RST_EVENT rst_a)
204
        if (rst_a == `OR1200_RST_VALUE)
205 258 julius
                addr_a_reg <=  {aw{1'b0}};
206 10 unneback
        else if (ce_a)
207 258 julius
                addr_a_reg <=  addr_a;
208 10 unneback
 
209
//
210
// RAM write
211
//
212
always @(posedge clk_b)
213
        if (ce_b && we_b)
214 258 julius
                mem[addr_b] <=  di_b;
215 10 unneback
 
216
`endif  // !OR1200_XILINX_RAMB16
217
`endif  // !OR1200_XILINX_RAMB4
218
endmodule

powered by: WebSVN 2.1.0

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