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

Subversion Repositories test_project

[/] [test_project/] [trunk/] [rtl/] [verilog/] [components/] [or1200r2/] [or1200_rfram_generic.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's register file generic memory                       ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Generic (flip-flop based) register file memory              ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - nothing                                                  ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
// $Log: or1200_rfram_generic.v,v $
46
// Revision 1.3  2004/06/08 18:16:32  lampret
47
// GPR0 hardwired to zero.
48
//
49
// Revision 1.2  2002/09/03 22:28:21  lampret
50
// As per Taylor Su suggestion all case blocks are full case by default and optionally (OR1200_CASE_DEFAULT) can be disabled to increase clock frequncy.
51
//
52
// Revision 1.1  2002/06/08 16:23:30  lampret
53
// Generic flip-flop based memory macro for register file.
54
//
55
//
56
 
57
// synopsys translate_off
58
`include "timescale.v"
59
// synopsys translate_on
60
`include "or1200_defines.v"
61
 
62
module or1200_rfram_generic(
63
        // Clock and reset
64
        clk, rst,
65
 
66
        // Port A
67
        ce_a, addr_a, do_a,
68
 
69
        // Port B
70
        ce_b, addr_b, do_b,
71
 
72
        // Port W
73
        ce_w, we_w, addr_w, di_w
74
);
75
 
76
parameter dw = `OR1200_OPERAND_WIDTH;
77
parameter aw = `OR1200_REGFILE_ADDR_WIDTH;
78
 
79
//
80
// I/O
81
//
82
 
83
//
84
// Clock and reset
85
//
86
input                           clk;
87
input                           rst;
88
 
89
//
90
// Port A
91
//
92
input                           ce_a;
93
input   [aw-1:0]         addr_a;
94
output  [dw-1:0]         do_a;
95
 
96
//
97
// Port B
98
//
99
input                           ce_b;
100
input   [aw-1:0]         addr_b;
101
output  [dw-1:0]         do_b;
102
 
103
//
104
// Port W
105
//
106
input                           ce_w;
107
input                           we_w;
108
input   [aw-1:0]         addr_w;
109
input   [dw-1:0]         di_w;
110
 
111
//
112
// Internal wires and regs
113
//
114
reg     [aw-1:0]         intaddr_a;
115
reg     [aw-1:0]         intaddr_b;
116
`ifdef OR1200_RFRAM_16REG
117
reg     [16*dw-1:0]              mem;
118
`else
119
reg     [32*dw-1:0]              mem;
120
`endif
121
reg     [dw-1:0]         do_a;
122
reg     [dw-1:0]         do_b;
123
 
124 48 julius
   // Function to access GPRs (for use by Verilator). No need to hide this one
125
   // from the simulator, since it has an input (as required by IEEE 1364-2001).
126
   function [31:0] get_gpr;
127
      // verilator public
128
      input [aw-1:0]             gpr_no;
129
 
130
      get_gpr = { mem[gpr_no*32 + 31], mem[gpr_no*32 + 30],
131
                  mem[gpr_no*32 + 29], mem[gpr_no*32 + 28],
132
                  mem[gpr_no*32 + 27], mem[gpr_no*32 + 26],
133
                  mem[gpr_no*32 + 25], mem[gpr_no*32 + 24],
134
                  mem[gpr_no*32 + 23], mem[gpr_no*32 + 22],
135
                  mem[gpr_no*32 + 21], mem[gpr_no*32 + 20],
136
                  mem[gpr_no*32 + 19], mem[gpr_no*32 + 18],
137
                  mem[gpr_no*32 + 17], mem[gpr_no*32 + 16],
138
                  mem[gpr_no*32 + 15], mem[gpr_no*32 + 14],
139
                  mem[gpr_no*32 + 13], mem[gpr_no*32 + 12],
140
                  mem[gpr_no*32 + 11], mem[gpr_no*32 + 10],
141
                  mem[gpr_no*32 +  9], mem[gpr_no*32 +  8],
142
                  mem[gpr_no*32 +  7], mem[gpr_no*32 +  6],
143
                  mem[gpr_no*32 +  5], mem[gpr_no*32 +  4],
144
                  mem[gpr_no*32 +  3], mem[gpr_no*32 +  2],
145
                  mem[gpr_no*32 +  1], mem[gpr_no*32 +  0] };
146
 
147
   endfunction // get_gpr
148
 
149 18 unneback
//
150
// Write port
151
//
152
always @(posedge clk or posedge rst)
153
        if (rst) begin
154
                mem <= #1 {512'h0, 512'h0};
155
        end
156
        else if (ce_w & we_w)
157
                case (addr_w)   // synopsys parallel_case
158
                        5'd01: mem[32*1+31:32*1] <= #1 di_w;
159
                        5'd02: mem[32*2+31:32*2] <= #1 di_w;
160
                        5'd03: mem[32*3+31:32*3] <= #1 di_w;
161
                        5'd04: mem[32*4+31:32*4] <= #1 di_w;
162
                        5'd05: mem[32*5+31:32*5] <= #1 di_w;
163
                        5'd06: mem[32*6+31:32*6] <= #1 di_w;
164
                        5'd07: mem[32*7+31:32*7] <= #1 di_w;
165
                        5'd08: mem[32*8+31:32*8] <= #1 di_w;
166
                        5'd09: mem[32*9+31:32*9] <= #1 di_w;
167
                        5'd10: mem[32*10+31:32*10] <= #1 di_w;
168
                        5'd11: mem[32*11+31:32*11] <= #1 di_w;
169
                        5'd12: mem[32*12+31:32*12] <= #1 di_w;
170
                        5'd13: mem[32*13+31:32*13] <= #1 di_w;
171
                        5'd14: mem[32*14+31:32*14] <= #1 di_w;
172
                        5'd15: mem[32*15+31:32*15] <= #1 di_w;
173
`ifdef OR1200_RFRAM_16REG
174
`else
175
                        5'd16: mem[32*16+31:32*16] <= #1 di_w;
176
                        5'd17: mem[32*17+31:32*17] <= #1 di_w;
177
                        5'd18: mem[32*18+31:32*18] <= #1 di_w;
178
                        5'd19: mem[32*19+31:32*19] <= #1 di_w;
179
                        5'd20: mem[32*20+31:32*20] <= #1 di_w;
180
                        5'd21: mem[32*21+31:32*21] <= #1 di_w;
181
                        5'd22: mem[32*22+31:32*22] <= #1 di_w;
182
                        5'd23: mem[32*23+31:32*23] <= #1 di_w;
183
                        5'd24: mem[32*24+31:32*24] <= #1 di_w;
184
                        5'd25: mem[32*25+31:32*25] <= #1 di_w;
185
                        5'd26: mem[32*26+31:32*26] <= #1 di_w;
186
                        5'd27: mem[32*27+31:32*27] <= #1 di_w;
187
                        5'd28: mem[32*28+31:32*28] <= #1 di_w;
188
                        5'd29: mem[32*29+31:32*29] <= #1 di_w;
189
                        5'd30: mem[32*30+31:32*30] <= #1 di_w;
190
                        5'd31: mem[32*31+31:32*31] <= #1 di_w;
191
`endif
192
                        default: mem[32*0+31:32*0] <= #1 32'h0000_0000;
193
                endcase
194
 
195
//
196
// Read port A
197
//
198
always @(posedge clk or posedge rst)
199
        if (rst) begin
200
                intaddr_a <= #1 5'h00;
201
        end
202
        else if (ce_a)
203
                intaddr_a <= #1 addr_a;
204
 
205
always @(mem or intaddr_a)
206
        case (intaddr_a)        // synopsys parallel_case
207
                5'd01: do_a = mem[32*1+31:32*1];
208
                5'd02: do_a = mem[32*2+31:32*2];
209
                5'd03: do_a = mem[32*3+31:32*3];
210
                5'd04: do_a = mem[32*4+31:32*4];
211
                5'd05: do_a = mem[32*5+31:32*5];
212
                5'd06: do_a = mem[32*6+31:32*6];
213
                5'd07: do_a = mem[32*7+31:32*7];
214
                5'd08: do_a = mem[32*8+31:32*8];
215
                5'd09: do_a = mem[32*9+31:32*9];
216
                5'd10: do_a = mem[32*10+31:32*10];
217
                5'd11: do_a = mem[32*11+31:32*11];
218
                5'd12: do_a = mem[32*12+31:32*12];
219
                5'd13: do_a = mem[32*13+31:32*13];
220
                5'd14: do_a = mem[32*14+31:32*14];
221
                5'd15: do_a = mem[32*15+31:32*15];
222
`ifdef OR1200_RFRAM_16REG
223
`else
224
                5'd16: do_a = mem[32*16+31:32*16];
225
                5'd17: do_a = mem[32*17+31:32*17];
226
                5'd18: do_a = mem[32*18+31:32*18];
227
                5'd19: do_a = mem[32*19+31:32*19];
228
                5'd20: do_a = mem[32*20+31:32*20];
229
                5'd21: do_a = mem[32*21+31:32*21];
230
                5'd22: do_a = mem[32*22+31:32*22];
231
                5'd23: do_a = mem[32*23+31:32*23];
232
                5'd24: do_a = mem[32*24+31:32*24];
233
                5'd25: do_a = mem[32*25+31:32*25];
234
                5'd26: do_a = mem[32*26+31:32*26];
235
                5'd27: do_a = mem[32*27+31:32*27];
236
                5'd28: do_a = mem[32*28+31:32*28];
237
                5'd29: do_a = mem[32*29+31:32*29];
238
                5'd30: do_a = mem[32*30+31:32*30];
239
                5'd31: do_a = mem[32*31+31:32*31];
240
`endif
241
                default: do_a = 32'h0000_0000;
242
        endcase
243
 
244
//
245
// Read port B
246
//
247
always @(posedge clk or posedge rst)
248
        if (rst) begin
249
                intaddr_b <= #1 5'h00;
250
        end
251
        else if (ce_b)
252
                intaddr_b <= #1 addr_b;
253
 
254
always @(mem or intaddr_b)
255
        case (intaddr_b)        // synopsys parallel_case
256
                5'd01: do_b = mem[32*1+31:32*1];
257
                5'd02: do_b = mem[32*2+31:32*2];
258
                5'd03: do_b = mem[32*3+31:32*3];
259
                5'd04: do_b = mem[32*4+31:32*4];
260
                5'd05: do_b = mem[32*5+31:32*5];
261
                5'd06: do_b = mem[32*6+31:32*6];
262
                5'd07: do_b = mem[32*7+31:32*7];
263
                5'd08: do_b = mem[32*8+31:32*8];
264
                5'd09: do_b = mem[32*9+31:32*9];
265
                5'd10: do_b = mem[32*10+31:32*10];
266
                5'd11: do_b = mem[32*11+31:32*11];
267
                5'd12: do_b = mem[32*12+31:32*12];
268
                5'd13: do_b = mem[32*13+31:32*13];
269
                5'd14: do_b = mem[32*14+31:32*14];
270
                5'd15: do_b = mem[32*15+31:32*15];
271
`ifdef OR1200_RFRAM_16REG
272
`else
273
                5'd16: do_b = mem[32*16+31:32*16];
274
                5'd17: do_b = mem[32*17+31:32*17];
275
                5'd18: do_b = mem[32*18+31:32*18];
276
                5'd19: do_b = mem[32*19+31:32*19];
277
                5'd20: do_b = mem[32*20+31:32*20];
278
                5'd21: do_b = mem[32*21+31:32*21];
279
                5'd22: do_b = mem[32*22+31:32*22];
280
                5'd23: do_b = mem[32*23+31:32*23];
281
                5'd24: do_b = mem[32*24+31:32*24];
282
                5'd25: do_b = mem[32*25+31:32*25];
283
                5'd26: do_b = mem[32*26+31:32*26];
284
                5'd27: do_b = mem[32*27+31:32*27];
285
                5'd28: do_b = mem[32*28+31:32*28];
286
                5'd29: do_b = mem[32*29+31:32*29];
287
                5'd30: do_b = mem[32*30+31:32*30];
288
                5'd31: do_b = mem[32*31+31:32*31];
289
`endif
290
                default: do_b = 32'h0000_0000;
291
        endcase
292
 
293
endmodule

powered by: WebSVN 2.1.0

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