1 module wallace(a, b, product);
2
3
4 input [7:0] a;
5 input [7:0] b;
6 output [15:0] product;
7 assign b7a7 = b[7] & a[7];
8 assign b7a6 = b[7] & a[6];
9 assign b7a5 = b[7] & a[5];
10 assign b7a4 = b[7] & a[4];
11 assign b7a3 = b[7] & a[3];
12 assign b7a2 = b[7] & a[2];
13 assign b7a1 = b[7] & a[1];
14 assign b7a0 = b[7] & a[0];
15 assign b6a7 = b[6] & a[7];
16 assign b6a6 = b[6] & a[6];
17 assign b6a5 = b[6] & a[5];
18 assign b6a4 = b[6] & a[4];
19 assign b6a3 = b[6] & a[3];
20 assign b6a2 = b[6] & a[2];
21 assign b6a1 = b[6] & a[1];
22 assign b6a0 = b[6] & a[0];
23 assign b5a7 = b[5] & a[7];
24 assign b5a6 = b[5] & a[6];
25 assign b5a5 = b[5] & a[5];
26 assign b5a4 = b[5] & a[4];
27 assign b5a3 = b[5] & a[3];
28 assign b5a2 = b[5] & a[2];
29 assign b5a1 = b[5] & a[1];
30 assign b5a0 = b[5] & a[0];
31 assign b4a7 = b[4] & a[7];
32 assign b4a6 = b[4] & a[6];
33 assign b4a5 = b[4] & a[5];
34 assign b4a4 = b[4] & a[4];
35 assign b4a3 = b[4] & a[3];
36 assign b4a2 = b[4] & a[2];
37 assign b4a1 = b[4] & a[1];
38 assign b4a0 = b[4] & a[0];
39 assign b3a7 = b[3] & a[7];
40 assign b3a6 = b[3] & a[6];
41 assign b3a5 = b[3] & a[5];
42 assign b3a4 = b[3] & a[4];
43 assign b3a3 = b[3] & a[3];
44 assign b3a2 = b[3] & a[2];
45 assign b3a1 = b[3] & a[1];
46 assign b3a0 = b[3] & a[0];
47 assign b2a7 = b[2] & a[7];
48 assign b2a6 = b[2] & a[6];
49 assign b2a5 = b[2] & a[5];
50 assign b2a4 = b[2] & a[4];
51 assign b2a3 = b[2] & a[3];
52 assign b2a2 = b[2] & a[2];
53 assign b2a1 = b[2] & a[1];
54 assign b2a0 = b[2] & a[0];
55 assign b1a7 = b[1] & a[7];
56 assign b1a6 = b[1] & a[6];
57 assign b1a5 = b[1] & a[5];
58 assign b1a4 = b[1] & a[4];
59 assign b1a3 = b[1] & a[3];
60 assign b1a2 = b[1] & a[2];
61 assign b1a1 = b[1] & a[1];
62 assign b1a0 = b[1] & a[0];
63 assign b0a7 = b[0] & a[7];
64 assign b0a6 = b[0] & a[6];
65 assign b0a5 = b[0] & a[5];
66 assign b0a4 = b[0] & a[4];
67 assign b0a3 = b[0] & a[3];
68 assign b0a2 = b[0] & a[2];
69 assign b0a1 = b[0] & a[1];
70 assign b0a0 = b[0] & a[0];
71 assign aaaa = b7a6 ^ b6a7;
72 assign aaab = b7a6 & b6a7;
73 assign aaac = b5a7 ^ b7a5 ^ b6a6;
74 assign aaad = (b5a7 & b7a5) | (b6a6 & (b5a7 ^ b7a5));
75 assign aaae = b5a6 ^ b7a4 ^ b4a7;
76 assign aaaf = (b5a6 & b7a4) | (b4a7 & (b5a6 ^ b7a4));
77 assign aaag = b7a3 ^ b6a4 ^ b3a7;
78 assign aaah = (b7a3 & b6a4) | (b3a7 & (b7a3 ^ b6a4));
79 assign aaai = b4a6 ^ b5a5;
80 assign aaaj = b4a6 & b5a5;
81 assign aaak = b4a5 ^ b7a2 ^ b5a4;
82 assign aaal = (b4a5 & b7a2) | (b5a4 & (b4a5 ^ b7a2));
83 assign aaam = b6a3 ^ b2a7 ^ b3a6;
84 assign aaan = (b6a3 & b2a7) | (b3a6 & (b6a3 ^ b2a7));
85 assign aaao = b3a5 ^ b1a7 ^ b4a4;
86 assign aaap = (b3a5 & b1a7) | (b4a4 & (b3a5 ^ b1a7));
87 assign aaaq = b2a6 ^ b5a3 ^ b6a2;
88 assign aaar = (b2a6 & b5a3) | (b6a2 & (b2a6 ^ b5a3));
89 assign aaas = b4a3 ^ b3a4 ^ b5a2;
90 assign aaat = (b4a3 & b3a4) | (b5a2 & (b4a3 ^ b3a4));
91 assign aaau = b1a6 ^ b2a5 ^ b6a1;
92 assign aaav = (b1a6 & b2a5) | (b6a1 & (b1a6 ^ b2a5));
93 assign aaaw = b0a7 ^ b7a0;
94 assign aaax = b0a7 & b7a0;
95 assign aaay = b6a0 ^ b1a5 ^ b4a2;
96 assign aaaz = (b6a0 & b1a5) | (b4a2 & (b6a0 ^ b1a5));
97 assign aaba = b0a6 ^ b5a1 ^ b3a3;
98 assign aabb = (b0a6 & b5a1) | (b3a3 & (b0a6 ^ b5a1));
99 assign aabc = b3a2 ^ b1a4 ^ b0a5;
100 assign aabd = (b3a2 & b1a4) | (b0a5 & (b3a2 ^ b1a4));
101 assign aabe = b5a0 ^ b4a1 ^ b2a3;
102 assign aabf = (b5a0 & b4a1) | (b2a3 & (b5a0 ^ b4a1));
103 assign aabg = b0a4 ^ b1a3 ^ b4a0;
104 assign aabh = (b0a4 & b1a3) | (b4a0 & (b0a4 ^ b1a3));
105 assign aabi = b3a1 ^ b2a2;
106 assign aabj = b3a1 & b2a2;
107 assign aabk = b2a1 ^ b1a2 ^ b0a3;
108 assign aabl = (b2a1 & b1a2) | (b0a3 & (b2a1 ^ b1a2));
109 assign aabm = b0a2 ^ b2a0 ^ b1a1;
110 assign aabn = (b0a2 & b2a0) | (b1a1 & (b0a2 ^ b2a0));
111 assign aabo = b0a1 ^ b1a0;
112 assign aabp = b0a1 & b1a0;
113 assign aabq = b7a7 ^ aaab;
114 assign aabr = b7a7 & aaab;
115 assign aabs = aaaa ^ aaad;
116 assign aabt = aaaa & aaad;
117 assign aabu = aaaf ^ aaac;
118 assign aabv = aaaf & aaac;
119 assign aabw = aaaj ^ aaae ^ aaah;
120 assign aabx = (aaaj & aaae) | (aaah & (aaaj ^ aaae));
121 assign aaby = aaag ^ aaai ^ aaan;
122 assign aabz = (aaag & aaai) | (aaan & (aaag ^ aaai));
123 assign aaca = aaar ^ aaam ^ aaak;
124 assign aacb = (aaar & aaam) | (aaak & (aaar ^ aaam));
125 assign aacc = aaax ^ aaaq ^ aaat;
126 assign aacd = (aaax & aaaq) | (aaat & (aaax ^ aaaq));
127 assign aace = aaav ^ aaao ^ b7a1;
128 assign aacf = (aaav & aaao) | (b7a1 & (aaav ^ aaao));
129 assign aacg = aaau ^ aaas ^ aaaz;
130 assign aach = (aaau & aaas) | (aaaz & (aaau ^ aaas));
131 assign aaci = aabb ^ aaaw;
132 assign aacj = aabb & aaaw;
133 assign aack = aaba ^ aabf ^ aabd;
134 assign aacl = (aaba & aabf) | (aabd & (aaba ^ aabf));
135 assign aacm = b2a4 ^ aaay;
136 assign aacn = b2a4 & aaay;
137 assign aaco = aabh ^ aabe ^ aabc;
138 assign aacp = (aabh & aabe) | (aabc & (aabh ^ aabe));
139 assign aacq = aabg ^ aabi ^ aabl;
140 assign aacr = (aabg & aabi) | (aabl & (aabg ^ aabi));
141 assign aacs = aabn ^ b3a0 ^ aabk;
142 assign aact = (aabn & b3a0) | (aabk & (aabn ^ b3a0));
143 assign aacu = aabp ^ aabm;
144 assign aacv = aabp & aabm;
145 assign aacw = aabq ^ aabt;
146 assign aacx = aabq & aabt;
147 assign aacy = aabv ^ aabs;
148 assign aacz = aabv & aabs;
149 assign aada = aabu ^ aabx;
150 assign aadb = aabu & aabx;
151 assign aadc = b6a5 ^ aabz ^ aabw;
152 assign aadd = (b6a5 & aabz) | (aabw & (b6a5 ^ aabz));
153 assign aade = aacb ^ aaby ^ aaal;
154 assign aadf = (aacb & aaby) | (aaal & (aacb ^ aaby));
155 assign aadg = aacf ^ aacd ^ aaca;
156 assign aadh = (aacf & aacd) | (aaca & (aacf ^ aacd));
157 assign aadi = aacj ^ aace ^ aacc;
158 assign aadj = (aacj & aace) | (aacc & (aacj ^ aace));
159 assign aadk = aacn ^ aaci ^ aacg;
160 assign aadl = (aacn & aaci) | (aacg & (aacn ^ aaci));
161 assign aadm = aacp ^ aacm ^ aack;
162 assign aadn = (aacp & aacm) | (aack & (aacp ^ aacm));
163 assign aado = aaco ^ aabj ^ aacr;
164 assign aadp = (aaco & aabj) | (aacr & (aaco ^ aabj));
165 assign aadq = aacq ^ aact;
166 assign aadr = aacq & aact;
167 assign aads = aacs ^ aacv;
168 assign aadt = aacs & aacv;
169 assign aadu = aacx ^ aabr;
170 assign aadv = aacx & aabr;
171 assign aadw = aacz ^ aacw;
172 assign aadx = aacz & aacw;
173 assign aady = aacy ^ aadb;
174 assign aadz = aacy & aadb;
175 assign aaea = aadd ^ aada;
176 assign aaeb = aadd & aada;
177 assign aaec = aadf ^ aadc;
178 assign aaed = aadf & aadc;
179 assign aaee = aade ^ aadh;
180 assign aaef = aade & aadh;
181 assign aaeg = aadj ^ aadg ^ aaap;
182 assign aaeh = (aadj & aadg) | (aaap & (aadj ^ aadg));
183 assign aaei = aadi ^ aach ^ aadl;
184 assign aaej = (aadi & aach) | (aadl & (aadi ^ aach));
185 assign aaek = aadk ^ aacl ^ aadn;
186 assign aael = (aadk & aacl) | (aadn & (aadk ^ aacl));
187 assign aaem = aadm ^ aadp;
188 assign aaen = aadm & aadp;
189 assign aaeo = aado ^ aadr;
190 assign aaep = aado & aadr;
191 assign aaeq = aadt ^ aadq;
192 assign aaer = aadt & aadq;
193 assign product[0] = b0a0;
194 assign product[1] = aabo;
195 assign product[2] = aacu;
196 assign product[3] = aads;
197 assign product[4] = aaeq;
198 assign p000 = aaer ^ aaeo;
199 assign product[5] = p000;
200 assign g000 = aaer & aaeo;
201 buf(pa000,p000);
202 buf(ga000,g000);
203 buf(pb000,pa000);
204 buf(gb000,ga000);
205 buf(pc000,pb000);
206 buf(gc000,gb000);
207 buf(pd000,pc000);
208 buf(gd000,gc000);
209 assign p001 = aaep ^ aaem;
210 assign g001 = aaep & aaem;
211 assign product[6] = p001 ^ gd000;
212 assign pa001 = p001 & p000;
213 assign ga001 = g001 | (p001 & g000);
214 buf(pb001,pa001);
215 buf(gb001,ga001);
216 buf(pc001,pb001);
217 buf(gc001,gb001);
218 buf(pd001,pc001);
219 buf(gd001,gc001);
220 assign p002 = aaek ^ aaen;
221 assign g002 = aaek & aaen;
222 assign product[7] = p002 ^ gd001;
223 assign pa002 = p002 & p001;
224 assign ga002 = g002 | (p002 & g001);
225 assign pb002 = pa002 & pa000;
226 assign gb002 = ga002 | (pa002 & ga000);
227 buf(pc002,pb002);
228 buf(gc002,gb002);
229 buf(pd002,pc002);
230 buf(gd002,gc002);
231 assign p003 = aael ^ aaei;
232 assign g003 = aael & aaei;
233 assign product[8] = p003 ^ gd002;
234 assign pa003 = p003 & p002;
235 assign ga003 = g003 | (p003 & g002);
236 assign pb003 = pa003 & pa001;
237 assign gb003 = ga003 | (pa003 & ga001);
238 buf(pc003,pb003);
239 buf(gc003,gb003);
240 buf(pd003,pc003);
241 buf(gd003,gc003);
242 assign p004 = aaej ^ aaeg;
243 assign g004 = aaej & aaeg;
244 assign product[9] = p004 ^ gd003;
245 assign pa004 = p004 & p003;
246 assign ga004 = g004 | (p004 & g003);
247 assign pb004 = pa004 & pa002;
248 assign gb004 = ga004 | (pa004 & ga002);
249 assign pc004 = pb004 & pb000;
250 assign gc004 = gb004 | (pb004 & gb000);
251 buf(pd004,pc004);
252 buf(gd004,gc004);
253 assign p005 = aaee ^ aaeh;
254 assign g005 = aaee & aaeh;
255 assign product[10] = p005 ^ gd004;
256 assign pa005 = p005 & p004;
257 assign ga005 = g005 | (p005 & g004);
258 assign pb005 = pa005 & pa003;
259 assign gb005 = ga005 | (pa005 & ga003);
260 assign pc005 = pb005 & pb001;
261 assign gc005 = gb005 | (pb005 & gb001);
262 buf(pd005,pc005);
263 buf(gd005,gc005);
264 assign p006 = aaef ^ aaec;
265 assign g006 = aaef & aaec;
266 assign product[11] = p006 ^ gd005;
267 assign pa006 = p006 & p005;
268 assign ga006 = g006 | (p006 & g005);
269 assign pb006 = pa006 & pa004;
270 assign gb006 = ga006 | (pa006 & ga004);
271 assign pc006 = pb006 & pb002;
272 assign gc006 = gb006 | (pb006 & gb002);
273 buf(pd006,pc006);
274 buf(gd006,gc006);
275 assign p007 = aaed ^ aaea;
276 assign g007 = aaed & aaea;
277 assign product[12] = p007 ^ gd006;
278 assign pa007 = p007 & p006;
279 assign ga007 = g007 | (p007 & g006);
280 assign pb007 = pa007 & pa005;
281 assign gb007 = ga007 | (pa007 & ga005);
282 assign pc007 = pb007 & pb003;
283 assign gc007 = gb007 | (pb007 & gb003);
284 buf(pd007,pc007);
285 buf(gd007,gc007);
286 assign p008 = aady ^ aaeb;
287 assign g008 = aady & aaeb;
288 assign product[13] = p008 ^ gd007;
289 assign pa008 = p008 & p007;
290 assign ga008 = g008 | (p008 & g007);
291 assign pb008 = pa008 & pa006;
292 assign gb008 = ga008 | (pa008 & ga006);
293 assign pc008 = pb008 & pb004;
294 assign gc008 = gb008 | (pb008 & gb004);
295 assign pd008 = pc008 & pc000;
296 assign gd008 = gc008 | (pc008 & gc000);
297 assign p009 = aadz ^ aadw;
298 assign g009 = aadz & aadw;
299 assign product[14] = p009 ^ gd008;
300 assign pa009 = p009 & p008;
301 assign ga009 = g009 | (p009 & g008);
302 assign pb009 = pa009 & pa007;
303 assign gb009 = ga009 | (pa009 & ga007);
304 assign pc009 = pb009 & pb005;
305 assign gc009 = gb009 | (pb009 & gb005);
306 assign pd009 = pc009 & pc001;
307 assign gd009 = gc009 | (pc009 & gc001);
308 assign p010 = aadu ^ aadx;
309 assign product[15] = p010 ^ gd009;
310 endmodule