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

Subversion Repositories sparc64soc

[/] [sparc64soc/] [trunk/] [T1-common/] [srams/] [bw_r_rf32x108.v] - Blame information for rev 6

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

Line No. Rev Author Line
1 2 dmitryr
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: bw_r_rf32x108.v
4
// Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
5
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6
// 
7
// The above named program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public
9
// License version 2 as published by the Free Software Foundation.
10
// 
11
// The above named program is distributed in the hope that it will be 
12
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
// General Public License for more details.
15
// 
16
// You should have received a copy of the GNU General Public
17
// License along with this work; if not, write to the Free Software
18
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19
// 
20
// ========== Copyright Header End ============================================
21
////////////////////////////////////////////////////////////////////////
22
// 32 X 108 R1 W1 RF macro
23
// REad/Write ports can be accessed in PH1 only.
24
////////////////////////////////////////////////////////////////////////
25
 
26
module bw_r_rf32x108(/*AUTOARG*/
27
   // Outputs
28
   dout, so,
29
   // Inputs
30
   din, rd_adr1, rd_adr2, sel_rdaddr1, wr_adr, read_en, wr_en,
31
   word_wen, rst_tri_en, rclk, se, si, reset_l, sehold
32
   );
33
 
34
   input [107:0]  din; // data input
35
   input [4:0]    rd_adr1;   // read addr1 
36
   input [4:0]    rd_adr2;   // read addr2 
37
   input          sel_rdaddr1; // sel read addr1
38
   input [4:0]     wr_adr;  // write addr
39
   input          read_en;
40
   input          wr_en ;       //   used in conjunction with
41
                                //  word_wen and byte_wen 
42
   input [3:0]    word_wen; // word enables ( if you don't use these
43
                            // tie them to Vdd )
44
   input          rst_tri_en ; // used to gate off write during scan.
45
   input          rclk;
46
   input          se, si ;
47
   input          reset_l;
48
   input          sehold; // hold scan in data.
49
 
50
   output [107:0] dout;
51
   output         so;
52
 
53
 
54
   // local signals
55
   reg [107:0]   wrdata_d1 ;
56
   reg [3:0]     word_wen_d1;
57
   reg [4:0]     rdptr_d1, wrptr_d1;
58
   reg           ren_d1;
59
   reg            wr_en_d1;
60
   reg          rst_tri_en_d1;
61
 
62
 
63
 
64
`ifdef DEFINE_0IN
65
   reg          so;
66
`else
67
   reg [107:0] dout;
68
 
69
   wire [122:0] scan_out ;
70
 
71
   // memory array
72
   reg [107:0]  inq_ary [31:0];
73
`endif
74
   // internal variable
75
   integer      i;
76
   reg [107:0]  temp, data_in, tmp_dout;
77
 
78
`ifdef DEFINE_0IN
79
   wire [107:0]  bit_en_d1;
80
 
81
                assign  bit_en_d1[0] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
82
                assign  bit_en_d1[1] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
83
                assign  bit_en_d1[2] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
84
                assign  bit_en_d1[3] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
85
 
86
                assign  bit_en_d1[4] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
87
                assign  bit_en_d1[5] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
88
                assign  bit_en_d1[6] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
89
                assign  bit_en_d1[7] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
90
 
91
                assign  bit_en_d1[8] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
92
                assign  bit_en_d1[9] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
93
                assign  bit_en_d1[10] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
94
                assign  bit_en_d1[11] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
95
 
96
                assign  bit_en_d1[12] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
97
                assign  bit_en_d1[13] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
98
                assign  bit_en_d1[14] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
99
                assign  bit_en_d1[15] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
100
 
101
                assign  bit_en_d1[16] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
102
                assign  bit_en_d1[17] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
103
                assign  bit_en_d1[18] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
104
                assign  bit_en_d1[19] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
105
 
106
                assign  bit_en_d1[20] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
107
                assign  bit_en_d1[21] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
108
                assign  bit_en_d1[22] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
109
                assign  bit_en_d1[23] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
110
 
111
                assign  bit_en_d1[24] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
112
                assign  bit_en_d1[25] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
113
                assign  bit_en_d1[26] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
114
                assign  bit_en_d1[27] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
115
 
116
                assign  bit_en_d1[28] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
117
                assign  bit_en_d1[29] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
118
                assign  bit_en_d1[30] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
119
                assign  bit_en_d1[31] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
120
 
121
                assign  bit_en_d1[32] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
122
                assign  bit_en_d1[33] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
123
                assign  bit_en_d1[34] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
124
                assign  bit_en_d1[35] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
125
 
126
                assign  bit_en_d1[36] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
127
                assign  bit_en_d1[37] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
128
                assign  bit_en_d1[38] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
129
                assign  bit_en_d1[39] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
130
 
131
                assign  bit_en_d1[40] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
132
                assign  bit_en_d1[41] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
133
                assign  bit_en_d1[42] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
134
                assign  bit_en_d1[43] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
135
 
136
                assign  bit_en_d1[44] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
137
                assign  bit_en_d1[45] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
138
                assign  bit_en_d1[46] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
139
                assign  bit_en_d1[47] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
140
 
141
                assign  bit_en_d1[48] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
142
                assign  bit_en_d1[49] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
143
                assign  bit_en_d1[50] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
144
                assign  bit_en_d1[51] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
145
 
146
                assign  bit_en_d1[52] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
147
                assign  bit_en_d1[53] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
148
                assign  bit_en_d1[54] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
149
                assign  bit_en_d1[55] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
150
 
151
                assign  bit_en_d1[56] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
152
                assign  bit_en_d1[57] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
153
                assign  bit_en_d1[58] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
154
                assign  bit_en_d1[59] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
155
 
156
                assign  bit_en_d1[60] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
157
                assign  bit_en_d1[61] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
158
                assign  bit_en_d1[62] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
159
                assign  bit_en_d1[63] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
160
 
161
                assign  bit_en_d1[64] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
162
                assign  bit_en_d1[65] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
163
                assign  bit_en_d1[66] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
164
                assign  bit_en_d1[67] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
165
 
166
                assign  bit_en_d1[68] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
167
                assign  bit_en_d1[69] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
168
                assign  bit_en_d1[70] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
169
                assign  bit_en_d1[71] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
170
 
171
                assign  bit_en_d1[72] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
172
                assign  bit_en_d1[73] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
173
                assign  bit_en_d1[74] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
174
                assign  bit_en_d1[75] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
175
 
176
                assign  bit_en_d1[76] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
177
                assign  bit_en_d1[77] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
178
                assign  bit_en_d1[78] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
179
                assign  bit_en_d1[79] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
180
 
181
                assign  bit_en_d1[80] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
182
                assign  bit_en_d1[81] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
183
                assign  bit_en_d1[82] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
184
                assign  bit_en_d1[83] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
185
 
186
                assign  bit_en_d1[84] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
187
                assign  bit_en_d1[85] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
188
                assign  bit_en_d1[86] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
189
                assign  bit_en_d1[87] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
190
 
191
                assign  bit_en_d1[88] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
192
                assign  bit_en_d1[89] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
193
                assign  bit_en_d1[90] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
194
                assign  bit_en_d1[91] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
195
 
196
                assign  bit_en_d1[92] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
197
                assign  bit_en_d1[93] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
198
                assign  bit_en_d1[94] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
199
                assign  bit_en_d1[95] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
200
 
201
                assign  bit_en_d1[96] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
202
                assign  bit_en_d1[97] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
203
                assign  bit_en_d1[98] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
204
                assign  bit_en_d1[99] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
205
 
206
                assign  bit_en_d1[100] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
207
                assign  bit_en_d1[101] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
208
                assign  bit_en_d1[102] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
209
                assign  bit_en_d1[103] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
210
 
211
                assign  bit_en_d1[104] = word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ;
212
                assign  bit_en_d1[105] = word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ;
213
                assign  bit_en_d1[106] = word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ;
214
                assign  bit_en_d1[107] = word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ;
215
 
216
`else
217
 
218
`endif
219
 
220
always  @(posedge rclk ) begin
221
 
222
        wrdata_d1 <= (sehold)? wrdata_d1 :din;
223
        word_wen_d1 <= (sehold)? word_wen_d1 : word_wen ;
224
        wrptr_d1 <= (sehold)? wrptr_d1 :wr_adr;
225
        ren_d1 <= (sehold)? ren_d1 : read_en;
226
        wr_en_d1 <= (sehold)? wr_en_d1 : wr_en;
227
        rdptr_d1 <= (sehold)? rdptr_d1 : ( (sel_rdaddr1)?  rd_adr1: rd_adr2 ) ;
228
        rst_tri_en_d1 <= rst_tri_en ;  // this is a dummy flop ( only used as a trigger )
229
end
230
 
231
 
232
 
233
`ifdef DEFINE_0IN
234
rf32x108 rf32x108 ( .rclk(rclk), .radr(rdptr_d1), .wadr(wrptr_d1), .ren(ren_d1),
235
                        .we(reset_l), .wm(bit_en_d1), .din(wrdata_d1), .dout(dout) );
236
`else
237
 
238
/////////////////////////////////////////////////////////////////////////////////
239
// Read Operation
240
/////////////////////////////////////////////////////////////////////////////////
241
 
242
always @(/*AUTOSENSE*/ /*memory or*/ rdptr_d1 or ren_d1 or reset_l
243
         or rst_tri_en_d1 or word_wen_d1 or wr_en_d1 or wrptr_d1)
244
     begin
245
             if (reset_l)
246
               begin
247
                  if (ren_d1 )
248
                    begin
249
 
250
                  // Checking for Xs on the rd pointer input when read is enabled
251
`ifdef  INNO_MUXEX
252
`else
253
                        if(rdptr_d1 == 5'bx) begin
254
                        `ifdef MODELSIM
255
                                $display("rf_error"," read pointer error %h ", rdptr_d1[4:0]);
256
                        `else
257
                                $error("rf_error"," read pointer error %h ", rdptr_d1[4:0]);
258
                        `endif
259
                        end
260
`endif
261
 
262
 
263
                        tmp_dout = inq_ary[rdptr_d1] ;
264
 
265
                        for(i=0; i< 108; i=i+4) begin
266
 
267
                                if((rdptr_d1 == wrptr_d1)) begin
268
                                        dout[i] =   ( word_wen_d1[0] & wr_en_d1 & ~rst_tri_en )?
269
                                                        1'bx : tmp_dout[i] ;
270
                                        dout[i+1] = ( word_wen_d1[1] & wr_en_d1 & ~rst_tri_en )?
271
                                                        1'bx : tmp_dout[i+1] ;
272
                                        dout[i+2] = ( word_wen_d1[2] & wr_en_d1 & ~rst_tri_en )?
273
                                                        1'bx : tmp_dout[i+2] ;
274
                                        dout[i+3] = ( word_wen_d1[3] & wr_en_d1 & ~rst_tri_en )?
275
                                                        1'bx : tmp_dout[i+3] ;
276
                                end
277
                                else begin
278
                                        dout[i] = tmp_dout[i] ;
279
                                        dout[i+1] = tmp_dout[i+1] ;
280
                                        dout[i+2] = tmp_dout[i+2] ;
281
                                        dout[i+3] = tmp_dout[i+3] ;
282
                                end
283
 
284
                        end // of for
285
 
286
                    end
287
 
288
 
289
            end // of if reset_l
290
 
291
            else dout  = 108'b0 ;
292
end
293
 
294
/////////////////////////////////////////////////////////////////////////////////
295
// Write Operation
296
/////////////////////////////////////////////////////////////////////////////////
297
 
298
always @(/*AUTOSENSE*/reset_l or rst_tri_en_d1 or word_wen_d1 or wr_en_d1
299
         or wrdata_d1 or wrptr_d1)
300
     begin
301
        if ( reset_l)
302
         begin
303
                 // Checking for Xs on bit write enables that are derived from
304
                // the word_enables and wr enable input.
305
`ifdef  INNO_MUXEX
306
`else
307
                if((word_wen_d1 & {4{wr_en_d1 & ~rst_tri_en}}) == 4'bx ) begin
308
                `ifdef MODELSIM
309
                        $display("rf_error"," write enable error %h ", word_wen_d1[3:0]);
310
                `else
311
                        $error("rf_error"," write enable error %h ", word_wen_d1[3:0]);
312
                `endif
313
                end
314
`endif
315
 
316
                if(wr_en_d1 & ~rst_tri_en)   begin
317
 
318
`ifdef  INNO_MUXEX
319
`else
320
                  // Checking for Xs on the wr pointer input when write is enabled
321
                        if(wrptr_d1 == 5'bx) begin
322
                        `ifdef MODELSIM
323
                                $display("rf_error"," read pointer error %h ", wrptr_d1[4:0]);
324
                        `else
325
                                $error("rf_error"," read pointer error %h ", wrptr_d1[4:0]);
326
                        `endif
327
                        end
328
`endif
329
 
330
                        temp =  inq_ary[wrptr_d1];
331
                        for (i=0; i<108; i=i+4) begin
332
                                data_in[i] = ( word_wen_d1[0] & wr_en_d1 & ~rst_tri_en ) ?
333
                                                        wrdata_d1[i] : temp[i] ;
334
                                data_in[i+1] = ( word_wen_d1[1] & wr_en_d1 & ~rst_tri_en ) ?
335
                                                        wrdata_d1[i+1] : temp[i+1] ;
336
                                data_in[i+2] = ( word_wen_d1[2] & wr_en_d1 & ~rst_tri_en ) ?
337
                                                        wrdata_d1[i+2] : temp[i+2] ;
338
                                data_in[i+3] = ( word_wen_d1[3] & wr_en_d1 & ~rst_tri_en ) ?
339
                                                        wrdata_d1[i+3] : temp[i+3] ;
340
                        end
341
                        inq_ary[wrptr_d1] = data_in ;
342
 
343
                end
344
 
345
          end
346
end // always @ (...
347
 
348
`endif
349
 
350
 
351
endmodule // rf_32x108
352
 
353
 
354
 

powered by: WebSVN 2.1.0

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