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

Revision 6, 23.1 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_maaeqb.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 when
24//                              A = B.
25*/
26////////////////////////////////////////////////////////////////////////
27// Global header file includes
28////////////////////////////////////////////////////////////////////////
29
30module spu_maaeqb (
31
32
33/*outputs*/
34spu_maaeqb_memren,
35spu_maaeqb_memwen,
36
37spu_maaeqb_rst_iptr,
38spu_maaeqb_rst_jptr,
39spu_maaeqb_incr_iptr,
40spu_maaeqb_incr_jptr,
41
42spu_maaeqb_a_rd_oprnd_sel,
43spu_maaeqb_ax_rd_oprnd_sel,
44spu_maaeqb_m_rd_oprnd_sel,
45spu_maaeqb_me_rd_oprnd_sel,
46spu_maaeqb_n_rd_oprnd_sel,
47spu_maaeqb_m_wr_oprnd_sel,
48spu_maaeqb_me_wr_oprnd_sel,
49
50spu_maaeqb_iminus1_ptr_sel,
51spu_maaeqb_j_ptr_sel,
52spu_maaeqb_iminusj_ptr_sel,
53spu_maaeqb_iminuslenminus1_sel,
54spu_maaeqb_irshft_sel,
55spu_maaeqb_jjptr_wen,
56
57spu_maaeqb_oprnd2_wen,
58spu_maaeqb_oprnd2_bypass,
59spu_maaeqb_a_leftshft,
60spu_maaeqb_oprnd1_mxsel,
61spu_maaeqb_oprnd1_wen,
62
63spu_maaeqb_mul_req_vld,
64spu_maaeqb_mul_areg_shf,
65spu_maaeqb_mul_acc,
66spu_maaeqb_mul_areg_rst,
67spu_maaeqb_mul_done,
68
69spu_maaeqb_jjptr_sel,
70
71/*inputs*/
72spu_mactl_mulop,
73
74spu_maaddr_iequtwolenplus2,
75spu_maaddr_iequtwolenplus1,
76spu_maaddr_jequiminus1,
77spu_maaddr_jequlen,
78spu_maaddr_halfpnt_set,
79spu_mactl_iss_pulse_dly,
80
81
82mul_spu_ack,
83mul_spu_shf_ack,
84
85spu_maexp_start_mulred_aequb,
86
87spu_mactl_expop,
88
89
90spu_maaddr_jequiminus1rshft,
91spu_maaddr_iequtwolen,
92spu_maaddr_ieven,
93spu_maaddr_ieq0,
94
95spu_maaddr_aequb,
96
97spu_mactl_kill_op,
98spu_mactl_stxa_force_abort,
99
100se,
101reset,
102rclk);
103
104// ---------------------------------------------------------------
105input reset;
106input rclk;
107input se;
108
109input spu_maaddr_iequtwolenplus2;
110input spu_maaddr_iequtwolenplus1;
111input spu_maaddr_jequiminus1;
112input spu_maaddr_jequlen;
113input spu_maaddr_halfpnt_set;
114
115input mul_spu_ack;
116input mul_spu_shf_ack;
117input spu_mactl_mulop;
118input spu_mactl_iss_pulse_dly;
119
120
121input spu_maexp_start_mulred_aequb;
122
123input spu_mactl_expop;
124
125
126
127input spu_maaddr_jequiminus1rshft;
128input spu_maaddr_iequtwolen;
129input spu_maaddr_ieven;
130input spu_maaddr_ieq0;
131
132
133input spu_maaddr_aequb;
134
135input spu_mactl_kill_op;
136input spu_mactl_stxa_force_abort;
137
138// ---------------------------------------------------------------
139
140output spu_maaeqb_memwen;
141output spu_maaeqb_memren;
142output spu_maaeqb_rst_iptr;
143output spu_maaeqb_rst_jptr;
144output spu_maaeqb_incr_iptr;
145output spu_maaeqb_incr_jptr;
146
147output spu_maaeqb_a_rd_oprnd_sel;
148output spu_maaeqb_ax_rd_oprnd_sel;
149output spu_maaeqb_m_rd_oprnd_sel;
150output spu_maaeqb_me_rd_oprnd_sel;
151output spu_maaeqb_n_rd_oprnd_sel;
152output spu_maaeqb_m_wr_oprnd_sel;
153output spu_maaeqb_me_wr_oprnd_sel;
154
155output spu_maaeqb_iminus1_ptr_sel;
156output spu_maaeqb_j_ptr_sel;
157output spu_maaeqb_iminusj_ptr_sel;
158output spu_maaeqb_iminuslenminus1_sel;
159output spu_maaeqb_irshft_sel;
160output spu_maaeqb_jjptr_wen;
161
162output spu_maaeqb_oprnd2_wen;
163output spu_maaeqb_oprnd2_bypass;
164output spu_maaeqb_a_leftshft;
165output [1:0] spu_maaeqb_oprnd1_mxsel;
166output spu_maaeqb_oprnd1_wen;
167
168output spu_maaeqb_mul_req_vld;
169output spu_maaeqb_mul_areg_shf;
170output spu_maaeqb_mul_acc;
171output spu_maaeqb_mul_areg_rst;
172output spu_maaeqb_mul_done;
173
174output spu_maaeqb_jjptr_sel;
175// ---------------------------------------------------------------
176wire tr2mwrite_frm_accumshft_pre;
177wire tr2mwrite_frm_accumshft;
178wire spu_maaeqb_rd_aj,spu_maaeqb_rd_mj,
179        spu_maaeqb_rd_niminusj,spu_maaeqb_rd_ai,
180        spu_maaeqb_wr_mi,spu_maaeqb_wr_miminuslenminus1,
181        spu_maaeqb_rd_n0;
182
183wire spu_maaeqb_rd_aiminusj;
184
185wire tr2accumshft_frm_mwrite;
186wire tr2accumshft_frm_iloopn;
187wire nxt_mwrite_state;
188// ---------------------------------------------------------------
189// ---------------------------------------------------------------
190// ---------------------------------------------------------------
191// ---------------------------------------------------------------
192// ---------------------------------------------------------------
193
194wire local_stxa_abort = nxt_mwrite_state & spu_mactl_stxa_force_abort;
195
196wire state_reset = reset | spu_mactl_kill_op | local_stxa_abort;
197
198// ---------------------------------------------------------------
199// ---------------------------------------------------------------
200// ---------------------------------------------------------------
201// ---------------------------------------------------------------
202// ---------------------------------------------------------------
203// ---------------------------------------------------------------
204dff_s    #(1) idle_state_ff (
205        .din(nxt_idle_state) , 
206        .q(cur_idle_state),
207        .clk (rclk), .se(se), .si(), .so()); 
208
209dffr_s  #(1) jloopa_state_ff (
210        .din(nxt_jloopa_state) , 
211        .q(cur_jloopa_state),
212        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
213
214dffr_s  #(1) ijloopa_state_ff (
215        .din(nxt_ijloopa_state) , 
216        .q(cur_ijloopa_state),
217        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
218
219dffr_s  #(1) jloopn_state_ff (
220        .din(nxt_jloopn_state) , 
221        .q(cur_jloopn_state),
222        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
223
224dffr_s  #(1) jloopm_state_ff (
225        .din(nxt_jloopm_state) , 
226        .q(cur_jloopm_state),
227        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
228
229dffr_s  #(1) iloopa1_state_ff (
230        .din(nxt_iloopa1_state) ,
231        .q(cur_iloopa1_state),
232        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
233
234dffr_s  #(1) iloopa_state_ff (
235        .din(nxt_iloopa_state) , 
236        .q(cur_iloopa_state),
237        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
238
239
240dffr_s  #(1) nprime_state_ff (
241        .din(nxt_nprime_state) , 
242        .q(cur_nprime_state),
243        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
244
245dffr_s  #(1) mwrite_state_ff (
246        .din(nxt_mwrite_state) , 
247        .q(cur_mwrite_state),
248        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
249
250dffr_s  #(1) iloopn_state_ff (
251        .din(nxt_iloopn_state) , 
252        .q(cur_iloopn_state),
253        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
254
255dffr_s  #(1) accumshft_state_ff (
256        .din(nxt_accumshft_state) , 
257        .q(cur_accumshft_state),
258        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
259
260// ---------------------------------------------------------------
261// ---------------------------------------------------------------
262// ---------------------------------------------------------------
263
264
265wire spu_maaddr_aequb_q;
266dff_s  #(1) spu_maaddr_aequb_ff (
267        .din(spu_maaddr_aequb) ,
268        .q(spu_maaddr_aequb_q),
269        .clk (rclk), .se(se), .si(), .so());
270
271
272// ---------------------------------------------------------------
273// 5 cycle delay for mul result coming back.
274// ---------------------------------------------------------------
275
276wire tr2mwrite_frm_jloopn = cur_jloopn_state & mul_spu_ack & spu_maaddr_halfpnt_set &
277                                spu_maaddr_jequlen;
278
279
280wire mul_result_c0,mul_result_c1,mul_result_c2,mul_result_c3,mul_result_c4,mul_result_c5;
281
282//assign mul_result_c0 = (cur_nprime_state & mul_spu_ack & ~spu_maaddr_halfpnt_set) |
283assign mul_result_c0 = (cur_nprime_state & mul_spu_ack) |
284                        ( tr2mwrite_frm_jloopn );
285
286
287dffr_s  #(5) mul_res_ff (
288        .din({mul_result_c0,mul_result_c1,mul_result_c2,mul_result_c3,mul_result_c4}) ,
289        .q({mul_result_c1,mul_result_c2,mul_result_c3,mul_result_c4,mul_result_c5}),
290        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
291
292
293// ----------------------------------------------------------------
294// ----------------------------------------------------------------
295// ---------------------------------------------------------------
296wire tr2idle_frm_accumshft = cur_accumshft_state & spu_maaddr_iequtwolenplus2 &
297                                mul_spu_shf_ack;
298
299
300wire spu_maaeqb_mul_done_pre = tr2idle_frm_accumshft;
301
302wire spu_maaeqb_mul_done_q;
303dff_s #(1) muldone_dly_ff (
304        .din(spu_maaeqb_mul_done_pre) , 
305        .q(spu_maaeqb_mul_done_q),
306        .clk (rclk), .se(se), .si(), .so()); 
307
308assign spu_maaeqb_mul_done = spu_maaeqb_mul_done_q | local_stxa_abort;
309
310
311assign spu_maaeqb_rst_iptr = tr2idle_frm_accumshft;
312
313
314// ----------------------------------------------------------------
315// transition to idle state
316
317wire mulop_start = (spu_mactl_iss_pulse_dly & spu_mactl_mulop & spu_maaddr_aequb_q) | 
318                                spu_maexp_start_mulred_aequb;
319
320assign spu_maaeqb_mul_areg_rst = mulop_start;
321
322
323assign  nxt_idle_state = (
324                         state_reset |
325                         tr2idle_frm_accumshft |
326                         (cur_idle_state & ~mulop_start));
327
328
329// ----------------------------------------------------------------
330// transition to jloopa state(rdA[j])
331
332wire tr2jloopa_frm_ijloopa = cur_ijloopa_state & mul_spu_ack & ~spu_maaddr_jequiminus1rshft;
333
334wire tr2jloopa_frm_accumshft = cur_accumshft_state & ~spu_maaddr_iequtwolenplus2 &
335                                ~spu_maaddr_iequtwolenplus1 & ~spu_maaddr_iequtwolen &
336                                mul_spu_shf_ack;
337
338wire tr2jloopa_frm_accumshft_dly;
339dffr_s #(1) tr2jloopa_frm_accumshft_dly_ff (
340        .din(tr2jloopa_frm_accumshft) ,
341        .q(tr2jloopa_frm_accumshft_dly),
342        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
343
344
345assign nxt_jloopa_state = (
346                          tr2jloopa_frm_ijloopa |
347                          tr2jloopa_frm_accumshft_dly );
348
349//assign spu_maaeqb_rd_aj = nxt_jloopa_state;
350assign spu_maaeqb_rd_aj = (cur_ijloopa_state & ~spu_maaddr_jequiminus1rshft) |
351                                tr2jloopa_frm_accumshft_dly;
352
353// ----------------------------------------------------------------
354// transition to jloopa state(rdA[i-j])
355
356
357assign nxt_ijloopa_state = (
358                          cur_jloopa_state |
359                          (cur_ijloopa_state & ~mul_spu_ack));
360
361assign spu_maaeqb_a_leftshft = cur_ijloopa_state;
362
363//assign spu_maaeqb_rd_aiminusj = nxt_ijloopa_state | cur_ijloopa_state;
364assign spu_maaeqb_rd_aiminusj = cur_jloopa_state;
365
366
367// ----------------------------------------------------------------
368// transition to iloopa state(rdA[i/2])
369
370wire tr2iloopa1_frm_ijloopa = cur_ijloopa_state & mul_spu_ack & spu_maaddr_ieven &
371                                spu_maaddr_jequiminus1rshft;
372
373wire tr2iloopa1_frm_accumshft = spu_maaddr_ieven & cur_accumshft_state & mul_spu_shf_ack &
374                        //(spu_maaddr_iequtwolenplus1 | spu_maaddr_iequtwolenplus2 |
375                        (spu_maaddr_iequtwolenplus1 | 
376                         spu_maaddr_iequtwolen); 
377
378wire tr2iloopa1_frm_accumshft_dly;
379dffr_s #(1) tr2iloopa1_frm_accumshft_dly_ff (
380        .din(tr2iloopa1_frm_accumshft) ,
381        .q(tr2iloopa1_frm_accumshft_dly),
382        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
383
384
385wire tr2iloopa1_frm_idle = cur_idle_state & mulop_start;
386
387wire tr2iloopa1_frm_idle_dly;
388dffr_s #(1) tr2iloopa1_frm_idle_ff (
389        .din(tr2iloopa1_frm_idle) ,
390        .q(tr2iloopa1_frm_idle_dly),
391        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
392
393
394
395assign nxt_iloopa1_state = (
396                          tr2iloopa1_frm_accumshft_dly |
397                          tr2iloopa1_frm_ijloopa |
398                          tr2iloopa1_frm_idle_dly) ;
399
400wire cur_iloopa1_state_dly;
401dffr_s #(1) cur_iloopa1_state_dly_ff (
402        .din(cur_iloopa1_state) ,
403        .q(cur_iloopa1_state_dly),
404        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
405
406
407assign nxt_iloopa_state = (
408                          cur_iloopa1_state_dly |
409                          (cur_iloopa_state & ~mul_spu_ack));
410
411
412
413//assign spu_maaeqb_rd_ai = cur_iloopa1_state | nxt_iloopa_state | cur_iloopa_state;
414
415assign spu_maaeqb_rd_ai = (cur_ijloopa_state & spu_maaddr_ieven & spu_maaddr_jequiminus1rshft) |
416                                tr2iloopa1_frm_idle_dly |
417        //(cur_accumshft_state & spu_maaddr_ieven & (spu_maaddr_iequtwolenplus1 | spu_maaddr_iequtwolen))       |
418                tr2iloopa1_frm_accumshft_dly |
419// above are for iloopa1 and below are for iloopa.
420        (cur_iloopa1_state_dly);
421
422// ----------------------------------------------------------------
423// transition to jloopm state(rdM[j])
424
425wire tr2jloopm_frm_ijloopa = cur_ijloopa_state & mul_spu_ack & ~spu_maaddr_ieven &
426                                spu_maaddr_jequiminus1rshft;
427
428// the following is needed to reset jptr on the transition
429// from ijloopa to jloopm.
430wire tr2jloopm_frm_ijloopa_dly;
431dffr_s #(1) tr2jloopm_frm_ijloopa_dly_ff (
432        .din(tr2jloopm_frm_ijloopa) ,
433        .q(tr2jloopm_frm_ijloopa_dly),
434        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
435
436
437wire tr2jloopm_frm_iloopa = cur_iloopa_state & mul_spu_ack & ~spu_maaddr_ieq0 ;
438wire tr2jloopm_frm_iloopa_dly;
439dffr_s #(1) tr2jloopm_frm_iloopa_dly_ff (
440        .din(tr2jloopm_frm_iloopa) ,
441        .q(tr2jloopm_frm_iloopa_dly),
442        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
443
444
445wire tr2jloopm_frm_jloopn = cur_jloopn_state & mul_spu_ack &
446                ((~spu_maaddr_jequiminus1 & ~spu_maaddr_halfpnt_set) |
447                (~spu_maaddr_jequlen & spu_maaddr_halfpnt_set)) ;
448
449assign nxt_jloopm_state = (
450                          tr2jloopm_frm_jloopn |
451                          tr2jloopm_frm_ijloopa_dly |
452                          tr2jloopm_frm_iloopa_dly);
453
454
455//assign spu_maaeqb_rd_mj = nxt_jloopm_state;
456assign spu_maaeqb_rd_mj = tr2jloopm_frm_ijloopa_dly | tr2jloopm_frm_iloopa_dly |
457                        cur_jloopn_state & 
458                ((~spu_maaddr_jequiminus1 & ~spu_maaddr_halfpnt_set) |
459                (~spu_maaddr_jequlen & spu_maaddr_halfpnt_set)) ;
460
461
462
463// ----------------------------------------------------------------
464// transition to jloopn state(rdN[j])
465
466assign nxt_jloopn_state = (
467                          cur_jloopm_state |
468                          (cur_jloopn_state & ~mul_spu_ack));
469
470assign spu_maaeqb_jjptr_wen = cur_jloopa_state | cur_jloopm_state;
471assign spu_maaeqb_incr_jptr = tr2jloopa_frm_ijloopa | tr2jloopm_frm_jloopn;
472
473assign spu_maaeqb_jjptr_sel = cur_ijloopa_state | cur_jloopn_state;
474
475
476//assign spu_maaeqb_rd_niminusj = nxt_jloopn_state;
477assign spu_maaeqb_rd_niminusj = cur_jloopm_state;
478
479
480// ----------------------------------------------------------------
481// transition to nprime state
482
483wire tr2nprime_frm_jloopn = cur_jloopn_state & mul_spu_ack &
484                spu_maaddr_jequiminus1 & ~spu_maaddr_halfpnt_set;
485
486wire tr2nprime_frm_iloopa = cur_iloopa_state & mul_spu_ack & spu_maaddr_ieq0;
487
488assign nxt_nprime_state = (
489                          tr2nprime_frm_jloopn |
490                          tr2nprime_frm_iloopa |
491                          (cur_nprime_state & ~mul_spu_ack));
492
493
494
495
496// the following is to reset jptr on the 1st half.
497wire tr2nprime_frm_jloopn_dly;
498dffr_s #(1) tr2nprime_frm_jloopn_dly_ff (
499        .din(tr2nprime_frm_jloopn) ,
500        .q(tr2nprime_frm_jloopn_dly),
501        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
502
503// ----------------------------------------------------------------
504// transition to mwrite state
505
506
507assign tr2mwrite_frm_accumshft_pre = cur_accumshft_state & mul_spu_shf_ack &
508                                spu_maaddr_iequtwolenplus1;
509
510// delaying for one cycle to allow time to do i ptr increment
511// and calculate i-len-1(M[i-len-1]).This is due to skipping jloop on last
512// i iteration, not enough time to do both.
513dffr_s #(1) tr2mwrite_frm_accumshft_ff (
514        .din(tr2mwrite_frm_accumshft_pre) ,
515        .q(tr2mwrite_frm_accumshft),
516        .rst(state_reset), .clk (rclk), .se(se), .si(), .so());
517
518
519assign nxt_mwrite_state = (
520                          tr2mwrite_frm_accumshft |
521                          (mul_result_c5));
522
523
524//assign spu_maaeqb_memwen = nxt_mwrite_state;
525
526wire spu_maaeqb_wr_mi_oprnd2_wenbyp = nxt_mwrite_state & ~spu_maaddr_halfpnt_set;
527wire spu_maaeqb_wr_miminuslenminus1_oprnd2_wenbyp = nxt_mwrite_state & spu_maaddr_halfpnt_set;
528
529
530// ---------------------------------------------------------------
531// transition to iloopn state
532
533assign nxt_iloopn_state = (
534                          (cur_mwrite_state & ~spu_maaddr_halfpnt_set) |
535                          (cur_iloopn_state & ~mul_spu_ack));
536
537
538//assign spu_maaeqb_rd_n0 =  nxt_iloopn_state | cur_iloopn_state;
539assign spu_maaeqb_rd_n0 =  cur_mwrite_state; 
540
541// ---------------------------------------------------------------
542// transition to accumshft state
543
544assign tr2accumshft_frm_mwrite = cur_mwrite_state & spu_maaddr_halfpnt_set;
545assign tr2accumshft_frm_iloopn = cur_iloopn_state & mul_spu_ack;
546
547assign nxt_accumshft_state = (
548                          tr2accumshft_frm_mwrite |
549                          tr2accumshft_frm_iloopn |
550                          (cur_accumshft_state & ~mul_spu_shf_ack));
551
552assign spu_maaeqb_incr_iptr = tr2accumshft_frm_mwrite | tr2accumshft_frm_iloopn;
553
554dff_s  #(1) memwen_dly_ff (
555        .din(spu_maaeqb_incr_iptr) ,
556        .q(spu_maaeqb_memwen),
557        .clk (rclk), .se(se), .si(), .so());
558
559assign spu_maaeqb_wr_mi = spu_maaeqb_memwen & ~spu_maaddr_halfpnt_set;
560assign spu_maaeqb_wr_miminuslenminus1 = spu_maaeqb_memwen & spu_maaddr_halfpnt_set;
561
562// ---------------------------------------------------------------
563
564wire cur_accumshft_pulse,cur_accumshft_q;
565
566dff_s  #(1) cur_accumshft_pulse_ff (
567        .din(cur_accumshft_state) ,
568        .q(cur_accumshft_q),
569        .clk (rclk), .se(se), .si(), .so());
570
571assign cur_accumshft_pulse = ~cur_accumshft_q & cur_accumshft_state;
572
573
574
575
576assign spu_maaeqb_rst_jptr = mulop_start | tr2nprime_frm_jloopn_dly | 
577                                tr2jloopm_frm_ijloopa | tr2iloopa1_frm_ijloopa |
578                        (cur_accumshft_pulse &
579                        spu_maaddr_halfpnt_set & ~spu_maaddr_iequtwolenplus2 &
580                        ~spu_maaddr_iequtwolenplus1);
581
582
583// ---------------------------------------------------------------
584// ---------------------------------------------------------------
585// ---------------------------------------------------------------
586// ---------------------------------------------------------------
587// ---------------------------------------------------------------
588// ---------------------------------------------------------------
589// send selects to spu_maaddr.v
590// ---------------------------------------------------------------
591// ---------------------------------------------------------------
592assign spu_maaeqb_memren = spu_maaeqb_rd_aj | 
593                spu_maaeqb_rd_aiminusj |
594                spu_maaeqb_rd_mj | 
595                spu_maaeqb_rd_niminusj |
596                spu_maaeqb_rd_ai | spu_maaeqb_rd_n0;   
597
598// ---------------------------------------------------------------
599// ---------------------------------------------------------------
600// ---------------------------------------------------------------
601// ---------------------------------------------------------------
602assign spu_maaeqb_a_rd_oprnd_sel = (spu_maaeqb_rd_aj | spu_maaeqb_rd_ai | 
603                                        spu_maaeqb_rd_aiminusj) & ~spu_mactl_expop ;
604assign spu_maaeqb_ax_rd_oprnd_sel = (spu_maaeqb_rd_aj | spu_maaeqb_rd_ai | 
605                                        spu_maaeqb_rd_aiminusj) & spu_mactl_expop ;
606
607assign spu_maaeqb_m_rd_oprnd_sel = spu_maaeqb_rd_mj & ~spu_mactl_expop;
608assign spu_maaeqb_me_rd_oprnd_sel = spu_maaeqb_rd_mj & spu_mactl_expop  ;
609
610
611
612assign spu_maaeqb_n_rd_oprnd_sel = (spu_maaeqb_rd_niminusj & ~spu_maaeqb_rd_mj) | 
613                                        spu_maaeqb_rd_n0;
614
615
616// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617
618assign spu_maaeqb_m_wr_oprnd_sel = (spu_maaeqb_wr_mi | spu_maaeqb_wr_miminuslenminus1) &
619                                                ~spu_mactl_expop;
620assign spu_maaeqb_me_wr_oprnd_sel = (spu_maaeqb_wr_mi | spu_maaeqb_wr_miminuslenminus1) &
621                                                spu_mactl_expop;
622
623
624
625wire spu_maaeqb_m_wr_oprnd2_wen = (spu_maaeqb_wr_mi_oprnd2_wenbyp | 
626                                        spu_maaeqb_wr_miminuslenminus1_oprnd2_wenbyp) &
627                                                ~spu_mactl_expop;
628wire spu_maaeqb_me_wr_oprnd2_wen = (spu_maaeqb_wr_mi_oprnd2_wenbyp | 
629                                        spu_maaeqb_wr_miminuslenminus1_oprnd2_wenbyp) &
630                                                spu_mactl_expop;
631
632// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
633
634
635assign spu_maaeqb_iminus1_ptr_sel = spu_maaeqb_wr_mi;
636
637assign spu_maaeqb_j_ptr_sel = spu_maaeqb_rd_aj | spu_maaeqb_rd_mj;
638assign spu_maaeqb_iminusj_ptr_sel = 
639                (spu_maaeqb_rd_aiminusj | spu_maaeqb_rd_niminusj) &
640                ~(spu_maaeqb_rd_aj | spu_maaeqb_rd_mj);
641
642assign spu_maaeqb_iminuslenminus1_sel = spu_maaeqb_wr_miminuslenminus1;
643
644
645assign spu_maaeqb_irshft_sel = spu_maaeqb_rd_ai;
646
647// ---------------------------------------------------------------
648// request to mul unit when asserted
649
650wire spu_maaeqb_mul_req_vld_pre = nxt_ijloopa_state | nxt_jloopn_state |
651                                nxt_nprime_state | nxt_iloopn_state |
652                                        nxt_iloopa_state;
653dffr_s #(1) spu_maaeqb_mul_req_vld_ff (
654        .din(spu_maaeqb_mul_req_vld_pre) , 
655        .q(spu_maaeqb_mul_req_vld),
656        .rst(state_reset), .clk (rclk), .se(se), .si(), .so()); 
657
658
659/*
660assign spu_maaeqb_mul_req_vld = cur_ijloopa_state | cur_jloopn_state |
661                                cur_nprime_state | cur_iloopn_state |
662                                        cur_iloopa_state;
663*/
664       
665// ---------------------------------------------------------------
666
667assign spu_maaeqb_mul_areg_shf = cur_accumshft_state;
668// ---------------------------------------------------------------
669
670/*
671wire oprnd2_sel = (spu_maaeqb_rd_aj | spu_maaeqb_rd_ai |
672                  spu_maaeqb_m_rd_oprnd_sel | spu_maaeqb_me_rd_oprnd_sel) ;
673*/
674
675//wire oprnd2_sel = nxt_jloopa_state | cur_iloopa1_state | nxt_iloopa_state | nxt_jloopm_state ;
676wire oprnd2_sel = nxt_jloopa_state | nxt_iloopa1_state | nxt_jloopm_state ;
677
678
679wire oprnd2_sel_q;
680dff_s #(1) oprnd2_wen_ff (
681        .din(oprnd2_sel) , 
682        .q(oprnd2_sel_q),
683        .clk (rclk), .se(se), .si(), .so()); 
684
685assign spu_maaeqb_oprnd2_wen = oprnd2_sel_q | spu_maaeqb_m_wr_oprnd2_wen |
686                                spu_maaeqb_me_wr_oprnd2_wen ;
687
688
689
690assign spu_maaeqb_oprnd2_bypass = spu_maaeqb_m_wr_oprnd2_wen | spu_maaeqb_me_wr_oprnd2_wen ;
691
692
693//assign spu_maaeqb_oprnd1_sel = cur_nprime_state; // only select nprime if set
694
695// ---------------------------------------------------------------
696assign spu_maaeqb_mul_acc = spu_maaeqb_mul_req_vld & ~cur_nprime_state;
697
698// ---------------------------------------------------------------
699// ---------------------------------------------------------------
700// ---------------------------------------------------------------
701
702wire spu_maaeqb_memrd4op1 = spu_maaeqb_rd_aiminusj | 
703                                //spu_maaeqb_rd_ai |
704                                cur_iloopa1_state_dly |
705                                spu_maaeqb_rd_niminusj | spu_maaeqb_rd_n0;
706
707wire spu_maaeqb_memrd4op1_q;
708dff_s #(1) spu_maaeqb_memrd4op1_ff (
709        .din(spu_maaeqb_memrd4op1) ,
710        .q(spu_maaeqb_memrd4op1_q),
711        .clk (rclk), .se(se), .si(), .so());
712
713
714wire [1:0] spu_maaeqb_oprnd1_mxsel;
715assign spu_maaeqb_oprnd1_mxsel[0] = ~cur_nprime_state & ~spu_maaeqb_memrd4op1_q;
716assign spu_maaeqb_oprnd1_mxsel[1] = ~cur_nprime_state & spu_maaeqb_memrd4op1_q;
717//assign spu_maaeqb_oprnd1_mxsel[2] = cur_nprime_state;
718
719
720assign spu_maaeqb_oprnd1_wen = spu_maaeqb_memrd4op1_q;
721
722
723
724endmodule
725
Note: See TracBrowser for help on using the repository browser.