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

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

versione iniziale opensparc

RevLine 
[6]1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T1 Processor File: spu_mamul.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 MA mul/acc/shf.
24*/
25////////////////////////////////////////////////////////////////////////
26
27module spu_mamul (
28
29
30/*outputs*/
31spu_mamul_memren,
32spu_mamul_memwen,
33
34spu_mamul_rst_iptr,
35spu_mamul_rst_jptr,
36spu_mamul_incr_iptr,
37spu_mamul_incr_jptr,
38
39spu_mamul_a_rd_oprnd_sel,
40spu_mamul_ax_rd_oprnd_sel,
41spu_mamul_b_rd_oprnd_sel,
42spu_mamul_ba_rd_oprnd_sel,
43spu_mamul_m_rd_oprnd_sel,
44spu_mamul_me_rd_oprnd_sel,
45spu_mamul_n_rd_oprnd_sel,
46spu_mamul_m_wr_oprnd_sel,
47spu_mamul_me_wr_oprnd_sel,
48
49spu_mamul_i_ptr_sel,
50spu_mamul_iminus1_ptr_sel,
51spu_mamul_j_ptr_sel,
52spu_mamul_iminusj_ptr_sel,
53spu_mamul_iminuslenminus1_sel,
54spu_mamul_jjptr_wen,
55
56spu_mamul_oprnd2_wen,
57spu_mamul_oprnd2_bypass,
58spu_mamul_oprnd1_mxsel_l,
59spu_mamul_oprnd1_wen,
60
61spu_mul_req_vld,
62spu_mul_areg_shf,
63spu_mul_acc,
64spu_mul_areg_rst,
65spu_mamul_mul_done,
66
67spu_mamul_jjptr_sel,
68
69spu_mamul_rst,
70
71/*inputs*/
72spu_maaeqb_jjptr_sel,
73
74spu_mactl_mulop,
75
76spu_maaddr_iequtwolenplus2,
77spu_maaddr_iequtwolenplus1,
78spu_maaddr_jequiminus1,
79spu_maaddr_jequlen,
80spu_maaddr_halfpnt_set,
81spu_mactl_iss_pulse_dly,
82
83spu_mared_oprnd2_wen,
84
85mul_spu_ack,
86mul_spu_shf_ack,
87
88spu_maexp_start_mulred_anoteqb,
89
90spu_mactl_expop,
91
92spu_maaddr_aequb,
93
94
95spu_maaeqb_rst_iptr,
96spu_maaeqb_rst_jptr,
97spu_maaeqb_incr_iptr,
98spu_maaeqb_incr_jptr,
99
100spu_maaeqb_a_rd_oprnd_sel,
101spu_maaeqb_ax_rd_oprnd_sel,
102spu_maaeqb_m_rd_oprnd_sel,
103spu_maaeqb_me_rd_oprnd_sel,
104spu_maaeqb_n_rd_oprnd_sel,
105spu_maaeqb_m_wr_oprnd_sel,
106spu_maaeqb_me_wr_oprnd_sel,
107
108spu_maaeqb_iminus1_ptr_sel,
109spu_maaeqb_j_ptr_sel,
110spu_maaeqb_iminusj_ptr_sel,
111spu_maaeqb_iminuslenminus1_sel,
112spu_maaeqb_jjptr_wen,
113
114spu_maaeqb_oprnd2_wen,
115spu_maaeqb_oprnd2_bypass,
116
117spu_maaeqb_mul_req_vld,
118spu_maaeqb_mul_areg_shf,
119spu_maaeqb_mul_acc,
120spu_maaeqb_mul_areg_rst,
121spu_maaeqb_mul_done,
122
123spu_maaeqb_oprnd1_mxsel,
124spu_maaeqb_oprnd1_wen,
125
126spu_mactl_kill_op,
127spu_mactl_stxa_force_abort,
128
129se,
130reset,
131rclk);
132
133// ---------------------------------------------------------------
134input reset;
135input rclk;
136input se;
137
138input spu_maaddr_iequtwolenplus2;
139input spu_maaddr_iequtwolenplus1;
140input spu_maaddr_jequiminus1;
141input spu_maaddr_jequlen;
142input spu_maaddr_halfpnt_set;
143
144input mul_spu_ack;
145input mul_spu_shf_ack;
146input spu_mactl_mulop;
147input spu_mactl_iss_pulse_dly;
148
149input spu_mared_oprnd2_wen;
150
151input spu_maexp_start_mulred_anoteqb;
152
153input spu_mactl_expop;
154
155input spu_maaddr_aequb;
156
157
158
159input spu_maaeqb_rst_iptr;
160input spu_maaeqb_rst_jptr;
161input spu_maaeqb_incr_iptr;
162input spu_maaeqb_incr_jptr;
163
164input spu_maaeqb_a_rd_oprnd_sel;
165input spu_maaeqb_ax_rd_oprnd_sel;
166input spu_maaeqb_m_rd_oprnd_sel;
167input spu_maaeqb_me_rd_oprnd_sel;
168input spu_maaeqb_n_rd_oprnd_sel;
169input spu_maaeqb_m_wr_oprnd_sel;
170input spu_maaeqb_me_wr_oprnd_sel;
171
172input spu_maaeqb_iminus1_ptr_sel;
173input spu_maaeqb_j_ptr_sel;
174input spu_maaeqb_iminusj_ptr_sel;
175input spu_maaeqb_iminuslenminus1_sel;
176input spu_maaeqb_jjptr_wen;
177
178input spu_maaeqb_oprnd2_wen;
179input spu_maaeqb_oprnd2_bypass;
180
181input spu_maaeqb_mul_req_vld;
182input spu_maaeqb_mul_areg_shf;
183input spu_maaeqb_mul_acc;
184input spu_maaeqb_mul_areg_rst;
185input spu_maaeqb_mul_done;
186
187input [1:0] spu_maaeqb_oprnd1_mxsel;
188input spu_maaeqb_oprnd1_wen;
189input spu_maaeqb_jjptr_sel;
190
191input spu_mactl_kill_op;
192input spu_mactl_stxa_force_abort;
193
194// ---------------------------------------------------------------
195
196output spu_mamul_memwen;
197output spu_mamul_memren;
198output spu_mamul_rst_iptr;
199output spu_mamul_rst_jptr;
200output spu_mamul_incr_iptr;
201output spu_mamul_incr_jptr;
202
203output spu_mamul_a_rd_oprnd_sel;
204output spu_mamul_ax_rd_oprnd_sel;
205output spu_mamul_b_rd_oprnd_sel;
206output spu_mamul_ba_rd_oprnd_sel;
207output spu_mamul_m_rd_oprnd_sel;
208output spu_mamul_me_rd_oprnd_sel;
209output spu_mamul_n_rd_oprnd_sel;
210output spu_mamul_m_wr_oprnd_sel;
211output spu_mamul_me_wr_oprnd_sel;
212
213output spu_mamul_i_ptr_sel;
214output spu_mamul_iminus1_ptr_sel;
215output spu_mamul_j_ptr_sel;
216output spu_mamul_iminusj_ptr_sel;
217output spu_mamul_iminuslenminus1_sel;
218output spu_mamul_jjptr_wen;
219
220output spu_mamul_oprnd2_wen;
221output spu_mamul_oprnd2_bypass;
222output [2:0] spu_mamul_oprnd1_mxsel_l;
223output spu_mamul_oprnd1_wen;
224
225output spu_mul_req_vld;
226output spu_mul_areg_shf;
227output spu_mul_acc;
228output spu_mul_areg_rst;
229output spu_mamul_mul_done;
230output spu_mamul_jjptr_sel;
231output spu_mamul_rst;
232
233// ---------------------------------------------------------------
234wire tr2mwrite_frm_accumshft_pre;
235wire tr2mwrite_frm_accumshft,tr2iloopa_frm_jloopn;
236wire spu_mamul_rd_aj,spu_mamul_rd_biminusj,spu_mamul_rd_mj,
237        spu_mamul_rd_niminusj,spu_mamul_rd_ai,spu_mamul_rd_b0,
238        spu_mamul_wr_mi,spu_mamul_wr_miminuslenminus1,
239        spu_mamul_rd_n0;
240
241wire tr2accumshft_frm_mwrite;
242wire tr2accumshft_frm_iloopn;
243wire nxt_mwrite_state;
244// ---------------------------------------------------------------
245// ---------------------------------------------------------------
246// ---------------------------------------------------------------
247// ---------------------------------------------------------------
248// ---------------------------------------------------------------
249
250//wire local_stxa_abort = cur_mwrite_state & spu_mactl_stxa_force_abort;// this causes x to in perr_set
251wire local_stxa_abort = nxt_mwrite_state & spu_mactl_stxa_force_abort;
252
253wire state_reset = reset | spu_mactl_kill_op | local_stxa_abort;
254
255// ---------------------------------------------------------------
256// ---------------------------------------------------------------
257// ---------------------------------------------------------------
258// ---------------------------------------------------------------
259// ---------------------------------------------------------------
260// ---------------------------------------------------------------
261dff_s    #(1) idle_state_ff (
262        .din(nxt_idle_state) , 
263        .q(cur_idle_state),
264        .clk (rclk), .se(se), .si(), .so()); 
265
266dffr_s  #(1) jloopa_state_ff (
267        .din(nxt_jloopa_state) , 
268        .q(cur_jloopa_state),
269        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
270
271dffr_s  #(1) jloopb_state_ff (
272        .din(nxt_jloopb_state) , 
273        .q(cur_jloopb_state),
274        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
275
276dffr_s  #(1) jloopn_state_ff (
277        .din(nxt_jloopn_state) , 
278        .q(cur_jloopn_state),
279        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
280
281dffr_s  #(1) jloopm_state_ff (
282        .din(nxt_jloopm_state) , 
283        .q(cur_jloopm_state),
284        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
285
286dffr_s  #(1) iloopa_state_ff (
287        .din(nxt_iloopa_state) , 
288        .q(cur_iloopa_state),
289        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
290
291dffr_s  #(1) iloopb_state_ff (
292        .din(nxt_iloopb_state) , 
293        .q(cur_iloopb_state),
294        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
295
296dffr_s  #(1) nprime_state_ff (
297        .din(nxt_nprime_state) , 
298        .q(cur_nprime_state),
299        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
300
301dffr_s  #(1) mwrite_state_ff (
302        .din(nxt_mwrite_state) , 
303        .q(cur_mwrite_state),
304        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
305
306dffr_s  #(1) iloopn_state_ff (
307        .din(nxt_iloopn_state) , 
308        .q(cur_iloopn_state),
309        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
310
311dffr_s  #(1) accumshft_state_ff (
312        .din(nxt_accumshft_state) , 
313        .q(cur_accumshft_state),
314        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
315
316// ---------------------------------------------------------------
317
318wire spu_maaddr_aequb_q;
319dff_s  #(1) spu_maaddr_aequb_ff (
320        .din(spu_maaddr_aequb) , 
321        .q(spu_maaddr_aequb_q),
322        .clk (rclk), .se(se), .si(), .so()); 
323
324
325// ---------------------------------------------------------------
326// ---------------------------------------------------------------
327// ---------------------------------------------------------------
328// 4 cycle delay for mul result coming back.
329// ---------------------------------------------------------------
330
331wire tr2mwrite_frm_jloopn = cur_jloopn_state & mul_spu_ack & spu_maaddr_halfpnt_set &
332                                spu_maaddr_jequlen;
333
334wire mul_result_c0,mul_result_c1,mul_result_c2,mul_result_c3,mul_result_c4,mul_result_c5;
335
336//assign mul_result_c0 = (cur_nprime_state & mul_spu_ack & ~spu_maaddr_halfpnt_set) |
337assign mul_result_c0 = (cur_nprime_state & mul_spu_ack) |
338                        ( tr2mwrite_frm_jloopn );
339
340
341dffr_s  #(5) mul_res_ff (
342        .din({mul_result_c0,mul_result_c1,mul_result_c2,mul_result_c3,mul_result_c4}) , 
343        .q({mul_result_c1,mul_result_c2,mul_result_c3,mul_result_c4,mul_result_c5}),
344        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
345
346// ---------------------------------------------------------------
347// ---------------------------------------------------------------
348// ---------------------------------------------------------------
349// ---------------------------------------------------------------
350// ---------------------------------------------------------------
351wire tr2idle_frm_accumshft = cur_accumshft_state & spu_maaddr_iequtwolenplus2 &
352                                mul_spu_shf_ack;
353
354wire spu_mamul_mul_done_pre = tr2idle_frm_accumshft;
355wire spu_mamul_mul_done_q;
356dff_s #(1) muldone_dly_ff (
357        .din(spu_mamul_mul_done_pre) , 
358        .q(spu_mamul_mul_done_q),
359        .clk (rclk), .se(se), .si(), .so()); 
360
361assign spu_mamul_mul_done = spu_mamul_mul_done_q | spu_maaeqb_mul_done | local_stxa_abort;
362
363assign spu_mamul_rst_iptr = tr2idle_frm_accumshft | spu_maaeqb_rst_iptr;
364
365
366// the following is to reset jptr on the 1st half.
367wire tr2iloopa_frm_jloopn_dly;
368dff_s #(1) tr2iloopa_frm_jloopn_dly_ff (
369        .din(tr2iloopa_frm_jloopn) , 
370        .q(tr2iloopa_frm_jloopn_dly),
371        .clk (rclk), .se(se), .si(), .so()); 
372
373// ---------------------------------------------------------------
374
375wire mulop_start = (spu_mactl_iss_pulse_dly & spu_mactl_mulop & ~spu_maaddr_aequb_q) | 
376                        spu_maexp_start_mulred_anoteqb;
377
378assign spu_mul_areg_rst = mulop_start | spu_maaeqb_mul_areg_rst;
379assign spu_mamul_rst = spu_mul_areg_rst;
380
381assign  nxt_idle_state = (
382                         state_reset | 
383                         tr2idle_frm_accumshft |
384                         (cur_idle_state & ~mulop_start));
385
386// ---------------------------------------------------------------
387wire tr2jloopa_frm_accumshft = cur_accumshft_state & ~spu_maaddr_iequtwolenplus2 &
388                                ~spu_maaddr_iequtwolenplus1 & mul_spu_shf_ack;
389
390wire tr2jloopa_frm_accumshft_dly;
391dffr_s #(1) tr2jloopa_frm_accumshft_dly_ff (
392        .din(tr2jloopa_frm_accumshft) ,
393        .q(tr2jloopa_frm_accumshft_dly),
394        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
395
396wire tr2jloopa_frm_jloopn = cur_jloopn_state & mul_spu_ack &
397                ((~spu_maaddr_jequiminus1 & ~spu_maaddr_halfpnt_set) |
398                (~spu_maaddr_jequlen & spu_maaddr_halfpnt_set)) ;
399
400assign nxt_jloopa_state = (
401                          tr2jloopa_frm_jloopn |
402                          tr2jloopa_frm_accumshft_dly );
403
404
405assign spu_mamul_jjptr_wen = cur_jloopm_state | spu_maaeqb_jjptr_wen;
406
407assign spu_mamul_incr_jptr = tr2jloopa_frm_jloopn | spu_maaeqb_incr_jptr;
408
409assign spu_mamul_jjptr_sel = cur_jloopn_state | spu_maaeqb_jjptr_sel;
410
411//assign spu_mamul_rd_aj = nxt_jloopa_state;
412assign spu_mamul_rd_aj = 
413        (cur_jloopn_state & ((~spu_maaddr_jequiminus1 & ~spu_maaddr_halfpnt_set) |
414                                (~spu_maaddr_jequlen & spu_maaddr_halfpnt_set))) | 
415        tr2jloopa_frm_accumshft_dly;
416
417// ---------------------------------------------------------------
418assign nxt_jloopb_state = (
419                          cur_jloopa_state |
420                          (cur_jloopb_state & ~mul_spu_ack));
421
422//assign spu_mamul_rd_biminusj = nxt_jloopb_state | cur_jloopb_state;
423assign spu_mamul_rd_biminusj = cur_jloopa_state;
424
425// ---------------------------------------------------------------
426assign nxt_jloopm_state = (
427                          (cur_jloopb_state & mul_spu_ack));
428
429//assign spu_mamul_rd_mj = nxt_jloopm_state;
430assign spu_mamul_rd_mj = cur_jloopb_state;
431
432// ---------------------------------------------------------------
433
434assign nxt_jloopn_state = (
435                          cur_jloopm_state |
436                          (cur_jloopn_state & ~mul_spu_ack));
437
438//assign spu_mamul_rd_niminusj = nxt_jloopn_state;
439assign spu_mamul_rd_niminusj = cur_jloopm_state;
440
441// ---------------------------------------------------------------
442assign tr2iloopa_frm_jloopn = cur_jloopn_state & mul_spu_ack &
443                spu_maaddr_jequiminus1 & ~spu_maaddr_halfpnt_set;
444
445wire tr2iloopa_frm_idle = cur_idle_state & mulop_start;
446
447wire tr2iloopa_frm_idle_dly;
448dff_s #(1) tr2iloopa_frm_idle_ff (
449        .din(tr2iloopa_frm_idle) ,
450        .q(tr2iloopa_frm_idle_dly),
451        .clk (rclk), .se(se), .si(), .so());
452
453
454assign nxt_iloopa_state = (
455                          (tr2iloopa_frm_idle_dly) |
456                          (tr2iloopa_frm_jloopn));
457
458// iloop reads are done in cur_* state where as the jloop reads
459// are done in nxt_* and cur_* state(this to hold the rd indx during
460// requests. Due to read of the iloop in cur_* state the spu_mul_req_vld
461// is delayed by a cycle.
462//assign spu_mamul_rd_ai = nxt_iloopa_state;
463assign spu_mamul_rd_ai = 
464        (cur_jloopn_state & (spu_maaddr_jequiminus1 & ~spu_maaddr_halfpnt_set)) | tr2iloopa_frm_idle_dly;
465
466// ---------------------------------------------------------------
467assign nxt_iloopb_state = (
468                          (cur_iloopa_state) |
469                          (cur_iloopb_state & ~mul_spu_ack));
470
471//assign spu_mamul_rd_b0 = nxt_iloopb_state;
472assign spu_mamul_rd_b0 = cur_iloopa_state;
473
474// ---------------------------------------------------------------
475assign nxt_nprime_state = (
476                          (cur_iloopb_state & mul_spu_ack) |
477                          (cur_nprime_state & ~mul_spu_ack));
478
479
480// ---------------------------------------------------------------
481// assign tr2mwrite_frm_accumshft = cur_accumshft_state & mul_spu_shf_ack &
482//                                 spu_maaddr_iequtwolenplus1;
483assign tr2mwrite_frm_accumshft_pre = cur_accumshft_state & mul_spu_shf_ack & 
484                                spu_maaddr_iequtwolenplus1; 
485// delaying for one cycle to allow time to do i ptr increment
486// and calculate i-len-1(M[i-len-1]).This is due to skipping jloop on last
487// i iteration, not enough time to do both.
488dffr_s #(1) tr2mwrite_frm_accumshft_ff (
489        .din(tr2mwrite_frm_accumshft_pre) , 
490        .q(tr2mwrite_frm_accumshft),
491        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
492
493assign nxt_mwrite_state = (
494                          tr2mwrite_frm_accumshft |
495                          (mul_result_c5));
496
497// assign spu_mamul_memwen = nxt_mwrite_state;
498//need the following to capture mul data into flop.
499wire spu_mamul_wr_mi_oprnd2_wenbyp = nxt_mwrite_state & ~spu_maaddr_halfpnt_set;
500wire spu_mamul_wr_miminuslenminus1_oprnd2_wenbyp = nxt_mwrite_state & spu_maaddr_halfpnt_set;
501
502// ---------------------------------------------------------------
503assign nxt_iloopn_state = (
504                          (cur_mwrite_state & ~spu_maaddr_halfpnt_set) |
505                          (cur_iloopn_state & ~mul_spu_ack));
506
507//assign spu_mamul_rd_n0 =  nxt_iloopn_state | cur_iloopn_state;
508assign spu_mamul_rd_n0 =  cur_mwrite_state;
509
510// ---------------------------------------------------------------
511assign tr2accumshft_frm_mwrite = cur_mwrite_state & spu_maaddr_halfpnt_set;
512assign tr2accumshft_frm_iloopn = cur_iloopn_state & mul_spu_ack;
513
514assign nxt_accumshft_state = (
515                          tr2accumshft_frm_mwrite |
516                          tr2accumshft_frm_iloopn |
517                          (cur_accumshft_state & ~mul_spu_shf_ack));
518
519wire mamul_incr_iptr = tr2accumshft_frm_mwrite | tr2accumshft_frm_iloopn;
520
521assign spu_mamul_incr_iptr = mamul_incr_iptr | spu_maaeqb_incr_iptr;
522
523
524dff_s  #(1) memwen_dly_ff (
525        .din(mamul_incr_iptr) ,
526        .q(spu_mamul_memwen),
527        .clk (rclk), .se(se), .si(), .so());
528
529assign spu_mamul_wr_mi = spu_mamul_memwen & ~spu_maaddr_halfpnt_set;
530assign spu_mamul_wr_miminuslenminus1 = spu_mamul_memwen & spu_maaddr_halfpnt_set;
531
532// ---------------------------------------------------------------
533
534wire cur_accumshft_pulse,cur_accumshft_q;
535
536dff_s  #(1) cur_accumshft_pulse_ff (
537        .din(cur_accumshft_state) ,
538        .q(cur_accumshft_q),
539        .clk (rclk), .se(se), .si(), .so());
540
541assign cur_accumshft_pulse = ~cur_accumshft_q & cur_accumshft_state;
542
543wire mamul_rst_jptr = mulop_start | tr2iloopa_frm_jloopn_dly |  (cur_accumshft_pulse &
544                        spu_maaddr_halfpnt_set & ~spu_maaddr_iequtwolenplus2 &
545                        ~spu_maaddr_iequtwolenplus1);
546
547assign spu_mamul_rst_jptr = mamul_rst_jptr | spu_maaeqb_rst_jptr;
548// ---------------------------------------------------------------
549// ---------------------------------------------------------------
550// send selects to spu_maaddr.v
551// ---------------------------------------------------------------
552// ---------------------------------------------------------------
553assign spu_mamul_memren = spu_mamul_rd_aj | 
554                spu_mamul_rd_biminusj |
555                spu_mamul_rd_mj | 
556                spu_mamul_rd_niminusj |
557                spu_mamul_rd_ai | spu_mamul_rd_b0 | spu_mamul_rd_n0;   
558
559// ---------------------------------------------------------------
560// ---------------------------------------------------------------
561// ---------------------------------------------------------------
562wire mamul_a_rd_oprnd_sel = (spu_mamul_rd_aj | spu_mamul_rd_ai) & ~spu_mactl_expop;
563assign spu_mamul_a_rd_oprnd_sel = mamul_a_rd_oprnd_sel | spu_maaeqb_a_rd_oprnd_sel;
564
565wire mamul_ax_rd_oprnd_sel = (spu_mamul_rd_aj | spu_mamul_rd_ai) & spu_mactl_expop;
566assign spu_mamul_ax_rd_oprnd_sel = mamul_ax_rd_oprnd_sel | spu_maaeqb_ax_rd_oprnd_sel;
567
568// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
569
570//assign spu_mamul_b_rd_oprnd_sel = ((spu_mamul_rd_biminusj & ~spu_mamul_rd_aj & ~spu_mamul_rd_mj) |
571assign spu_mamul_b_rd_oprnd_sel = (spu_mamul_rd_biminusj | 
572                                        spu_mamul_rd_b0) & ~spu_mactl_expop;
573
574// bx should be removed, since xxnm does not start mamul, instead it starts maaeqb.
575// assign spu_mamul_bx_rd_oprnd_sel = ((spu_mamul_rd_biminusj & ~spu_mamul_rd_aj & ~spu_mamul_rd_mj) |
576//                                      spu_mamul_rd_b0) & spu_maexp_b_to_x_sel & spu_mactl_expop;
577
578//assign spu_mamul_ba_rd_oprnd_sel = ((spu_mamul_rd_biminusj & ~spu_mamul_rd_aj & ~spu_mamul_rd_mj) |
579assign spu_mamul_ba_rd_oprnd_sel = (spu_mamul_rd_biminusj | 
580                                        spu_mamul_rd_b0) & spu_mactl_expop;
581
582
583// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
584
585wire mamul_m_rd_oprnd_sel = spu_mamul_rd_mj & ~spu_mactl_expop ;
586assign spu_mamul_m_rd_oprnd_sel = mamul_m_rd_oprnd_sel | spu_maaeqb_m_rd_oprnd_sel  ;
587
588wire mamul_me_rd_oprnd_sel = spu_mamul_rd_mj & spu_mactl_expop ;
589assign spu_mamul_me_rd_oprnd_sel = mamul_me_rd_oprnd_sel | spu_maaeqb_me_rd_oprnd_sel  ;
590
591// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
592//wire mamul_n_rd_oprnd_sel = (spu_mamul_rd_niminusj & ~spu_mamul_rd_aj & ~spu_mamul_rd_mj) | spu_mamul_rd_n0;
593wire mamul_n_rd_oprnd_sel = spu_mamul_rd_niminusj | spu_mamul_rd_n0;
594assign spu_mamul_n_rd_oprnd_sel = mamul_n_rd_oprnd_sel | spu_maaeqb_n_rd_oprnd_sel;
595
596// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
597wire mamul_m_wr_oprnd_sel = (spu_mamul_wr_mi | spu_mamul_wr_miminuslenminus1) & 
598                                                ~spu_mactl_expop;
599assign spu_mamul_m_wr_oprnd_sel = mamul_m_wr_oprnd_sel | spu_maaeqb_m_wr_oprnd_sel;
600
601wire mamul_me_wr_oprnd_sel = (spu_mamul_wr_mi | spu_mamul_wr_miminuslenminus1) & 
602                                                spu_mactl_expop;
603assign spu_mamul_me_wr_oprnd_sel = mamul_me_wr_oprnd_sel | spu_maaeqb_me_wr_oprnd_sel;
604
605
606
607wire mamul_m_wr_oprnd2_wen = (spu_mamul_wr_mi_oprnd2_wenbyp | 
608                                spu_mamul_wr_miminuslenminus1_oprnd2_wenbyp) &
609                                                ~spu_mactl_expop;
610wire mamul_me_wr_oprnd2_wen = (spu_mamul_wr_mi_oprnd2_wenbyp | 
611                                spu_mamul_wr_miminuslenminus1_oprnd2_wenbyp) &
612                                                spu_mactl_expop;
613
614// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
615
616//assign spu_mamul_i_ptr_sel = (spu_mamul_rd_ai | spu_mamul_wr_mi) | spu_maaeqb_i_ptr_sel;
617assign spu_mamul_i_ptr_sel = spu_mamul_rd_ai ;
618assign spu_mamul_iminus1_ptr_sel = spu_mamul_wr_mi | spu_maaeqb_iminus1_ptr_sel ;
619
620assign spu_mamul_j_ptr_sel = (spu_mamul_rd_aj | spu_mamul_rd_mj) | spu_maaeqb_j_ptr_sel;
621
622wire mamul_iminusj_ptr_sel = 
623                //(spu_mamul_rd_biminusj | spu_mamul_rd_niminusj) & ~(spu_mamul_rd_aj | spu_mamul_rd_mj);
624                (spu_mamul_rd_biminusj | spu_mamul_rd_niminusj) ;
625assign spu_mamul_iminusj_ptr_sel = mamul_iminusj_ptr_sel | spu_maaeqb_iminusj_ptr_sel;
626
627
628assign spu_mamul_iminuslenminus1_sel = spu_mamul_wr_miminuslenminus1 | spu_maaeqb_iminuslenminus1_sel;
629
630// ---------------------------------------------------------------
631// ---------------------------------------------------------------
632// request to mul unit when asserted
633/*
634wire iloop_or_req_d;
635wire iloop_or_req = (cur_iloopb_state | cur_nprime_state | cur_iloopn_state)&
636                          ~mul_spu_ack;
637dff_s #(1) iloop_dly_req_ff (
638        .din(iloop_or_req) ,
639        .q(iloop_or_req_d),
640        .clk (rclk), .se(se), .si(), .so());
641assign spu_mul_req_vld = (cur_jloopb_state | cur_jloopn_state | iloop_or_req_d) ;
642*/
643
644
645wire mamul_mul_req_vld_pre = nxt_jloopb_state | nxt_jloopn_state | nxt_iloopb_state |
646                                nxt_nprime_state | nxt_iloopn_state ;
647
648dffr_s #(1) mamul_mul_req_vld_ff (
649        .din(mamul_mul_req_vld_pre) , 
650        .q(mamul_mul_req_vld),
651        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
652
653/*
654wire mamul_mul_req_vld = cur_jloopb_state | cur_jloopn_state | cur_iloopb_state |
655                                cur_nprime_state | cur_iloopn_state ;
656*/
657
658assign spu_mul_req_vld = mamul_mul_req_vld | spu_maaeqb_mul_req_vld;
659       
660// ---------------------------------------------------------------
661
662assign spu_mul_areg_shf = cur_accumshft_state | spu_maaeqb_mul_areg_shf;
663// ---------------------------------------------------------------
664
665/*
666wire oprnd2_sel = mamul_a_rd_oprnd_sel | mamul_ax_rd_oprnd_sel |
667                  mamul_m_rd_oprnd_sel | mamul_me_rd_oprnd_sel) &
668*/
669
670wire oprnd2_sel = nxt_jloopa_state | nxt_iloopa_state | nxt_jloopm_state ;
671
672wire oprnd2_sel_q;
673dff_s #(1) oprnd2_wen_ff (
674        .din(oprnd2_sel) , 
675        .q(oprnd2_sel_q),
676        .clk (rclk), .se(se), .si(), .so()); 
677
678assign spu_mamul_oprnd2_wen = oprnd2_sel_q | mamul_m_wr_oprnd2_wen | mamul_me_wr_oprnd2_wen | 
679                                spu_mared_oprnd2_wen |
680                                spu_maaeqb_oprnd2_wen;
681
682assign spu_mamul_oprnd2_bypass = mamul_m_wr_oprnd2_wen | mamul_me_wr_oprnd2_wen |
683                                        spu_maaeqb_oprnd2_bypass;
684
685
686//assign spu_mamul_oprnd1_sel = cur_nprime_state | spu_maaeqb_oprnd1_sel; // only select nprime if set
687
688// ---------------------------------------------------------------
689assign spu_mul_acc = (mamul_mul_req_vld & ~cur_nprime_state) | spu_maaeqb_mul_acc;
690
691// ---------------------------------------------------------------
692// ---------------------------------------------------------------
693// ---------------------------------------------------------------
694
695
696wire select_mamul = ~cur_idle_state; 
697
698
699wire spu_mamul_memrd4op1 = spu_mamul_rd_biminusj | spu_mamul_rd_b0 | spu_mamul_rd_n0 |
700                                        spu_mamul_rd_niminusj;
701
702wire spu_mamul_memrd4op1_q;
703dff_s #(1) spu_mamul_memrd4op1_ff (
704        .din(spu_mamul_memrd4op1) ,
705        .q(spu_mamul_memrd4op1_q),
706        .clk (rclk), .se(se), .si(), .so());
707
708
709wire [1:0] spu_mamul_oprnd1_mxsel;
710assign spu_mamul_oprnd1_mxsel[0] = (select_mamul & (~cur_nprime_state & ~spu_mamul_memrd4op1_q)) |
711                                   (~select_mamul & spu_maaeqb_oprnd1_mxsel[0]) ;
712assign spu_mamul_oprnd1_mxsel[1] = (select_mamul & (~cur_nprime_state & spu_mamul_memrd4op1_q)) |
713                                   (~select_mamul & spu_maaeqb_oprnd1_mxsel[1]);
714//assign spu_mamul_oprnd1_mxsel[2] = (select_mamul & cur_nprime_state) | (~select_mamul & spu_maaeqb_oprnd1_mxsel[2]);
715
716
717wire [2:0] spu_mamul_oprnd1_mxsel_ps;
718assign spu_mamul_oprnd1_mxsel_ps[0] = spu_mamul_oprnd1_mxsel[0];
719assign spu_mamul_oprnd1_mxsel_ps[1] = ~spu_mamul_oprnd1_mxsel[0] & spu_mamul_oprnd1_mxsel[1];
720assign spu_mamul_oprnd1_mxsel_ps[2] = ~spu_mamul_oprnd1_mxsel[0] & ~spu_mamul_oprnd1_mxsel[1];
721
722
723assign spu_mamul_oprnd1_mxsel_l = ~spu_mamul_oprnd1_mxsel_ps;
724
725assign spu_mamul_oprnd1_wen = spu_mamul_memrd4op1_q | spu_maaeqb_oprnd1_wen;
726
727endmodule
Note: See TracBrowser for help on using the repository browser.