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

Subversion Repositories sparc64soc

[/] [sparc64soc/] [trunk/] [T1-CPU/] [spu/] [spu_madp.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_madp.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:    MA datapath .
24
*/
25
////////////////////////////////////////////////////////////////////////
26
 
27
//FPGA_SYN enables all FPGA related modifications
28
`ifdef FPGA_SYN
29
`define FPGA_SYN_CLK_EN
30
`define FPGA_SYN_CLK_DFF
31
`endif
32
 
33
module spu_madp (
34
 
35
/*outputs*/
36
spu_madp_evedata,
37
spu_madp_odddata,
38
 
39
spu_mul_op2_data,
40
 
41
spu_madp_m_lt_n,
42
spu_madp_m_eq_n,
43
 
44
spu_madp_store_data,
45
 
46
spu_madp_cout_oprnd_sub_mod,
47
 
48
spu_madp_e_eq_one,
49
 
50
spu_madp_mpa_addr_out,
51
 
52
spu_madp_perr,
53
 
54
so,
55
 
56
spu_mul_op1_data,
57
 
58
spu_madp_maaddr_reg,
59
 
60
spu_madp_ldxa_data,
61
 
62
/*inputs*/
63
 
64
spu_mamul_oprnd2_wen,
65
spu_mamul_oprnd2_bypass,
66
 
67
mul_data_out,
68
 
69
spu_mared_data_sel_l,
70
spu_mared_rdn_wen,
71
spu_mared_cin_oprnd_sub_mod,
72
 
73
spu_maexp_e_data_wen,
74
spu_maexp_shift_e,
75
 
76
spu_maaddr_mpa_incr_val,
77
spu_maaddr_mpa_wen,
78
spu_maaddr_mpa_addrinc,
79
spu_mactl_mpa_sel,
80
 
81
spu_mactl_ldop,
82
spu_mactl_madp_parflop_wen,
83
 
84
spu_mactl_memmxsel_l,
85
 
86
spu_mactl_force_perr,
87
 
88
spu_mamem_rd_eve_data,
89
spu_mamem_rd_odd_data,
90
 
91
spu_mamul_oprnd1_mxsel_l,
92
spu_maaddr_mamem_eveodd_sel_l,
93
spu_mamul_oprnd1_wen,
94
 
95
exu_spu_st_rs3_data_g2,
96
 
97
lsu_spu_vload_data,
98
spu_mactl_mactl_reg,
99
spu_wen_maln_wen,
100
spu_mactl_mpa_wen,
101
spu_mactl_maaddr_wen,
102
spu_mactl_manp_wen,
103
 
104
spu_mactl_ldxa_data_w_sel_l,
105
spu_mactl_ldxa_data_w_select,
106
 
107
se,
108
si,
109
sehold,
110
 
111
rclk);
112
 
113
// ---------------------------------------------------------
114
 
115
input rclk;
116
 
117
 
118
input spu_mamul_oprnd2_wen;
119
input spu_mamul_oprnd2_bypass;
120
 
121
input [63:0] mul_data_out;
122
 
123
input [3:0] spu_mared_data_sel_l;
124
input spu_mared_rdn_wen;
125
input spu_mared_cin_oprnd_sub_mod;
126
 
127
input spu_maexp_e_data_wen;
128
input spu_maexp_shift_e;
129
 
130
input [4:0] spu_maaddr_mpa_incr_val;
131
input spu_maaddr_mpa_wen;
132
input spu_maaddr_mpa_addrinc;
133
input spu_mactl_mpa_sel;
134
 
135
input spu_mactl_ldop;
136
input spu_mactl_madp_parflop_wen;
137
 
138
input [2:0] spu_mactl_memmxsel_l;
139
 
140
 
141
input spu_mactl_force_perr;
142
input spu_wen_maln_wen;
143
input spu_mactl_mpa_wen;
144
input spu_mactl_maaddr_wen;
145
input spu_mactl_manp_wen;
146
 
147
input [3:0] spu_mactl_ldxa_data_w_sel_l;
148
input spu_mactl_ldxa_data_w_select;
149
 
150
input se;
151
input si;
152
input sehold;
153
 
154
input [65:0] spu_mamem_rd_eve_data;
155
input [65:0] spu_mamem_rd_odd_data;
156
 
157
input [2:0] spu_mamul_oprnd1_mxsel_l;
158
input [3:0] spu_maaddr_mamem_eveodd_sel_l;
159
input spu_mamul_oprnd1_wen;
160
 
161
 
162
input [63:0] exu_spu_st_rs3_data_g2;
163
 
164
input [13:0] spu_mactl_mactl_reg;
165
input [127:0] lsu_spu_vload_data;
166
// ---------------------------------------------------------
167
 
168
output [65:0] spu_madp_evedata;
169
output [65:0] spu_madp_odddata;
170
 
171
output [63:0] spu_mul_op2_data;
172
 
173
output spu_madp_m_lt_n;
174
output spu_madp_m_eq_n;
175
 
176
output spu_madp_cout_oprnd_sub_mod;
177
 
178
output [63:0] spu_madp_store_data;
179
 
180
 
181
output spu_madp_e_eq_one;
182
 
183
output [38:3] spu_madp_mpa_addr_out;
184
 
185
output spu_madp_perr;
186
 
187
output so;
188
 
189
output [63:0] spu_mul_op1_data;
190
 
191
output [47:0] spu_madp_maaddr_reg;
192
 
193
output [63:0] spu_madp_ldxa_data;
194
 
195
// ---------------------------------------------------------
196
// ---------------------------------------------------------
197
 
198
wire [47:0] spu_madp_maaddr_reg_int;
199
wire [39:0] spu_madp_mpa_addr;
200
 
201
wire [63:0] spu_madp_oprnd2_data;
202
wire [64:0] oprand_minus_modulus_or_mpa;
203
wire [63:0] spu_madp_modulus;
204
//wire [63:0] spu_madp_modulus_b;
205
wire [63:0] spu_madp_mpa_or_m,spu_madp_mpa_or_n_b;
206
wire [39:0] spu_madp_mpa_mx;
207
wire carry_out;
208
wire [63:0] mulorred_data;
209
wire [63:0] spu_madp_exp_e_data,spu_madp_exp_e_data_q;
210
wire [63:0] mulorred_data_q;
211
wire [63:0] mul_ldlower_data_mx;
212
wire [1:0] mul_ldlower_data_par;
213
wire [1:0] mem_ldupper_data_par;
214
wire [1:0] mul_ldlower_data_par_pre;
215
wire [1:0] mem_ldupper_data_par_pre;
216
wire [63:0] mem_ldupper_data_mx;
217
wire [65:0] spu_madp_odddata_mx;
218
wire [63:0] spu_madp_mem_rd_data;
219
wire [65:0] spu_madp_evedata_mx;
220
 
221
 
222
wire [65:0] spu_mamem_rd_data_unbuf;
223
wire [63:0] spu_mamem_rd_data;
224
 
225
wire [1:0] spu_madp_rdmem_pargen;
226
 
227
wire [38:3] spu_madp_mpa_reg;
228
wire [63:0] spu_madp_manp_reg;
229
wire [63:0] spu_madp_lnupper_data;
230
wire [63:0] spu_madp_lnlower_data;
231
 
232
// ---------------------------------------------------------
233
// ---------------------------------------------------------
234
// ---------------------------------------------------------
235
 
236
wire testmode_l = ~se;
237
 
238
// ---------------------------------------------------------
239
// ---------------------------------------------------------
240
// ---------------------------------------------------------
241
// ---------------------------------------------------------
242
// Arrange the parity bits accordingly 
243
wire [63:0] read_data_q;
244
wire [1:0] spu_madp_par_data;
245
 
246
 
247
dp_mux4ds #(66) mamem_rd_data_mx (
248
        .in0    (spu_mamem_rd_eve_data[65:0]),
249
        .in1    (spu_mamem_rd_odd_data[65:0]),
250
        .in2    ({2'b11,64'h0000000000000000}),
251
        .in3    ({spu_madp_par_data[1:0],read_data_q[63:0]}),// added for dft to test downstream logic.
252
        .sel0_l (spu_maaddr_mamem_eveodd_sel_l[0]),
253
        .sel1_l (spu_maaddr_mamem_eveodd_sel_l[1]),
254
        .sel2_l (spu_maaddr_mamem_eveodd_sel_l[2]),
255
        .sel3_l (spu_maaddr_mamem_eveodd_sel_l[3]),
256
        .dout   (spu_mamem_rd_data_unbuf[65:0]));
257
 
258
assign spu_mamem_rd_data[63:0] = spu_mamem_rd_data_unbuf[63:0];// used internal decouple from critical path
259
                                                                // make sure its buffered buf_x10 not critical
260
 
261
 
262
wire mem_rddata_clk;
263
`ifdef FPGA_SYN_CLK_EN
264
`else
265
clken_buf mem_rddata_lcd (.clk(mem_rddata_clk), .rclk(rclk),
266
                         .enb_l(~spu_mamul_oprnd1_wen), .tmb_l(testmode_l));
267
`endif
268
 
269
`ifdef FPGA_SYN_CLK_DFF
270
dffe_s #(64) mem_rddata_ff (
271
        .din(spu_mamem_rd_data_unbuf[63:0]) ,
272
        .q(read_data_q[63:0]),
273
        .en (~(~spu_mamul_oprnd1_wen)), .clk(rclk), .se(1'b0),.si (),.so ()
274
        );
275
`else
276
dff_s #(64) mem_rddata_ff (
277
        .din(spu_mamem_rd_data_unbuf[63:0]) ,
278
        .q(read_data_q[63:0]),
279
        .clk (mem_rddata_clk), .se(1'b0),.si (),.so ()
280
        );
281
`endif
282
 
283
wire [63:0] spu_mul_op1_data_unbuf;
284
dp_mux3ds #(64) oprnd1_mx (
285
        .in0    (read_data_q[63:0]),
286
        .in1    (spu_mamem_rd_data_unbuf[63:0]),
287
        .in2    (spu_madp_manp_reg[63:0]),
288
        .sel0_l (spu_mamul_oprnd1_mxsel_l[0]),
289
        .sel1_l (spu_mamul_oprnd1_mxsel_l[1]),
290
        .sel2_l (spu_mamul_oprnd1_mxsel_l[2]),
291
        .dout   (spu_mul_op1_data_unbuf[63:0]));
292
 
293
assign spu_mul_op1_data[63:0] = spu_mul_op1_data_unbuf[63:0]; // this is critical going to mul unit.
294
 
295
// --------- parity logic
296
wire [1:0] spu_madp_mamem_rddata_par;
297
assign spu_madp_mamem_rddata_par[1:0] = spu_mamem_rd_data_unbuf[65:64]; // its going out buffer.
298
 
299
// place the following flop on the left handside.
300
dff_s    #(2) par_ff (
301
        .din(spu_madp_mamem_rddata_par[1:0]) ,
302
        .q(spu_madp_par_data[1:0]),
303
        .clk (rclk), .se(se), .si(), .so());
304
 
305
// upper=parity for [63:32], lower= parity for [31:0]
306
wire spu_madp_upper_perr = spu_madp_par_data[1] ^ ~spu_madp_rdmem_pargen[1];
307
wire spu_madp_lower_perr = spu_madp_par_data[0] ^ ~spu_madp_rdmem_pargen[0];
308
 
309
assign spu_madp_perr = spu_madp_upper_perr | spu_madp_lower_perr;
310
 
311
// ############################################################
312
// ---------------------------------------------------------
313
// ---------------------------------------------------------
314
// ---------------------------------------------------------
315
 
316
wire spu_mactl_ldop_q;
317
dff_s  #(1) ldop_ff (
318
        .din(spu_mactl_ldop) ,
319
        .q(spu_mactl_ldop_q),
320
        .clk (rclk), .se(se),.si (),.so ()
321
        );
322
 
323
wire spu_madp_ldop_q_buf1 = spu_mactl_ldop_q;
324
wire spu_madp_ldop_q_buf2 = spu_mactl_ldop_q;
325
 
326
// ############################################################
327
 
328
// ############################################################
329
 
330
// ############################################################
331
// ---------------------------------------------------------
332
// ------------ OPERAND1 and OPERAND2 to mul unit ----------
333
// ---------------------------------------------------------
334
// ---------------------------------------------------------
335
// operand2 = A,M,ACCUM
336
// operand1 = B,N,NP
337
// ---------------------------------------------------------
338
 
339
dp_mux2es #(64) oprnd2_mx2 (
340
        .in0    (spu_mamem_rd_data[63:0]),
341
        .in1    (mul_data_out[63:0]),
342
        .sel    (spu_mamul_oprnd2_bypass),
343
        .dout   (spu_madp_oprnd2_data[63:0]));
344
 
345
 
346
wire oprnd2_clk;
347
`ifdef FPGA_SYN_CLK_EN
348
`else
349
clken_buf oprnd2_lcd (
350
                        .clk(oprnd2_clk), .rclk(rclk),
351
                        .enb_l(~spu_mamul_oprnd2_wen), .tmb_l(testmode_l));
352
`endif
353
 
354
`ifdef FPGA_SYN_CLK_DFF
355
dffe_s  #(64) oprnd2_ff (
356
        .din(spu_madp_oprnd2_data[63:0]) ,
357
        .q(spu_mul_op2_data[63:0]),
358
        .en (~(~spu_mamul_oprnd2_wen)), .clk(rclk), .se(1'b0),.si (),.so ()
359
        );
360
`else
361
dff_s  #(64) oprnd2_ff (
362
        .din(spu_madp_oprnd2_data[63:0]) ,
363
        .q(spu_mul_op2_data[63:0]),
364
        .clk (oprnd2_clk), .se(1'b0),.si (),.so ()
365
        );
366
`endif
367
 
368
// ----------------------
369
// operand1 mux was moved to spu_mamem.v
370
 
371
 
372
// ############################################################
373
// ---------------------------------------------------------
374
// ------------ muxing of MPA with reduction operands ------
375
// ---------------------------------------------------------
376
// ---------------------------------------------------------
377
 
378
//assign spu_madp_modulus_b = ~spu_madp_modulus;
379
 
380
 
381
wire spu_mactl_mpa_sel_q_upper,spu_mactl_mpa_sel_q_lower;
382
 
383
dff_s  #(1) spu_mactl_mpa_sel_upper_ff (
384
        .din(spu_mactl_mpa_sel) ,
385
        .q(spu_mactl_mpa_sel_q_upper),
386
        .clk (rclk), .se(1'b0),.si (),.so ()
387
        );
388
 
389
dff_s  #(1) spu_mactl_mpa_sel_lower_ff (
390
        .din(spu_mactl_mpa_sel) ,
391
        .q(spu_mactl_mpa_sel_q_lower),
392
        .clk (rclk), .se(1'b0),.si (),.so ()
393
        );
394
 
395
wire spu_madp_mpa_sel_q_buf1_upper = spu_mactl_mpa_sel_q_upper;
396
wire spu_madp_mpa_sel_q_buf1_lower = spu_mactl_mpa_sel_q_lower;
397
wire spu_madp_mpa_sel_q_buf2_upper = spu_mactl_mpa_sel_q_upper;
398
wire spu_madp_mpa_sel_q_buf2_lower = spu_mactl_mpa_sel_q_lower;
399
 
400
dp_mux2es #(32) mpa_or_m_mx_upper (
401
        .in0    (spu_mul_op2_data[63:32]),
402
        .in1    ({24'h000000,spu_madp_mpa_addr[39:32]}),
403
        .sel    (spu_madp_mpa_sel_q_buf1_upper),
404
        .dout   (spu_madp_mpa_or_m[63:32]));
405
 
406
dp_mux2es #(32) mpa_or_m_mx_lower (
407
        .in0    (spu_mul_op2_data[31:0]),
408
        .in1    (spu_madp_mpa_addr[31:0]),
409
        .sel    (spu_madp_mpa_sel_q_buf1_lower),
410
        .dout   (spu_madp_mpa_or_m[31:0]));
411
 
412
 
413
/*
414
dp_mux2es #(64) mpa_or_n_mx (
415
        .in0    (spu_madp_modulus_b[63:0]),
416
        .in1    ({56'h00000000000000,3'b000,spu_maaddr_mpa_incr_val[4:0]}),
417
        .sel    (spu_mactl_mpa_sel),
418
        .dout   (spu_madp_mpa_or_n_b[63:0]));
419
*/
420
 
421
 
422
wire [4:0] spu_maaddr_mpa_incr_val_q;
423
dff_s  #(5) spu_maaddr_mpa_incr_val_ff (
424
        .din(spu_maaddr_mpa_incr_val[4:0]) ,
425
        .q(spu_maaddr_mpa_incr_val_q[4:0]),
426
        .clk (rclk), .se(1'b0), .si(), .so());
427
 
428
wire [4:0] spu_maaddr_mpa_incr_val_q_l = ~spu_maaddr_mpa_incr_val_q;
429
 
430
 
431
wire [63:0] spu_madp_mpa_or_n;
432
 
433
dp_mux2es #(32) mpa_or_n_mx_upper (
434
        .in0    (spu_madp_modulus[63:32]),
435
        .in1    (32'hffffffff),
436
        .sel    (spu_madp_mpa_sel_q_buf2_upper),
437
        .dout   (spu_madp_mpa_or_n[63:32]));
438
 
439
dp_mux2es #(32) mpa_or_n_mx_lower (
440
        .in0    (spu_madp_modulus[31:0]),
441
        .in1    ({24'hffffff,3'b111,spu_maaddr_mpa_incr_val_q_l[4:0]}),
442
        .sel    (spu_madp_mpa_sel_q_buf2_lower),
443
        .dout   (spu_madp_mpa_or_n[31:0]));
444
 
445
assign spu_madp_mpa_or_n_b = ~spu_madp_mpa_or_n;
446
 
447
 
448
 
449
// ------------------------
450
dp_mux2es  #(40) mpa_pa_iss_mx (
451
        .in0    ({1'b0,spu_madp_mpa_reg[38:3],3'b000}),
452
        .in1    (oprand_minus_modulus_or_mpa[39:0]),
453
        .sel    (spu_maaddr_mpa_addrinc),
454
        .dout   (spu_madp_mpa_mx[39:0]));
455
 
456
 
457
wire mpa_clk;
458
`ifdef FPGA_SYN_CLK_EN
459
`else
460
clken_buf mpa_lcd (
461
                        .clk(mpa_clk), .rclk(rclk),
462
                        .enb_l(~spu_maaddr_mpa_wen), .tmb_l(testmode_l));
463
`endif
464
 
465
`ifdef FPGA_SYN_CLK_DFF
466
dffe_s  #(40) mpa_ff  (
467
        .din({spu_madp_mpa_mx[39:3],3'b000}) ,
468
        .q(spu_madp_mpa_addr[39:0]),
469
        .en (~(~spu_maaddr_mpa_wen)), .clk(rclk), .se(1'b0),.si (),.so ()
470
        );
471
`else
472
dff_s  #(40) mpa_ff  (
473
        .din({spu_madp_mpa_mx[39:3],3'b000}) ,
474
        .q(spu_madp_mpa_addr[39:0]),
475
        .clk (mpa_clk), .se(1'b0),.si (),.so ()
476
        );
477
`endif
478
 
479
assign spu_madp_mpa_addr_out[38:3] = spu_madp_mpa_addr[38:3];
480
 
481
// ############################################################
482
// ---------------------------------------------------------
483
// ------------ MOD REDUCTION DATAPATH ---------------------
484
// ---------------------------------------------------------
485
// ---------------------------------------------------------
486
 
487
wire modulus_clk;
488
`ifdef FPGA_SYN_CLK_EN
489
`else
490
clken_buf modulus_lcd (
491
                        .clk(modulus_clk), .rclk(rclk),
492
                        .enb_l(~spu_mared_rdn_wen), .tmb_l(testmode_l));
493
`endif
494
 
495
`ifdef FPGA_SYN_CLK_DFF
496
dffe_s  #(64) modulus_ff (
497
        .din(spu_mamem_rd_data[63:0]) ,
498
        .q(spu_madp_modulus[63:0]),
499
        .en (~(~spu_mared_rdn_wen)), .clk(rclk), .se(1'b0),.si (),.so ()
500
        );
501
`else
502
dff_s  #(64) modulus_ff (
503
        .din(spu_mamem_rd_data[63:0]) ,
504
        .q(spu_madp_modulus[63:0]),
505
        .clk (modulus_clk), .se(1'b0),.si (),.so ()
506
        );
507
`endif
508
 
509
 
510
// USE 64BIT ADDER FROM LIB.
511
assign oprand_minus_modulus_or_mpa[64:0] = {1'b0,spu_madp_mpa_or_m[63:0]} +
512
                                    {1'b0,spu_madp_mpa_or_n_b[63:0]} +
513
                                    {64'h0000000000000000,spu_mared_cin_oprnd_sub_mod};
514
 
515
assign carry_out = oprand_minus_modulus_or_mpa[64];
516
 
517
assign spu_madp_cout_oprnd_sub_mod = carry_out;
518
 
519
assign spu_madp_m_lt_n = ~carry_out;
520
 
521
// USE 64BIT COMPARATOR FROM LIB.
522
assign spu_madp_m_eq_n = (spu_mul_op2_data[63:0] == spu_madp_modulus[63:0]);
523
 
524
dp_mux4ds #(64) modred_data_mx3  (
525
        .in0    (mul_data_out[63:0]),
526
        .in1    (64'h0000000000000000),                 // wr0tox
527
        .in2    (spu_mul_op2_data[63:0]),                // wrmtox
528
        .in3    (oprand_minus_modulus_or_mpa[63:0]),     // wrstox
529
        .sel0_l   (spu_mared_data_sel_l[0]),
530
        .sel1_l   (spu_mared_data_sel_l[1]),
531
        .sel2_l   (spu_mared_data_sel_l[2]),
532
        .sel3_l   (spu_mared_data_sel_l[3]),
533
        .dout   (mulorred_data[63:0]));
534
 
535
 
536
assign spu_madp_store_data[63:0] = spu_madp_modulus[63:0];
537
 
538
 
539
// ############################################################
540
// ---------------------------------------------------------
541
// ------------ MOD EXPONENTIATION DATAPATH ----------------
542
// ---------------------------------------------------------
543
// ---------------------------------------------------------
544
 
545
dp_mux2es #(64) exp_e_data_mx (
546
        .in0    (spu_mamem_rd_data[63:0]),
547
        .in1    ({spu_madp_exp_e_data_q[62:0],1'b0}),
548
        .sel    (spu_maexp_shift_e),
549
        .dout   (spu_madp_exp_e_data[63:0]));
550
 
551
 
552
wire exp_e_data_clk;
553
`ifdef FPGA_SYN_CLK_EN
554
`else
555
clken_buf exp_e_data_lcd (
556
                        .clk(exp_e_data_clk), .rclk(rclk),
557
                        .enb_l(~spu_maexp_e_data_wen), .tmb_l(testmode_l));
558
`endif
559
 
560
`ifdef FPGA_SYN_CLK_DFF
561
dffe_s  #(64) exp_e_data_ff (
562
        .din(spu_madp_exp_e_data[63:0]) ,
563
        .q(spu_madp_exp_e_data_q[63:0]),
564
        .en (~(~spu_maexp_e_data_wen)), .clk(rclk), .se(1'b0),.si (),.so ()
565
        );
566
`else
567
dff_s  #(64) exp_e_data_ff (
568
        .din(spu_madp_exp_e_data[63:0]) ,
569
        .q(spu_madp_exp_e_data_q[63:0]),
570
        .clk (exp_e_data_clk), .se(1'b0),.si (),.so ()
571
        );
572
`endif
573
 
574
assign spu_madp_e_eq_one = spu_madp_exp_e_data_q[63];
575
 
576
 
577
// ############################################################
578
// ---------------------------------------------------------
579
// ------------ MA PARITY DATAPATH ----------------
580
// ---------------------------------------------------------
581
// ---------------------------------------------------------
582
wire [63:0] mem_ldupper_data_mx_l;
583
 
584
wire mulorred_data_clk;
585
`ifdef FPGA_SYN_CLK_EN
586
`else
587
clken_buf mulorred_data_lcd (
588
                        .clk(mulorred_data_clk), .rclk(rclk),
589
                        .enb_l(~spu_mactl_madp_parflop_wen), .tmb_l(testmode_l));
590
`endif
591
 
592
`ifdef FPGA_SYN_CLK_DFF
593
dffe_s  #(64) mulorred_data_ff (
594
        .din(mulorred_data[63:0]) ,
595
        .q(mulorred_data_q[63:0]),
596
        .en (~(~spu_mactl_madp_parflop_wen)), .clk(rclk), .se(1'b0),.si (),.so ()
597
        );
598
`else
599
dff_s  #(64) mulorred_data_ff (
600
        .din(mulorred_data[63:0]) ,
601
        .q(mulorred_data_q[63:0]),
602
        .clk (mulorred_data_clk), .se(1'b0),.si (),.so ()
603
        );
604
`endif
605
 
606
dp_mux2es #(64) mul_ldlower_mx (
607
        .in0    (mulorred_data_q[63:0]),
608
        .in1    (spu_madp_lnlower_data[63:0]),
609
        .sel    (spu_madp_ldop_q_buf1),
610
        .dout   (mul_ldlower_data_mx[63:0]));
611
 
612
wire [63:0] mul_ldlower_data_mx_l;
613
assign mul_ldlower_data_mx_l = ~mul_ldlower_data_mx;    //to match gatemap.
614
 
615
// USE THE LIBRARY MACRO FOR THE FOLLOWING PARITY GENERATORS.
616
assign mul_ldlower_data_par_pre[1] = (^mul_ldlower_data_mx_l[63:32]);   //to match gatemap.
617
assign mul_ldlower_data_par_pre[0] = (^mul_ldlower_data_mx_l[31:0]);      //to match gatemap.
618
 
619
assign mul_ldlower_data_par[1] = mul_ldlower_data_par_pre[1] ^ spu_mactl_force_perr;
620
assign mul_ldlower_data_par[0] = mul_ldlower_data_par_pre[0] ^ spu_mactl_force_perr;
621
 
622
 
623
wire [65:0] spu_madp_odddata_mx_l;
624
 
625
dp_mux3ds #(66) odd_data_mx (
626
        .in0    ({mul_ldlower_data_par[1:0],mul_ldlower_data_mx_l[63:0]}),
627
        .in1    ({mem_ldupper_data_par[1:0],mem_ldupper_data_mx_l[63:0]}),
628
        .in2    ({mul_ldlower_data_par[1:0],mul_ldlower_data_mx_l[63:0]}),
629
        .sel0_l    (spu_mactl_memmxsel_l[0]),
630
        .sel1_l    (spu_mactl_memmxsel_l[1]),
631
        .sel2_l    (spu_mactl_memmxsel_l[2]),
632
        .dout   (spu_madp_odddata_mx_l[65:0]));
633
 
634
 
635
assign spu_madp_odddata_mx = ~spu_madp_odddata_mx_l;    //to match gatemap.
636
 
637
 
638
wire [65:0] spu_madp_odddata_mx_sehold;
639
dp_mux2es #(66) odddata_mx_sehold (
640
        .in0    (spu_madp_odddata_mx[65:0]),
641
        .in1    (spu_madp_odddata[65:0]),
642
        .sel    (sehold),
643
        .dout   (spu_madp_odddata_mx_sehold[65:0]));
644
 
645
dff_s  #(66) mul_ldlower_ff (
646
        .din(spu_madp_odddata_mx_sehold[65:0]) ,
647
        .q(spu_madp_odddata[65:0]),
648
        .clk (rclk), .se(1'b0),.si (),.so ()
649
        );
650
 
651
 
652
// ---------------------------------------------------------
653
 
654
dff_s  #(64) mem_data_ff (
655
        .din(spu_mamem_rd_data[63:0]) ,
656
        .q(spu_madp_mem_rd_data[63:0]),
657
        .clk (rclk), .se(1'b0),.si (),.so ()
658
        );
659
 
660
// ---------------------------------------------------------
661
 
662
dp_mux2es #(64) mem_ldupper_mx (
663
        .in0    (spu_madp_mem_rd_data[63:0]),
664
        .in1    (spu_madp_lnupper_data[63:0]),
665
        .sel    (spu_madp_ldop_q_buf2),
666
        .dout   (mem_ldupper_data_mx[63:0]));
667
 
668
assign mem_ldupper_data_mx_l = ~mem_ldupper_data_mx;
669
 
670
// USE THE LIBRARY MACRO FOR THE FOLLOWING PARITY GENERATORS.
671
assign mem_ldupper_data_par_pre[1] = (^mem_ldupper_data_mx_l[63:32]);
672
assign mem_ldupper_data_par_pre[0] = (^mem_ldupper_data_mx_l[31:0]);
673
 
674
assign mem_ldupper_data_par[1] = mem_ldupper_data_par_pre[1] ^ spu_mactl_force_perr;
675
assign mem_ldupper_data_par[0] = mem_ldupper_data_par_pre[0] ^ spu_mactl_force_perr;
676
 
677
wire [65:0] spu_madp_evedata_mx_l;
678
dp_mux3ds #(66) eve_data_mx (
679
        .in0    ({mem_ldupper_data_par[1:0],mem_ldupper_data_mx_l[63:0]}),
680
        .in1    ({mul_ldlower_data_par[1:0],mul_ldlower_data_mx_l[63:0]}),
681
        .in2    ({mul_ldlower_data_par[1:0],mul_ldlower_data_mx_l[63:0]}),
682
        .sel0_l    (spu_mactl_memmxsel_l[0]),
683
        .sel1_l    (spu_mactl_memmxsel_l[1]),
684
        .sel2_l    (spu_mactl_memmxsel_l[2]),
685
        .dout   (spu_madp_evedata_mx_l[65:0]));
686
 
687
assign spu_madp_evedata_mx = ~spu_madp_evedata_mx_l;
688
 
689
 
690
wire [65:0] spu_madp_evedata_mx_sehold;
691
dp_mux2es #(66) evedata_mx_sehold (
692
        .in0    (spu_madp_evedata_mx[65:0]),
693
        .in1    (spu_madp_evedata[65:0]),
694
        .sel    (sehold),
695
        .dout   (spu_madp_evedata_mx_sehold[65:0]));
696
 
697
dff_s  #(66) mem_ldupper_ff (
698
        .din(spu_madp_evedata_mx_sehold[65:0]) ,
699
        .q(spu_madp_evedata[65:0]),
700
        .clk (rclk), .se(1'b0),.si (),.so ()
701
        );
702
 
703
 
704
 
705
// ---------------------------------------------------------
706
// following is for readmem parity check only performed in spu_mactl.v
707
assign spu_madp_rdmem_pargen[1:0] = mem_ldupper_data_par_pre[1:0];
708
 
709
// ---------------------------------------------------------
710
// ---------------------------------------------------------
711
 
712
// ############################################################
713
// ---------------------------------------------------------
714
// ---------------------------------------------------------
715
// ------- MA ASI REGISTERS
716
 
717
wire mampa_reg_clk;
718
`ifdef FPGA_SYN_CLK_EN
719
`else
720
clken_buf mampa_reg_lcd (
721
                        .clk(mampa_reg_clk), .rclk(rclk),
722
                        .enb_l(~spu_mactl_mpa_wen), .tmb_l(testmode_l));
723
`endif
724
 
725
`ifdef FPGA_SYN_CLK_DFF
726
dffe_s  #(36) mampa_reg_ff (
727
        .din(exu_spu_st_rs3_data_g2[38:3]) ,
728
        .q(spu_madp_mpa_reg[38:3]),
729
        .en (~(~spu_mactl_mpa_wen)), .clk(rclk), .se(1'b0),.si(),.so()
730
        );
731
`else
732
dff_s  #(36) mampa_reg_ff (
733
        .din(exu_spu_st_rs3_data_g2[38:3]) ,
734
        .q(spu_madp_mpa_reg[38:3]),
735
        .clk (mampa_reg_clk), .se(1'b0),.si(),.so()
736
        );
737
`endif
738
 
739
wire maaddr_reg_clk;
740
`ifdef FPGA_SYN_CLK_EN
741
`else
742
clken_buf maaddr_reg_lcd (
743
                        .clk(maaddr_reg_clk), .rclk(rclk),
744
                        .enb_l(~spu_mactl_maaddr_wen), .tmb_l(testmode_l));
745
`endif
746
 
747
`ifdef FPGA_SYN_CLK_DFF
748
dffe_s  #(48) maaddr_reg_ff (
749
        .din(exu_spu_st_rs3_data_g2[47:0]) ,
750
        .q(spu_madp_maaddr_reg_int[47:0]),
751
        .en (~(~spu_mactl_maaddr_wen)), .clk(rclk), .se(1'b0),.si (),.so ()
752
        );
753
`else
754
dff_s  #(48) maaddr_reg_ff (
755
        .din(exu_spu_st_rs3_data_g2[47:0]) ,
756
        .q(spu_madp_maaddr_reg_int[47:0]),
757
        .clk (maaddr_reg_clk), .se(1'b0),.si (),.so ()
758
        );
759
`endif
760
 
761
 
762
assign spu_madp_maaddr_reg[47:0] = spu_madp_maaddr_reg_int[47:0];
763
 
764
 
765
wire manp_reg_clk;
766
`ifdef FPGA_SYN_CLK_EN
767
`else
768
clken_buf manp_reg_lcd (
769
                        .clk(manp_reg_clk), .rclk(rclk),
770
                        .enb_l(~spu_mactl_manp_wen), .tmb_l(testmode_l));
771
`endif
772
 
773
`ifdef FPGA_SYN_CLK_DFF
774
dffe_s  #(64) manp_reg_ff (
775
        .din(exu_spu_st_rs3_data_g2[63:0]) ,
776
        .q(spu_madp_manp_reg[63:0]),
777
        .en (~(~spu_mactl_manp_wen)), .clk(rclk), .se(1'b0),.si (),.so ()
778
        );
779
`else
780
dff_s  #(64) manp_reg_ff (
781
        .din(exu_spu_st_rs3_data_g2[63:0]) ,
782
        .q(spu_madp_manp_reg[63:0]),
783
        .clk (manp_reg_clk), .se(1'b0),.si (),.so ()
784
        );
785
`endif
786
 
787
wire [63:0] spu_madp_ldxa_data_a;
788
dp_mux4ds #(64) ldxa_data_a_mx  (
789
        .in0    ({24'h000000,1'b0,spu_madp_mpa_reg[38:3],3'b000}),
790
        .in1    ({16'h0000,spu_madp_maaddr_reg_int[47:0]}),
791
        .in2    (spu_madp_manp_reg[63:0]),
792
        .in3    ({50'b00000000000000000000000000000000000000000000000000,spu_mactl_mactl_reg[13:0]}),
793
        .sel0_l   (spu_mactl_ldxa_data_w_sel_l[0]),
794
        .sel1_l   (spu_mactl_ldxa_data_w_sel_l[1]),
795
        .sel2_l   (spu_mactl_ldxa_data_w_sel_l[2]),
796
        .sel3_l   (spu_mactl_ldxa_data_w_sel_l[3]),
797
        .dout   (spu_madp_ldxa_data_a[63:0]));
798
 
799
dp_mux2es #(64) ldxa_data_mx (
800
        .in0    (spu_madp_ldxa_data_a[63:0]),
801
        .in1    (64'h0000000000000000),
802
        .sel    (spu_mactl_ldxa_data_w_select),
803
        .dout   (spu_madp_ldxa_data[63:0]));
804
 
805
 
806
 
807
// ############################################################
808
// ------------------------------------------------------------
809
// load buffer.
810
// ------------------------------------------------------------
811
// ------------------------------------------------------------
812
 
813
wire lnupper_data_clk;
814
`ifdef FPGA_SYN_CLK_EN
815
`else
816
clken_buf lnupper_data_lcd (
817
                        .clk(lnupper_data_clk), .rclk(rclk),
818
                        .enb_l(~spu_wen_maln_wen), .tmb_l(testmode_l));
819
`endif
820
 
821
`ifdef FPGA_SYN_CLK_DFF
822
dffe_s  #(64) lnupper_data_ff (
823
        .din(lsu_spu_vload_data[127:64]) ,
824
        .q(spu_madp_lnupper_data[63:0]),
825
        .en (~(~spu_wen_maln_wen)), .clk(rclk), .se(1'b0),.si (),.so ()
826
        );
827
`else
828
dff_s  #(64) lnupper_data_ff (
829
        .din(lsu_spu_vload_data[127:64]) ,
830
        .q(spu_madp_lnupper_data[63:0]),
831
        .clk (lnupper_data_clk), .se(1'b0),.si (),.so ()
832
        );
833
`endif
834
 
835
wire lnlower_data_clk;
836
`ifdef FPGA_SYN_CLK_EN
837
`else
838
clken_buf lnlower_data_lcd (
839
                        .clk(lnlower_data_clk), .rclk(rclk),
840
                        .enb_l(~spu_wen_maln_wen), .tmb_l(testmode_l));
841
`endif
842
 
843
`ifdef FPGA_SYN_CLK_DFF
844
dffe_s  #(64) lnlower_data_ff (
845
        .din(lsu_spu_vload_data[63:0]) ,
846
        .q(spu_madp_lnlower_data[63:0]),
847
        .en (~(~spu_wen_maln_wen)), .clk(rclk), .se(1'b0),.si (),.so ()
848
        );
849
`else
850
dff_s  #(64) lnlower_data_ff (
851
        .din(lsu_spu_vload_data[63:0]) ,
852
        .q(spu_madp_lnlower_data[63:0]),
853
        .clk (lnlower_data_clk), .se(1'b0),.si (),.so ()
854
        );
855
`endif
856
 
857
 
858
// ############################################################
859
 
860
 
861
endmodule

powered by: WebSVN 2.1.0

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