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

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

versione iniziale opensparc

Line 
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T1 Processor File: spu_mast.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:   state machine to do stores to L2.
24*/
25////////////////////////////////////////////////////////////////////////
26
27module spu_mast (
28
29/*outputs*/
30spu_mast_maaddr_addrinc,
31spu_mast_memren,
32spu_mast_stbuf_wen,
33spu_mast_mpa_addrinc,
34spu_mast_streq,
35
36spu_mast_done_set,
37/*inputs*/
38
39spu_mactl_iss_pulse_dly,
40mactl_stop,
41streq_ack,
42len_neqz,
43
44spu_wen_allma_stacks_ok,
45
46spu_mactl_perr_set,
47
48spu_mactl_stxa_force_abort,
49
50se,
51reset,
52rclk);
53
54
55input reset;
56input rclk;
57input se;
58
59input spu_mactl_iss_pulse_dly;
60input mactl_stop;
61input streq_ack;
62input len_neqz;
63
64input spu_wen_allma_stacks_ok;
65
66input spu_mactl_perr_set;
67
68input spu_mactl_stxa_force_abort;
69// -----------------------------------------------------------------
70
71output spu_mast_maaddr_addrinc;
72output spu_mast_memren;
73output spu_mast_stbuf_wen;
74output spu_mast_mpa_addrinc;
75output spu_mast_streq;
76output spu_mast_done_set;
77// -----------------------------------------------------------------
78// -----------------------------------------------------------------
79wire spu_mast_st_done,tr2rdmem_frm_wait4stdrain;
80
81wire ok_to_signal_cmplt;
82
83wire start_set;
84wire spu_mast_allow_rdmem;
85
86wire [1:0] rd_cntr_add,rd_cntr_q;
87
88wire tr2laststreq_frm_wait4stdrain;
89
90wire local_kill_abort;
91// -----------------------------------------------------------------
92wire streq_ack_dly;
93dff_s    #(1) streq_ack_ff (
94        .din(streq_ack) ,
95        .q(streq_ack_dly),
96        .clk (rclk), .se(se), .si(), .so());
97
98// -----------------------------------------------------------------
99// -----------------------------------------------------------------
100// -----------------------------------------------------------------
101// we need a state set to indcate st is done, and when an
102// masync gets issued later, then the load asi is returned.
103wire spu_mast_done_wen = (spu_mast_st_done | local_kill_abort) & mactl_stop;
104wire spu_mast_done_rst = reset | spu_mactl_iss_pulse_dly;
105
106wire spu_mast_done_set_q;
107
108dffre_s    #(1) spu_mast_done_ff (
109        .din(1'b1) , 
110        .q(spu_mast_done_set_q),
111        .en(spu_mast_done_wen),
112        .rst(spu_mast_done_rst), .clk (rclk), .se(se), .si(), .so()); 
113
114assign spu_mast_done_set = spu_mast_done_set_q & ok_to_signal_cmplt;
115
116
117// -----------------------------------------------------------------
118// -----------------------------------------------------------------
119
120// added the following dly to fix bug5212. I had added a flop to lsu_spu_ldst_ack to
121// the logic to increment the store req in spu_wen ack_cmplt counter to prevent
122// introducing a timing path. Now in the case if an ma_store has a length 1, then
123// the done_set gets asserted a cycle before the store ack incrementer increments.
124// So now i have to delay the done_set by a cycle so that the incrementer has
125// seen a store request by that time and the counter is no longer zero.
126wire spu_mast_done_wen_dly;
127dff_s    #(1) spu_mast_done_wen_ff (
128        .din(spu_mast_done_wen) ,
129        .q(spu_mast_done_wen_dly),
130        .clk (rclk), .se(se), .si(), .so());
131
132dffre_s    #(1) spu_mast_done_stack_ff (
133        .din(1'b1) ,
134        .q(spu_mast_done_set_stack),
135        .en(spu_mast_done_wen_dly),
136        .rst(spu_mast_done_rst), .clk (rclk), .se(se), .si(), .so());
137
138assign ok_to_signal_cmplt = spu_wen_allma_stacks_ok & spu_mast_done_set_stack;
139
140
141// -----------------------------------------------------------------
142// -----------------------------------------------------------------
143// -----------------------------------------------------------------
144// -----------------------------------------------------------------
145// -----------------------------------------------------------------
146// -----------------------------------------------------------------
147wire  state_reset = reset | local_kill_abort;
148// -------------------------------------------------------------------------
149dff_s    #(1) idle_state_ff (
150        .din(nxt_idle_state) ,
151        .q(cur_idle_state),
152        .clk (rclk), .se(se), .si(), .so());
153
154dffr_s  #(1) rdmem_state_ff (
155        .din(nxt_rdmem_state) ,
156        .q(cur_rdmem_state),
157        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
158
159dffr_s  #(1) wait4stdrain_state_ff (
160        .din(nxt_wait4stdrain_state) , 
161        .q(cur_wait4stdrain_state),
162        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
163
164dffr_s  #(1) laststreq_state_ff (
165        .din(nxt_laststreq_state) ,
166        .q(cur_laststreq_state),
167        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
168
169// -------------------------------------------------------------------------
170// -------------------------------------------------------------------------
171wire start_stop = spu_mactl_iss_pulse_dly & mactl_stop;
172
173// -------------------------------------------------------------------------
174//  transition to idle state.
175
176/*
177assign spu_mast_st_done = cur_wait4stdrain_state & streq_ack &
178                                (~len_neqz | spu_mactl_stxa_force_abort);
179*/
180
181
182assign spu_mast_st_done = 
183                        //((cur_wait4stdrain_state & ~len_neqz & start_set) |
184                        ((cur_wait4stdrain_state & ~len_neqz & rd_cntr_q[0]) |
185                          cur_laststreq_state) & streq_ack ; 
186
187
188assign  nxt_idle_state = (
189                         state_reset | spu_mast_st_done |
190                         (cur_idle_state & ~start_stop));
191
192
193wire tr2rdmem_frm_idle = cur_idle_state & start_stop;
194
195// this delay is because spu_mast_memren is based on nxt_rdmem_state
196// and it happens before cur_idle_state goes to zero.
197wire dly_tr2rdmem_frm_idle;
198dff_s    #(1) dly_tr2rdmem_frm_idle_ff (
199        .din(tr2rdmem_frm_idle) ,
200        .q(dly_tr2rdmem_frm_idle),
201        .clk (rclk), .se(se), .si(), .so());
202
203// -------------------------------------------------------------------------
204//  transition to rdmem state.
205
206
207assign tr2rdmem_frm_wait4stdrain = cur_wait4stdrain_state & 
208                                        (streq_ack | spu_mast_allow_rdmem) & 
209                                        len_neqz ;
210
211assign  nxt_rdmem_state = (
212                         (dly_tr2rdmem_frm_idle) |
213                         (tr2rdmem_frm_wait4stdrain));
214
215// -------------------------------------------------------------------------
216//  transition to wait4stdrain state.
217
218assign nxt_wait4stdrain_state = (
219                         cur_rdmem_state |
220                         (cur_wait4stdrain_state & ~(streq_ack | (spu_mast_allow_rdmem & 
221                                                                        len_neqz)) ));
222
223// -------------------------------------------------------------------------
224//  transition to laststreq state.
225
226assign tr2laststreq_frm_wait4stdrain = cur_wait4stdrain_state & streq_ack & ~len_neqz &
227                                                //~start_set;
228                                                ~rd_cntr_q[0];
229
230assign nxt_laststreq_state = (
231                         tr2laststreq_frm_wait4stdrain |
232                         (cur_laststreq_state & ~streq_ack) );
233
234wire tr2laststreq_frm_wait4stdrain_dly;
235dff_s    #(1) tr2laststreq_frm_wait4stdrain_ff (
236        .din(tr2laststreq_frm_wait4stdrain) ,
237        .q(tr2laststreq_frm_wait4stdrain_dly),
238        .clk (rclk), .se(se), .si(), .so());
239
240// -------------------------------------------------------------------------
241// -------------------------------------------------------------------------
242// -------------------------------------------------------------------------
243
244assign spu_mast_maaddr_addrinc = cur_rdmem_state;
245
246//assign spu_mast_memren = nxt_rdmem_state;
247assign spu_mast_memren = cur_rdmem_state & ~local_kill_abort;
248
249wire cur_rdmem_state_dly;
250dff_s    #(1) cur_rdmem_state_ff (
251        .din(cur_rdmem_state) ,
252        .q(cur_rdmem_state_dly),
253        .clk (rclk), .se(se), .si(), .so());
254
255wire cur_rdmem_state_dly2,cur_rdmem_state_dly3;
256dff_s    #(2) cur_rdmem_state_dly_ff (
257        .din({cur_rdmem_state_dly,cur_rdmem_state_dly2}) ,
258        .q({cur_rdmem_state_dly2,cur_rdmem_state_dly3}),
259        .clk (rclk), .se(se), .si(), .so());
260
261assign spu_mast_stbuf_wen = cur_rdmem_state_dly;
262
263
264// cannot use cur_rdmem_state to start the request since the data will
265// not be in the store buffer till the next cyle after mem rd.
266//assign spu_mast_streq = cur_wait4stdrain_state | cur_rdmem_state;
267
268
269//assign spu_mast_streq = cur_wait4stdrain_state & ~spu_mactl_dly_streq &
270assign spu_mast_streq = ((cur_rdmem_state_dly3 & start_set & ~rd_cntr_q[1]) |
271                                (streq_ack_dly & len_neqz) |
272                                (tr2laststreq_frm_wait4stdrain_dly) )&
273                                ~cur_idle_state & ~spu_mactl_perr_set &
274                                ~spu_mactl_stxa_force_abort;
275                        // when perr is asserted
276                        // the state machine to goto idle. but due to above eq, len is not zero and
277                        // whith streq_ack it will continue doing streq and hence the st_ack counter keeps incr.
278
279
280assign local_kill_abort = ((cur_rdmem_state_dly3 & start_set & ~rd_cntr_q[1]) |
281                                (streq_ack_dly & len_neqz) |
282                                (tr2laststreq_frm_wait4stdrain_dly) )&
283                                (spu_mactl_perr_set | spu_mactl_stxa_force_abort);
284
285
286wire tr2rdmem_frm_wait4stdrain_dly;
287dff_s    #(1) tr2rdmem_frm_wait4stdrain_ff (
288        .din(tr2rdmem_frm_wait4stdrain) ,
289        .q(tr2rdmem_frm_wait4stdrain_dly),
290        .clk (rclk), .se(se), .si(), .so());
291
292wire tr2rdmem_frm_wait4stdrain_dly2;
293dff_s    #(1) tr2rdmem_frm_wait4stdrain_dly_ff (
294        .din(tr2rdmem_frm_wait4stdrain_dly) ,
295        .q(tr2rdmem_frm_wait4stdrain_dly2),
296        .clk (rclk), .se(se), .si(), .so());
297
298assign spu_mast_mpa_addrinc = tr2rdmem_frm_wait4stdrain_dly2;
299
300
301// -------------------------------------------------------------------------
302// -------------------------------------------------------------------------
303// -------------------------------------------------------------------------
304// cntr to do an extra st req.
305
306wire rd_cntr_en = cur_rdmem_state;
307
308wire rd_cntr_rst = state_reset | streq_ack_dly | start_stop;
309
310assign rd_cntr_add[1:0] = rd_cntr_q[1:0] + 2'b01;
311
312dffre_s  #(2) rd_cntr_ff (
313        .din(rd_cntr_add[1:0]) ,
314        .q(rd_cntr_q[1:0]),
315        .en(rd_cntr_en),
316        .rst(rd_cntr_rst), .clk (rclk), .se(se), .si(), .so());
317
318
319dffre_s  #(1) start_stop_ff (
320        .din(1'b1) ,
321        .q(start_set),
322        .en(start_stop),
323        .rst(state_reset | streq_ack_dly), .clk (rclk), .se(se), .si(), .so());
324
325
326/*
327assign  spu_mast_allow_rdmem = (start_set & ~rd_cntr_q[1] & cur_rdmem_state_dly3) |
328                                (~start_set & rd_cntr_q[0]) ;
329*/
330
331
332assign  spu_mast_allow_rdmem = (start_set & ~rd_cntr_q[1] & cur_rdmem_state_dly3) ; 
333//------------------------------------------------------------------
334
335endmodule
Note: See TracBrowser for help on using the repository browser.