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

Subversion Repositories sparc64soc

[/] [sparc64soc/] [trunk/] [T1-common/] [srams/] [bw_r_scm.v] - Blame information for rev 8

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_scm.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
/*
23
//      Description:    Store Buffer of Load/Store Unit (CAM Side)
24
//               - Physically divided into CAM and DATA RAMs.
25
//                              - CAM RAM has a single cam port and a single
26
//                              port for read/writes. The cam port is for loads,
27
//                              write for stores, read for test/diagnostic purposes.
28
//                              rd or write can be simultaneous with cam. can rd and cam
29
//                              a single entry simultaneously. cannot write and cam
30
//                              the same entry.
31
//                              - DATA RAM read occurs for a load raw match in the
32
//                              stb CAM RAM. DATA RAM write occurs a store. Both
33
//                              actions are architecturally guaranteed to be
34
//                              mutex.
35
//                              - Write occurs simultaneously to both arrays.
36
//                              - Reads are not necessarily simultaneous and are
37
//                              controlled by individual read signals.
38
//                              - Certain bits are maintained outside the array
39
//                              in the stb's control section, such as the valid
40
//                              bits.
41
//
42
*/
43
 
44
////////////////////////////////////////////////////////////////////////
45
// Local header file includes / local defines
46
////////////////////////////////////////////////////////////////////////
47
 
48
//FPGA_SYN enables all FPGA related modifications
49
`ifdef FPGA_SYN
50
`define FPGA_SYN_SCM
51
`endif
52
 
53
module bw_r_scm (/*AUTOARG*/
54
   // Outputs
55
   stb_rdata_ramc, stb_ld_full_raw, stb_ld_partial_raw,
56
   stb_cam_hit_ptr, stb_cam_hit, stb_cam_mhit,
57
   // Inputs
58
   stb_cam_data, stb_alt_wr_data, stb_camwr_data, stb_alt_wsel,
59
   stb_cam_vld, stb_cam_cm_tid, stb_cam_sqsh_msk, stb_cam_rw_ptr,
60
   stb_cam_wptr_vld, stb_cam_rptr_vld, stb_cam_rw_tid,
61
   stb_quad_ld_cam, rclk, rst_tri_en
62
   ) ;
63
 
64
parameter NUMENTRIES = 32 ;                             // number of entries in stb
65
 
66
input   [44:15]         stb_cam_data ;    // data for compare; disjoint msb
67
input   [44:15]         stb_alt_wr_data ;         // data for compare; disjoint msb
68
input   [14:0]           stb_camwr_data ;  // data for compare/write; common lsb
69
input                   stb_alt_wsel ;
70
input                   stb_cam_vld ;     // cam is required.
71
input   [1:0]            stb_cam_cm_tid ;  // thread id for cam operation.
72
input   [7:0]            stb_cam_sqsh_msk; // mask for squashing cam results.
73
 
74
input   [2:0]            stb_cam_rw_ptr ;  // wr pointer for single port.
75
input                   stb_cam_wptr_vld ;// write pointer vld
76
input                   stb_cam_rptr_vld ;// write pointer vld
77
input   [1:0]            stb_cam_rw_tid ;  // thread id for rw.
78
input                   stb_quad_ld_cam ; // quad-ld cam.
79
 
80
input                   rclk ;            // clock
81
 
82
//input                 scan_ena ;        // no longer required !
83
//input [7:0]           adj ;
84
 
85
input                   rst_tri_en ;
86
 
87
output  [44:0]           stb_rdata_ramc ;  // rd data from CAM RAM.
88
// raw output is muxed on a thread basis.
89
output  [7:0]            stb_ld_full_raw ; // ld with full raw.
90
output  [7:0]            stb_ld_partial_raw ; // ld with partial raw.
91
output  [2:0]            stb_cam_hit_ptr ;
92
output                  stb_cam_hit ;     // any hit in stb
93
output                  stb_cam_mhit ;    // multiple hits in stb       
94
 
95
 
96
/*UTOREG*/
97
// Beginning of automatic regs (for this module's undeclared outputs)
98
// End of automatics
99
reg [44:0]               stb_rdata_ramc ;
100
reg [31:0]               rw_wdline ;
101
reg [44:0]               stb_ramc [NUMENTRIES-1:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */;
102
reg [44:0]               ramc_entry ;
103
reg [36:0]               cam_tag ;
104
reg [31:0]               ptag_hit ;
105
reg [7:0]                cam_bmask ;
106
reg [31:0]               byte_match ;
107
reg [31:0]               byte_overlap ;
108
reg [31:0]               ld_full_raw ;
109
reg [31:0]               ld_partial_raw ;
110
reg [44:15]             alt_wr_data ;
111 8 dmitryr
wire [44:15]            pipe_wr_data ;
112 2 dmitryr
reg [14:0]               camwr_data ;
113
reg                     wptr_vld ;
114
reg                     rptr_vld_tmp ;
115
reg [1:0]                cam_tid ;
116
reg [1:0]                cam_vld ;
117
reg                     alt_wsel ;
118
 
119
wire            rptr_vld ;
120
wire            ldq ;
121
wire    [7:0]    sqsh_msk ;
122
wire    [7:0]    ld_full_raw_mx ;
123
wire    [7:0]    ld_partial_raw_mx ;
124
wire    [7:0]    ptag_hit_mx ;
125
wire    [7:0]    byte_overlap_mx ;
126
wire    [7:0]    byte_match_mx ;
127
wire    [7:0]    cam_hit ;
128
wire    [44:0]   wdata_ramc ;
129
wire    [44:0]   cam_data ;
130
wire    [44:15] wr_data ;
131
`ifdef FPGA_SYN_SCM
132
reg     [4:0]    stb_addr;
133
`endif
134
 
135
 
136
integer i,j,k,l ;
137
 
138
 
139
wire    scan_ena ;
140
assign  scan_ena = 1'b0 ;
141
 
142
//=========================================================================================
143
//      generate wordlines
144
//=========================================================================================
145
 
146
assign  sqsh_msk[7:0]    = stb_cam_sqsh_msk[7:0];
147
 
148
// cam_vld and cam_tid_tmp are set-up a phase earlier. 
149
// Comment out - Now setup to posedge.
150
/*always @(negedge clk)
151
        begin
152
                cam_tid_tmp[1:0]        <= stb_cam_cm_tid[1:0] ;
153
                cam_vld_tmp             <= stb_cam_vld ;
154
        end */
155
 
156
`ifdef FPGA_SYN_SCM
157
`else
158
// Wordlines need to be generated locally 
159
always @ (posedge rclk)
160
        begin
161
                for (i=0;i<32;i=i+1)
162
                        begin
163
                        if ({stb_cam_rw_tid[1:0],stb_cam_rw_ptr[2:0]} == i)
164
                                rw_wdline[i]  <= 1'b1;
165
                        else
166
                                rw_wdline[i]  <= 1'b0;
167
                        end
168
        end
169
`endif
170
 
171 8 dmitryr
assign pipe_wr_data[44:15] = stb_cam_data[44:15];
172
 
173 2 dmitryr
always @(posedge rclk)
174
        begin
175
                alt_wr_data[44:15] <= stb_alt_wr_data[44:15];
176
                camwr_data[14:0] <= stb_camwr_data[14:0];
177
                wptr_vld        <= stb_cam_wptr_vld ;
178
                rptr_vld_tmp    <= stb_cam_rptr_vld ;
179
                cam_tid[1:0]     <= stb_cam_cm_tid[1:0] ;
180
                //cam_tid[1:0]  <= cam_tid_tmp[1:0] ;
181
                //ldq           <=  stb_quad_ld_cam ; Bug 2870
182
                alt_wsel        <= stb_alt_wsel ;
183
`ifdef FPGA_SYN_SCM
184
                stb_addr        <= {stb_cam_rw_tid[1:0],stb_cam_rw_ptr[2:0]};
185
`endif
186
        end
187
 
188
assign  ldq =  stb_quad_ld_cam ;
189
assign  rptr_vld = rptr_vld_tmp | rst_tri_en ;
190
 
191
//=========================================================================================
192
//      write or read to/from memory
193
//=========================================================================================
194
 
195
// For blk-st, select out-of-pipe.
196
assign  wr_data[44:15] = alt_wsel ?
197
                alt_wr_data[44:15] : pipe_wr_data[44:15] ;
198
 
199
assign  wdata_ramc[44:0] = {wr_data[44:15],camwr_data[14:0]};
200
 
201
// Write
202
always @ (negedge rclk)
203
        begin
204
`ifdef FPGA_SYN_SCM
205
        if(wptr_vld) begin
206
                if(~rst_tri_en) begin
207
                        stb_ramc[stb_addr] <= wdata_ramc[44:0];
208
                        stb_rdata_ramc[44:0] <=  wdata_ramc[44:0];
209
                end else begin
210
                        stb_rdata_ramc[44:0] <=  stb_ramc[stb_addr];
211
                end
212
        end
213
`else
214
                for (j=0;j<NUMENTRIES;j=j+1)
215
                        begin
216
                        if (rw_wdline[j] & wptr_vld)
217
                                begin
218
                                if (~rst_tri_en)
219
                                        begin
220
                                        stb_ramc[j] <=  wdata_ramc[44:0];
221
                                        // write data is write-thru
222
                                        stb_rdata_ramc[44:0] <=  wdata_ramc[44:0];
223
                                        end
224
                                else
225
                                        begin
226
                                        // INNO - default rd if wr squashed by scan_ena.
227
                                        stb_rdata_ramc[44:0] <=  stb_ramc[j];
228
                                        end
229
                                end
230
                        end
231
`endif
232
// Read
233
`ifdef FPGA_SYN_SCM
234
                if(rptr_vld & ~scan_ena) begin
235
                        if (rptr_vld & wptr_vld & ~rst_tri_en) begin
236
                                stb_rdata_ramc[44:0] <=  wdata_ramc[44:0];
237
                        end
238
                        else begin
239
                                stb_rdata_ramc[44:0] <=  stb_ramc[stb_addr];
240
                        end
241
                end
242
`else
243
                for (k=0;k<NUMENTRIES;k=k+1)
244
                        begin
245
                        if (rw_wdline[k] & rptr_vld & ~scan_ena)
246
                                begin
247
                                if (rptr_vld & wptr_vld & ~rst_tri_en) // INNO - write-thru
248
                                        stb_rdata_ramc[44:0] <=  wdata_ramc[44:0];
249
                                else
250
                                        stb_rdata_ramc[44:0] <=  stb_ramc[k];
251
                                end
252
                        end
253
`endif
254
        end
255
 
256
//=========================================================================================
257
//      CAM contents of CAM RAM
258
//=========================================================================================
259
 
260
// - Generate full/partial raw for incoming load.
261
// - Output signals need to be qualified with per entry
262
// vlds before causing any subsequent event, the read of
263
// the DATA RAM specifically.
264
// - full_raw & vld will cause rd of DATA RAM.
265
// - partial_raw & vld will cause ld to follow corresponding
266
// st on way out to xbar.
267
// - logic to generate partial and full raws may be done outside
268
// but that would require an additional signal per entry to
269
// be output.
270
 
271
// Mapping of cam/write data
272
// 
273
//      |       40-3=37b(pa)    | 1b(stquad)    |       8b(bytemask)    | <- use
274
//      |       45:9            | 8             |       7:0             | <- input port
275
//                              **^ stquad rm'ed
276
 
277 8 dmitryr
reg [14:0] stb_camwr_data_d;
278
reg        ldq_d;
279
reg        stb_cam_vld_d;
280
reg        scan_ena_d;
281
reg [44:0]               stb_ramc_d [NUMENTRIES-1:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */;
282 2 dmitryr
 
283 8 dmitryr
always @(posedge rclk)
284
   begin
285
      stb_camwr_data_d[14:0]<=stb_camwr_data[14:0];
286
      ldq_d<=ldq;
287
      stb_cam_vld_d<=stb_cam_vld;
288
      scan_ena_d<=scan_ena;
289 2 dmitryr
                for (l=0;l<NUMENTRIES;l=l+1)
290 8 dmitryr
         stb_ramc_d[l]<=stb_ramc[l];
291
   end
292
 
293
assign  cam_data[44:0] = {stb_cam_data[44:15],stb_camwr_data_d[14:0]};
294
 
295
always @( * )
296
                for (l=0;l<NUMENTRIES;l=l+1)
297
         begin
298
                                ramc_entry[44:0] = stb_ramc_d[l] ;
299 2 dmitryr
 
300
                                cam_tag[36:0] = ramc_entry[44:8] ;
301
                                cam_bmask[7:0] = ramc_entry[7:0] ;
302 8 dmitryr
            ptag_hit[l] = (cam_tag[36:1] == cam_data[44:9]) &
303
                                                (((cam_tag[0] == cam_data[8]) & ~ldq_d) | ldq_d) & stb_cam_vld_d & ~scan_ena_d ;
304
                                byte_match[l] = |(cam_bmask[7:0] & cam_data[7:0]) & stb_cam_vld_d & ~scan_ena_d ;
305 2 dmitryr
                                // Simplification :
306 8 dmitryr
                                byte_overlap[l] = |(~cam_bmask[7:0] & cam_data[7:0]) & stb_cam_vld_d & ~scan_ena_d ;
307
         end
308 2 dmitryr
 
309
 
310
// Mux the raw signals down to 8b quantities. Squash mask comes mid-way thru cycle.
311
 
312
 
313
assign  byte_overlap_mx[7:0] =
314
        (cam_tid[1:0] == 2'b00) ? byte_overlap[7:0] :
315
                (cam_tid[1:0] == 2'b01) ? byte_overlap[15:8] :
316
                        (cam_tid[1:0] == 2'b10) ? byte_overlap[23:16] :
317
                                (cam_tid[1:0] == 2'b11) ? byte_overlap[31:24] : 8'bxxxx_xxxx ;
318
 
319
assign  byte_match_mx[7:0] =
320
        (cam_tid[1:0] == 2'b00) ? byte_match[7:0] :
321
                (cam_tid[1:0] == 2'b01) ? byte_match[15:8] :
322
                        (cam_tid[1:0] == 2'b10) ? byte_match[23:16] :
323
                                (cam_tid[1:0] == 2'b11) ? byte_match[31:24] : 8'bxxxx_xxxx ;
324
 
325
assign  ptag_hit_mx[7:0] =
326
        (cam_tid[1:0] == 2'b00) ? ptag_hit[7:0] :
327
                (cam_tid[1:0] == 2'b01) ? ptag_hit[15:8] :
328
                        (cam_tid[1:0] == 2'b10) ? ptag_hit[23:16] :
329
                                (cam_tid[1:0] == 2'b11) ? ptag_hit[31:24] : 8'bxxxx_xxxx ;
330
 
331
assign  stb_ld_full_raw[7:0] =
332
        ptag_hit_mx[7:0] & byte_match_mx[7:0] & ~byte_overlap_mx[7:0] & ~sqsh_msk[7:0] ;
333
assign  stb_ld_partial_raw[7:0] =
334
        ptag_hit_mx[7:0] & byte_match_mx[7:0] &  byte_overlap_mx[7:0] & ~sqsh_msk[7:0] ;
335
 
336
assign  cam_hit[7:0] =
337
        ptag_hit_mx[7:0] & byte_match_mx[7:0] & ~sqsh_msk[7:0] ;
338
assign  stb_cam_hit = |(cam_hit[7:0]);
339
 
340
// The stb data is meant to be read for single hit full raw case. It may actually be read
341
// for full raw, partial raw or multiple hit case but the read output will be ignored for
342
// partial and multiple hit case. Multiple hits will not cause a hazard as the ptr is first
343
// encoded and then decoded to form the wdline for the stb-data
344
// Use cam_hit result to void false hits.
345
assign  stb_cam_hit_ptr[0]       =  cam_hit[1] | cam_hit[3] | cam_hit[5] | cam_hit[7] ;
346
assign  stb_cam_hit_ptr[1]      =  cam_hit[2] | cam_hit[3] | cam_hit[6] | cam_hit[7] ;
347
assign  stb_cam_hit_ptr[2]      =  cam_hit[4] | cam_hit[5] | cam_hit[6] | cam_hit[7] ;
348
 
349
//Generating multiple hits
350
assign  stb_cam_mhit            =  (cam_hit[0]  & cam_hit[1]) | (cam_hit[2] & cam_hit[3])  |
351
                                   (cam_hit[4]  & cam_hit[5]) | (cam_hit[6] & cam_hit[7])  |
352
                                   ((cam_hit[0] | cam_hit[1]) & (cam_hit[2] | cam_hit[3])) |
353
                                   ((cam_hit[4] | cam_hit[5]) & (cam_hit[6] | cam_hit[7])) |
354
                                   ((|cam_hit[3:0]) & (|cam_hit[7:4]));
355
 
356
//--------------------------------------------------------------
357
// Error Checking.
358
//--------------------------------------------------------------
359
 
360
// 1. simultaneous rd/wr on single port - terminate 
361
// 2. simultaneous cam and wr - terminate
362
// * PUT OUTSIDE OF SRAM RTL, AS RST NOT AVAILABLE. *
363
 
364
endmodule

powered by: WebSVN 2.1.0

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