OpenCores
URL https://opencores.org/ocsvn/sparc64soc/sparc64soc/trunk

Subversion Repositories sparc64soc

[/] [sparc64soc/] [trunk/] [T1-CPU/] [spu/] [spu_maaddr.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dmitryr
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: spu_maaddr.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:    adderss generator for MA.
24
//                      MPA,MA_ADDR,LENGTH,I_PTR,J_PTR...
25
*/
26
////////////////////////////////////////////////////////////////////////
27
// Global header file includes
28
////////////////////////////////////////////////////////////////////////
29
 
30
module spu_maaddr (
31
 
32
/*outputs*/
33
spu_maaddr_len_neqz,
34
spu_maaddr_mpa1maddr0,
35
spu_maaddr_memindx,
36
spu_maaddr_mamem_eveodd_sel_l,
37
spu_maaddr_iequtwolenplus2,
38
spu_maaddr_iequtwolenplus1,
39
spu_maaddr_jequiminus1,
40
spu_maaddr_jequlen,
41
 
42
spu_maaddr_halfpnt_set,
43
 
44
spu_maaddr_len_eqmax,
45
 
46
spu_maaddr_esmax,
47
spu_maaddr_esmod64,
48
 
49
spu_maaddr_nooddwr_on_leneq1,
50
 
51
spu_maaddr_mpa_addrinc,
52
spu_maaddr_mpa_wen,
53
spu_maaddr_mpa_incr_val,
54
 
55
spu_maaddr_len_cntr,
56
 
57
spu_maaddr_wrindx_0,
58
spu_maaddr_jptr_eqz_mared,
59
 
60
/*inputs*/
61
 
62
spu_mald_force_mpa_add16,
63
 
64
spu_mactl_iss_pulse_pre,
65
spu_mactl_iss_pulse,
66
 
67
 
68
//spu_mactl_mulop,
69
spu_mactl_ldop,
70
spu_madp_maaddr_reg_in,
71
spu_madp_mactl_reg,
72
 
73
spu_mald_maaddr_addrinc,
74
spu_mald_mpa_addrinc,
75
spu_mast_maaddr_addrinc,
76
spu_mast_mpa_addrinc,
77
 
78
spu_mamul_memwen,
79
 
80
spu_mamul_rst_iptr,
81
spu_mamul_rst_jptr,
82
spu_mamul_incr_iptr,
83
spu_mamul_incr_jptr,
84
 
85
spu_mamul_a_rd_oprnd_sel,
86
spu_mamul_ax_rd_oprnd_sel,
87
spu_mamul_b_rd_oprnd_sel,
88
spu_mamul_ba_rd_oprnd_sel,
89
spu_mamul_m_rd_oprnd_sel,
90
spu_mamul_n_rd_oprnd_sel,
91
spu_mamul_m_wr_oprnd_sel,
92
 
93
spu_mared_me_rd_oprnd_sel,
94
spu_mared_xe_wr_oprnd_sel,
95
spu_mamul_me_rd_oprnd_sel,
96
spu_mamul_me_wr_oprnd_sel,
97
 
98
spu_mamul_i_ptr_sel,
99
spu_mamul_iminus1_ptr_sel,
100
spu_mamul_j_ptr_sel,
101
spu_mamul_iminusj_ptr_sel,
102
spu_mamul_iminuslenminus1_sel,
103
 
104
spu_mamul_jjptr_wen,
105
 
106
spu_mared_m_rd_oprnd_sel,
107
spu_mared_nm_rd_oprnd_sel,
108
spu_mared_x_wr_oprnd_sel,
109
spu_mared_a_rd_oprnd_sel,
110
spu_mared_nr_rd_oprnd_sel,
111
spu_mared_r_wr_oprnd_sel,
112
spu_mared_memwen,
113
spu_mared_j_ptr_sel,
114
spu_mared_update_jptr,
115
spu_mared_rst_jptr,
116
spu_mared_maxlen_wen,
117
spu_mared_cin_set_4sub,
118
 
119
spu_mast_memren,
120
spu_mared_start_wen,
121
spu_mared_start_sel,
122
 
123
spu_maexp_incr_es_ptr,
124
spu_maexp_e_rd_oprnd_sel,
125
spu_maexp_es_max_init,
126
spu_maexp_es_e_ptr_rst,
127
 
128
spu_madp_mpa_addr_3,
129
 
130
 
131
 
132
spu_maaddr_jequiminus1rshft,
133
spu_maaddr_iequtwolen,
134
spu_maaddr_ieven,
135
spu_maaddr_ieq0,
136
 
137
spu_maaddr_aequb,
138
 
139
spu_maaeqb_memwen,
140
spu_maaeqb_irshft_sel,
141
 
142
spu_mared_update_redwr_jptr,
143
spu_mared_jjptr_wen,
144
 
145
spu_mamul_jjptr_sel,
146
 
147
mem_bypass,
148
sehold,
149
 
150
spu_mamul_rst,
151
 
152
se,
153
reset,
154
rclk);
155
 
156
// ---------------------------------------------------------------
157
input reset;
158
input rclk;
159
input se;
160
 
161
 
162
input spu_mald_force_mpa_add16;
163
 
164
input spu_mactl_ldop;
165
//input spu_mactl_mulop;
166
input [47:0] spu_madp_maaddr_reg_in;
167
input [5:0] spu_madp_mactl_reg;
168
 
169
input spu_mald_maaddr_addrinc;
170
input spu_mald_mpa_addrinc;
171
input spu_mast_maaddr_addrinc;
172
input spu_mast_mpa_addrinc;
173
 
174
input spu_mamul_memwen;
175
input spu_mamul_rst_iptr;
176
input spu_mamul_rst_jptr;
177
input spu_mamul_incr_iptr;
178
input spu_mamul_incr_jptr;
179
 
180
input spu_mamul_a_rd_oprnd_sel;
181
input spu_mamul_ax_rd_oprnd_sel;
182
input spu_mamul_b_rd_oprnd_sel;
183
input spu_mamul_ba_rd_oprnd_sel;
184
input spu_mamul_m_rd_oprnd_sel;
185
input spu_mamul_n_rd_oprnd_sel;
186
input spu_mamul_m_wr_oprnd_sel;
187
 
188
input spu_mared_me_rd_oprnd_sel;
189
input spu_mared_xe_wr_oprnd_sel;
190
input spu_mamul_me_rd_oprnd_sel;
191
input spu_mamul_me_wr_oprnd_sel;
192
 
193
input spu_mamul_i_ptr_sel;
194
input spu_mamul_iminus1_ptr_sel;
195
input spu_mamul_j_ptr_sel;
196
input spu_mamul_iminusj_ptr_sel;
197
input spu_mamul_iminuslenminus1_sel;
198
 
199
input spu_mamul_jjptr_wen;
200
 
201
input spu_mactl_iss_pulse_pre;
202
input spu_mactl_iss_pulse;
203
 
204
input spu_mared_m_rd_oprnd_sel;
205
input spu_mared_nm_rd_oprnd_sel;
206
input spu_mared_x_wr_oprnd_sel;
207
input spu_mared_a_rd_oprnd_sel;
208
input spu_mared_nr_rd_oprnd_sel;
209
input spu_mared_r_wr_oprnd_sel;
210
input spu_mared_memwen;
211
input spu_mared_j_ptr_sel;
212
input spu_mared_update_jptr;
213
input spu_mared_rst_jptr;
214
input spu_mared_maxlen_wen;
215
input spu_mared_cin_set_4sub;
216
 
217
input spu_mast_memren;
218
input spu_mared_start_wen;
219
input spu_mared_start_sel;
220
 
221
input spu_maexp_incr_es_ptr;
222
input spu_maexp_e_rd_oprnd_sel;
223
input spu_maexp_es_max_init;
224
input spu_maexp_es_e_ptr_rst;
225
 
226
 
227
input spu_madp_mpa_addr_3;
228
input spu_maaeqb_memwen;
229
input spu_maaeqb_irshft_sel;
230
 
231
input spu_mared_update_redwr_jptr;
232
input spu_mared_jjptr_wen;
233
 
234
input spu_mamul_jjptr_sel;
235
 
236
input mem_bypass;
237
input sehold;
238
 
239
input spu_mamul_rst;
240
// ---------------------------------------------------------------
241
output spu_maaddr_len_neqz;
242
 
243
output spu_maaddr_mpa1maddr0;
244
 
245
output [7:1] spu_maaddr_memindx;
246
output [3:0] spu_maaddr_mamem_eveodd_sel_l;
247
 
248
output spu_maaddr_iequtwolenplus2;
249
output spu_maaddr_iequtwolenplus1;
250
output spu_maaddr_jequiminus1;
251
output spu_maaddr_jequlen;
252
 
253
output spu_maaddr_halfpnt_set;
254
 
255
output spu_maaddr_len_eqmax;
256
 
257
output spu_maaddr_esmod64;
258
output spu_maaddr_esmax;
259
 
260
output spu_maaddr_nooddwr_on_leneq1;
261
 
262
output spu_maaddr_mpa_addrinc;
263
output spu_maaddr_mpa_wen;
264
output [4:0] spu_maaddr_mpa_incr_val;
265
 
266
 
267
 
268
 
269
output spu_maaddr_jequiminus1rshft;
270
output spu_maaddr_iequtwolen;
271
output spu_maaddr_ieven;
272
output spu_maaddr_ieq0;
273
 
274
output spu_maaddr_aequb;
275
 
276
output [5:0] spu_maaddr_len_cntr;
277
 
278
output spu_maaddr_wrindx_0;
279
output spu_maaddr_jptr_eqz_mared;
280
 
281
// ---------------------------------------------------------------
282
// ---------------------------------------------------------------
283
// ---------------------------------------------------------------
284
 
285
wire reset_local = reset | spu_mactl_iss_pulse_pre;
286
 
287
// ---------------------------------------------------------------
288
// ---------------------------------------------------------------
289
// ---------------------------------------------------------------
290
 
291
wire [47:0] spu_madp_maaddr_reg;
292
wire [6:0] len_decr_val,len_ptr_sub_q,len_ptr_mx,len_ptr_sub;
293
wire incr_2wd;
294
wire [1:0] len_1or2_dec;
295
 
296
wire [7:0] maaddr_mx,maaddr_incr_val,spu_maaddr_maaddr_add,spu_maaddr_maaddr_q;
297
wire maaddr_wen;
298
 
299
wire [6:0] j_ptr_data;
300
// ---------------------------------------------------------------
301
// ---------------------------------------------------------------
302
 
303
dffe_s  #(48) maaddr_reg_ff  (
304
        .din(spu_madp_maaddr_reg_in[47:0]) ,
305
        .q(spu_madp_maaddr_reg[47:0]),
306
        .en(spu_mactl_iss_pulse_pre),
307
        .clk (rclk), .se(se), .si(), .so());
308
 
309
 
310
// ---------------------------------------------------------------
311
wire spu_maaddr_maaddr_addrinc = spu_mald_maaddr_addrinc | spu_mast_maaddr_addrinc;
312
assign spu_maaddr_mpa_addrinc = spu_mald_mpa_addrinc | spu_mast_mpa_addrinc;
313
// ---------------------------------------------------------------
314
// ***************** LEN *******************
315
// --------------------------------------------------------------
316
 
317
wire len_wen = spu_maaddr_maaddr_addrinc | spu_mactl_iss_pulse;
318
 
319
mux2ds  #(7) len_issorex_mx (
320
        .in0    (len_ptr_sub_q[6:0]),
321
        .in1    ({1'b0,spu_madp_mactl_reg[5:0]}),
322
        .sel0   (spu_maaddr_maaddr_addrinc),
323
        .sel1   (~spu_maaddr_maaddr_addrinc),
324
        .dout   (len_ptr_mx[6:0])
325
);
326
 
327
// for memload decr by 16bytes(2words) and for memstore & mulop decr by
328
// 8bytes(1word) or when transferring one word rather than two from 
329
// ld buf to mamem.
330
 
331
 
332
mux2ds  #(2) len_1or2_mx (
333
        .in0    (2'b01), // already inverted
334
        .in1    (2'b10),
335
        .sel0   (incr_2wd),
336
        .sel1   (~incr_2wd),
337
        .dout   (len_1or2_dec[1:0])
338
);
339
 
340
 
341
mux2ds  #(7) len_ptr_iss_mx (
342
        .in0    (7'b0000000),
343
        .in1    ({5'b11111,len_1or2_dec[1:0]}),
344
        .sel0   (spu_mactl_iss_pulse),
345
        .sel1   (~spu_mactl_iss_pulse),
346
        .dout   (len_decr_val[6:0])
347
);
348
 
349
assign len_ptr_sub[6:0] = len_ptr_mx[6:0] + len_decr_val[6:0] +
350
                                                7'b0000001;
351
 
352
dffre_s  #(7) len_ptr_ff  (
353
        .din(len_ptr_sub[6:0]) ,
354
        .q(len_ptr_sub_q[6:0]),
355
        .en(len_wen),
356
        .rst(reset_local), .clk (rclk), .se(se), .si(), .so());
357
 
358
assign spu_maaddr_len_neqz = |len_ptr_sub_q[6:0];
359
 
360
// his for the case when the len has been decremented to 1 and there
361
// is possibilty the next decr will be -2 which makes the len be a
362
// neg number.
363
 
364
wire allow_incr_2wd = (|len_ptr_sub_q[6:1]) & spu_mactl_ldop;
365
 
366
 
367
 
368
// when mpa0maddr0 make sure the last write does not happen to 
369
// odd side when len has reached one. mpa=0 and maddr=0 are checked in
370
// spu_mactl.v.
371
 
372
assign spu_maaddr_nooddwr_on_leneq1 = ~(~allow_incr_2wd & len_ptr_sub_q[0]);
373
 
374
 
375
wire [5:0] spu_maaddr_len_cntr_l;
376
assign spu_maaddr_len_cntr_l[5:0] = ~len_ptr_sub_q[5:0];
377
assign spu_maaddr_len_cntr[5:0] = ~spu_maaddr_len_cntr_l[5:0];
378
 
379
// --------------------------------------------------------------
380
// ***************** MPA *******************
381
// --------------------------------------------------------------
382
 
383
wire mpa_incr_2wd = incr_2wd | spu_mald_force_mpa_add16;
384
 
385
 
386
mux2ds  #(5) mpa_iss_mx (
387
        .in0    (5'b10000),
388
        .in1    (5'b01000),
389
        .sel0   (mpa_incr_2wd),
390
        .sel1   (~mpa_incr_2wd),
391
        .dout   (spu_maaddr_mpa_incr_val[4:0])
392
);
393
 
394
 
395
assign spu_maaddr_mpa_wen = spu_maaddr_mpa_addrinc | spu_mactl_iss_pulse;
396
 
397
// --------------------------------------------------------------
398
// ***************** MA_ADDR *******************
399
// --------------------------------------------------------------
400
 
401
mux2ds  #(8) maaddr_issorex_mx (
402
        .in0    (spu_maaddr_maaddr_add[7:0]),
403
        .in1    (spu_madp_maaddr_reg[7:0]),
404
        .sel0   (spu_maaddr_maaddr_addrinc),
405
        .sel1   (~spu_maaddr_maaddr_addrinc),
406
        .dout   (maaddr_mx[7:0])
407
);
408
 
409
 
410
mux2ds  #(8) maaddr_iss_mx (
411
        .in0    (8'b00000010),
412
        .in1    (8'b00000001),
413
        .sel0   (incr_2wd),
414
        .sel1   (~incr_2wd),
415
        .dout   (maaddr_incr_val[7:0])
416
);
417
 
418
assign spu_maaddr_maaddr_add[7:0] = spu_maaddr_maaddr_q[7:0] + maaddr_incr_val[7:0];
419
 
420
assign maaddr_wen = spu_maaddr_maaddr_addrinc | spu_mactl_iss_pulse;
421
 
422
dffre_s  #(8) maaadr_pa_mx  (
423
        .din(maaddr_mx[7:0]) ,
424
        .q(spu_maaddr_maaddr_q[7:0]),
425
        .en(maaddr_wen),
426
        .rst(reset_local), .clk (rclk), .se(se), .si(), .so());
427
 
428
 
429
// --------------------------------------------------------------
430
// ***************** INCR VALUE DECODE *******************
431
// --------------------------------------------------------------
432
 
433
// 16byte increments for load from L2 and 8byte increment for
434
// store to L2 or if its 8byte transfer from ld buff to mamem.
435
 
436
 
437
assign incr_2wd = ~spu_madp_mpa_addr_3 & ~spu_maaddr_maaddr_q[0] & spu_mactl_ldop &
438
                                allow_incr_2wd;
439
 
440
 
441
 
442
assign spu_maaddr_mpa1maddr0 = spu_madp_mpa_addr_3 & ~spu_maaddr_maaddr_q[0] &
443
                                        spu_mactl_ldop;
444
 
445
 
446
// --------------------------------------------------------------
447
// --------------------------------------------------------------
448
// ******************* A == B ******************
449
// --------------------------------------------------------------
450
// --------------------------------------------------------------
451
 
452
assign spu_maaddr_aequb = (spu_madp_maaddr_reg[7:0] == spu_madp_maaddr_reg[15:8]);
453
 
454
// --------------------------------------------------------------
455
// --------------------------------------------------------------
456
// ***************** MEMINDEX *******************
457
// --------------------------------------------------------------
458
// --------------------------------------------------------------
459
 
460
wire [7:0] memld_wroffset,x_mul_wroffset,m_mul_wroffset,r_red_wroffset,
461
                x_exp_wroffset,memst_rdoffset,mmx_mulredexp_rdoffset,nrn_mulredexp_rdoffset,
462
                bnm_mulredexp_rdoffset,aaa_mulredexp_rdoffset,e_exp_rdoffset;
463
 
464
 
465
assign memld_wroffset = spu_maaddr_maaddr_q[7:0];
466
 
467
assign x_mul_wroffset = spu_madp_maaddr_reg[39:32];
468
assign m_mul_wroffset = spu_madp_maaddr_reg[31:24];
469
assign r_red_wroffset = spu_madp_maaddr_reg[23:16];
470
assign x_exp_wroffset = spu_madp_maaddr_reg[31:24];
471
 
472
assign memst_rdoffset = spu_maaddr_maaddr_q[7:0];
473
 
474
assign mmx_mulredexp_rdoffset = spu_madp_maaddr_reg[31:24];
475
assign nrn_mulredexp_rdoffset = spu_madp_maaddr_reg[23:16];
476
assign bnm_mulredexp_rdoffset = spu_madp_maaddr_reg[15:8];
477
assign aaa_mulredexp_rdoffset = spu_madp_maaddr_reg[7:0];
478
assign e_exp_rdoffset = spu_madp_maaddr_reg[39:32];
479
 
480
// --------------- WR INDEX -------------------------------------
481
 
482
wire [7:0] wroffset_a,wroffset_b,wr_offset;
483
wire [7:0] rdoffset_a,rdoffset_b,rd_offset;
484
 
485
wire wr_a_sel = spu_mactl_ldop | spu_mamul_m_wr_oprnd_sel |
486
                spu_mared_x_wr_oprnd_sel;
487
 
488
/******
489
// converting muxes to AO logic to fix 0in problems.
490
mux3ds  #(8) wroffset_a_mx (
491
        .in0    (memld_wroffset[7:0]),
492
        .in1    (x_mul_wroffset[7:0]),
493
        .in2    (m_mul_wroffset[7:0]),
494
        .sel0   (spu_mactl_ldop),
495
        .sel1   (spu_mared_x_wr_oprnd_sel),
496
        .sel2   (spu_mamul_m_wr_oprnd_sel),
497
        .dout   (wroffset_a[7:0])
498
);
499
 
500
mux3ds  #(8) wroffset_b_mx (
501
        .in0    (r_red_wroffset[7:0]),
502
        .in1    (x_exp_wroffset[7:0]),
503
        .in2    (spu_madp_maaddr_reg[15:8]),
504
        .sel0   (spu_mared_r_wr_oprnd_sel),
505
        .sel1   (spu_mared_xe_wr_oprnd_sel),
506
        .sel2   (spu_mamul_me_wr_oprnd_sel),
507
        .dout   (wroffset_b[7:0])
508
);
509
 
510
******/
511
 
512
assign wroffset_a[7:0] =
513
                        (memld_wroffset[7:0] & {8{spu_mactl_ldop}}) |
514
                        (x_mul_wroffset[7:0] & {8{spu_mared_x_wr_oprnd_sel}}) |
515
                        (m_mul_wroffset[7:0] & {8{spu_mamul_m_wr_oprnd_sel}}) ;
516
 
517
assign wroffset_b[7:0] =
518
                        (r_red_wroffset[7:0] & {8{spu_mared_r_wr_oprnd_sel}}) |
519
                        (x_exp_wroffset[7:0] & {8{spu_mared_xe_wr_oprnd_sel}}) |
520
                        (spu_madp_maaddr_reg[15:8] & {8{spu_mamul_me_wr_oprnd_sel}}) ;
521
 
522
 
523
 
524
 
525
mux2ds  #(8) wroffset_mx (
526
        .in0    (wroffset_a[7:0]),
527
        .in1    (wroffset_b[7:0]),
528
        .sel0   (wr_a_sel),
529
        .sel1   (~wr_a_sel),
530
        .dout   (wr_offset[7:0])
531
);
532
 
533
// --------------- RD INDEX -------------------------------------
534
wire [2:0] rd_a_sel;
535
wire [2:0] rd_b_sel;
536
 
537
// sel for store needs to be added
538
wire rd_a_select = spu_mamul_m_rd_oprnd_sel | spu_mamul_n_rd_oprnd_sel |
539
                spu_mared_m_rd_oprnd_sel | spu_mared_nm_rd_oprnd_sel |
540
                spu_mamul_ax_rd_oprnd_sel |
541
                        spu_mast_memren;
542
 
543
assign rd_a_sel[0] = spu_mast_memren;
544
assign rd_a_sel[1] = spu_mamul_m_rd_oprnd_sel | spu_mared_m_rd_oprnd_sel |
545
                        spu_mamul_ax_rd_oprnd_sel ;
546
assign rd_a_sel[2] = spu_mamul_n_rd_oprnd_sel | spu_mared_nm_rd_oprnd_sel;
547
 
548
assign rd_b_sel[0] = spu_mamul_b_rd_oprnd_sel | spu_mared_nr_rd_oprnd_sel |
549
                        spu_mared_me_rd_oprnd_sel | spu_mamul_me_rd_oprnd_sel;
550
assign rd_b_sel[1] = spu_mamul_a_rd_oprnd_sel | spu_mared_a_rd_oprnd_sel |
551
                        spu_mamul_ba_rd_oprnd_sel;
552
assign rd_b_sel[2] = spu_maexp_e_rd_oprnd_sel;
553
 
554
 
555
/***************
556
mux3ds  #(8) rdoffset_a_mx (
557
        .in0    (memst_rdoffset[7:0]),
558
        .in1    (mmx_mulredexp_rdoffset[7:0]),
559
        .in2    (nrn_mulredexp_rdoffset[7:0]),
560
        .sel0   (rd_a_sel[0]),
561
        .sel1   (rd_a_sel[1]),
562
        .sel2   (rd_a_sel[2]),
563
        .dout   (rdoffset_a[7:0])
564
);
565
 
566
mux3ds  #(8) rdoffset_b_mx (
567
        .in0    (bnm_mulredexp_rdoffset[7:0]),
568
        .in1    (aaa_mulredexp_rdoffset[7:0]),
569
        .in2    (e_exp_rdoffset[7:0]),
570
        .sel0   (rd_b_sel[0]),
571
        .sel1   (rd_b_sel[1]),
572
        .sel2   (rd_b_sel[2]),
573
        .dout   (rdoffset_b[7:0])
574
);
575
****************/
576
 
577
assign rdoffset_a[7:0] =
578
                        (memst_rdoffset[7:0] & {8{rd_a_sel[0]}}) |
579
                        (mmx_mulredexp_rdoffset[7:0] & {8{rd_a_sel[1]}}) |
580
                        (nrn_mulredexp_rdoffset[7:0] & {8{rd_a_sel[2]}}) ;
581
 
582
assign rdoffset_b[7:0] =
583
                        (bnm_mulredexp_rdoffset[7:0] & {8{rd_b_sel[0]}}) |
584
                        (aaa_mulredexp_rdoffset[7:0] & {8{rd_b_sel[1]}}) |
585
                        (e_exp_rdoffset[7:0] & {8{rd_b_sel[2]}}) ;
586
 
587
 
588
 
589
 
590
mux2ds  #(8) rdoffset_mx (
591
        .in0    (rdoffset_a[7:0]),
592
        .in1    (rdoffset_b[7:0]),
593
        .sel0   (rd_a_select),
594
        .sel1   (~rd_a_select),
595
        .dout   (rd_offset[7:0])
596
);
597
 
598
 
599
// --------------------------------------------------------------
600
 
601
// spu_mamul_memwen is true when m[i] operand is updated.
602
wire mem_wr_op = spu_mactl_ldop | spu_mamul_memwen | spu_mared_memwen |
603
                                spu_maaeqb_memwen;
604
 
605
wire [7:0] memoffset;
606
 
607
mux2ds  #(8) memoffset_rd_wr (
608
        .in0    (wr_offset[7:0]),
609
        .in1    (rd_offset[7:0]),
610
        .sel0   (mem_wr_op),
611
        .sel1   (~mem_wr_op),
612
        .dout   (memoffset[7:0])
613
);
614
 
615
 
616
// --------------------------------------------------------------
617
// --------------------------------------------------------------
618
// --------------------------------------------------------------
619
// --------------------------------------------------------------
620
// --------------------------------------------------------------
621
 
622
wire [6:0] j_ptr,j_ptr_add;
623
wire [5:0] len;
624
wire [6:0] twolen,lenplus1,twolenplus2,iminus1_rshft,i_rshft,
625
                twolenplus1,iminus1_ptr,iminus_len,i_ptr_add,i_ptr;
626
 
627
wire i_equ_lenplus1,j_equ_iminus1rshft,
628
                j_equ_iminus1,
629
                i_ptr_rst;
630
 
631
//wire i_equ_zero;
632
 
633
 
634
// --------------------------------------------------------------
635
// --------------------------------------------------------------
636
// --------------------------------------------------------------
637
// ------------ FINAL ADDER & ADDVAL MUX FOR MEMINDEX -----------
638
// --------------------------------------------------------------
639
// --------------------------------------------------------------
640
// --------------------------------------------------------------
641
wire [6:0] jj_ptr;
642
wire [6:0] e_ptr;
643
wire [6:0] j_ptr_redwr_val;
644
 
645
wire [6:0] add_val,addval_a,addval_b;
646
wire [6:0] iminusj_ptr,iminus1_lenminus1;
647
 
648
wire add_a_sel = spu_mamul_iminuslenminus1_sel |
649
                        spu_mamul_iminus1_ptr_sel |
650
                        spu_mamul_i_ptr_sel | spu_maaeqb_irshft_sel;
651
 
652
wire mulred_j_ptr_sel = spu_mamul_j_ptr_sel | spu_mared_j_ptr_sel;
653
wire add_b_sel = mulred_j_ptr_sel | spu_mamul_iminusj_ptr_sel |
654
                                spu_maexp_e_rd_oprnd_sel | spu_mared_memwen;
655
 
656
//wire add_c_sel = ~(add_a_sel | add_b_sel);
657
 
658
/*****
659
mux4ds  #(7) addval_a_mux (
660
        .in0    (iminus1_lenminus1[6:0]),
661
        .in1    (iminus1_ptr[6:0]),
662
        .in2    (i_rshft[6:0]),
663
        .in3    (i_ptr[6:0]),
664
        .sel0   (spu_mamul_iminuslenminus1_sel),
665
        .sel1   (spu_mamul_iminus1_ptr_sel),
666
        .sel2   (spu_maaeqb_irshft_sel),
667
        .sel3   (spu_mamul_i_ptr_sel),
668
        .dout   (addval_a[6:0])
669
);
670
 
671
*******/
672
 
673
assign addval_a[6:0] =
674
                        (iminus1_lenminus1[6:0] & {7{spu_mamul_iminuslenminus1_sel}}) |
675
                        (iminus1_ptr[6:0] & {7{spu_mamul_iminus1_ptr_sel}}) |
676
                        (i_rshft[6:0] & {7{spu_maaeqb_irshft_sel}}) |
677
                        (i_ptr[6:0] & {7{spu_mamul_i_ptr_sel}}) ;
678
 
679
/******
680
mux4ds  #(7) addval_b_mux (
681
        .in0    (jj_ptr[6:0]),
682
        .in1    (iminusj_ptr[6:0]),
683
        .in2    (e_ptr[6:0]),
684
        .in3    (j_ptr_redwr_val[6:0]),
685
        .sel0   (mulred_j_ptr_sel),
686
        .sel1   (spu_mamul_iminusj_ptr_sel),
687
        .sel2   (spu_maexp_e_rd_oprnd_sel),
688
        .sel3   (spu_mared_memwen),
689
        .dout   (addval_b[6:0])
690
);
691
**********/
692
 
693
assign addval_b[6:0] =
694
                        (jj_ptr[6:0] & {7{mulred_j_ptr_sel}}) |
695
                        (iminusj_ptr[6:0] & {7{spu_mamul_iminusj_ptr_sel}}) |
696
                        (e_ptr[6:0] & {7{spu_maexp_e_rd_oprnd_sel}}) |
697
                        (j_ptr_redwr_val[6:0] & {7{spu_mared_memwen}}) ;
698
 
699
 
700
/*******
701
mux3ds  #(7) addval_mux (
702
        .in0    (addval_a[6:0]),
703
        .in1    (addval_b[6:0]),
704
        .in2    (7'b0000000),
705
        .sel0   (add_a_sel),
706
        .sel1   (add_b_sel),
707
        .sel2   (add_c_sel),
708
        .dout   (add_val[6:0])
709
);
710
 
711
********/
712
 
713
assign add_val[6:0] =
714
                        (addval_a[6:0] & {7{add_a_sel}}) |
715
                        (addval_b[6:0] & {7{add_b_sel}}) ;
716
 
717
wire spu_maaddr_memindx_0;
718
assign {spu_maaddr_memindx[7:1],spu_maaddr_memindx_0} = {1'b0,add_val[6:0]} + memoffset[7:0];
719
 
720
 
721
assign spu_maaddr_wrindx_0 = wr_offset[0] + add_val[0];
722
 
723
 
724
// ----------------------
725
// check for out of range
726
// ----------------------
727
wire spu_maaddr_memindx_outofrange_q;
728
 
729
wire spu_maaddr_memindx_outofrange = (spu_maaddr_memindx[7] & spu_maaddr_memindx[6]) |
730
                                        (spu_maaddr_memindx[7] & spu_maaddr_memindx[5]) ;
731
 
732
 
733
wire spu_maaddr_memindx_outofrange_sehold = sehold ? spu_maaddr_memindx_outofrange_q :
734
                                                        spu_maaddr_memindx_outofrange;
735
 
736
dff_s #(1) spu_maaddr_memindx_outofrange_ff (
737
        .din(spu_maaddr_memindx_outofrange_sehold) ,
738
        .q(spu_maaddr_memindx_outofrange_q),
739
        .clk (rclk), .se(1'b0),.si (),.so ()
740
        );
741
 
742
// ----------------------
743
wire spu_maaddr_memindx_0_q;
744
 
745
wire spu_maaddr_memindx_0_sehold = sehold ? spu_maaddr_memindx_0_q :
746
                                                spu_maaddr_memindx_0;
747
 
748
dff_s #(1) mem_indx_0_ff (
749
        .din(spu_maaddr_memindx_0_sehold) ,
750
        .q(spu_maaddr_memindx_0_q),
751
        .clk (rclk), .se(1'b0),.si (),.so ()
752
        );
753
 
754
wire [3:0] spu_maaddr_mamem_eveodd_sel;
755
assign spu_maaddr_mamem_eveodd_sel[0] = ~(mem_bypass | spu_maaddr_memindx_outofrange_q) & ~spu_maaddr_memindx_0_q;
756
assign spu_maaddr_mamem_eveodd_sel[1] = ~(mem_bypass | spu_maaddr_memindx_outofrange_q) & spu_maaddr_memindx_0_q;
757
assign spu_maaddr_mamem_eveodd_sel[2] = ~mem_bypass & spu_maaddr_memindx_outofrange_q;
758
assign spu_maaddr_mamem_eveodd_sel[3] =  mem_bypass;
759
 
760
assign spu_maaddr_mamem_eveodd_sel_l = ~spu_maaddr_mamem_eveodd_sel;
761
 
762
// --------------------------------------------------------
763
// --------------------------------------------------------
764
// --------------------------------------------------------
765
// --------------------------------------------------------
766
// --------------------------------------------------------
767
// ---------------- POINTERS ------------------------------
768
// --------------------------------------------------------
769
// --------------------------------------------------------
770
// --------------------------------------------------------
771
// --------------------------------------------------------
772
 
773
 
774
// ---------------------------------------------------------------
775
 
776
assign len[5:0] = spu_madp_mactl_reg[5:0];
777
assign twolen[6:0] = {spu_madp_mactl_reg[5],spu_madp_mactl_reg[4],
778
                    spu_madp_mactl_reg[3],spu_madp_mactl_reg[2],
779
                    spu_madp_mactl_reg[1],spu_madp_mactl_reg[0],1'b0};
780
assign lenplus1[6:0] = {1'b0,spu_madp_mactl_reg[5:0]} + 7'b0000001;
781
//assign lenminus1[5:0] = spu_madp_mactl_reg[5:0] - 1'b1;
782
assign twolenplus1[6:0] = twolen[6:0] + 7'b0000001;
783
assign twolenplus2[6:0] = twolen[6:0] + 7'b0000010;
784
 
785
 
786
 
787
assign iminus1_rshft[6:0] = {1'b0,iminus1_ptr[6],iminus1_ptr[5],
788
                                iminus1_ptr[4],iminus1_ptr[3],
789
                                iminus1_ptr[2],iminus1_ptr[1]};
790
 
791
assign i_rshft[6:0] = {1'b0,i_ptr[6],i_ptr[5],i_ptr[4],i_ptr[3],
792
                                i_ptr[2],i_ptr[1]};
793
 
794
// ---------------------------------------------------------------
795
// ---------------------------------------------------------------
796
// start pointer comparisons.
797
// ---------------------------------------------------------------
798
 
799
//assign i_equ_len = (i_ptr_add[6:0] == {1'b0,len[5:0]}); 
800
assign i_equ_lenplus1 = (i_ptr[6:0] == lenplus1[6:0]);
801
 
802
wire i_equ_twolenplus2_pre = (i_ptr_add[6:0] == twolenplus2[6:0]);
803
wire i_equ_twolenplus1_pre = (i_ptr_add[6:0] == twolenplus1[6:0]);
804
 
805
wire i_equ_twolen_pre = (i_ptr_add[6:0] == twolen[6:0]);
806
wire i_equ_zero_pre = (i_ptr[6:0] == 7'b0000000);
807
 
808
assign j_equ_iminus1rshft = (j_ptr[6:0] == iminus1_rshft[6:0]);
809
//assign j_equ_iminuslen = (j_ptr[6:0] == iminus_len[6:0]); 
810
assign j_equ_iminus1 = (j_ptr[6:0] == iminus1_ptr[6:0]);
811
//wire j_equ_iminus1_pre = (j_ptr_data[6:0] == i_ptr[6:0]); 
812
wire j_equ_len_pre = (j_ptr_data[6:0] == {1'b0,len[5:0]});
813
 
814
//assign spu_maaddr_iequtwolenplus2 = i_equ_twolenplus2;
815
//assign spu_maaddr_iequtwolenplus1 = i_equ_twolenplus1;
816
//assign spu_maaddr_iequtwolen = i_equ_twolen_pre;
817
 
818
//assign spu_maaddr_jequiminus1 = j_equ_iminus1;
819
//assign spu_maaddr_jequlen = j_equ_len;
820
//assign spu_maaddr_jequiminus1rshft = j_equ_iminus1rshft;
821
 
822
assign spu_maaddr_ieq0 = i_equ_zero_pre;
823
assign spu_maaddr_ieven = ~i_ptr[0];
824
 
825
// ***************************************************************
826
// start of pointers
827
// ***************************************************************
828
// ---------------------------------------------------------------
829
 
830
wire rst_halfpnt,halfpnt_set;
831
 
832
//assign rst_halfpnt = reset_local | spu_mamul_rst_iptr | ~spu_mactl_mulop;
833
assign rst_halfpnt = reset_local | spu_mamul_rst_iptr | spu_mamul_rst ;
834
 
835
dffre_s  #(1) halfpnt_ff (
836
        .din(1'b1) ,
837
        .q(halfpnt_set),
838
        .en(i_equ_lenplus1),
839
        .rst(rst_halfpnt), .clk (rclk), .se(se), .si(), .so());
840
 
841
assign spu_maaddr_halfpnt_set = halfpnt_set ;
842
 
843
 
844
// --------------------
845
 
846
wire halfpnt_set_pulse,halfpnt_set_q;
847
 
848
dff_s  #(1) halfpnt_set_pulse_ff (
849
        .din(halfpnt_set) ,
850
        .q(halfpnt_set_q),
851
        .clk (rclk), .se(se), .si(), .so());
852
 
853
assign halfpnt_set_pulse = ~halfpnt_set_q & halfpnt_set;
854
 
855
// ---------------------------------------------------------------
856
// J pointer (used for mamul and mared)
857
// ---------------------------------------------------------------
858
 
859
wire [6:0] jj_ptr_val;
860
wire [2:0] jptr_rst_sel;
861
 
862
wire j_ptr_wen = (spu_mamul_incr_jptr | spu_mamul_rst_jptr | halfpnt_set_pulse) |
863
                 (spu_mared_update_jptr | spu_mared_rst_jptr) |
864
                         spu_mared_start_wen;
865
 
866
 
867
// in the case of mamul we need to incr and for mared we
868
// need to start from msw and decr, and if we find that M is
869
// greater than N then we need to start from 0 and incr.
870
 
871
wire carryin = spu_mared_cin_set_4sub;
872
 
873
wire [6:0] incr_decr_val;
874
mux2ds  #(7) incr_decr_val_mx2 (
875
        .in0    (7'b1111110),
876
        .in1    (7'b0000001),
877
        .sel0   (carryin),
878
        .sel1   (~carryin),
879
        .dout   (incr_decr_val[6:0])
880
);
881
 
882
 
883
assign j_ptr_add[6:0] = j_ptr[6:0] + incr_decr_val[6:0] + {6'b000000,carryin};
884
 
885
wire jptr_eqz_pre = ~(|j_ptr_data[6:0]);
886
 
887
wire jptr_eqz_q;
888
wire spu_maaddr_jequlen_q;
889
 
890
dffre_s  #(7) j_ptr_ff (
891
        .din(j_ptr_data[6:0]) ,
892
        .q(j_ptr[6:0]),
893
        .en(j_ptr_wen),
894
        .rst(reset_local), .clk (rclk), .se(se), .si(), .so());
895
 
896
dffre_s  #(2) j_ptr_b_ff (
897
        .din({jptr_eqz_pre, j_equ_len_pre}) ,
898
        .q({jptr_eqz_q, spu_maaddr_jequlen_q}),
899
        .en(j_ptr_wen),
900
        .rst(reset_local), .clk (rclk), .se(se), .si(), .so());
901
 
902
assign spu_maaddr_jequlen = spu_maaddr_jequlen_q;
903
 
904
assign spu_maaddr_jptr_eqz_mared = jptr_eqz_q;
905
 
906
//assign spu_maaddr_jptr_eqz = ~(|j_ptr[6:0]);
907
 
908
/*
909
assign jptr_rst_sel[0] = (spu_mamul_rst_jptr & spu_maaddr_halfpnt_set) | halfpnt_set_pulse ;
910
assign jptr_rst_sel[1] = (spu_mamul_rst_jptr & ~spu_maaddr_halfpnt_set) | spu_mared_rst_jptr;
911
assign jptr_rst_sel[2] = ~(halfpnt_set_pulse | spu_mamul_rst_jptr | spu_mared_rst_jptr |
912
                                spu_mared_start_sel);
913
assign jptr_rst_sel[3] =  spu_mared_start_sel;
914
*/
915
 
916
assign jptr_rst_sel[0] = (spu_mamul_rst_jptr & spu_maaddr_halfpnt_set) | halfpnt_set_pulse ;
917
assign jptr_rst_sel[1] = ~(halfpnt_set_pulse | spu_mamul_rst_jptr | spu_mared_rst_jptr |
918
                                spu_mared_start_sel);
919
assign jptr_rst_sel[2] =  spu_mared_start_sel;
920
 
921
/*
922
mux3ds  #(7) jptr_rst_mux (
923
        .in0    (iminus_len[6:0]),
924
        .in1    (7'b0000000),
925
        .in2    (j_ptr_add[6:0]),
926
        .sel0   (jptr_rst_sel[0]),
927
        .sel1   (jptr_rst_sel[1]),
928
        .sel2   (jptr_rst_sel[2]),
929
        .dout   (j_ptr_data[6:0])
930
);*/
931
 
932
/*********
933
mux4ds  #(7) jptr_rst_mux (
934
        .in0    (iminus_len[6:0]),
935
        .in1    (7'b0000000),
936
        .in2    (j_ptr_add[6:0]),
937
        .in3    ({1'b0,spu_madp_mactl_reg[5:0]}),//when mared op starts,load the LEN into jptr.
938
        .sel0   (jptr_rst_sel[0]),
939
        .sel1   (jptr_rst_sel[1]),
940
        .sel2   (jptr_rst_sel[2]),
941
        .sel3   (jptr_rst_sel[3]),
942
        .dout   (j_ptr_data[6:0])
943
);
944
************/
945
 
946
assign j_ptr_data[6:0] =
947
                        (iminus_len[6:0] & {7{jptr_rst_sel[0]}}) |
948
                        (j_ptr_add[6:0] & {7{jptr_rst_sel[1]}}) |
949
                        ({1'b0,spu_madp_mactl_reg[5:0]} & {7{jptr_rst_sel[2]}}) ;
950
 
951
wire jj_ptr_update = spu_mamul_jjptr_wen | spu_mared_jjptr_wen;
952
dffre_s  #(7) jj_ptr_ff (
953
        .din(j_ptr_add[6:0]) ,
954
        .q(jj_ptr_val[6:0]),
955
        .en(jj_ptr_update),
956
        .rst(reset_local), .clk (rclk), .se(se), .si(), .so());
957
 
958
//wire jptr_oldnew_sel = spu_mamul_incr_jptr | spu_mared_update_jptr;
959
wire jptr_oldnew_sel = spu_mamul_jjptr_sel | spu_mared_update_jptr;
960
mux2ds  #(7) jptr_oldnew_mx2 (
961
        .in0    (jj_ptr_val[6:0]),
962
        .in1    (j_ptr[6:0]),
963
        .sel0   (jptr_oldnew_sel),
964
        .sel1   (~jptr_oldnew_sel),
965
        .dout   (jj_ptr[6:0])
966
);
967
 
968
 
969
dffre_s  #(7) j_ptr_redwr_ff (
970
        .din(j_ptr[6:0]) ,
971
        .q(j_ptr_redwr_val[6:0]),
972
        .en(spu_mared_update_redwr_jptr),
973
        .rst(reset_local), .clk (rclk), .se(se), .si(), .so());
974
 
975
// ----------------------
976
//saving the jptr this will be the maxlen
977
// for the mared subtract count.
978
wire [6:0] maxlen;
979
dffre_s  #(7) maxlen_ff (
980
        .din(j_ptr[6:0]) ,
981
        .q(maxlen[6:0]),
982
        .en(spu_mared_maxlen_wen),
983
        .rst(reset_local), .clk (rclk), .se(se), .si(), .so());
984
 
985
//assign spu_maaddr_len_eqmax = (j_ptr[6:0] == maxlen[6:0]);
986
wire spu_maaddr_len_eqmax_pre = (j_ptr_data[6:0] == maxlen[6:0]);
987
 
988
 
989
dffre_s  #(1) len_eqmax_ff (
990
        .din(spu_maaddr_len_eqmax_pre) ,
991
        .q(spu_maaddr_len_eqmax),
992
        .en(j_ptr_wen),
993
        .rst(reset_local), .clk (rclk), .se(se), .si(), .so());
994
 
995
 
996
// ---------------------------------------------------------------
997
// I pointer 
998
// ---------------------------------------------------------------
999
 
1000
assign i_ptr_rst = reset_local | spu_mamul_rst_iptr;
1001
 
1002
assign i_ptr_add[6:0] = i_ptr[6:0] + 7'b0000001;
1003
 
1004
dffre_s  #(7) i_ptr_ff (
1005
        .din(i_ptr_add[6:0]) ,
1006
        .q(i_ptr[6:0]),
1007
        .en(spu_mamul_incr_iptr),
1008
        .rst(i_ptr_rst), .clk (rclk), .se(se), .si(), .so());
1009
 
1010
dffre_s  #(7) iminus1_ptr_ff (
1011
        .din(i_ptr[6:0]) ,
1012
        .q(iminus1_ptr[6:0]),
1013
        .en(spu_mamul_incr_iptr),
1014
        .rst(reset_local), .clk (rclk), .se(se), .si(), .so());
1015
 
1016
 
1017
wire spu_maaddr_jequiminus1_q;
1018
wire spu_maaddr_jequiminus1rshft_q;
1019
dffre_s  #(2) j_equ_iminus1_ff (
1020
        .din({j_equ_iminus1, j_equ_iminus1rshft}) ,
1021
        .q({spu_maaddr_jequiminus1_q, spu_maaddr_jequiminus1rshft_q}),
1022
        .en(1'b1),
1023
        .rst(reset_local), .clk (rclk), .se(se), .si(), .so());
1024
 
1025
assign spu_maaddr_jequiminus1 = spu_maaddr_jequiminus1_q;
1026
assign spu_maaddr_jequiminus1rshft = spu_maaddr_jequiminus1rshft_q;
1027
 
1028
 
1029
        // added this to fix timing path.
1030
dffre_s  #(3) i_equ_stuff_pre_ff (
1031
        .din({i_equ_twolenplus2_pre,i_equ_twolenplus1_pre,i_equ_twolen_pre}) ,
1032
        .q({spu_maaddr_iequtwolenplus2,spu_maaddr_iequtwolenplus1,spu_maaddr_iequtwolen}),
1033
        .en(spu_mamul_incr_iptr),
1034
        .rst(i_ptr_rst), .clk (rclk), .se(se), .si(), .so());
1035
 
1036
// ---------------------------------------------------------------
1037
// I-J pointer 
1038
// ---------------------------------------------------------------
1039
 
1040
wire [6:0] iminusj_ptr_pre;
1041
assign iminusj_ptr_pre[6:0] = i_ptr[6:0] + ~jj_ptr[6:0] + 7'b0000001;
1042
 
1043
dff_s  #(7) iminusj_ff (
1044
        .din(iminusj_ptr_pre[6:0]) ,
1045
        .q(iminusj_ptr[6:0]),
1046
        .clk (rclk), .se(se), .si(), .so());
1047
 
1048
// assign iminusj_ptr = iminusj_ptr_pre;
1049
 
1050
// ---------------------------------------------------------------
1051
// I-LEN-1 pointer 
1052
// ---------------------------------------------------------------
1053
 
1054
// assign iminus_lenminus1 = i_ptr[6:0] + {1'b1,~lenminus1[5:0]} + 1'b1;
1055
//assign iminus_lenminus1[6:0] = (i_ptr[6:0] + {1'b1,~len[5:0]} + 1'b1) - 1'b1;
1056
assign iminus1_lenminus1[6:0] = (iminus1_ptr[6:0] + {1'b1,~len[5:0]} + 7'b0000001) -
1057
                                                        7'b0000001;
1058
 
1059
// ---------------------------------------------------------------
1060
// I-LEN pointer
1061
// ---------------------------------------------------------------
1062
 
1063
assign iminus_len[6:0] = i_ptr[6:0] + {1'b1,~len[5:0]} + 7'b0000001;
1064
 
1065
// ---------------------------------------------------------------
1066
 
1067
/*
1068
always @(posedge clk) begin
1069
 
1070
$display ("%t iminus1_ptr",$time);
1071
end
1072
*/
1073
 
1074
// ---------------------------------------------------------------
1075
// ---------------------------------------------------------------
1076
// --------------------- MA EXP ----------------------------------
1077
// ---------------------------------------------------------------
1078
// ---------------------------------------------------------------
1079
 
1080
// ---------------------------------------------------------------
1081
// ^^^^^^^^^^^^^^ ES COUNTER ^^^^^^^^^^^
1082
// ---------------------------------------------------------------
1083
 
1084
wire [10:0] es_add,es_ptr;
1085
 
1086
assign es_add = es_ptr  + 11'b00000000001;
1087
 
1088
dffre_s  #(11) es_ptr_ff (
1089
        .din(es_add[10:0]) ,
1090
        .q(es_ptr[10:0]),
1091
        .en(spu_maexp_incr_es_ptr),
1092
        .rst(spu_maexp_es_e_ptr_rst), .clk (rclk), .se(se), .si(), .so());
1093
 
1094
// ---------------------------------------------------------------
1095
// ^^^^^^^^^ ES_MAX_MINUS1 & COMPARE ^^^^^^^^^
1096
// ---------------------------------------------------------------
1097
wire [10:0] es_max_minus1_q,es_max_minus1;
1098
//wire [8:0] es_max_plus1;
1099
wire [7:0] es_max_plus1;
1100
 
1101
//assign es_max_plus1[8:0] = {1'b0,spu_madp_maaddr_reg[47:40]} + 9'b000000001;
1102
assign es_max_plus1[7:0] = spu_madp_maaddr_reg[47:40] + 8'b00000001;
1103
 
1104
// vlint error:left size: 11,  right size: 12
1105
//assign es_max_minus1[10:0] = {es_max_plus1[8:0],3'b000} - 11'b00000000001;
1106
assign es_max_minus1[10:0] = {es_max_plus1[7:0],3'b000} - 11'b00000000001;
1107
 
1108
dffre_s  #(11) esmax_minus1_ptr_ff (
1109
        .din(es_max_minus1[10:0]) ,
1110
        .q(es_max_minus1_q[10:0]),
1111
        .en(spu_maexp_es_max_init),//save es_max at start of maexp_op
1112
        .rst(spu_maexp_es_e_ptr_rst), .clk (rclk), .se(se), .si(), .so());
1113
 
1114
assign spu_maaddr_esmax = (es_max_minus1_q[10:0] == es_ptr[10:0]);
1115
 
1116
 
1117
// ---------------------------------------------------------------
1118
// ^^^^^^^^^^^^^^ MOD64 CHECK ^^^^^^^^^^^
1119
// ---------------------------------------------------------------
1120
 
1121
wire max_mod64_reached;
1122
wire max_mod64_reached_q;
1123
wire max_mod64_reached_pulse;
1124
 
1125
 
1126
assign max_mod64_reached = &es_ptr[5:0];
1127
 
1128
assign spu_maaddr_esmod64 = max_mod64_reached;
1129
 
1130
dff_s  #(1) mod64_pulse_ff (
1131
        .din(max_mod64_reached) ,
1132
        .q(max_mod64_reached_q),
1133
        .clk (rclk), .se(se), .si(), .so());
1134
 
1135
assign max_mod64_reached_pulse = ~max_mod64_reached_q & max_mod64_reached;
1136
 
1137
// ---------------------------------------------------------------
1138
// ^^^^^^^^^^^^^^ E PTR ^^^^^^^^^^^
1139
// ---------------------------------------------------------------
1140
// E ptr 
1141
wire [6:0] e_add;
1142
 
1143
assign e_add = e_ptr + 7'b0000001;
1144
 
1145
dffre_s  #(7) e_ptr_ff (
1146
        .din(e_add[6:0]) ,
1147
        .q(e_ptr[6:0]),
1148
        .en(max_mod64_reached_pulse),
1149
        .rst(spu_maexp_es_e_ptr_rst), .clk (rclk), .se(se), .si(), .so());
1150
 
1151
 
1152
endmodule
1153
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.