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 |
|
|
reg [44:15] pipe_wr_data ;
|
112 |
|
|
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 |
|
|
always @(posedge rclk)
|
172 |
|
|
begin
|
173 |
|
|
pipe_wr_data[44:15] <= stb_cam_data[44:15];
|
174 |
|
|
alt_wr_data[44:15] <= stb_alt_wr_data[44:15];
|
175 |
|
|
camwr_data[14:0] <= stb_camwr_data[14:0];
|
176 |
|
|
wptr_vld <= stb_cam_wptr_vld ;
|
177 |
|
|
rptr_vld_tmp <= stb_cam_rptr_vld ;
|
178 |
|
|
cam_tid[1:0] <= stb_cam_cm_tid[1:0] ;
|
179 |
|
|
//cam_tid[1:0] <= cam_tid_tmp[1:0] ;
|
180 |
|
|
//ldq <= stb_quad_ld_cam ; Bug 2870
|
181 |
|
|
alt_wsel <= stb_alt_wsel ;
|
182 |
|
|
`ifdef FPGA_SYN_SCM
|
183 |
|
|
stb_addr <= {stb_cam_rw_tid[1:0],stb_cam_rw_ptr[2:0]};
|
184 |
|
|
`endif
|
185 |
|
|
end
|
186 |
|
|
|
187 |
|
|
assign ldq = stb_quad_ld_cam ;
|
188 |
|
|
assign rptr_vld = rptr_vld_tmp | rst_tri_en ;
|
189 |
|
|
|
190 |
|
|
//=========================================================================================
|
191 |
|
|
// write or read to/from memory
|
192 |
|
|
//=========================================================================================
|
193 |
|
|
|
194 |
|
|
// For blk-st, select out-of-pipe.
|
195 |
|
|
assign wr_data[44:15] = alt_wsel ?
|
196 |
|
|
alt_wr_data[44:15] : pipe_wr_data[44:15] ;
|
197 |
|
|
|
198 |
|
|
assign wdata_ramc[44:0] = {wr_data[44:15],camwr_data[14:0]};
|
199 |
|
|
|
200 |
|
|
// Write
|
201 |
|
|
always @ (negedge rclk)
|
202 |
|
|
begin
|
203 |
|
|
`ifdef FPGA_SYN_SCM
|
204 |
|
|
if(wptr_vld) begin
|
205 |
|
|
if(~rst_tri_en) begin
|
206 |
|
|
stb_ramc[stb_addr] <= wdata_ramc[44:0];
|
207 |
|
|
stb_rdata_ramc[44:0] <= wdata_ramc[44:0];
|
208 |
|
|
end else begin
|
209 |
|
|
stb_rdata_ramc[44:0] <= stb_ramc[stb_addr];
|
210 |
|
|
end
|
211 |
|
|
end
|
212 |
|
|
`else
|
213 |
|
|
for (j=0;j<NUMENTRIES;j=j+1)
|
214 |
|
|
begin
|
215 |
|
|
if (rw_wdline[j] & wptr_vld)
|
216 |
|
|
begin
|
217 |
|
|
if (~rst_tri_en)
|
218 |
|
|
begin
|
219 |
|
|
stb_ramc[j] <= wdata_ramc[44:0];
|
220 |
|
|
// write data is write-thru
|
221 |
|
|
stb_rdata_ramc[44:0] <= wdata_ramc[44:0];
|
222 |
|
|
end
|
223 |
|
|
else
|
224 |
|
|
begin
|
225 |
|
|
// INNO - default rd if wr squashed by scan_ena.
|
226 |
|
|
stb_rdata_ramc[44:0] <= stb_ramc[j];
|
227 |
|
|
end
|
228 |
|
|
end
|
229 |
|
|
end
|
230 |
|
|
`endif
|
231 |
|
|
// Read
|
232 |
|
|
`ifdef FPGA_SYN_SCM
|
233 |
|
|
if(rptr_vld & ~scan_ena) begin
|
234 |
|
|
if (rptr_vld & wptr_vld & ~rst_tri_en) begin
|
235 |
|
|
stb_rdata_ramc[44:0] <= wdata_ramc[44:0];
|
236 |
|
|
end
|
237 |
|
|
else begin
|
238 |
|
|
stb_rdata_ramc[44:0] <= stb_ramc[stb_addr];
|
239 |
|
|
end
|
240 |
|
|
end
|
241 |
|
|
`else
|
242 |
|
|
for (k=0;k<NUMENTRIES;k=k+1)
|
243 |
|
|
begin
|
244 |
|
|
if (rw_wdline[k] & rptr_vld & ~scan_ena)
|
245 |
|
|
begin
|
246 |
|
|
if (rptr_vld & wptr_vld & ~rst_tri_en) // INNO - write-thru
|
247 |
|
|
stb_rdata_ramc[44:0] <= wdata_ramc[44:0];
|
248 |
|
|
else
|
249 |
|
|
stb_rdata_ramc[44:0] <= stb_ramc[k];
|
250 |
|
|
end
|
251 |
|
|
end
|
252 |
|
|
`endif
|
253 |
|
|
end
|
254 |
|
|
|
255 |
|
|
//=========================================================================================
|
256 |
|
|
// CAM contents of CAM RAM
|
257 |
|
|
//=========================================================================================
|
258 |
|
|
|
259 |
|
|
// - Generate full/partial raw for incoming load.
|
260 |
|
|
// - Output signals need to be qualified with per entry
|
261 |
|
|
// vlds before causing any subsequent event, the read of
|
262 |
|
|
// the DATA RAM specifically.
|
263 |
|
|
// - full_raw & vld will cause rd of DATA RAM.
|
264 |
|
|
// - partial_raw & vld will cause ld to follow corresponding
|
265 |
|
|
// st on way out to xbar.
|
266 |
|
|
// - logic to generate partial and full raws may be done outside
|
267 |
|
|
// but that would require an additional signal per entry to
|
268 |
|
|
// be output.
|
269 |
|
|
|
270 |
|
|
// Mapping of cam/write data
|
271 |
|
|
//
|
272 |
|
|
// | 40-3=37b(pa) | 1b(stquad) | 8b(bytemask) | <- use
|
273 |
|
|
// | 45:9 | 8 | 7:0 | <- input port
|
274 |
|
|
// **^ stquad rm'ed
|
275 |
|
|
|
276 |
|
|
assign cam_data[44:0] = {stb_cam_data[44:15],stb_camwr_data[14:0]};
|
277 |
|
|
|
278 |
|
|
always @ (posedge rclk)
|
279 |
|
|
begin
|
280 |
|
|
|
281 |
|
|
for (l=0;l<NUMENTRIES;l=l+1)
|
282 |
|
|
begin
|
283 |
|
|
ramc_entry[44:0] = stb_ramc[l] ;
|
284 |
|
|
|
285 |
|
|
cam_tag[36:0] = ramc_entry[44:8] ;
|
286 |
|
|
cam_bmask[7:0] = ramc_entry[7:0] ;
|
287 |
|
|
//stq = ramc_entry[8] ; // additional bit -stq
|
288 |
|
|
|
289 |
|
|
// Prior to adding stb_quad_ld_cam port.
|
290 |
|
|
/*ptag_hit[l] =
|
291 |
|
|
((cam_tag[36:1] == cam_data[44:9]) &
|
292 |
|
|
(((cam_tag[0] == cam_data[8]) & ~stq) | stq)) & stcam_vld_tmp & ~scan_ena ;*/
|
293 |
|
|
// Modification.
|
294 |
|
|
// * remove ramc_entry[8]. Or keep it but it won't be used.
|
295 |
|
|
// * Instead we'll control this from outside.
|
296 |
|
|
ptag_hit[l] =
|
297 |
|
|
(cam_tag[36:1] == cam_data[44:9]) &
|
298 |
|
|
(((cam_tag[0] == cam_data[8]) & ~ldq) | ldq) & stb_cam_vld & ~scan_ena ;
|
299 |
|
|
byte_match[l] = |(cam_bmask[7:0] & cam_data[7:0]) & stb_cam_vld & ~scan_ena ;
|
300 |
|
|
// Simplification :
|
301 |
|
|
byte_overlap[l] = |(~cam_bmask[7:0] & cam_data[7:0]) & stb_cam_vld & ~scan_ena ;
|
302 |
|
|
|
303 |
|
|
end
|
304 |
|
|
end
|
305 |
|
|
|
306 |
|
|
// Mux the raw signals down to 8b quantities. Squash mask comes mid-way thru cycle.
|
307 |
|
|
|
308 |
|
|
|
309 |
|
|
assign byte_overlap_mx[7:0] =
|
310 |
|
|
(cam_tid[1:0] == 2'b00) ? byte_overlap[7:0] :
|
311 |
|
|
(cam_tid[1:0] == 2'b01) ? byte_overlap[15:8] :
|
312 |
|
|
(cam_tid[1:0] == 2'b10) ? byte_overlap[23:16] :
|
313 |
|
|
(cam_tid[1:0] == 2'b11) ? byte_overlap[31:24] : 8'bxxxx_xxxx ;
|
314 |
|
|
|
315 |
|
|
assign byte_match_mx[7:0] =
|
316 |
|
|
(cam_tid[1:0] == 2'b00) ? byte_match[7:0] :
|
317 |
|
|
(cam_tid[1:0] == 2'b01) ? byte_match[15:8] :
|
318 |
|
|
(cam_tid[1:0] == 2'b10) ? byte_match[23:16] :
|
319 |
|
|
(cam_tid[1:0] == 2'b11) ? byte_match[31:24] : 8'bxxxx_xxxx ;
|
320 |
|
|
|
321 |
|
|
assign ptag_hit_mx[7:0] =
|
322 |
|
|
(cam_tid[1:0] == 2'b00) ? ptag_hit[7:0] :
|
323 |
|
|
(cam_tid[1:0] == 2'b01) ? ptag_hit[15:8] :
|
324 |
|
|
(cam_tid[1:0] == 2'b10) ? ptag_hit[23:16] :
|
325 |
|
|
(cam_tid[1:0] == 2'b11) ? ptag_hit[31:24] : 8'bxxxx_xxxx ;
|
326 |
|
|
|
327 |
|
|
assign stb_ld_full_raw[7:0] =
|
328 |
|
|
ptag_hit_mx[7:0] & byte_match_mx[7:0] & ~byte_overlap_mx[7:0] & ~sqsh_msk[7:0] ;
|
329 |
|
|
assign stb_ld_partial_raw[7:0] =
|
330 |
|
|
ptag_hit_mx[7:0] & byte_match_mx[7:0] & byte_overlap_mx[7:0] & ~sqsh_msk[7:0] ;
|
331 |
|
|
|
332 |
|
|
assign cam_hit[7:0] =
|
333 |
|
|
ptag_hit_mx[7:0] & byte_match_mx[7:0] & ~sqsh_msk[7:0] ;
|
334 |
|
|
assign stb_cam_hit = |(cam_hit[7:0]);
|
335 |
|
|
|
336 |
|
|
// The stb data is meant to be read for single hit full raw case. It may actually be read
|
337 |
|
|
// for full raw, partial raw or multiple hit case but the read output will be ignored for
|
338 |
|
|
// partial and multiple hit case. Multiple hits will not cause a hazard as the ptr is first
|
339 |
|
|
// encoded and then decoded to form the wdline for the stb-data
|
340 |
|
|
// Use cam_hit result to void false hits.
|
341 |
|
|
assign stb_cam_hit_ptr[0] = cam_hit[1] | cam_hit[3] | cam_hit[5] | cam_hit[7] ;
|
342 |
|
|
assign stb_cam_hit_ptr[1] = cam_hit[2] | cam_hit[3] | cam_hit[6] | cam_hit[7] ;
|
343 |
|
|
assign stb_cam_hit_ptr[2] = cam_hit[4] | cam_hit[5] | cam_hit[6] | cam_hit[7] ;
|
344 |
|
|
|
345 |
|
|
//Generating multiple hits
|
346 |
|
|
assign stb_cam_mhit = (cam_hit[0] & cam_hit[1]) | (cam_hit[2] & cam_hit[3]) |
|
347 |
|
|
(cam_hit[4] & cam_hit[5]) | (cam_hit[6] & cam_hit[7]) |
|
348 |
|
|
((cam_hit[0] | cam_hit[1]) & (cam_hit[2] | cam_hit[3])) |
|
349 |
|
|
((cam_hit[4] | cam_hit[5]) & (cam_hit[6] | cam_hit[7])) |
|
350 |
|
|
((|cam_hit[3:0]) & (|cam_hit[7:4]));
|
351 |
|
|
|
352 |
|
|
//--------------------------------------------------------------
|
353 |
|
|
// Error Checking.
|
354 |
|
|
//--------------------------------------------------------------
|
355 |
|
|
|
356 |
|
|
// 1. simultaneous rd/wr on single port - terminate
|
357 |
|
|
// 2. simultaneous cam and wr - terminate
|
358 |
|
|
// * PUT OUTSIDE OF SRAM RTL, AS RST NOT AVAILABLE. *
|
359 |
|
|
|
360 |
|
|
endmodule
|