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 | |
---|
27 | module spu_mast ( |
---|
28 | |
---|
29 | /*outputs*/ |
---|
30 | spu_mast_maaddr_addrinc, |
---|
31 | spu_mast_memren, |
---|
32 | spu_mast_stbuf_wen, |
---|
33 | spu_mast_mpa_addrinc, |
---|
34 | spu_mast_streq, |
---|
35 | |
---|
36 | spu_mast_done_set, |
---|
37 | /*inputs*/ |
---|
38 | |
---|
39 | spu_mactl_iss_pulse_dly, |
---|
40 | mactl_stop, |
---|
41 | streq_ack, |
---|
42 | len_neqz, |
---|
43 | |
---|
44 | spu_wen_allma_stacks_ok, |
---|
45 | |
---|
46 | spu_mactl_perr_set, |
---|
47 | |
---|
48 | spu_mactl_stxa_force_abort, |
---|
49 | |
---|
50 | se, |
---|
51 | reset, |
---|
52 | rclk); |
---|
53 | |
---|
54 | |
---|
55 | input reset; |
---|
56 | input rclk; |
---|
57 | input se; |
---|
58 | |
---|
59 | input spu_mactl_iss_pulse_dly; |
---|
60 | input mactl_stop; |
---|
61 | input streq_ack; |
---|
62 | input len_neqz; |
---|
63 | |
---|
64 | input spu_wen_allma_stacks_ok; |
---|
65 | |
---|
66 | input spu_mactl_perr_set; |
---|
67 | |
---|
68 | input spu_mactl_stxa_force_abort; |
---|
69 | // ----------------------------------------------------------------- |
---|
70 | |
---|
71 | output spu_mast_maaddr_addrinc; |
---|
72 | output spu_mast_memren; |
---|
73 | output spu_mast_stbuf_wen; |
---|
74 | output spu_mast_mpa_addrinc; |
---|
75 | output spu_mast_streq; |
---|
76 | output spu_mast_done_set; |
---|
77 | // ----------------------------------------------------------------- |
---|
78 | // ----------------------------------------------------------------- |
---|
79 | wire spu_mast_st_done,tr2rdmem_frm_wait4stdrain; |
---|
80 | |
---|
81 | wire ok_to_signal_cmplt; |
---|
82 | |
---|
83 | wire start_set; |
---|
84 | wire spu_mast_allow_rdmem; |
---|
85 | |
---|
86 | wire [1:0] rd_cntr_add,rd_cntr_q; |
---|
87 | |
---|
88 | wire tr2laststreq_frm_wait4stdrain; |
---|
89 | |
---|
90 | wire local_kill_abort; |
---|
91 | // ----------------------------------------------------------------- |
---|
92 | wire streq_ack_dly; |
---|
93 | dff_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. |
---|
103 | wire spu_mast_done_wen = (spu_mast_st_done | local_kill_abort) & mactl_stop; |
---|
104 | wire spu_mast_done_rst = reset | spu_mactl_iss_pulse_dly; |
---|
105 | |
---|
106 | wire spu_mast_done_set_q; |
---|
107 | |
---|
108 | dffre_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 | |
---|
114 | assign 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. |
---|
126 | wire spu_mast_done_wen_dly; |
---|
127 | dff_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 | |
---|
132 | dffre_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 | |
---|
138 | assign ok_to_signal_cmplt = spu_wen_allma_stacks_ok & spu_mast_done_set_stack; |
---|
139 | |
---|
140 | |
---|
141 | // ----------------------------------------------------------------- |
---|
142 | // ----------------------------------------------------------------- |
---|
143 | // ----------------------------------------------------------------- |
---|
144 | // ----------------------------------------------------------------- |
---|
145 | // ----------------------------------------------------------------- |
---|
146 | // ----------------------------------------------------------------- |
---|
147 | wire state_reset = reset | local_kill_abort; |
---|
148 | // ------------------------------------------------------------------------- |
---|
149 | dff_s #(1) idle_state_ff ( |
---|
150 | .din(nxt_idle_state) , |
---|
151 | .q(cur_idle_state), |
---|
152 | .clk (rclk), .se(se), .si(), .so()); |
---|
153 | |
---|
154 | dffr_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 | |
---|
159 | dffr_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 | |
---|
164 | dffr_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 | // ------------------------------------------------------------------------- |
---|
171 | wire start_stop = spu_mactl_iss_pulse_dly & mactl_stop; |
---|
172 | |
---|
173 | // ------------------------------------------------------------------------- |
---|
174 | // transition to idle state. |
---|
175 | |
---|
176 | /* |
---|
177 | assign spu_mast_st_done = cur_wait4stdrain_state & streq_ack & |
---|
178 | (~len_neqz | spu_mactl_stxa_force_abort); |
---|
179 | */ |
---|
180 | |
---|
181 | |
---|
182 | assign 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 | |
---|
188 | assign nxt_idle_state = ( |
---|
189 | state_reset | spu_mast_st_done | |
---|
190 | (cur_idle_state & ~start_stop)); |
---|
191 | |
---|
192 | |
---|
193 | wire 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. |
---|
197 | wire dly_tr2rdmem_frm_idle; |
---|
198 | dff_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 | |
---|
207 | assign tr2rdmem_frm_wait4stdrain = cur_wait4stdrain_state & |
---|
208 | (streq_ack | spu_mast_allow_rdmem) & |
---|
209 | len_neqz ; |
---|
210 | |
---|
211 | assign nxt_rdmem_state = ( |
---|
212 | (dly_tr2rdmem_frm_idle) | |
---|
213 | (tr2rdmem_frm_wait4stdrain)); |
---|
214 | |
---|
215 | // ------------------------------------------------------------------------- |
---|
216 | // transition to wait4stdrain state. |
---|
217 | |
---|
218 | assign 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 | |
---|
226 | assign tr2laststreq_frm_wait4stdrain = cur_wait4stdrain_state & streq_ack & ~len_neqz & |
---|
227 | //~start_set; |
---|
228 | ~rd_cntr_q[0]; |
---|
229 | |
---|
230 | assign nxt_laststreq_state = ( |
---|
231 | tr2laststreq_frm_wait4stdrain | |
---|
232 | (cur_laststreq_state & ~streq_ack) ); |
---|
233 | |
---|
234 | wire tr2laststreq_frm_wait4stdrain_dly; |
---|
235 | dff_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 | |
---|
244 | assign spu_mast_maaddr_addrinc = cur_rdmem_state; |
---|
245 | |
---|
246 | //assign spu_mast_memren = nxt_rdmem_state; |
---|
247 | assign spu_mast_memren = cur_rdmem_state & ~local_kill_abort; |
---|
248 | |
---|
249 | wire cur_rdmem_state_dly; |
---|
250 | dff_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 | |
---|
255 | wire cur_rdmem_state_dly2,cur_rdmem_state_dly3; |
---|
256 | dff_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 | |
---|
261 | assign 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 & |
---|
270 | assign 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 | |
---|
280 | assign 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 | |
---|
286 | wire tr2rdmem_frm_wait4stdrain_dly; |
---|
287 | dff_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 | |
---|
292 | wire tr2rdmem_frm_wait4stdrain_dly2; |
---|
293 | dff_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 | |
---|
298 | assign spu_mast_mpa_addrinc = tr2rdmem_frm_wait4stdrain_dly2; |
---|
299 | |
---|
300 | |
---|
301 | // ------------------------------------------------------------------------- |
---|
302 | // ------------------------------------------------------------------------- |
---|
303 | // ------------------------------------------------------------------------- |
---|
304 | // cntr to do an extra st req. |
---|
305 | |
---|
306 | wire rd_cntr_en = cur_rdmem_state; |
---|
307 | |
---|
308 | wire rd_cntr_rst = state_reset | streq_ack_dly | start_stop; |
---|
309 | |
---|
310 | assign rd_cntr_add[1:0] = rd_cntr_q[1:0] + 2'b01; |
---|
311 | |
---|
312 | dffre_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 | |
---|
319 | dffre_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 | /* |
---|
327 | assign spu_mast_allow_rdmem = (start_set & ~rd_cntr_q[1] & cur_rdmem_state_dly3) | |
---|
328 | (~start_set & rd_cntr_q[0]) ; |
---|
329 | */ |
---|
330 | |
---|
331 | |
---|
332 | assign spu_mast_allow_rdmem = (start_set & ~rd_cntr_q[1] & cur_rdmem_state_dly3) ; |
---|
333 | //------------------------------------------------------------------ |
---|
334 | |
---|
335 | endmodule |
---|