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

Subversion Repositories pid_controller

[/] [pid_controller/] [trunk/] [RTL/] [CLA_fixed.v] - Blame information for rev 12

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 m99
/*Carry look-ahead adder
2
Author: Zhu Xu
3
Email: m99a1@yahoo.cn
4
*/
5
 
6
module  operator_A(
7
input   A,
8
input   B,
9
output  P,
10
output  G
11
);
12
 
13
assign  P=A^B;
14
assign  G=A&B;
15
 
16
endmodule
17
 
18
module  operator_B(
19
input   P,G,P1,G1,
20
output  Po,Go
21
);
22
 
23
assign  Po=P&P1;
24
assign  Go=G|(P&G1);
25
 
26
endmodule
27
 
28
module  operator_C(
29
input   P,G,G1,
30
output  Go
31
);
32
 
33
assign  Go=G|(P&G1);
34
 
35
endmodule
36
 
37
 
38
/* 32-bit prefix-2 Han-Carlson adder
39
stage 0:        Number of Generation=32,        NP=32,  NOA=32, NOB=0,  NOC=0.
40
stage 1:        NG=16,  NP=15,  NOA=0,  NOB=15, NOC=1.
41
stage 2:        NG=16,  NP=14,  NOA=0,  NOB=14, NOC=1.
42
stage 3:        NG=16,  NP=12,  NOA=0,  NOB=12, NOC=2.
43
stage 4:        NG=16,  NP=8,   NOA=0,  NOB=8,  NOC=4.
44
stage 5:        NG=16,  NP=0,   NOA=0,  NOB=0,  NOC=8.
45
stage 6;        NG=32,  NP=0,   NOA=0,  NOB=0,  NOC=15.
46
*/
47
module  adder_32bit(
48
input   [31:0]i_a,i_b,
49
input   i_c,
50
output  [31:0]o_s,
51
output  o_c
52
);
53
 
54
//stage 0
55
wire    [31:0]P0,G0;
56
operator_A      operator_A_0(i_a[0],i_b[0],P0[0],G0[0]);
57
operator_A      operator_A_1(i_a[1],i_b[1],P0[1],G0[1]);
58
operator_A      operator_A_2(i_a[2],i_b[2],P0[2],G0[2]);
59
operator_A      operator_A_3(i_a[3],i_b[3],P0[3],G0[3]);
60
operator_A      operator_A_4(i_a[4],i_b[4],P0[4],G0[4]);
61
operator_A      operator_A_5(i_a[5],i_b[5],P0[5],G0[5]);
62
operator_A      operator_A_6(i_a[6],i_b[6],P0[6],G0[6]);
63
operator_A      operator_A_7(i_a[7],i_b[7],P0[7],G0[7]);
64
operator_A      operator_A_8(i_a[8],i_b[8],P0[8],G0[8]);
65
operator_A      operator_A_9(i_a[9],i_b[9],P0[9],G0[9]);
66
operator_A      operator_A_10(i_a[10],i_b[10],P0[10],G0[10]);
67
operator_A      operator_A_11(i_a[11],i_b[11],P0[11],G0[11]);
68
operator_A      operator_A_12(i_a[12],i_b[12],P0[12],G0[12]);
69
operator_A      operator_A_13(i_a[13],i_b[13],P0[13],G0[13]);
70
operator_A      operator_A_14(i_a[14],i_b[14],P0[14],G0[14]);
71
operator_A      operator_A_15(i_a[15],i_b[15],P0[15],G0[15]);
72
operator_A      operator_A_16(i_a[16],i_b[16],P0[16],G0[16]);
73
operator_A      operator_A_17(i_a[17],i_b[17],P0[17],G0[17]);
74
operator_A      operator_A_18(i_a[18],i_b[18],P0[18],G0[18]);
75
operator_A      operator_A_19(i_a[19],i_b[19],P0[19],G0[19]);
76
operator_A      operator_A_20(i_a[20],i_b[20],P0[20],G0[20]);
77
operator_A      operator_A_21(i_a[21],i_b[21],P0[21],G0[21]);
78
operator_A      operator_A_22(i_a[22],i_b[22],P0[22],G0[22]);
79
operator_A      operator_A_23(i_a[23],i_b[23],P0[23],G0[23]);
80
operator_A      operator_A_24(i_a[24],i_b[24],P0[24],G0[24]);
81
operator_A      operator_A_25(i_a[25],i_b[25],P0[25],G0[25]);
82
operator_A      operator_A_26(i_a[26],i_b[26],P0[26],G0[26]);
83
operator_A      operator_A_27(i_a[27],i_b[27],P0[27],G0[27]);
84
operator_A      operator_A_28(i_a[28],i_b[28],P0[28],G0[28]);
85
operator_A      operator_A_29(i_a[29],i_b[29],P0[29],G0[29]);
86
operator_A      operator_A_30(i_a[30],i_b[30],P0[30],G0[30]);
87
operator_A      operator_A_31(i_a[31],i_b[31],P0[31],G0[31]);
88
 
89
//stage 1
90
wire    [15:0]G1;
91
wire    [15:1]P1;
92
operator_C      operator_C_stage_1_0(P0[0],G0[0],i_c,G1[0]);
93
operator_B      operator_B_stage_1_1(P0[2],G0[2],P0[1],G0[1],P1[1],G1[1]);
94
operator_B      operator_B_stage_1_2(P0[4],G0[4],P0[3],G0[3],P1[2],G1[2]);
95
operator_B      operator_B_stage_1_3(P0[6],G0[6],P0[5],G0[5],P1[3],G1[3]);
96
operator_B      operator_B_stage_1_4(P0[8],G0[8],P0[7],G0[7],P1[4],G1[4]);
97
operator_B      operator_B_stage_1_5(P0[10],G0[10],P0[9],G0[9],P1[5],G1[5]);
98
operator_B      operator_B_stage_1_6(P0[12],G0[12],P0[11],G0[11],P1[6],G1[6]);
99
operator_B      operator_B_stage_1_7(P0[14],G0[14],P0[13],G0[13],P1[7],G1[7]);
100
operator_B      operator_B_stage_1_8(P0[16],G0[16],P0[15],G0[15],P1[8],G1[8]);
101
operator_B      operator_B_stage_1_9(P0[18],G0[18],P0[17],G0[17],P1[9],G1[9]);
102
operator_B      operator_B_stage_1_10(P0[20],G0[20],P0[19],G0[19],P1[10],G1[10]);
103
operator_B      operator_B_stage_1_11(P0[22],G0[22],P0[21],G0[21],P1[11],G1[11]);
104
operator_B      operator_B_stage_1_12(P0[24],G0[24],P0[23],G0[23],P1[12],G1[12]);
105
operator_B      operator_B_stage_1_13(P0[26],G0[26],P0[25],G0[25],P1[13],G1[13]);
106
operator_B      operator_B_stage_1_14(P0[28],G0[28],P0[27],G0[27],P1[14],G1[14]);
107
operator_B      operator_B_stage_1_15(P0[30],G0[30],P0[29],G0[29],P1[15],G1[15]);
108
 
109
 
110
 
111
//stage 2
112
wire    [15:0]G2;
113
wire    [15:2]P2;
114
assign  G2[0]=G1[0];
115
operator_C      operator_C_stage_2_1(P1[1],G1[1],G1[0],G2[1]);
116
operator_B      operator_B_stage_2_2(P1[2], G1[2],P1[1],G1[1],P2[2],G2[2]);
117
operator_B      operator_B_stage_2_3(P1[3], G1[3],P1[2],G1[2],P2[3],G2[3]);
118
operator_B      operator_B_stage_2_4(P1[4], G1[4],P1[3],G1[3],P2[4],G2[4]);
119
operator_B      operator_B_stage_2_5(P1[5], G1[5],P1[4],G1[4],P2[5],G2[5]);
120
operator_B      operator_B_stage_2_6(P1[6], G1[6],P1[5],G1[5],P2[6],G2[6]);
121
operator_B      operator_B_stage_2_7(P1[7], G1[7],P1[6],G1[6],P2[7],G2[7]);
122
operator_B      operator_B_stage_2_8(P1[8], G1[8],P1[7],G1[7],P2[8],G2[8]);
123
operator_B      operator_B_stage_2_9(P1[9], G1[9],P1[8],G1[8],P2[9],G2[9]);
124
operator_B      operator_B_stage_2_10(P1[10], G1[10],P1[9],G1[9],P2[10],G2[10]);
125
operator_B      operator_B_stage_2_11(P1[11], G1[11],P1[10],G1[10],P2[11],G2[11]);
126
operator_B      operator_B_stage_2_12(P1[12], G1[12],P1[11],G1[11],P2[12],G2[12]);
127
operator_B      operator_B_stage_2_13(P1[13], G1[13],P1[12],G1[12],P2[13],G2[13]);
128
operator_B      operator_B_stage_2_14(P1[14], G1[14],P1[13],G1[13],P2[14],G2[14]);
129
operator_B      operator_B_stage_2_15(P1[15], G1[15],P1[14],G1[14],P2[15],G2[15]);
130
 
131
//stage 3
132
wire    [15:0]G3;
133
wire    [15:4]P3;
134
assign  G3[0]=G2[0];
135
assign  G3[1]=G2[1];
136
operator_C      operator_C_stage_3_2(P2[2],G2[2],G2[0],G3[2]);
137
operator_C      operator_C_stage_3_3(P2[3],G2[3],G2[1],G3[3]);
138
operator_B      operator_B_stage_3_4(P2[4], G2[4],P2[2],G2[2],P3[4],G3[4]);
139
operator_B      operator_B_stage_3_5(P2[5], G2[5],P2[3],G2[3],P3[5],G3[5]);
140
operator_B      operator_B_stage_3_6(P2[6], G2[6],P2[4],G2[4],P3[6],G3[6]);
141
operator_B      operator_B_stage_3_7(P2[7], G2[7],P2[5],G2[5],P3[7],G3[7]);
142
operator_B      operator_B_stage_3_8(P2[8], G2[8],P2[6],G2[6],P3[8],G3[8]);
143
operator_B      operator_B_stage_3_9(P2[9], G2[9],P2[7],G2[7],P3[9],G3[9]);
144
operator_B      operator_B_stage_3_10(P2[10], G2[10],P2[8],G2[8],P3[10],G3[10]);
145
operator_B      operator_B_stage_3_11(P2[11], G2[11],P2[9],G2[9],P3[11],G3[11]);
146
operator_B      operator_B_stage_3_12(P2[12], G2[12],P2[10],G2[10],P3[12],G3[12]);
147
operator_B      operator_B_stage_3_13(P2[13], G2[13],P2[11],G2[11],P3[13],G3[13]);
148
operator_B      operator_B_stage_3_14(P2[14], G2[14],P2[12],G2[12],P3[14],G3[14]);
149
operator_B      operator_B_stage_3_15(P2[15], G2[15],P2[13],G2[13],P3[15],G3[15]);
150
 
151
//stage 4
152
wire    [15:0]G4;
153
wire    [15:8]P4;
154
assign  G4[0]=G3[0];
155
assign  G4[1]=G3[1];
156
assign  G4[2]=G3[2];
157
assign  G4[3]=G3[3];
158
operator_C      operator_C_stage_4_4(P3[4],G3[4],G3[0],G4[4]);
159
operator_C      operator_C_stage_4_5(P3[5],G3[5],G3[1],G4[5]);
160
operator_C      operator_C_stage_4_6(P3[6],G3[6],G3[2],G4[6]);
161
operator_C      operator_C_stage_4_7(P3[7],G3[7],G3[3],G4[7]);
162
operator_B      operator_B_stage_4_8(P3[8], G3[8],P3[4],G3[4],P4[8],G4[8]);
163
operator_B      operator_B_stage_4_9(P3[9], G3[9],P3[5],G3[5],P4[9],G4[9]);
164
operator_B      operator_B_stage_4_10(P3[10], G3[10],P3[6],G3[6],P4[10],G4[10]);
165
operator_B      operator_B_stage_4_11(P3[11], G3[11],P3[7],G3[7],P4[11],G4[11]);
166
operator_B      operator_B_stage_4_12(P3[12], G3[12],P3[8],G3[8],P4[12],G4[12]);
167
operator_B      operator_B_stage_4_13(P3[13], G3[13],P3[9],G3[9],P4[13],G4[13]);
168
operator_B      operator_B_stage_4_14(P3[14], G3[14],P3[10],G3[10],P4[14],G4[14]);
169
operator_B      operator_B_stage_4_15(P3[15], G3[15],P3[11],G3[11],P4[15],G4[15]);
170
 
171
//stage 5
172
wire    [15:0]G5;
173
assign  G5[0]=G4[0];
174
assign  G5[1]=G4[1];
175
assign  G5[2]=G4[2];
176
assign  G5[3]=G4[3];
177
assign  G5[4]=G4[4];
178
assign  G5[5]=G4[5];
179
assign  G5[6]=G4[6];
180
assign  G5[7]=G4[7];
181
operator_C      operator_C_stage_5_8(P4[8],G4[8],G4[0],G5[8]);
182
operator_C      operator_C_stage_5_9(P4[9],G4[9],G4[1],G5[9]);
183
operator_C      operator_C_stage_5_10(P4[10],G4[10],G4[2],G5[10]);
184
operator_C      operator_C_stage_5_11(P4[11],G4[11],G4[3],G5[11]);
185
operator_C      operator_C_stage_5_12(P4[12],G4[12],G4[4],G5[12]);
186
operator_C      operator_C_stage_5_13(P4[13],G4[13],G4[5],G5[13]);
187
operator_C      operator_C_stage_5_14(P4[14],G4[14],G4[6],G5[14]);
188
operator_C      operator_C_stage_5_15(P4[15],G4[15],G4[7],G5[15]);
189
 
190
//stage 6
191
wire    [31:0]G6;
192
assign  G6[0]=G5[0];
193
assign  G6[2]=G5[1];
194
assign  G6[4]=G5[2];
195
assign  G6[6]=G5[3];
196
assign  G6[8]=G5[4];
197
assign  G6[10]=G5[5];
198
assign  G6[12]=G5[6];
199
assign  G6[14]=G5[7];
200
assign  G6[16]=G5[8];
201
assign  G6[18]=G5[9];
202
assign  G6[20]=G5[10];
203
assign  G6[22]=G5[11];
204
assign  G6[24]=G5[12];
205
assign  G6[26]=G5[13];
206
assign  G6[28]=G5[14];
207
assign  G6[30]=G5[15];
208
operator_C      operator_C_stage_6_0(P0[1],G0[1],G5[0],G6[1]);
209
operator_C      operator_C_stage_6_1(P0[3],G0[3],G5[1],G6[3]);
210
operator_C      operator_C_stage_6_2(P0[5],G0[5],G5[2],G6[5]);
211
operator_C      operator_C_stage_6_3(P0[7],G0[7],G5[3],G6[7]);
212
operator_C      operator_C_stage_6_4(P0[9],G0[9],G5[4],G6[9]);
213
operator_C      operator_C_stage_6_5(P0[11],G0[11],G5[5],G6[11]);
214
operator_C      operator_C_stage_6_6(P0[13],G0[13],G5[6],G6[13]);
215
operator_C      operator_C_stage_6_7(P0[15],G0[15],G5[7],G6[15]);
216
operator_C      operator_C_stage_6_8(P0[17],G0[17],G5[8],G6[17]);
217
operator_C      operator_C_stage_6_9(P0[19],G0[19],G5[9],G6[19]);
218
operator_C      operator_C_stage_6_10(P0[21],G0[21],G5[10],G6[21]);
219
operator_C      operator_C_stage_6_11(P0[23],G0[23],G5[11],G6[23]);
220
operator_C      operator_C_stage_6_12(P0[25],G0[25],G5[12],G6[25]);
221
operator_C      operator_C_stage_6_13(P0[27],G0[27],G5[13],G6[27]);
222
operator_C      operator_C_stage_6_14(P0[29],G0[29],G5[14],G6[29]);
223
operator_C      operator_C_stage_6_15(P0[31],G0[31],G5[15],G6[31]);
224
 
225
assign  o_s[0]=P0[0]^i_c;
226
assign  o_s[1]=P0[1]^G6[0];
227
assign  o_s[2]=P0[2]^G6[1];
228
assign  o_s[3]=P0[3]^G6[2];
229
assign  o_s[4]=P0[4]^G6[3];
230
assign  o_s[5]=P0[5]^G6[4];
231
assign  o_s[6]=P0[6]^G6[5];
232
assign  o_s[7]=P0[7]^G6[6];
233
assign  o_s[8]=P0[8]^G6[7];
234
assign  o_s[9]=P0[9]^G6[8];
235
assign  o_s[10]=P0[10]^G6[9];
236
assign  o_s[11]=P0[11]^G6[10];
237
assign  o_s[12]=P0[12]^G6[11];
238
assign  o_s[13]=P0[13]^G6[12];
239
assign  o_s[14]=P0[14]^G6[13];
240
assign  o_s[15]=P0[15]^G6[14];
241
assign  o_s[16]=P0[16]^G6[15];
242
assign  o_s[17]=P0[17]^G6[16];
243
assign  o_s[18]=P0[18]^G6[17];
244
assign  o_s[19]=P0[19]^G6[18];
245
assign  o_s[20]=P0[20]^G6[19];
246
assign  o_s[21]=P0[21]^G6[20];
247
assign  o_s[22]=P0[22]^G6[21];
248
assign  o_s[23]=P0[23]^G6[22];
249
assign  o_s[24]=P0[24]^G6[23];
250
assign  o_s[25]=P0[25]^G6[24];
251
assign  o_s[26]=P0[26]^G6[25];
252
assign  o_s[27]=P0[27]^G6[26];
253
assign  o_s[28]=P0[28]^G6[27];
254
assign  o_s[29]=P0[29]^G6[28];
255
assign  o_s[30]=P0[30]^G6[29];
256
assign  o_s[31]=P0[31]^G6[30];
257
assign  o_c=G6[31];
258
 
259
endmodule

powered by: WebSVN 2.1.0

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