source: XOpenSparcT1/trunk/T1-CPU/spu/spu_wen.v @ 6

Revision 6, 10.2 KB checked in by pntsvt00, 14 years ago (diff)

versione iniziale opensparc

Line 
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T1 Processor File: spu_wen.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:    this block generates the write enables for
24//                      various registers in spu.   
25//                      Storage for valid bits also are here.
26*/
27////////////////////////////////////////////////////////////////////////
28
29module spu_wen (
30
31/*outputs*/
32
33spu_wen_maln_wen,
34spu_wen_vld_maln,
35
36spu_wen_mast_ack,
37
38spu_wen_mald_ack,
39
40spu_wen_ldst_pcx_vld,
41
42spu_wen_allma_stacks_ok,
43
44spu_wen_ma_unc_err_pulse,
45spu_wen_ma_unc_err,
46spu_wen_ma_cor_err,
47
48spu_wen_pckt_req,
49
50/*inputs*/
51
52spu_mald_ldreq,
53spu_mactl_streq,
54
55
56lsu_spu_vload_rtntyp,
57lsu_spu_vload_vld,
58
59lsu_spu_st_ack_tid,
60lsu_spu_st_asop,
61lsu_spu_st_ackvld,
62lsu_spu_ld_ack_tid,
63lsu_spu_ld_asop,
64lsu_spu_ld_ackvld,
65
66spu_mald_done,
67spu_mald_rstln,
68
69
70
71lsu_spu_strm_ack_cmplt,
72
73l2_err,
74
75
76spu_mactl_uncerr_rst,
77
78cpuid,
79
80se,
81reset,
82rclk);
83
84input reset;
85input rclk;
86input se;
87
88input [1:0] l2_err;
89
90input spu_mald_ldreq;
91input spu_mactl_streq;
92
93input [3:0]     lsu_spu_vload_rtntyp;
94input           lsu_spu_vload_vld;
95
96input [1:0]     lsu_spu_st_ack_tid;
97input           lsu_spu_st_asop;
98input           lsu_spu_st_ackvld;
99
100input [1:0]     lsu_spu_ld_ack_tid;
101input           lsu_spu_ld_asop;
102input           lsu_spu_ld_ackvld;
103
104input spu_mald_done;
105input spu_mald_rstln;
106
107
108
109input [1:0] lsu_spu_strm_ack_cmplt;
110
111
112input [2:0] cpuid;
113
114input spu_mactl_uncerr_rst;
115
116// -----------------------------------------------------
117
118output spu_wen_mast_ack;
119
120output spu_wen_maln_wen;
121output spu_wen_mald_ack;
122output spu_wen_vld_maln;
123
124output spu_wen_ldst_pcx_vld;
125
126output spu_wen_allma_stacks_ok;
127
128output spu_wen_ma_unc_err_pulse;
129output spu_wen_ma_unc_err;
130output spu_wen_ma_cor_err;
131
132output [122:104] spu_wen_pckt_req;
133
134// -----------------------------------------------------
135// -----------------------------------------------------
136// -----------------------------------------------------
137wire spu_wen_maln_wen_local;
138// -----------------------------------------------------
139// -----------------------------------------------------
140// -----------------------------------------------------
141// -----------------------------------------------------
142// -----------------------------------------------------
143// -----------------------------------------------------
144
145wire [1:0] l2_err_q;
146wire spu_wen_maln_wen_local_q;
147
148dff_s  #(3) l2_err_ff (
149        .din({l2_err[1:0], spu_wen_maln_wen_local}) , 
150        .q({l2_err_q[1:0], spu_wen_maln_wen_local_q}),
151        .clk (rclk), .se(se), .si(), .so()); 
152
153wire spu_wen_ma_unc_err_decode = l2_err_q[1] & spu_wen_maln_wen_local_q;
154
155assign spu_wen_ma_unc_err_pulse = spu_wen_ma_unc_err_decode;
156
157wire spu_wen_ma_cor_err = ~l2_err_q[1] & l2_err_q[0] & spu_wen_maln_wen_local_q;
158
159dffre_s  #(1) ma_unc_err_ff (
160        .din(1'b1) ,
161        .q(spu_wen_ma_unc_err),
162        .en(spu_wen_ma_unc_err_decode),
163        .rst(reset | spu_mactl_uncerr_rst), .clk (rclk), .se(se), .si(), .so());
164
165 
166// -----------------------------------------------------
167
168assign spu_wen_ldst_pcx_vld = spu_mald_ldreq | spu_mactl_streq;
169
170wire spu_lsu_load_req = spu_mald_ldreq;
171wire spu_lsu_store_req = spu_mactl_streq;
172// -----------------------------------------------------
173
174
175wire [1:0] lsu_spu_st_ack_tid_q;
176dff_s #(2) lsu_spu_st_ack_tid_ff (
177        .din(lsu_spu_st_ack_tid[1:0]) , 
178        .q(lsu_spu_st_ack_tid_q[1:0]),
179        .clk (rclk), .se(se), .si(), .so()); 
180
181wire lsu_spu_st_asop_q;
182dff_s #(1) lsu_spu_st_asop_ff (
183        .din(lsu_spu_st_asop) , 
184        .q(lsu_spu_st_asop_q),
185        .clk (rclk), .se(se), .si(), .so()); 
186
187
188wire [1:0] lsu_spu_ld_ack_tid_q;
189dff_s #(2) lsu_spu_ld_ack_tid_ff (
190        .din(lsu_spu_ld_ack_tid[1:0]) , 
191        .q(lsu_spu_ld_ack_tid_q[1:0]),
192        .clk (rclk), .se(se), .si(), .so()); 
193
194wire lsu_spu_ld_asop_q;
195dff_s #(1) lsu_spu_ld_asop_ff (
196        .din(lsu_spu_ld_asop) ,
197        .q(lsu_spu_ld_asop_q),
198        .clk (rclk), .se(se), .si(), .so());
199
200
201
202
203// -----------------------------------------------------
204// -----------------------------------------------------
205// -----------------------------------------------------
206
207//wire spu_wen_tid_bit0 = spu_rrstr_streq_mx2sel[0] | spu_rrld_ldreq_mx2sel;
208//wire spu_wen_tid_bit0 = 1'b0;
209
210wire spu_wen_ma_st_req_q;
211dff_s #(1) spu_wen_ma_st_req_ff (
212        .din(spu_lsu_store_req) ,
213        .q(spu_wen_ma_st_req_q),
214        .clk (rclk), .se(se), .si(), .so());
215
216// -----------------------------------------------------
217// -----------------------------------------------------
218// -----------------------------------------------------
219// ^^^^^^^^^^ LOAD RETURN FROM L2 ^^^^^^^^^^^^^^
220// -----------------------------------------------------
221
222wire load_rtntyp = (lsu_spu_vload_rtntyp[3:0] == 4'b0010);
223
224
225/*
226wire spu_wen_maln_wen =   lsu_spu_vload_vld & ~lsu_spu_vload_bid &
227                           lsu_spu_vload_asop & load_rtntyp &
228                           (2'b00 == lsu_spu_vload_data_tid[1:0]);
229*/
230
231// wire spu_wen_maln_wen_prequal =   lsu_spu_vload_vld & ~lsu_spu_vload_data_tid[0];
232
233wire spu_wen_maln_wen =  lsu_spu_vload_vld & load_rtntyp ; 
234
235assign spu_wen_maln_wen_local = spu_wen_maln_wen;
236
237
238// ------------------------------------------------------------
239// load/store acks from lsu captured in spu.
240// ------------------------------------------------------------
241
242
243wire spu_wen_mast_ack_prequal = (lsu_spu_st_ack_tid_q[1:0] == 2'b00) & lsu_spu_st_asop_q &
244                                spu_lsu_store_req;
245
246wire spu_wen_mast_ack = lsu_spu_st_ackvld & spu_wen_mast_ack_prequal;
247
248
249wire spu_wen_mald_ack_prequal = (lsu_spu_ld_ack_tid_q[1:0] == 2'b00) & lsu_spu_ld_asop_q &
250                                spu_lsu_load_req & ~spu_lsu_store_req;
251
252wire spu_wen_mald_ack = lsu_spu_ld_ackvld & spu_wen_mald_ack_prequal;
253
254
255// =================================================================
256// -----------------------------------------------------------------
257// -----------------------------------------------------------------
258// ***************** MA STUFF **************************************
259
260wire spu_wen_ma_reset = reset;
261
262// -----------------------------------------------------------------
263
264wire reset_vld_maln = spu_wen_ma_reset | spu_mald_rstln | spu_mald_done ;
265
266// -----------------------------------------------------------------
267
268dffre_s  #(1) maln_vld_bit_ff (
269        .din(1'b1) , 
270        .q(spu_wen_vld_maln),
271        .en(spu_wen_maln_wen_local), 
272        .rst(reset_vld_maln), .clk (rclk), .se(se), .si(), .so()); 
273
274// =================================================================
275// -----------------------------------------------------------------
276
277// -----------------------------------------------------------------
278// -----------------------------------------------------------------
279// -----------------------------------------------------------------
280// -----------------------------------------------------------------
281// -----------------------------------------------------------------
282// ^^^^^^^^^^ STORE RETURN FROM L2 ^^^^^^^^^^^^^^
283// -----------------------------------------------------------------
284// -----------------------------------------------------------------
285
286wire [1:0] lsu_spu_strm_ack_cmplt_q;
287
288dff_s  #(2) lsu_spu_strm_ff (
289        .din(lsu_spu_strm_ack_cmplt[1:0]) ,
290        .q(lsu_spu_strm_ack_cmplt_q[1:0]),
291        .clk (rclk), .se(se), .si(), .so());
292
293wire lsu_spu_st_ackvld_q;
294dff_s  #(1) lsu_spu_st_ackvld_ff (
295        .din(lsu_spu_st_ackvld) ,
296        .q(lsu_spu_st_ackvld_q),
297        .clk (rclk), .se(se), .si(), .so());
298
299wire spu_wen_ma_st_req_qq;
300dff_s  #(1) spu_wen_ma_st_req_q_ff (
301        .din(spu_wen_ma_st_req_q) ,
302        .q(spu_wen_ma_st_req_qq),
303        .clk (rclk), .se(se), .si(), .so());
304
305
306wire ma_stack_decr_sel = lsu_spu_strm_ack_cmplt_q[0] | lsu_spu_strm_ack_cmplt_q[1];
307
308
309wire ma_stack_incr_sel = spu_wen_ma_st_req_qq & lsu_spu_st_ackvld_q;
310
311
312wire ma_stack_cntr_wen  = ma_stack_incr_sel | ma_stack_decr_sel ;
313
314
315// -----------------------------------------------------------------
316// -----------------------------------------------------------------
317// ^^^^^^^^^^ STORE ACK COUNTERS ^^^^^^^^^^^^
318// -----------------------------------------------------------------
319// -----------------------------------------------------------------
320wire [5:0] ma_stack_cntr_q, ma_stack_incrdecr_val;
321
322
323// -----------------------------------------------------------------
324// -----------------------------------------------------------------
325// ^^^^^^ MA ST_ACK ^^^^^^^^
326// -----------------------------------------------------------------
327/*
328assign ma_stack_incr_val[5:0] = ma_stack_cntr_q[5:0] + 6'b000001;
329assign ma_stack_decr_val[5:0] = ma_stack_cntr_q[5:0] - 6'b000001;
330
331assign ma_stack_incrdecr_val[5:0] = ma_stack_incr_sel ?    ma_stack_incr_val[5:0] :
332                                                                ma_stack_decr_val[5:0];
333*/
334
335assign ma_stack_incrdecr_val[5:0] =  ma_stack_cntr_q[5:0] + {5'b00000,ma_stack_incr_sel} -
336                                        {4'b0000,lsu_spu_strm_ack_cmplt_q[1:0]};
337
338dffre_s  #(6) ma_stack_cntr_ff (
339        .din(ma_stack_incrdecr_val[5:0]) ,
340        .q(ma_stack_cntr_q[5:0]),
341        .en(ma_stack_cntr_wen),
342        .rst(reset), .clk (rclk), .se(se), .si(), .so());
343
344
345assign spu_wen_allma_stacks_ok = ~(|ma_stack_cntr_q[5:0]) ;
346
347
348// -----------------------------------------------------------------
349// -----------------------------------------------------------------
350
351dp_mux2es #(19) ldstreq_misc_mx (
352        .in0    ({6'b001001,cpuid[2:0],1'b0,1'b0,8'b00000100}),
353        .in1    ({6'b001011,cpuid[2:0],1'b0,1'b0,8'b00010000}),
354        .sel    (spu_lsu_store_req),
355        .dout   (spu_wen_pckt_req[122:104]));
356
357
358endmodule
359
Note: See TracBrowser for help on using the repository browser.