tc_div.v
40.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
// $Id: tc_div.v,v 1.1 2002/03/28 00:26:13 berndt Exp $
////////////////////////////////////////////////////////////////////////
//
// Project Reality
//
// module: tc_div
// description: Texture Coordinate Unit Perspective Divide
//
// designers: Matthew Rohm, Tony DeLaurier
// date: 7/25/94
//
////////////////////////////////////////////////////////////////////////
module tc_div (w, s, t, dis, gclk, sw_out, tw_out);
input [15:0] w;
input [15:0] s, t;
input dis;
input gclk;
output [18:0] sw_out, tw_out;
wire [9:0] w_frac;
wire [3:0] w_shft;
wire [14:0] tlu_pt;
wire [9:0] tlu_sl;
wire [14:0] tlu_rcp;
wire [29:0] sw_mul;
wire [29:0] tw_mul;
reg [14:0] cmask;
reg [9:0] norm1;
reg [9:0] tlu_sl1;
reg [14:0] tlu_pt1;
reg [3:0] shft1;
reg dis1;
reg [3:0] shft2;
reg [14:0] rcp2;
reg [29:0] sw_mul3;
reg [29:0] tw_mul3;
reg [3:0] shft3;
reg [14:0] cmask3;
reg w_under;
reg w_under_1d;
reg w_under_2d;
// detect w underflow
always @ (posedge gclk) begin
w_under <= !dis && (w[15] || (w[14:0] == 15'b0));
w_under_1d <= w_under;
w_under_2d <= w_under_1d;
end
// normalizer with tlu
tc_div_nrmtlu nrmtlu (.in(w[14:0]), .norm(w_frac), .shft(w_shft),
.pt(tlu_pt), .slope(tlu_sl));
// first pipeline regs
always @ (posedge gclk) begin
norm1 <= w_frac;
tlu_sl1 <= tlu_sl;
tlu_pt1 <= tlu_pt;
shft1 <= w_shft;
dis1 <= dis;
end
// recip mult/add
tc_div_mul1 mul1 (.mc({1'b1, tlu_sl1}), .mp(norm1), .pt(tlu_pt1), .out(tlu_rcp));
// second pipeline regs
always @ (posedge gclk) begin
rcp2 <= dis1 ? 15'h2000 : tlu_rcp;
shft2 <= dis1 ? 4'h0 : shft1;
end
// s multiply
tc_div_mul2 mul_s (.mc(s), .mp(rcp2), .out(sw_mul));
// t multiply
tc_div_mul2 mul_t (.mc(t), .mp(rcp2), .out(tw_mul));
// clamp mask decoder
always @ (shft2) begin
casez (shft2)
4'h0 : cmask = 15'h4000;
4'h1 : cmask = 15'h6000;
4'h2 : cmask = 15'h7000;
4'h3 : cmask = 15'h7800;
4'h4 : cmask = 15'h7C00;
4'h5 : cmask = 15'h7E00;
4'h6 : cmask = 15'h7F00;
4'h7 : cmask = 15'h7F80;
4'h8 : cmask = 15'h7FC0;
4'h9 : cmask = 15'h7FE0;
4'hA : cmask = 15'h7FF0;
4'hB : cmask = 15'h7FF8;
4'hC : cmask = 15'h7FFC;
4'hD : cmask = 15'h7FFE;
4'hE : cmask = 15'h7FFF;
4'hF : cmask = 15'h7FFF;
default : cmask = 15'bx;
endcase
end // always
// third pipeline regs
always @ (posedge gclk) begin
sw_mul3 <= sw_mul;
tw_mul3 <= tw_mul;
shft3 <= shft2;
cmask3 <= cmask;
end
// s denormalize
tc_div_dnrmclmp denorm_s (.in(sw_mul3), .shft(shft3), .cmask(cmask3),
.w_under(w_under_2d), .out(sw_out));
// t denormalize
tc_div_dnrmclmp denorm_t (.in(tw_mul3), .shft(shft3), .cmask(cmask3),
.w_under(w_under_2d), .out(tw_out));
endmodule // tc_div
// divider normalizer with tlu
module tc_div_nrmtlu (in, norm, shft, pt, slope);
input [14:0] in;
output [14:0] pt;
output [9:0] slope;
output [9:0] norm;
output [3:0] shft;
reg [13:0] nrm_out;
reg [3:0] shft;
reg [14:0] shfta, shftb;
reg [15:0] tmp_pt;
reg [11:0] tmp_slope;
always @(in) begin
// priority encode
if (in[14]) shft = 4'b0000;
else if (in[13]) shft = 4'b0001;
else if (in[12]) shft = 4'b0010;
else if (in[11]) shft = 4'b0011;
else if (in[10]) shft = 4'b0100;
else if (in[9]) shft = 4'b0101;
else if (in[8]) shft = 4'b0110;
else if (in[7]) shft = 4'b0111;
else if (in[6]) shft = 4'b1000;
else if (in[5]) shft = 4'b1001;
else if (in[4]) shft = 4'b1010;
else if (in[3]) shft = 4'b1011;
else if (in[2]) shft = 4'b1100;
else if (in[1]) shft = 4'b1101;
else shft = 4'b1110;
// shift mux A (x0, x2, x4, x6)
casez ({shft[2], shft[1]})
2'b00 : shfta = in[14:0];
2'b01 : shfta = {in[12:0], 2'b0};
2'b10 : shfta = {in[10:0], 4'b0};
2'b11 : shfta = {in[8:0], 6'b0};
default : shfta = 15'bx;
endcase
// shift mux B (x8, x10, x12, x14)
casez ({shft[2], shft[1]})
2'b00 : shftb = {in[6:0], 8'b0};
2'b01 : shftb = {in[4:0], 10'b0};
2'b10 : shftb = {in[2:0], 12'b0};
2'b11 : shftb = {in[0], 14'b0};
default : shftb = 15'bx;
endcase
// shift mux C (Ax0, Ax1, Bx0, Bx1)
casez ({shft[3], shft[0]})
2'b00 : nrm_out = shfta[13:0];
2'b01 : nrm_out = {shfta[12:0], 1'b0};
2'b10 : nrm_out = shftb[13:0];
2'b11 : nrm_out = {shftb[12:0], 1'b0};
default : nrm_out = 14'bx;
endcase
// point lookup
case (nrm_out[13:8])
6'd00: tmp_pt = 16'h4000;
6'd01: tmp_pt = 16'h3f04;
6'd02: tmp_pt = 16'h3e10;
6'd03: tmp_pt = 16'h3d22;
6'd04: tmp_pt = 16'h3c3c;
6'd05: tmp_pt = 16'h3b5d;
6'd06: tmp_pt = 16'h3a83;
6'd07: tmp_pt = 16'h39b1;
6'd08: tmp_pt = 16'h38e4;
6'd09: tmp_pt = 16'h381c;
6'd10: tmp_pt = 16'h375a;
6'd11: tmp_pt = 16'h369d;
6'd12: tmp_pt = 16'h35e5;
6'd13: tmp_pt = 16'h3532;
6'd14: tmp_pt = 16'h3483;
6'd15: tmp_pt = 16'h33d9;
6'd16: tmp_pt = 16'h3333;
6'd17: tmp_pt = 16'h3291;
6'd18: tmp_pt = 16'h31f4;
6'd19: tmp_pt = 16'h3159;
6'd20: tmp_pt = 16'h30c3;
6'd21: tmp_pt = 16'h3030;
6'd22: tmp_pt = 16'h2fa1;
6'd23: tmp_pt = 16'h2f15;
6'd24: tmp_pt = 16'h2e8c;
6'd25: tmp_pt = 16'h2e06;
6'd26: tmp_pt = 16'h2d83;
6'd27: tmp_pt = 16'h2d03;
6'd28: tmp_pt = 16'h2c86;
6'd29: tmp_pt = 16'h2c0b;
6'd30: tmp_pt = 16'h2b93;
6'd31: tmp_pt = 16'h2b1e;
6'd32: tmp_pt = 16'h2aab;
6'd33: tmp_pt = 16'h2a3a;
6'd34: tmp_pt = 16'h29cc;
6'd35: tmp_pt = 16'h2960;
6'd36: tmp_pt = 16'h28f6;
6'd37: tmp_pt = 16'h288e;
6'd38: tmp_pt = 16'h2828;
6'd39: tmp_pt = 16'h27c4;
6'd40: tmp_pt = 16'h2762;
6'd41: tmp_pt = 16'h2702;
6'd42: tmp_pt = 16'h26a4;
6'd43: tmp_pt = 16'h2648;
6'd44: tmp_pt = 16'h25ed;
6'd45: tmp_pt = 16'h2594;
6'd46: tmp_pt = 16'h253d;
6'd47: tmp_pt = 16'h24e7;
6'd48: tmp_pt = 16'h2492;
6'd49: tmp_pt = 16'h243f;
6'd50: tmp_pt = 16'h23ee;
6'd51: tmp_pt = 16'h239e;
6'd52: tmp_pt = 16'h234f;
6'd53: tmp_pt = 16'h2302;
6'd54: tmp_pt = 16'h22b6;
6'd55: tmp_pt = 16'h226c;
6'd56: tmp_pt = 16'h2222;
6'd57: tmp_pt = 16'h21da;
6'd58: tmp_pt = 16'h2193;
6'd59: tmp_pt = 16'h214d;
6'd60: tmp_pt = 16'h2108;
6'd61: tmp_pt = 16'h20c5;
6'd62: tmp_pt = 16'h2082;
6'd63: tmp_pt = 16'h2041;
endcase
// slope lookup
case (nrm_out[13:8])
6'd00: tmp_slope = 12'hf03;
6'd01: tmp_slope = 12'hf0b;
6'd02: tmp_slope = 12'hf11;
6'd03: tmp_slope = 12'hf19;
6'd04: tmp_slope = 12'hf20;
6'd05: tmp_slope = 12'hf25;
6'd06: tmp_slope = 12'hf2d;
6'd07: tmp_slope = 12'hf32;
6'd08: tmp_slope = 12'hf37;
6'd09: tmp_slope = 12'hf3d;
6'd10: tmp_slope = 12'hf42;
6'd11: tmp_slope = 12'hf47;
6'd12: tmp_slope = 12'hf4c;
6'd13: tmp_slope = 12'hf50;
6'd14: tmp_slope = 12'hf55;
6'd15: tmp_slope = 12'hf59;
6'd16: tmp_slope = 12'hf5d;
6'd17: tmp_slope = 12'hf62;
6'd18: tmp_slope = 12'hf64;
6'd19: tmp_slope = 12'hf69;
6'd20: tmp_slope = 12'hf6c;
6'd21: tmp_slope = 12'hf70;
6'd22: tmp_slope = 12'hf73;
6'd23: tmp_slope = 12'hf76;
6'd24: tmp_slope = 12'hf79;
6'd25: tmp_slope = 12'hf7c;
6'd26: tmp_slope = 12'hf7f;
6'd27: tmp_slope = 12'hf82;
6'd28: tmp_slope = 12'hf84;
6'd29: tmp_slope = 12'hf87;
6'd30: tmp_slope = 12'hf8a;
6'd31: tmp_slope = 12'hf8c;
6'd32: tmp_slope = 12'hf8e;
6'd33: tmp_slope = 12'hf91;
6'd34: tmp_slope = 12'hf93;
6'd35: tmp_slope = 12'hf95;
6'd36: tmp_slope = 12'hf97;
6'd37: tmp_slope = 12'hf99;
6'd38: tmp_slope = 12'hf9b;
6'd39: tmp_slope = 12'hf9d;
6'd40: tmp_slope = 12'hf9f;
6'd41: tmp_slope = 12'hfa1;
6'd42: tmp_slope = 12'hfa3;
6'd43: tmp_slope = 12'hfa4;
6'd44: tmp_slope = 12'hfa6;
6'd45: tmp_slope = 12'hfa8;
6'd46: tmp_slope = 12'hfa9;
6'd47: tmp_slope = 12'hfaa;
6'd48: tmp_slope = 12'hfac;
6'd49: tmp_slope = 12'hfae;
6'd50: tmp_slope = 12'hfaf;
6'd51: tmp_slope = 12'hfb0;
6'd52: tmp_slope = 12'hfb2;
6'd53: tmp_slope = 12'hfb3;
6'd54: tmp_slope = 12'hfb5;
6'd55: tmp_slope = 12'hfb5;
6'd56: tmp_slope = 12'hfb7;
6'd57: tmp_slope = 12'hfb8;
6'd58: tmp_slope = 12'hfb9;
6'd59: tmp_slope = 12'hfba;
6'd60: tmp_slope = 12'hfbc;
6'd61: tmp_slope = 12'hfbc;
6'd62: tmp_slope = 12'hfbe;
6'd63: tmp_slope = 12'hfbe;
endcase
end // always
// tlu outputs
assign pt = tmp_pt[14:0];
assign slope = tmp_slope[9:0];
// normalizer outputs
assign norm = {nrm_out[7:0], 2'b0};
endmodule // tc_div_nrmtlu
// denormalizer with clamp
module tc_div_dnrmclmp (in, shft, cmask, w_under, out);
input [29:0] in;
input [3:0] shft;
input [14:0] cmask;
input w_under;
output [18:0] out;
wire [16:0] dn_out;
wire pass;
wire [18:0] out;
wire [14:0] zeros_bus, ones_bus;
// barrel shifter
tc_div_16to1 shf16 (.in({in[29:15], 1'b0}), .shift(shft), .out(dn_out[16]));
tc_div_16to1 shf15 (.in({in[28:14], 1'b0}), .shift(shft), .out(dn_out[15]));
tc_div_16to1 shf14 (.in({in[27:13], 1'b0}), .shift(shft), .out(dn_out[14]));
tc_div_16to1 shf13 (.in({in[26:12], 1'b0}), .shift(shft), .out(dn_out[13]));
tc_div_16to1 shf12 (.in({in[25:11], 1'b0}), .shift(shft), .out(dn_out[12]));
tc_div_16to1 shf11 (.in({in[24:10], 1'b0}), .shift(shft), .out(dn_out[11]));
tc_div_16to1 shf10 (.in({in[23:9], 1'b0}), .shift(shft), .out(dn_out[10]));
tc_div_16to1 shf9 (.in({in[22:8], 1'b0}), .shift(shft), .out(dn_out[9]));
tc_div_16to1 shf8 (.in({in[21:7], 1'b0}), .shift(shft), .out(dn_out[8]));
tc_div_16to1 shf7 (.in({in[20:6], 1'b0}), .shift(shft), .out(dn_out[7]));
tc_div_16to1 shf6 (.in({in[19:5], 1'b0}), .shift(shft), .out(dn_out[6]));
tc_div_16to1 shf5 (.in({in[18:4], 1'b0}), .shift(shft), .out(dn_out[5]));
tc_div_16to1 shf4 (.in({in[17:3], 1'b0}), .shift(shft), .out(dn_out[4]));
tc_div_16to1 shf3 (.in({in[16:2], 1'b0}), .shift(shft), .out(dn_out[3]));
tc_div_16to1 shf2 (.in({in[15:1], 1'b0}), .shift(shft), .out(dn_out[2]));
tc_div_16to1 shf1 (.in({in[14:0], 1'b0}), .shift(shft), .out(dn_out[1]));
tc_div_16to1 shf0 (.in({in[13:0], 2'b0}), .shift(shft), .out(dn_out[0]));
// create two copies of input bus for comparison
assign zeros_bus = (in[29:15] & cmask);
assign ones_bus = (in[29:15] | ~cmask);
// determine over/underflow flags
assign pass = ((zeros_bus == 15'h0000) || (ones_bus == 15'h7FFF));
assign out[18] = (!pass && !in[29]) || w_under;
assign out[17] = !pass && in[29];
assign out[16:0] = dn_out[16:0];
endmodule // tc_div_dnrmclmp
// 10 X 10 multiplier
module tc_div_mul1 (mc, mp, pt, out);
input [10:0] mc;
input [9:0] mp;
input [14:0] pt;
output [14:0] out;
wire [10:0] p0, p1, p2, p3, p4, p5, p6, p7, p8, p9;
wire [11:0] s_a, co_a;
wire [12:0] s_b, co_b;
wire [12:0] s_c, co_c;
wire [16:0] s_d, co_d;
wire [14:0] s_e, co_e;
wire [19:0] s_f, co_f;
wire [14:0] s_g, co_g;
wire [19:0] s_h, co_h;
wire [24:0] s_i, co_i;
wire [24:0] s_j, co_j;
wire [3:0] s_m0, s_m1;
wire [4:0] s_n0, s_n1;
wire [5:0] s_q0, s_q1;
wire [2:0] sel;
wire [2:0] sel_d3;
wire [19:0] sum;
// calculate partial products
assign p0 = mc & {11{mp[0]}};
assign p1 = (mc & {11{mp[1]}}) ^ 11'h400;
assign p2 = (mc & {11{mp[2]}}) ^ 11'h400;
assign p3 = (mc & {11{mp[3]}}) ^ 11'h400;
assign p4 = (mc & {11{mp[4]}}) ^ 11'h400;
assign p5 = (mc & {11{mp[5]}}) ^ 11'h400;
assign p6 = (mc & {11{mp[6]}}) ^ 11'h400;
assign p7 = (mc & {11{mp[7]}}) ^ 11'h400;
assign p8 = (mc & {11{mp[8]}}) ^ 11'h400;
assign p9 = (mc & {11{mp[9]}}) ^ 11'h400;
// carry-save adder tree
// 1st level
tc_div_csa12 csa_a (.a({p1, 1'b0}), .b({~p0[10], p0}), .ci({2'b0, mp}),
.s(s_a), .co(co_a));
tc_div_csa13 csa_b (.a({p4, 2'b0}), .b({1'b0, p3, 1'b0}), .ci({2'b0, p2}),
.s(s_b), .co(co_b));
tc_div_csa13 csa_c (.a({p7, 2'b0}), .b({1'b0, p6, 1'b0}), .ci({2'b0, p5}),
.s(s_c), .co(co_c));
tc_div_csa17 csa_d (.a({pt, 2'b0}), .b({5'b11111, p9, 1'b0}), .ci({6'b0, p8}),
.s(s_d), .co(co_d));
// 2nd level
tc_div_csa15 csa_e (.a({co_b[11:1], 4'b0}), .b({2'b0, co_a, 1'b0}), .ci({3'b0, s_a}),
.s(s_e), .co(co_e));
tc_div_csa20 csa_f (.a({co_d[15:1], 5'b0}), .b({7'b0, co_c[11:1], 2'b0}), .ci({7'b0, s_c}),
.s(s_f), .co(co_f));
// 3rd level
tc_div_csa15 csa_g (.a({s_b, 2'b0}), .b({1'b0, co_e[12:1], 2'b0}), .ci(s_e),
.s(s_g), .co(co_g));
tc_div_csa20 csa_h (.a({s_d, 3'b0}), .b({6'b0, co_f[12:2], 3'b0}), .ci(s_f),
.s(s_h), .co(co_h));
// 4th level
tc_div_csa25 csa_i (.a({co_h[18:3], 9'b0}), .b({9'b0, co_g[14:2], 3'b0}), .ci({10'b0, s_g}),
.s(s_i), .co(co_i));
// 5th level
tc_div_csa25 csa_j (.a({s_h, 5'b0}), .b({8'b0, co_i[15:3], 4'b0}), .ci(s_i),
.s(s_j), .co(co_j));
// carry select adder
tc_div_radd2 radd_k (.a(s_j[6:5]), .b(co_j[5:4]), .co(co_k));
tc_div_radd3 radd_l0 (.a(s_j[9:7]), .b(co_j[8:6]), .ci(1'b0), .co(co_l0));
tc_div_radd3 radd_l1 (.a(s_j[9:7]), .b(co_j[8:6]), .ci(1'b1), .co(co_l1));
tc_div_radd4 radd_m0 (.a(s_j[13:10]), .b(co_j[12:9]), .ci(1'b0), .s(s_m0), .co(co_m0));
tc_div_radd4 radd_m1 (.a(s_j[13:10]), .b(co_j[12:9]), .ci(1'b1), .s(s_m1), .co(co_m1));
tc_div_radd5 radd_n0 (.a(s_j[18:14]), .b(co_j[17:13]), .ci(1'b0), .s(s_n0), .co(co_n0));
tc_div_radd5 radd_n1 (.a(s_j[18:14]), .b(co_j[17:13]), .ci(1'b1), .s(s_n1), .co(co_n1));
tc_div_radd6 radd_q0 (.a(s_j[24:19]), .b(co_j[23:18]), .ci(1'b0), .s(s_q0));
tc_div_radd6 radd_q1 (.a(s_j[24:19]), .b(co_j[23:18]), .ci(1'b1), .s(s_q1));
mx21d1 mx0 (.z(sel[0]), .i0(co_l0), .i1(co_l1), .s(co_k));
mx21d1 mx1 (.z(sel[1]), .i0(co_m0), .i1(co_m1), .s(sel[0]));
mx21d1 mx2 (.z(sel[2]), .i0(co_n0), .i1(co_n1), .s(sel[1]));
ni01d3 sel_buf0 (.z(sel_d3[0]), .i(sel[0]));
ni01d3 sel_buf1 (.z(sel_d3[1]), .i(sel[1]));
ni01d3 sel_buf2 (.z(sel_d3[2]), .i(sel[2]));
mx21d1 mx3 (.z(sum[8]), .i0(s_m0[3]), .i1(s_m1[3]), .s(sel_d3[0]));
mx21d1 mx4 (.z(sum[7]), .i0(s_m0[2]), .i1(s_m1[2]), .s(sel_d3[0]));
mx21d1 mx5 (.z(sum[6]), .i0(s_m0[1]), .i1(s_m1[1]), .s(sel_d3[0]));
mx21d1 mx6 (.z(sum[5]), .i0(s_m0[0]), .i1(s_m1[0]), .s(sel_d3[0]));
mx21d1 mx7 (.z(sum[13]), .i0(s_n0[4]), .i1(s_n1[4]), .s(sel_d3[1]));
mx21d1 mx8 (.z(sum[12]), .i0(s_n0[3]), .i1(s_n1[3]), .s(sel_d3[1]));
mx21d1 mx9 (.z(sum[11]), .i0(s_n0[2]), .i1(s_n1[2]), .s(sel_d3[1]));
mx21d1 mx10 (.z(sum[10]), .i0(s_n0[1]), .i1(s_n1[1]), .s(sel_d3[1]));
mx21d1 mx11 (.z(sum[9]), .i0(s_n0[0]), .i1(s_n1[0]), .s(sel_d3[1]));
mx21d1 mx12 (.z(sum[19]), .i0(s_q0[5]), .i1(s_q1[5]), .s(sel_d3[2]));
mx21d1 mx13 (.z(sum[18]), .i0(s_q0[4]), .i1(s_q1[4]), .s(sel_d3[2]));
mx21d1 mx14 (.z(sum[17]), .i0(s_q0[3]), .i1(s_q1[3]), .s(sel_d3[2]));
mx21d1 mx15 (.z(sum[16]), .i0(s_q0[2]), .i1(s_q1[2]), .s(sel_d3[2]));
mx21d1 mx16 (.z(sum[15]), .i0(s_q0[1]), .i1(s_q1[1]), .s(sel_d3[2]));
mx21d1 mx17 (.z(sum[14]), .i0(s_q0[0]), .i1(s_q1[0]), .s(sel_d3[2]));
assign out[14:0] = sum[19:5];
endmodule // tc_div_mul1
// 15 X S.15 multiplier
module tc_div_mul2 (mc, mp, out);
input [15:0] mc;
input [14:0] mp;
output [29:0] out;
wire [15:0] p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14;
wire [17:0] s_a, co_a;
wire [17:0] s_b, co_b;
wire [17:0] s_c, co_c;
wire [18:0] s_d, co_d;
wire [18:0] s_e, co_e;
wire [18:0] s_f, co_f;
wire [17:0] s_g, co_g;
wire [22:0] s_h, co_h;
wire [21:0] s_i, co_i;
wire [22:0] s_j, co_j;
wire [21:0] s_k, co_k;
wire [29:0] s_l, co_l;
wire [29:0] s_m, co_m;
// calculate partial products
assign p0 = mc & {16{mp[0]}};
assign p1 = {~(mc[15] & mp[1]), (mc[14:0] & {15{mp[1]}})};
assign p2 = {~(mc[15] & mp[2]), (mc[14:0] & {15{mp[2]}})};
assign p3 = {~(mc[15] & mp[3]), (mc[14:0] & {15{mp[3]}})};
assign p4 = {~(mc[15] & mp[4]), (mc[14:0] & {15{mp[4]}})};
assign p5 = {~(mc[15] & mp[5]), (mc[14:0] & {15{mp[5]}})};
assign p6 = {~(mc[15] & mp[6]), (mc[14:0] & {15{mp[6]}})};
assign p7 = {~(mc[15] & mp[7]), (mc[14:0] & {15{mp[7]}})};
assign p8 = {~(mc[15] & mp[8]), (mc[14:0] & {15{mp[8]}})};
assign p9 = {~(mc[15] & mp[9]), (mc[14:0] & {15{mp[9]}})};
assign p10 = {~(mc[15] & mp[10]), (mc[14:0] & {15{mp[10]}})};
assign p11 = {~(mc[15] & mp[11]), (mc[14:0] & {15{mp[11]}})};
assign p12 = {~(mc[15] & mp[12]), (mc[14:0] & {15{mp[12]}})};
assign p13 = {~(mc[15] & mp[13]), (mc[14:0] & {15{mp[13]}})};
assign p14 = {~(mc[15] & mp[14]), (mc[14:0] & {15{mp[14]}})};
// carry-save adder tree
tc_div_csa18 csa_a (.a({p2, 2'b0}), .b({1'b0, p1, 1'b0}), .ci({1'b0, ~p0[15], p0}),
.s(s_a), .co(co_a));
tc_div_csa18 csa_b (.a({p6, 2'b0}), .b({1'b0, p5, 1'b0}), .ci({2'b0, p4}),
.s(s_b), .co(co_b));
tc_div_csa18 csa_c (.a({p10, 2'b0}), .b({1'b0, p9, 1'b0}), .ci({2'b0, p8}),
.s(s_c), .co(co_c));
tc_div_csa19 csa_d (.a({p3, 3'b0}), .b({1'b0, co_a[16:1], 2'b0}), .ci({1'b0, s_a}),
.s(s_d), .co(co_d));
tc_div_csa19 csa_e (.a({p7, 3'b0}), .b({1'b0, co_b[16:1], 2'b0}), .ci({1'b0, s_b}),
.s(s_e), .co(co_e));
tc_div_csa19 csa_f (.a({p11, 3'b0}), .b({1'b0, co_c[16:1], 2'b0}), .ci({1'b0, s_c}),
.s(s_f), .co(co_f));
tc_div_csa18 csa_g (.a({p14, 2'b0}), .b({1'b0, p13, 1'b0}), .ci({2'b0, p12}),
.s(s_g), .co(co_g));
tc_div_csa23 csa_h (.a({co_e[17:2], 7'b0}), .b({4'b0, co_d[17:2], 3'b0}), .ci({4'b0, s_d}),
.s(s_h), .co(co_h));
tc_div_csa22 csa_i (.a({co_g[16:1], 6'b0}), .b({3'b0, co_f[17:2], 3'b0}), .ci({3'b0, s_f}),
.s(s_i), .co(co_i));
tc_div_csa23 csa_j (.a({s_e, 4'b0}), .b({3'b0, co_h[18:3], 4'b0}), .ci(s_h),
.s(s_j), .co(co_j));
tc_div_csa22 csa_k (.a({s_g, 4'b0}), .b({2'b0, co_i[18:3], 4'b0}), .ci(s_i),
.s(s_k), .co(co_k));
tc_div_csa30 csa_l (.a({co_k[20:4], 13'b0}), .b({6'b0, co_j[22:4], 5'b0}), .ci({7'b0, s_j}),
.s(s_l), .co(co_l));
tc_div_csa30 csa_m (.a({s_k, 8'b0}), .b({5'b0, co_l[23:5], 6'b0}), .ci(s_l),
.s(s_m), .co(co_m));
// carry-select adder
assign out[6:0] = s_m[6:0];
assign out[29:7] = s_m[29:7] + co_m[28:6]; //compass adder_arch carry_select_add
endmodule // tc_div_mul2
module tc_div_radd2 (a, b, s, co);
input [1:0] a;
input [1:0] b;
output [1:0] s;
output co;
wire [1:0] c;
ad01d1h rb0 (.a(a[0]), .b(b[0]), .ci(1'b0), .s(s[0]), .co(c[0]));
ad01d1h rb1 (.a(a[1]), .b(b[1]), .ci(c[0]), .s(s[1]), .co(c[1]));
assign co = c[1];
endmodule // tc_div_radd2
module tc_div_radd3 (a, b, ci, s, co);
input [2:0] a;
input [2:0] b;
input ci;
output [2:0] s;
output co;
wire [2:0] c;
ad01d1h rb0 (.a(a[0]), .b(b[0]), .ci(ci), .s(s[0]), .co(c[0]));
ad01d1h rb1 (.a(a[1]), .b(b[1]), .ci(c[0]), .s(s[1]), .co(c[1]));
ad01d1h rb2 (.a(a[2]), .b(b[2]), .ci(c[1]), .s(s[2]), .co(c[2]));
assign co = c[2];
endmodule // tc_div_radd3
module tc_div_radd4 (a, b, ci, s, co);
input [3:0] a;
input [3:0] b;
input ci;
output [3:0] s;
output co;
wire [3:0] c;
ad01d1h rb0 (.a(a[0]), .b(b[0]), .ci(ci), .s(s[0]), .co(c[0]));
ad01d1h rb1 (.a(a[1]), .b(b[1]), .ci(c[0]), .s(s[1]), .co(c[1]));
ad01d1h rb2 (.a(a[2]), .b(b[2]), .ci(c[1]), .s(s[2]), .co(c[2]));
ad01d1h rb3 (.a(a[3]), .b(b[3]), .ci(c[2]), .s(s[3]), .co(c[3]));
assign co = c[3];
endmodule // tc_div_radd4
module tc_div_radd5 (a, b, ci, s, co);
input [4:0] a;
input [4:0] b;
input ci;
output [4:0] s;
output co;
wire [4:0] c;
ad01d1h rb0 (.a(a[0]), .b(b[0]), .ci(ci), .s(s[0]), .co(c[0]));
ad01d1h rb1 (.a(a[1]), .b(b[1]), .ci(c[0]), .s(s[1]), .co(c[1]));
ad01d1h rb2 (.a(a[2]), .b(b[2]), .ci(c[1]), .s(s[2]), .co(c[2]));
ad01d1h rb3 (.a(a[3]), .b(b[3]), .ci(c[2]), .s(s[3]), .co(c[3]));
ad01d1h rb4 (.a(a[4]), .b(b[4]), .ci(c[3]), .s(s[4]), .co(c[4]));
assign co = c[4];
endmodule // tc_div_radd5
module tc_div_radd6 (a, b, ci, s, co);
input [5:0] a;
input [5:0] b;
input ci;
output [5:0] s;
output co;
wire [5:0] c;
ad01d1h rb0 (.a(a[0]), .b(b[0]), .ci(ci), .s(s[0]), .co(c[0]));
ad01d1h rb1 (.a(a[1]), .b(b[1]), .ci(c[0]), .s(s[1]), .co(c[1]));
ad01d1h rb2 (.a(a[2]), .b(b[2]), .ci(c[1]), .s(s[2]), .co(c[2]));
ad01d1h rb3 (.a(a[3]), .b(b[3]), .ci(c[2]), .s(s[3]), .co(c[3]));
ad01d1h rb4 (.a(a[4]), .b(b[4]), .ci(c[3]), .s(s[4]), .co(c[4]));
ad01d1h rb5 (.a(a[5]), .b(b[5]), .ci(c[4]), .s(s[5]), .co(c[5]));
assign co = c[5];
endmodule // tc_div_radd6
module tc_div_csa12 (a, b, ci, s, co);
input [11:0] a;
input [11:0] b;
input [11:0] ci;
output [11:0] s;
output [11:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
endmodule // tc_div_csa12
module tc_div_csa13 (a, b, ci, s, co);
input [12:0] a;
input [12:0] b;
input [12:0] ci;
output [12:0] s;
output [12:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
ad01d1h csb12 (.a(a[12]), .b(b[12]), .ci(ci[12]), .s(s[12]), .co(co[12]));
endmodule // tc_div_csa13
module tc_div_csa15 (a, b, ci, s, co);
input [14:0] a;
input [14:0] b;
input [14:0] ci;
output [14:0] s;
output [14:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
ad01d1h csb12 (.a(a[12]), .b(b[12]), .ci(ci[12]), .s(s[12]), .co(co[12]));
ad01d1h csb13 (.a(a[13]), .b(b[13]), .ci(ci[13]), .s(s[13]), .co(co[13]));
ad01d1h csb14 (.a(a[14]), .b(b[14]), .ci(ci[14]), .s(s[14]), .co(co[14]));
endmodule // tc_div_csa15
module tc_div_csa17 (a, b, ci, s, co);
input [16:0] a;
input [16:0] b;
input [16:0] ci;
output [16:0] s;
output [16:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
ad01d1h csb12 (.a(a[12]), .b(b[12]), .ci(ci[12]), .s(s[12]), .co(co[12]));
ad01d1h csb13 (.a(a[13]), .b(b[13]), .ci(ci[13]), .s(s[13]), .co(co[13]));
ad01d1h csb14 (.a(a[14]), .b(b[14]), .ci(ci[14]), .s(s[14]), .co(co[14]));
ad01d1h csb15 (.a(a[15]), .b(b[15]), .ci(ci[15]), .s(s[15]), .co(co[15]));
ad01d1h csb16 (.a(a[16]), .b(b[16]), .ci(ci[16]), .s(s[16]), .co(co[16]));
endmodule // tc_div_csa17
module tc_div_csa20 (a, b, ci, s, co);
input [19:0] a;
input [19:0] b;
input [19:0] ci;
output [19:0] s;
output [19:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
ad01d1h csb12 (.a(a[12]), .b(b[12]), .ci(ci[12]), .s(s[12]), .co(co[12]));
ad01d1h csb13 (.a(a[13]), .b(b[13]), .ci(ci[13]), .s(s[13]), .co(co[13]));
ad01d1h csb14 (.a(a[14]), .b(b[14]), .ci(ci[14]), .s(s[14]), .co(co[14]));
ad01d1h csb15 (.a(a[15]), .b(b[15]), .ci(ci[15]), .s(s[15]), .co(co[15]));
ad01d1h csb16 (.a(a[16]), .b(b[16]), .ci(ci[16]), .s(s[16]), .co(co[16]));
ad01d1h csb17 (.a(a[17]), .b(b[17]), .ci(ci[17]), .s(s[17]), .co(co[17]));
ad01d1h csb18 (.a(a[18]), .b(b[18]), .ci(ci[18]), .s(s[18]), .co(co[18]));
ad01d1h csb19 (.a(a[19]), .b(b[19]), .ci(ci[19]), .s(s[19]), .co(co[19]));
endmodule // tc_div_csa20
module tc_div_csa25 (a, b, ci, s, co);
input [24:0] a;
input [24:0] b;
input [24:0] ci;
output [24:0] s;
output [24:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
ad01d1h csb12 (.a(a[12]), .b(b[12]), .ci(ci[12]), .s(s[12]), .co(co[12]));
ad01d1h csb13 (.a(a[13]), .b(b[13]), .ci(ci[13]), .s(s[13]), .co(co[13]));
ad01d1h csb14 (.a(a[14]), .b(b[14]), .ci(ci[14]), .s(s[14]), .co(co[14]));
ad01d1h csb15 (.a(a[15]), .b(b[15]), .ci(ci[15]), .s(s[15]), .co(co[15]));
ad01d1h csb16 (.a(a[16]), .b(b[16]), .ci(ci[16]), .s(s[16]), .co(co[16]));
ad01d1h csb17 (.a(a[17]), .b(b[17]), .ci(ci[17]), .s(s[17]), .co(co[17]));
ad01d1h csb18 (.a(a[18]), .b(b[18]), .ci(ci[18]), .s(s[18]), .co(co[18]));
ad01d1h csb19 (.a(a[19]), .b(b[19]), .ci(ci[19]), .s(s[19]), .co(co[19]));
ad01d1h csb20 (.a(a[20]), .b(b[20]), .ci(ci[20]), .s(s[20]), .co(co[20]));
ad01d1h csb21 (.a(a[21]), .b(b[21]), .ci(ci[21]), .s(s[21]), .co(co[21]));
ad01d1h csb22 (.a(a[22]), .b(b[22]), .ci(ci[22]), .s(s[22]), .co(co[22]));
ad01d1h csb23 (.a(a[23]), .b(b[23]), .ci(ci[23]), .s(s[23]), .co(co[23]));
ad01d1h csb24 (.a(a[24]), .b(b[24]), .ci(ci[24]), .s(s[24]), .co(co[24]));
endmodule // tc_div_csa25
module tc_div_csa18 (a, b, ci, s, co);
input [17:0] a;
input [17:0] b;
input [17:0] ci;
output [17:0] s;
output [17:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
ad01d1h csb12 (.a(a[12]), .b(b[12]), .ci(ci[12]), .s(s[12]), .co(co[12]));
ad01d1h csb13 (.a(a[13]), .b(b[13]), .ci(ci[13]), .s(s[13]), .co(co[13]));
ad01d1h csb14 (.a(a[14]), .b(b[14]), .ci(ci[14]), .s(s[14]), .co(co[14]));
ad01d1h csb15 (.a(a[15]), .b(b[15]), .ci(ci[15]), .s(s[15]), .co(co[15]));
ad01d1h csb16 (.a(a[16]), .b(b[16]), .ci(ci[16]), .s(s[16]), .co(co[16]));
ad01d1h csb17 (.a(a[17]), .b(b[17]), .ci(ci[17]), .s(s[17]), .co(co[17]));
endmodule // tc_div_csa18
module tc_div_csa19 (a, b, ci, s, co);
input [18:0] a;
input [18:0] b;
input [18:0] ci;
output [18:0] s;
output [18:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
ad01d1h csb12 (.a(a[12]), .b(b[12]), .ci(ci[12]), .s(s[12]), .co(co[12]));
ad01d1h csb13 (.a(a[13]), .b(b[13]), .ci(ci[13]), .s(s[13]), .co(co[13]));
ad01d1h csb14 (.a(a[14]), .b(b[14]), .ci(ci[14]), .s(s[14]), .co(co[14]));
ad01d1h csb15 (.a(a[15]), .b(b[15]), .ci(ci[15]), .s(s[15]), .co(co[15]));
ad01d1h csb16 (.a(a[16]), .b(b[16]), .ci(ci[16]), .s(s[16]), .co(co[16]));
ad01d1h csb17 (.a(a[17]), .b(b[17]), .ci(ci[17]), .s(s[17]), .co(co[17]));
ad01d1h csb18 (.a(a[18]), .b(b[18]), .ci(ci[18]), .s(s[18]), .co(co[18]));
endmodule // tc_div_csa19
module tc_div_csa23 (a, b, ci, s, co);
input [22:0] a;
input [22:0] b;
input [22:0] ci;
output [22:0] s;
output [22:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
ad01d1h csb12 (.a(a[12]), .b(b[12]), .ci(ci[12]), .s(s[12]), .co(co[12]));
ad01d1h csb13 (.a(a[13]), .b(b[13]), .ci(ci[13]), .s(s[13]), .co(co[13]));
ad01d1h csb14 (.a(a[14]), .b(b[14]), .ci(ci[14]), .s(s[14]), .co(co[14]));
ad01d1h csb15 (.a(a[15]), .b(b[15]), .ci(ci[15]), .s(s[15]), .co(co[15]));
ad01d1h csb16 (.a(a[16]), .b(b[16]), .ci(ci[16]), .s(s[16]), .co(co[16]));
ad01d1h csb17 (.a(a[17]), .b(b[17]), .ci(ci[17]), .s(s[17]), .co(co[17]));
ad01d1h csb18 (.a(a[18]), .b(b[18]), .ci(ci[18]), .s(s[18]), .co(co[18]));
ad01d1h csb19 (.a(a[19]), .b(b[19]), .ci(ci[19]), .s(s[19]), .co(co[19]));
ad01d1h csb20 (.a(a[20]), .b(b[20]), .ci(ci[20]), .s(s[20]), .co(co[20]));
ad01d1h csb21 (.a(a[21]), .b(b[21]), .ci(ci[21]), .s(s[21]), .co(co[21]));
ad01d1h csb22 (.a(a[22]), .b(b[22]), .ci(ci[22]), .s(s[22]), .co(co[22]));
endmodule // tc_div_csa23
module tc_div_csa22 (a, b, ci, s, co);
input [21:0] a;
input [21:0] b;
input [21:0] ci;
output [21:0] s;
output [21:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
ad01d1h csb12 (.a(a[12]), .b(b[12]), .ci(ci[12]), .s(s[12]), .co(co[12]));
ad01d1h csb13 (.a(a[13]), .b(b[13]), .ci(ci[13]), .s(s[13]), .co(co[13]));
ad01d1h csb14 (.a(a[14]), .b(b[14]), .ci(ci[14]), .s(s[14]), .co(co[14]));
ad01d1h csb15 (.a(a[15]), .b(b[15]), .ci(ci[15]), .s(s[15]), .co(co[15]));
ad01d1h csb16 (.a(a[16]), .b(b[16]), .ci(ci[16]), .s(s[16]), .co(co[16]));
ad01d1h csb17 (.a(a[17]), .b(b[17]), .ci(ci[17]), .s(s[17]), .co(co[17]));
ad01d1h csb18 (.a(a[18]), .b(b[18]), .ci(ci[18]), .s(s[18]), .co(co[18]));
ad01d1h csb19 (.a(a[19]), .b(b[19]), .ci(ci[19]), .s(s[19]), .co(co[19]));
ad01d1h csb20 (.a(a[20]), .b(b[20]), .ci(ci[20]), .s(s[20]), .co(co[20]));
ad01d1h csb21 (.a(a[21]), .b(b[21]), .ci(ci[21]), .s(s[21]), .co(co[21]));
endmodule // tc_div_csa22
module tc_div_csa30 (a, b, ci, s, co);
input [29:0] a;
input [29:0] b;
input [29:0] ci;
output [29:0] s;
output [29:0] co;
ad01d1h csb0 (.a(a[0]), .b(b[0]), .ci(ci[0]), .s(s[0]), .co(co[0]));
ad01d1h csb1 (.a(a[1]), .b(b[1]), .ci(ci[1]), .s(s[1]), .co(co[1]));
ad01d1h csb2 (.a(a[2]), .b(b[2]), .ci(ci[2]), .s(s[2]), .co(co[2]));
ad01d1h csb3 (.a(a[3]), .b(b[3]), .ci(ci[3]), .s(s[3]), .co(co[3]));
ad01d1h csb4 (.a(a[4]), .b(b[4]), .ci(ci[4]), .s(s[4]), .co(co[4]));
ad01d1h csb5 (.a(a[5]), .b(b[5]), .ci(ci[5]), .s(s[5]), .co(co[5]));
ad01d1h csb6 (.a(a[6]), .b(b[6]), .ci(ci[6]), .s(s[6]), .co(co[6]));
ad01d1h csb7 (.a(a[7]), .b(b[7]), .ci(ci[7]), .s(s[7]), .co(co[7]));
ad01d1h csb8 (.a(a[8]), .b(b[8]), .ci(ci[8]), .s(s[8]), .co(co[8]));
ad01d1h csb9 (.a(a[9]), .b(b[9]), .ci(ci[9]), .s(s[9]), .co(co[9]));
ad01d1h csb10 (.a(a[10]), .b(b[10]), .ci(ci[10]), .s(s[10]), .co(co[10]));
ad01d1h csb11 (.a(a[11]), .b(b[11]), .ci(ci[11]), .s(s[11]), .co(co[11]));
ad01d1h csb12 (.a(a[12]), .b(b[12]), .ci(ci[12]), .s(s[12]), .co(co[12]));
ad01d1h csb13 (.a(a[13]), .b(b[13]), .ci(ci[13]), .s(s[13]), .co(co[13]));
ad01d1h csb14 (.a(a[14]), .b(b[14]), .ci(ci[14]), .s(s[14]), .co(co[14]));
ad01d1h csb15 (.a(a[15]), .b(b[15]), .ci(ci[15]), .s(s[15]), .co(co[15]));
ad01d1h csb16 (.a(a[16]), .b(b[16]), .ci(ci[16]), .s(s[16]), .co(co[16]));
ad01d1h csb17 (.a(a[17]), .b(b[17]), .ci(ci[17]), .s(s[17]), .co(co[17]));
ad01d1h csb18 (.a(a[18]), .b(b[18]), .ci(ci[18]), .s(s[18]), .co(co[18]));
ad01d1h csb19 (.a(a[19]), .b(b[19]), .ci(ci[19]), .s(s[19]), .co(co[19]));
ad01d1h csb20 (.a(a[20]), .b(b[20]), .ci(ci[20]), .s(s[20]), .co(co[20]));
ad01d1h csb21 (.a(a[21]), .b(b[21]), .ci(ci[21]), .s(s[21]), .co(co[21]));
ad01d1h csb22 (.a(a[22]), .b(b[22]), .ci(ci[22]), .s(s[22]), .co(co[22]));
ad01d1h csb23 (.a(a[23]), .b(b[23]), .ci(ci[23]), .s(s[23]), .co(co[23]));
ad01d1h csb24 (.a(a[24]), .b(b[24]), .ci(ci[24]), .s(s[24]), .co(co[24]));
ad01d1h csb25 (.a(a[25]), .b(b[25]), .ci(ci[25]), .s(s[25]), .co(co[25]));
ad01d1h csb26 (.a(a[26]), .b(b[26]), .ci(ci[26]), .s(s[26]), .co(co[26]));
ad01d1h csb27 (.a(a[27]), .b(b[27]), .ci(ci[27]), .s(s[27]), .co(co[27]));
ad01d1h csb28 (.a(a[28]), .b(b[28]), .ci(ci[28]), .s(s[28]), .co(co[28]));
ad01d1h csb29 (.a(a[29]), .b(b[29]), .ci(ci[29]), .s(s[29]), .co(co[29]));
endmodule // tc_div_csa30
module tc_div_16to1 (in, shift, out);
input [15:0] in;
input [3:0] shift;
output out;
wire [7:0] stg0;
wire [3:0] stg1;
wire [1:0] stg2;
mx21d1h mxa0 (.z(stg0[7]), .i0(in[15]), .i1(in[7]), .s(shift[3]));
mx21d1h mxa1 (.z(stg0[6]), .i0(in[14]), .i1(in[6]), .s(shift[3]));
mx21d1h mxa2 (.z(stg0[5]), .i0(in[13]), .i1(in[5]), .s(shift[3]));
mx21d1h mxa3 (.z(stg0[4]), .i0(in[12]), .i1(in[4]), .s(shift[3]));
mx21d1h mxa4 (.z(stg0[3]), .i0(in[11]), .i1(in[3]), .s(shift[3]));
mx21d1h mxa5 (.z(stg0[2]), .i0(in[10]), .i1(in[2]), .s(shift[3]));
mx21d1h mxa6 (.z(stg0[1]), .i0(in[9]), .i1(in[1]), .s(shift[3]));
mx21d1h mxa7 (.z(stg0[0]), .i0(in[8]), .i1(in[0]), .s(shift[3]));
mx21d1h mxb0 (.z(stg1[3]), .i0(stg0[7]), .i1(stg0[3]), .s(shift[2]));
mx21d1h mxb1 (.z(stg1[2]), .i0(stg0[6]), .i1(stg0[2]), .s(shift[2]));
mx21d1h mxb2 (.z(stg1[1]), .i0(stg0[5]), .i1(stg0[1]), .s(shift[2]));
mx21d1h mxb3 (.z(stg1[0]), .i0(stg0[4]), .i1(stg0[0]), .s(shift[2]));
mx21d1h mxc0 (.z(stg2[1]), .i0(stg1[3]), .i1(stg1[1]), .s(shift[1]));
mx21d1h mxc1 (.z(stg2[0]), .i0(stg1[2]), .i1(stg1[0]), .s(shift[1]));
mx21d1h mxd0 (.z(out), .i0(stg2[1]), .i1(stg2[0]), .s(shift[0]));
endmodule // tc_div_16to1