1 /**CFile****************************************************************
2
3 FileName [abcGen.c]
4
5 SystemName [ABC: Logic synthesis and verification system.]
6
7 PackageName [Network and node package.]
8
9 Synopsis [Procedures to generate various type of circuits.]
10
11 Author [Alan Mishchenko]
12
13 Affiliation [UC Berkeley]
14
15 Date [Ver. 1.0. Started - June 20, 2005.]
16
17 Revision [$Id: abcGen.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18
19 ***********************************************************************/
20
21 #include "base/abc/abc.h"
22 #include "aig/miniaig/miniaig.h"
23
24 ABC_NAMESPACE_IMPL_START
25
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33
34 /**Function*************************************************************
35
36 Synopsis []
37
38 Description []
39
40 SideEffects []
41
42 SeeAlso []
43
44 ***********************************************************************/
Abc_WriteFullAdder(FILE * pFile)45 void Abc_WriteFullAdder( FILE * pFile )
46 {
47 int fNaive = 0;
48 fprintf( pFile, ".model FA\n" );
49 fprintf( pFile, ".inputs a b cin\n" );
50 fprintf( pFile, ".outputs s cout\n" );
51 if ( fNaive )
52 {
53 fprintf( pFile, ".names a b k\n" );
54 fprintf( pFile, "10 1\n" );
55 fprintf( pFile, "01 1\n" );
56 fprintf( pFile, ".names k cin s\n" );
57 fprintf( pFile, "10 1\n" );
58 fprintf( pFile, "01 1\n" );
59 fprintf( pFile, ".names a b cin cout\n" );
60 fprintf( pFile, "11- 1\n" );
61 fprintf( pFile, "1-1 1\n" );
62 fprintf( pFile, "-11 1\n" );
63 }
64 else
65 {
66 fprintf( pFile, ".names a b and1\n" );
67 fprintf( pFile, "11 1\n" );
68 fprintf( pFile, ".names a b and1_\n" );
69 fprintf( pFile, "00 1\n" );
70 fprintf( pFile, ".names and1 and1_ xor\n" );
71 fprintf( pFile, "00 1\n" );
72
73 fprintf( pFile, ".names cin xor and2\n" );
74 fprintf( pFile, "11 1\n" );
75 fprintf( pFile, ".names cin xor and2_\n" );
76 fprintf( pFile, "00 1\n" );
77 fprintf( pFile, ".names and2 and2_ s\n" );
78 fprintf( pFile, "00 1\n" );
79
80 fprintf( pFile, ".names and1 and2 cout\n" );
81 fprintf( pFile, "00 0\n" );
82 }
83 fprintf( pFile, ".end\n" );
84 fprintf( pFile, "\n" );
85 }
Abc_WriteAdder(FILE * pFile,int nVars)86 void Abc_WriteAdder( FILE * pFile, int nVars )
87 {
88 int i, nDigits = Abc_Base10Log( nVars );
89
90 assert( nVars > 0 );
91 fprintf( pFile, ".model ADD%d\n", nVars );
92
93 fprintf( pFile, ".inputs" );
94 for ( i = 0; i < nVars; i++ )
95 fprintf( pFile, " a%0*d", nDigits, i );
96 for ( i = 0; i < nVars; i++ )
97 fprintf( pFile, " b%0*d", nDigits, i );
98 fprintf( pFile, "\n" );
99
100 fprintf( pFile, ".outputs" );
101 for ( i = 0; i <= nVars; i++ )
102 fprintf( pFile, " s%0*d", nDigits, i );
103 fprintf( pFile, "\n" );
104
105 fprintf( pFile, ".names c\n" );
106 if ( nVars == 1 )
107 fprintf( pFile, ".subckt FA a=a0 b=b0 cin=c s=y0 cout=s1\n" );
108 else
109 {
110 fprintf( pFile, ".subckt FA a=a%0*d b=b%0*d cin=c s=s%0*d cout=%0*d\n", nDigits, 0, nDigits, 0, nDigits, 0, nDigits, 0 );
111 for ( i = 1; i < nVars-1; i++ )
112 fprintf( pFile, ".subckt FA a=a%0*d b=b%0*d cin=%0*d s=s%0*d cout=%0*d\n", nDigits, i, nDigits, i, nDigits, i-1, nDigits, i, nDigits, i );
113 fprintf( pFile, ".subckt FA a=a%0*d b=b%0*d cin=%0*d s=s%0*d cout=s%0*d\n", nDigits, i, nDigits, i, nDigits, i-1, nDigits, i, nDigits, i+1 );
114 }
115 fprintf( pFile, ".end\n" );
116 fprintf( pFile, "\n" );
117 Abc_WriteFullAdder( pFile );
118 }
Abc_GenAdder(char * pFileName,int nVars)119 void Abc_GenAdder( char * pFileName, int nVars )
120 {
121 FILE * pFile;
122 assert( nVars > 0 );
123 pFile = fopen( pFileName, "w" );
124 fprintf( pFile, "# %d-bit ripple-carry adder generated by ABC on %s\n", nVars, Extra_TimeStamp() );
125 Abc_WriteAdder( pFile, nVars );
126 fclose( pFile );
127 }
128
129 /**Function*************************************************************
130
131 Synopsis []
132
133 Description []
134
135 SideEffects []
136
137 SeeAlso []
138
139 ***********************************************************************/
Abc_WriteMulti(FILE * pFile,int nVars)140 void Abc_WriteMulti( FILE * pFile, int nVars )
141 {
142 int i, k, nDigits = Abc_Base10Log( nVars ), nDigits2 = Abc_Base10Log( 2*nVars );
143
144 assert( nVars > 0 );
145 fprintf( pFile, ".model Multi%d\n", nVars );
146
147 fprintf( pFile, ".inputs" );
148 for ( i = 0; i < nVars; i++ )
149 fprintf( pFile, " a%0*d", nDigits, i );
150 for ( i = 0; i < nVars; i++ )
151 fprintf( pFile, " b%0*d", nDigits, i );
152 fprintf( pFile, "\n" );
153
154 fprintf( pFile, ".outputs" );
155 for ( i = 0; i < 2*nVars; i++ )
156 fprintf( pFile, " m%0*d", nDigits2, i );
157 fprintf( pFile, "\n" );
158
159 for ( i = 0; i < 2*nVars; i++ )
160 fprintf( pFile, ".names x%0*d_%0*d\n", nDigits, 0, nDigits2, i );
161 for ( k = 0; k < nVars; k++ )
162 {
163 for ( i = 0; i < 2 * nVars; i++ )
164 if ( i >= k && i < k + nVars )
165 fprintf( pFile, ".names b%0*d a%0*d y%0*d_%0*d\n11 1\n", nDigits, k, nDigits, i-k, nDigits, k, nDigits2, i );
166 else
167 fprintf( pFile, ".names y%0*d_%0*d\n", nDigits, k, nDigits2, i );
168 fprintf( pFile, ".subckt ADD%d", 2*nVars );
169 for ( i = 0; i < 2*nVars; i++ )
170 fprintf( pFile, " a%0*d=x%0*d_%0*d", nDigits2, i, nDigits, k, nDigits2, i );
171 for ( i = 0; i < 2*nVars; i++ )
172 fprintf( pFile, " b%0*d=y%0*d_%0*d", nDigits2, i, nDigits, k, nDigits2, i );
173 for ( i = 0; i <= 2*nVars; i++ )
174 fprintf( pFile, " s%0*d=x%0*d_%0*d", nDigits2, i, nDigits, k+1, nDigits2, i );
175 fprintf( pFile, "\n" );
176 }
177 for ( i = 0; i < 2 * nVars; i++ )
178 fprintf( pFile, ".names x%0*d_%0*d m%0*d\n1 1\n", nDigits, k, nDigits2, i, nDigits2, i );
179 fprintf( pFile, ".end\n" );
180 fprintf( pFile, "\n" );
181 Abc_WriteAdder( pFile, 2*nVars );
182 }
Abc_GenMulti(char * pFileName,int nVars)183 void Abc_GenMulti( char * pFileName, int nVars )
184 {
185 FILE * pFile;
186 assert( nVars > 0 );
187 pFile = fopen( pFileName, "w" );
188 fprintf( pFile, "# %d-bit multiplier generated by ABC on %s\n", nVars, Extra_TimeStamp() );
189 Abc_WriteMulti( pFile, nVars );
190 fclose( pFile );
191 }
192
193 /**Function*************************************************************
194
195 Synopsis []
196
197 Description []
198
199 SideEffects []
200
201 SeeAlso []
202
203 ***********************************************************************/
Abc_WriteComp(FILE * pFile)204 void Abc_WriteComp( FILE * pFile )
205 {
206 fprintf( pFile, ".model Comp\n" );
207 fprintf( pFile, ".inputs a b\n" );
208 fprintf( pFile, ".outputs x y\n" );
209 fprintf( pFile, ".names a b x\n" );
210 fprintf( pFile, "11 1\n" );
211 fprintf( pFile, ".names a b y\n" );
212 fprintf( pFile, "1- 1\n" );
213 fprintf( pFile, "-1 1\n" );
214 fprintf( pFile, ".end\n" );
215 fprintf( pFile, "\n" );
216 }
Abc_WriteLayer(FILE * pFile,int nVars,int fSkip1)217 void Abc_WriteLayer( FILE * pFile, int nVars, int fSkip1 )
218 {
219 int i;
220 fprintf( pFile, ".model Layer%d\n", fSkip1 );
221 fprintf( pFile, ".inputs" );
222 for ( i = 0; i < nVars; i++ )
223 fprintf( pFile, " x%02d", i );
224 fprintf( pFile, "\n" );
225 fprintf( pFile, ".outputs" );
226 for ( i = 0; i < nVars; i++ )
227 fprintf( pFile, " y%02d", i );
228 fprintf( pFile, "\n" );
229 if ( fSkip1 )
230 {
231 fprintf( pFile, ".names x00 y00\n" );
232 fprintf( pFile, "1 1\n" );
233 i = 1;
234 }
235 else
236 i = 0;
237 for ( ; i + 1 < nVars; i += 2 )
238 fprintf( pFile, ".subckt Comp a=x%02d b=x%02d x=y%02d y=y%02d\n", i, i+1, i, i+1 );
239 if ( i < nVars )
240 {
241 fprintf( pFile, ".names x%02d y%02d\n", i, i );
242 fprintf( pFile, "1 1\n" );
243 }
244 fprintf( pFile, ".end\n" );
245 fprintf( pFile, "\n" );
246 }
247
248 /**Function*************************************************************
249
250 Synopsis []
251
252 Description []
253
254 SideEffects []
255
256 SeeAlso []
257
258 ***********************************************************************/
Abc_GenSorter(char * pFileName,int nVars)259 void Abc_GenSorter( char * pFileName, int nVars )
260 {
261 FILE * pFile;
262 int i, k, Counter, nDigits;
263
264 assert( nVars > 1 );
265
266 pFile = fopen( pFileName, "w" );
267 fprintf( pFile, "# %d-bit sorter generated by ABC on %s\n", nVars, Extra_TimeStamp() );
268 fprintf( pFile, ".model Sorter%02d\n", nVars );
269
270 fprintf( pFile, ".inputs" );
271 for ( i = 0; i < nVars; i++ )
272 fprintf( pFile, " x%02d", i );
273 fprintf( pFile, "\n" );
274
275 fprintf( pFile, ".outputs" );
276 for ( i = 0; i < nVars; i++ )
277 fprintf( pFile, " y%02d", i );
278 fprintf( pFile, "\n" );
279
280 Counter = 0;
281 nDigits = Abc_Base10Log( (nVars-2)*nVars );
282 if ( nVars == 2 )
283 fprintf( pFile, ".subckt Comp a=x00 b=x01 x=y00 y=y01\n" );
284 else
285 {
286 fprintf( pFile, ".subckt Layer0" );
287 for ( k = 0; k < nVars; k++ )
288 fprintf( pFile, " x%02d=x%02d", k, k );
289 for ( k = 0; k < nVars; k++ )
290 fprintf( pFile, " y%02d=%0*d", k, nDigits, Counter++ );
291 fprintf( pFile, "\n" );
292 Counter -= nVars;
293 for ( i = 1; i < 2*nVars-2; i++ )
294 {
295 fprintf( pFile, ".subckt Layer%d", (i&1) );
296 for ( k = 0; k < nVars; k++ )
297 fprintf( pFile, " x%02d=%0*d", k, nDigits, Counter++ );
298 for ( k = 0; k < nVars; k++ )
299 fprintf( pFile, " y%02d=%0*d", k, nDigits, Counter++ );
300 fprintf( pFile, "\n" );
301 Counter -= nVars;
302 }
303 fprintf( pFile, ".subckt Layer%d", (i&1) );
304 for ( k = 0; k < nVars; k++ )
305 fprintf( pFile, " x%02d=%0*d", k, nDigits, Counter++ );
306 for ( k = 0; k < nVars; k++ )
307 fprintf( pFile, " y%02d=y%02d", k, k );
308 fprintf( pFile, "\n" );
309 }
310 fprintf( pFile, ".end\n" );
311 fprintf( pFile, "\n" );
312
313 Abc_WriteLayer( pFile, nVars, 0 );
314 Abc_WriteLayer( pFile, nVars, 1 );
315 Abc_WriteComp( pFile );
316 fclose( pFile );
317 }
318
319 /**Function*************************************************************
320
321 Synopsis []
322
323 Description []
324
325 SideEffects []
326
327 SeeAlso []
328
329 ***********************************************************************/
Abc_WriteCell(FILE * pFile)330 void Abc_WriteCell( FILE * pFile )
331 {
332 fprintf( pFile, ".model cell\n" );
333 fprintf( pFile, ".inputs px1 px2 py1 py2 x y\n" );
334 fprintf( pFile, ".outputs fx fy\n" );
335 fprintf( pFile, ".names x y a\n" );
336 fprintf( pFile, "11 1\n" );
337 fprintf( pFile, ".names px1 a x nx\n" );
338 fprintf( pFile, "11- 1\n" );
339 fprintf( pFile, "0-1 1\n" );
340 fprintf( pFile, ".names py1 a y ny\n" );
341 fprintf( pFile, "11- 1\n" );
342 fprintf( pFile, "0-1 1\n" );
343 fprintf( pFile, ".names px2 nx fx\n" );
344 fprintf( pFile, "10 1\n" );
345 fprintf( pFile, "01 1\n" );
346 fprintf( pFile, ".names py2 ny fy\n" );
347 fprintf( pFile, "10 1\n" );
348 fprintf( pFile, "01 1\n" );
349 fprintf( pFile, ".end\n" );
350 fprintf( pFile, "\n" );
351 }
352
353 /**Function*************************************************************
354
355 Synopsis []
356
357 Description []
358
359 SideEffects []
360
361 SeeAlso []
362
363 ***********************************************************************/
Abc_GenMesh(char * pFileName,int nVars)364 void Abc_GenMesh( char * pFileName, int nVars )
365 {
366 FILE * pFile;
367 int i, k;
368
369 assert( nVars > 0 );
370
371 pFile = fopen( pFileName, "w" );
372 fprintf( pFile, "# %dx%d mesh generated by ABC on %s\n", nVars, nVars, Extra_TimeStamp() );
373 fprintf( pFile, ".model mesh%d\n", nVars );
374
375 for ( i = 0; i < nVars; i++ )
376 for ( k = 0; k < nVars; k++ )
377 {
378 fprintf( pFile, ".inputs" );
379 fprintf( pFile, " p%d%dx1", i, k );
380 fprintf( pFile, " p%d%dx2", i, k );
381 fprintf( pFile, " p%d%dy1", i, k );
382 fprintf( pFile, " p%d%dy2", i, k );
383 fprintf( pFile, "\n" );
384 }
385 fprintf( pFile, ".inputs" );
386 for ( i = 0; i < nVars; i++ )
387 fprintf( pFile, " v%02d v%02d", 2*i, 2*i+1 );
388 fprintf( pFile, "\n" );
389
390 fprintf( pFile, ".outputs" );
391 fprintf( pFile, " fx00" );
392 fprintf( pFile, "\n" );
393
394 for ( i = 0; i < nVars; i++ ) // horizontal
395 for ( k = 0; k < nVars; k++ ) // vertical
396 {
397 fprintf( pFile, ".subckt cell" );
398 fprintf( pFile, " px1=p%d%dx1", i, k );
399 fprintf( pFile, " px2=p%d%dx2", i, k );
400 fprintf( pFile, " py1=p%d%dy1", i, k );
401 fprintf( pFile, " py2=p%d%dy2", i, k );
402 if ( k == nVars - 1 )
403 fprintf( pFile, " x=v%02d", i );
404 else
405 fprintf( pFile, " x=fx%d%d", i, k+1 );
406 if ( i == nVars - 1 )
407 fprintf( pFile, " y=v%02d", nVars+k );
408 else
409 fprintf( pFile, " y=fy%d%d", i+1, k );
410 // outputs
411 fprintf( pFile, " fx=fx%d%d", i, k );
412 fprintf( pFile, " fy=fy%d%d", i, k );
413 fprintf( pFile, "\n" );
414 }
415 fprintf( pFile, ".end\n" );
416 fprintf( pFile, "\n" );
417 fprintf( pFile, "\n" );
418
419 Abc_WriteCell( pFile );
420 fclose( pFile );
421 }
422
423
424 /**Function*************************************************************
425
426 Synopsis []
427
428 Description []
429
430 SideEffects []
431
432 SeeAlso []
433
434 ***********************************************************************/
Abc_WriteKLut(FILE * pFile,int nLutSize)435 void Abc_WriteKLut( FILE * pFile, int nLutSize )
436 {
437 int i, iVar, iNext, nPars = (1 << nLutSize);
438 fprintf( pFile, "\n" );
439 fprintf( pFile, ".model lut%d\n", nLutSize );
440 fprintf( pFile, ".inputs" );
441 for ( i = 0; i < nPars; i++ )
442 fprintf( pFile, " p%02d", i );
443 fprintf( pFile, "\n" );
444 fprintf( pFile, ".inputs" );
445 for ( i = 0; i < nLutSize; i++ )
446 fprintf( pFile, " i%d", i );
447 fprintf( pFile, "\n" );
448 fprintf( pFile, ".outputs o\n" );
449 fprintf( pFile, ".names n01 o\n" );
450 fprintf( pFile, "1 1\n" );
451 // write internal MUXes
452 iVar = 0;
453 iNext = 2;
454 for ( i = 1; i < nPars; i++ )
455 {
456 if ( i == iNext )
457 {
458 iNext *= 2;
459 iVar++;
460 }
461 if ( iVar == nLutSize - 1 )
462 fprintf( pFile, ".names i%d p%02d p%02d n%02d\n", iVar, 2*(i-nPars/2), 2*(i-nPars/2)+1, i );
463 else
464 fprintf( pFile, ".names i%d n%02d n%02d n%02d\n", iVar, 2*i, 2*i+1, i );
465 fprintf( pFile, "01- 1\n" );
466 fprintf( pFile, "1-1 1\n" );
467 }
468 fprintf( pFile, ".end\n" );
469 fprintf( pFile, "\n" );
470 }
471
472 /**Function*************************************************************
473
474 Synopsis [Generates structure of L K-LUTs implementing an N-var function.]
475
476 Description []
477
478 SideEffects []
479
480 SeeAlso []
481
482 ***********************************************************************/
Abc_GenFpga(char * pFileName,int nLutSize,int nLuts,int nVars)483 void Abc_GenFpga( char * pFileName, int nLutSize, int nLuts, int nVars )
484 {
485 int fGenerateFunc = 1;
486 FILE * pFile;
487 int nVarsLut = (1 << nLutSize); // the number of LUT variables
488 int nVarsLog = Abc_Base2Log( nVars + nLuts - 1 ); // the number of encoding vars
489 int nVarsDeg = (1 << nVarsLog); // the number of LUT variables (total)
490 int nParsLut = nLuts * (1 << nLutSize); // the number of LUT params
491 int nParsVar = nLuts * nLutSize * nVarsLog; // the number of var params
492 int i, j, k;
493
494 assert( nVars > 0 );
495
496 pFile = fopen( pFileName, "w" );
497 fprintf( pFile, "# Structure with %d %d-LUTs for %d-var function generated by ABC on %s\n", nLuts, nLutSize, nVars, Extra_TimeStamp() );
498 fprintf( pFile, ".model struct%dx%d_%d\n", nLuts, nLutSize, nVars );
499
500 fprintf( pFile, ".inputs" );
501 for ( i = 0; i < nParsLut; i++ )
502 {
503 // if ( i % (1 << nLutSize) == 0 && i != (nLuts - 1) * (1 << nLutSize) )
504 // continue;
505 fprintf( pFile, " pl%02d", i );
506 }
507 fprintf( pFile, "\n" );
508
509 fprintf( pFile, ".inputs" );
510 for ( i = 0; i < nParsVar; i++ )
511 fprintf( pFile, " pv%02d", i );
512 fprintf( pFile, "\n" );
513
514 fprintf( pFile, ".inputs" );
515 for ( i = 0; i < nVars; i++ )
516 fprintf( pFile, " v%02d", i );
517 fprintf( pFile, "\n" );
518
519 fprintf( pFile, ".outputs" );
520 // fprintf( pFile, " v%02d", nVars + nLuts - 1 );
521 fprintf( pFile, " out" );
522 fprintf( pFile, "\n" );
523 fprintf( pFile, ".names Gnd\n" );
524 fprintf( pFile, " 0\n" );
525
526 // generate function
527 if ( fGenerateFunc )
528 {
529 fprintf( pFile, ".names v%02d func out\n", nVars + nLuts - 1 );
530 fprintf( pFile, "00 1\n11 1\n" );
531 fprintf( pFile, ".names" );
532 for ( i = 0; i < nVars; i++ )
533 fprintf( pFile, " v%02d", i );
534 fprintf( pFile, " func\n" );
535 for ( i = 0; i < nVars; i++ )
536 fprintf( pFile, "1" );
537 fprintf( pFile, " 1\n" );
538 }
539 else
540 fprintf( pFile, ".names v%02d out\n1 1\n", nVars + nLuts - 1 );
541
542 // generate LUTs
543 for ( i = 0; i < nLuts; i++ )
544 {
545 fprintf( pFile, ".subckt lut%d", nLutSize );
546 // generate config parameters
547 for ( k = 0; k < nVarsLut; k++ )
548 fprintf( pFile, " p%02d=pl%02d", k, i * nVarsLut + k );
549 // generate the inputs
550 for ( k = 0; k < nLutSize; k++ )
551 fprintf( pFile, " i%d=s%02d", k, i * nLutSize + k );
552 // generate the output
553 fprintf( pFile, " o=v%02d", nVars + i );
554 fprintf( pFile, "\n" );
555 }
556
557 // generate LUT inputs
558 for ( i = 0; i < nLuts; i++ )
559 {
560 for ( j = 0; j < nLutSize; j++ )
561 {
562 fprintf( pFile, ".subckt lut%d", nVarsLog );
563 // generate config parameters
564 for ( k = 0; k < nVarsDeg; k++ )
565 {
566 if ( k < nVars + nLuts - 1 && k < nVars + i )
567 fprintf( pFile, " p%02d=v%02d", k, k );
568 else
569 fprintf( pFile, " p%02d=Gnd", k );
570 }
571 // generate the inputs
572 for ( k = 0; k < nVarsLog; k++ )
573 fprintf( pFile, " i%d=pv%02d", k, (i * nLutSize + j) * nVarsLog + k );
574 // generate the output
575 fprintf( pFile, " o=s%02d", i * nLutSize + j );
576 fprintf( pFile, "\n" );
577 }
578 }
579
580 fprintf( pFile, ".end\n" );
581 fprintf( pFile, "\n" );
582
583 // generate LUTs
584 Abc_WriteKLut( pFile, nLutSize );
585 if ( nVarsLog != nLutSize )
586 Abc_WriteKLut( pFile, nVarsLog );
587 fclose( pFile );
588 }
589
590 /**Function*************************************************************
591
592 Synopsis [Generates structure of L K-LUTs implementing an N-var function.]
593
594 Description []
595
596 SideEffects []
597
598 SeeAlso []
599
600 ***********************************************************************/
Abc_GenOneHot(char * pFileName,int nVars)601 void Abc_GenOneHot( char * pFileName, int nVars )
602 {
603 FILE * pFile;
604 int i, k, Counter, nDigitsIn, nDigitsOut;
605 pFile = fopen( pFileName, "w" );
606 fprintf( pFile, "# One-hotness condition for %d vars generated by ABC on %s\n", nVars, Extra_TimeStamp() );
607 fprintf( pFile, ".model 1hot_%dvars\n", nVars );
608 fprintf( pFile, ".inputs" );
609 nDigitsIn = Abc_Base10Log( nVars );
610 for ( i = 0; i < nVars; i++ )
611 fprintf( pFile, " i%0*d", nDigitsIn, i );
612 fprintf( pFile, "\n" );
613 fprintf( pFile, ".outputs" );
614 nDigitsOut = Abc_Base10Log( nVars * (nVars - 1) / 2 );
615 for ( i = 0; i < nVars * (nVars - 1) / 2; i++ )
616 fprintf( pFile, " o%0*d", nDigitsOut, i );
617 fprintf( pFile, "\n" );
618 Counter = 0;
619 for ( i = 0; i < nVars; i++ )
620 for ( k = i+1; k < nVars; k++ )
621 {
622 fprintf( pFile, ".names i%0*d i%0*d o%0*d\n", nDigitsIn, i, nDigitsIn, k, nDigitsOut, Counter );
623 fprintf( pFile, "11 0\n" );
624 Counter++;
625 }
626 fprintf( pFile, ".end\n" );
627 fprintf( pFile, "\n" );
628 fclose( pFile );
629 }
630
631 /**Function*************************************************************
632
633 Synopsis [Generates structure of L K-LUTs implementing an N-var function.]
634
635 Description []
636
637 SideEffects []
638
639 SeeAlso []
640
641 ***********************************************************************/
Abc_GenOneHotIntervals(char * pFileName,int nPis,int nRegs,Vec_Ptr_t * vOnehots)642 void Abc_GenOneHotIntervals( char * pFileName, int nPis, int nRegs, Vec_Ptr_t * vOnehots )
643 {
644 Vec_Int_t * vLine;
645 FILE * pFile;
646 int i, j, k, iReg1, iReg2, Counter, Counter2, nDigitsIn, nDigitsOut;
647 pFile = fopen( pFileName, "w" );
648 fprintf( pFile, "# One-hotness with %d vars and %d regs generated by ABC on %s\n", nPis, nRegs, Extra_TimeStamp() );
649 fprintf( pFile, "# Used %d intervals of 1-hot registers: { ", Vec_PtrSize(vOnehots) );
650 Counter = 0;
651 Vec_PtrForEachEntry( Vec_Int_t *, vOnehots, vLine, k )
652 {
653 fprintf( pFile, "%d ", Vec_IntSize(vLine) );
654 Counter += Vec_IntSize(vLine) * (Vec_IntSize(vLine) - 1) / 2;
655 }
656 fprintf( pFile, "}\n" );
657 fprintf( pFile, ".model 1hot_%dvars_%dregs\n", nPis, nRegs );
658 fprintf( pFile, ".inputs" );
659 nDigitsIn = Abc_Base10Log( nPis+nRegs );
660 for ( i = 0; i < nPis+nRegs; i++ )
661 fprintf( pFile, " i%0*d", nDigitsIn, i );
662 fprintf( pFile, "\n" );
663 fprintf( pFile, ".outputs" );
664 nDigitsOut = Abc_Base10Log( Counter );
665 for ( i = 0; i < Counter; i++ )
666 fprintf( pFile, " o%0*d", nDigitsOut, i );
667 fprintf( pFile, "\n" );
668 Counter2 = 0;
669 Vec_PtrForEachEntry( Vec_Int_t *, vOnehots, vLine, k )
670 {
671 Vec_IntForEachEntry( vLine, iReg1, i )
672 Vec_IntForEachEntryStart( vLine, iReg2, j, i+1 )
673 {
674 fprintf( pFile, ".names i%0*d i%0*d o%0*d\n", nDigitsIn, nPis+iReg1, nDigitsIn, nPis+iReg2, nDigitsOut, Counter2 );
675 fprintf( pFile, "11 0\n" );
676 Counter2++;
677 }
678 }
679 assert( Counter == Counter2 );
680 fprintf( pFile, ".end\n" );
681 fprintf( pFile, "\n" );
682 fclose( pFile );
683 }
684
685 ABC_NAMESPACE_IMPL_END
686
687 #include "aig/aig/aig.h"
688
689 ABC_NAMESPACE_IMPL_START
690
691
692 /**Function*************************************************************
693
694 Synopsis [Generates structure of L K-LUTs implementing an N-var function.]
695
696 Description []
697
698 SideEffects []
699
700 SeeAlso []
701
702 ***********************************************************************/
Abc_GenRandom(char * pFileName,int nPis)703 void Abc_GenRandom( char * pFileName, int nPis )
704 {
705 FILE * pFile;
706 unsigned * pTruth;
707 int i, b, w, nWords = Abc_TruthWordNum( nPis );
708 int nDigitsIn;
709 Aig_ManRandom( 1 );
710 pTruth = ABC_ALLOC( unsigned, nWords );
711 for ( w = 0; w < nWords; w++ )
712 pTruth[w] = Aig_ManRandom( 0 );
713 pFile = fopen( pFileName, "w" );
714 fprintf( pFile, "# Random function with %d inputs generated by ABC on %s\n", nPis, Extra_TimeStamp() );
715 fprintf( pFile, ".model rand%d\n", nPis );
716 fprintf( pFile, ".inputs" );
717 nDigitsIn = Abc_Base10Log( nPis );
718 for ( i = 0; i < nPis; i++ )
719 fprintf( pFile, " i%0*d", nDigitsIn, i );
720 fprintf( pFile, "\n" );
721 fprintf( pFile, ".outputs f\n" );
722 fprintf( pFile, ".names" );
723 nDigitsIn = Abc_Base10Log( nPis );
724 for ( i = 0; i < nPis; i++ )
725 fprintf( pFile, " i%0*d", nDigitsIn, i );
726 fprintf( pFile, " f\n" );
727 for ( i = 0; i < (1<<nPis); i++ )
728 if ( Abc_InfoHasBit(pTruth, i) )
729 {
730 for ( b = nPis-1; b >= 0; b-- )
731 fprintf( pFile, "%d", (i>>b)&1 );
732 fprintf( pFile, " 1\n" );
733 }
734 fprintf( pFile, ".end\n" );
735 fprintf( pFile, "\n" );
736 fclose( pFile );
737 ABC_FREE( pTruth );
738 }
739
740
741 /**Function*************************************************************
742
743 Synopsis [Generates structure of L K-LUTs implementing an N-var function.]
744
745 Description []
746
747 SideEffects []
748
749 SeeAlso []
750
751 ***********************************************************************/
Abc_GenFsmCond(Vec_Str_t * vCond,int nPis,int Prob)752 void Abc_GenFsmCond( Vec_Str_t * vCond, int nPis, int Prob )
753 {
754 int i, Rand;
755 Vec_StrClear( vCond );
756 for ( i = 0; i < nPis; i++ )
757 {
758 Rand = Aig_ManRandom( 0 );
759 if ( Rand % 100 > Prob )
760 Vec_StrPush( vCond, '-' );
761 else if ( Rand & 1 )
762 Vec_StrPush( vCond, '1' );
763 else
764 Vec_StrPush( vCond, '0' );
765 }
766 Vec_StrPush( vCond, '\0' );
767 }
Abc_GenFsm(char * pFileName,int nPis,int nPos,int nStates,int nLines,int ProbI,int ProbO)768 void Abc_GenFsm( char * pFileName, int nPis, int nPos, int nStates, int nLines, int ProbI, int ProbO )
769 {
770 FILE * pFile;
771 Vec_Wrd_t * vStates;
772 Vec_Str_t * vCond;
773 int i, iState, iState2;
774 int nDigits = Abc_Base10Log( nStates );
775 Aig_ManRandom( 1 );
776 vStates = Vec_WrdAlloc( nLines );
777 vCond = Vec_StrAlloc( 1000 );
778 for ( i = 0; i < nStates; )
779 {
780 iState = Aig_ManRandom( 0 ) % nStates;
781 if ( iState == i )
782 continue;
783 Vec_WrdPush( vStates, ((word)i << 32) | iState );
784 i++;
785 }
786 for ( ; i < nLines; )
787 {
788 iState = Aig_ManRandom( 0 ) % nStates;
789 iState2 = Aig_ManRandom( 0 ) % nStates;
790 if ( iState2 == iState )
791 continue;
792 Vec_WrdPush( vStates, ((word)iState << 32) | iState2 );
793 i++;
794 }
795 Vec_WrdSort( vStates, 0 );
796 // write the file
797 pFile = fopen( pFileName, "w" );
798 fprintf( pFile, "# This random FSM was generated by ABC on %s\n", Extra_TimeStamp() );
799 fprintf( pFile, "# Command line was: \"genfsm -I %d -O %d -S %d -L %d -P %d -Q %d %s\"\n", nPis, nPos, nStates, nLines, ProbI, ProbO, pFileName );
800 fprintf( pFile, "# FSM has %d inputs, %d outputs, %d states, and %d products\n", nPis, nPos, nStates, nLines );
801 fprintf( pFile, ".i %d\n", nPis );
802 fprintf( pFile, ".o %d\n", nPos );
803 fprintf( pFile, ".p %d\n", nLines );
804 fprintf( pFile, ".s %d\n", nStates );
805 for ( i = 0; i < nLines; i++ )
806 {
807 Abc_GenFsmCond( vCond, nPis, ProbI );
808 fprintf( pFile, "%s ", Vec_StrArray(vCond) );
809 fprintf( pFile, "%0*d ", nDigits, (int)(Vec_WrdEntry(vStates, i) >> 32) );
810 fprintf( pFile, "%0*d ", nDigits, (int)(Vec_WrdEntry(vStates, i)) );
811 if ( nPos > 0 )
812 {
813 Abc_GenFsmCond( vCond, nPos, ProbO );
814 fprintf( pFile, "%s", Vec_StrArray(vCond) );
815 }
816 fprintf( pFile, "\n" );
817 }
818 fprintf( pFile, ".e" );
819 fprintf( pFile, "\n" );
820 fclose( pFile );
821 Vec_WrdFree( vStates );
822 Vec_StrFree( vCond );
823 }
824
825 /**Function*************************************************************
826
827 Synopsis []
828
829 Description []
830
831 SideEffects []
832
833 SeeAlso []
834
835 ***********************************************************************/
Abc_AdderTree(FILE * pFile,int nArgs,int nBits)836 void Abc_AdderTree( FILE * pFile, int nArgs, int nBits )
837 {
838 int i, k, nDigits = Abc_Base10Log( nBits ), Log2 = Abc_Base2Log( nArgs );
839 assert( nArgs > 1 && nBits > 1 );
840 fprintf( pFile, "module adder_tree_%d_%d (\n ", nArgs, nBits );
841 for ( i = 0; i < nBits; i++, fprintf(pFile, "\n ") )
842 for ( k = 0; k < nArgs; k++ )
843 fprintf( pFile, " i%0*d_%0*d,", nDigits, k, nDigits, nBits-1-i );
844 fprintf( pFile, " z\n" );
845 fprintf( pFile, " );\n" );
846 for ( i = 0; i < nBits; i++ )
847 {
848 fprintf( pFile, " input" );
849 for ( k = 0; k < nArgs; k++ )
850 fprintf( pFile, " i%0*d_%0*d%s", nDigits, k, nDigits, nBits-1-i, k==nArgs-1 ? "":"," );
851 fprintf( pFile, ";\n" );
852 }
853 fprintf( pFile, " output [%d:0] z;\n", nBits+Log2-1 );
854 for ( i = 0; i < nArgs; i++ )
855 {
856 fprintf( pFile, " wire [%d:0] t%d = {", nBits-1, i );
857 for ( k = 0; k < nBits; k++ )
858 fprintf( pFile, " i%0*d_%0*d%s", nDigits, i, nDigits, nBits-1-k, k==nBits-1 ? "":"," );
859 fprintf( pFile, " };\n" );
860 }
861 for ( i = 0; i < nArgs-1; i++ )
862 fprintf( pFile, " wire [%d:0] s%d = t%d + %s%d;\n", nBits+Log2-1, i+1, i+1, i ? "s":"t", i );
863 fprintf( pFile, " assign z = s%d;\n", nArgs-1 );
864 fprintf( pFile, "endmodule\n\n" );
865 }
Abc_GenAdderTree(char * pFileName,int nArgs,int nBits)866 void Abc_GenAdderTree( char * pFileName, int nArgs, int nBits )
867 {
868 FILE * pFile = fopen( pFileName, "w" );
869 fprintf( pFile, "// %d-argument %d-bit adder-tree generated by ABC on %s\n", nArgs, nBits, Extra_TimeStamp() );
870 Abc_AdderTree( pFile, nArgs, nBits );
871 fclose( pFile );
872 }
873
874
875 /**Function*************************************************************
876
877 Synopsis [Generating signed Booth multiplier.]
878
879 Description []
880
881 SideEffects []
882
883 SeeAlso []
884
885 ***********************************************************************/
Abc_GenSignedBoothPP(Gia_Man_t * p,int a,int b,int c,int d,int e)886 int Abc_GenSignedBoothPP( Gia_Man_t * p, int a, int b, int c, int d, int e )
887 {
888 /*
889 abc> lutexact -I 5 -N 7 -g F335ACC0
890
891 05 = 4'b0110( d e )
892 06 = 4'b0110( c d )
893 07 = 4'b0100( a 06 )
894 08 = 4'b1000( b 06 )
895 09 = 4'b0100( 05 07 )
896 10 = 4'b0110( 08 09 )
897 11 = 4'b0110( d 10 )
898 */
899 int n05 = Gia_ManHashXor( p, d, e );
900 int n06 = Gia_ManHashXor( p, c, d );
901 int n07 = Gia_ManHashAnd( p, a, Abc_LitNot(n06) );
902 int n08 = Gia_ManHashAnd( p, b, n06 );
903 int n09 = Gia_ManHashAnd( p, n05, Abc_LitNot(n07) );
904 int n10 = Gia_ManHashXor( p, n08, n09 );
905 int n11 = Gia_ManHashXor( p, d, n10 );
906 return n11;
907 }
Abc_GenSignedBoothPPTest(int nArgA,int nArgB)908 Gia_Man_t * Abc_GenSignedBoothPPTest( int nArgA, int nArgB )
909 {
910 Gia_Man_t * pNew; int i, iLit;
911 pNew = Gia_ManStart( 1000 );
912 pNew->pName = Abc_UtilStrsav( "booth" );
913 for ( i = 0; i < 5; i++ )
914 Gia_ManAppendCi(pNew);
915 iLit = Abc_GenSignedBoothPP( pNew, 2, 4, 6, 8, 10 );
916 Gia_ManAppendCo(pNew, iLit);
917 return pNew;
918 }
919
920 /*
921 // parametrized implementation of signed Booth multiplier
922 module booth #(
923 parameter N = 4 // bit-width of input a
924 ,parameter M = 4 // bit-width of input b
925 )(
926 input [N-1:0] a // input data
927 ,input [M-1:0] b // input data
928 ,output [N+M-1:0] z // output data
929 );
930
931 localparam TT = 32'hF335ACC0;
932 localparam W = N+M+1;
933 localparam L = (M+1)/2;
934
935 wire [W-1:0] data1[L:0];
936 wire [W-1:0] data2[L:0];
937
938 assign data2[0] = data1[0];
939 assign z = data2[L][N+M-1:0];
940
941 wire [N+1:0] a2 = {a[N-1], a, 1'b0};
942 wire [M+1:0] b2 = {b[M-1], b, 1'b0};
943
944 genvar j;
945 generate
946 for ( j = 0; j < W; j = j + 1 ) begin : J
947 assign data1[0][j] = (j%2 == 0 && j/2 < L) ? b2[j+2] : 1'b0;
948 end
949 endgenerate
950
951 genvar k, i0, i1, i2;
952 generate
953 for ( k = 0; k < 2*L; k = k + 2 ) begin : K
954
955 for ( i0 = 0; i0 < k; i0 = i0 + 1 ) begin : I0
956 assign data1[k/2+1][i0] = 1'b0;
957 end
958
959 for ( i1 = 0; i1 <= N; i1 = i1 + 1 ) begin : I1
960 wire [4:0] in = {b2[k+2], b2[k+1], b2[k], a2[i1+1], a2[i1]};
961 assign data1[k/2+1][k+i1] = (k > 0 && i1 == N) ? ~TT[in] : TT[in];
962 end
963
964 assign data1[k/2+1][k+N+1] = k > 0 ? 1'b1 : data1[k/2+1][k+N];
965 for ( i2 = k+N+2; i2 < W; i2 = i2 + 1 ) begin : I2
966 assign data1[k/2+1][i2] = (k > 0 || i2 > k+N+2)? 1'b0 : ~data1[k/2+1][k+N];
967 end
968
969 assign data2[k/2+1] = data2[k/2] + data1[k/2+1];
970
971 end
972 endgenerate
973
974 endmodule
975 */
976
Abc_GenSignedBooth(int nArgN,int nArgM)977 Gia_Man_t * Abc_GenSignedBooth( int nArgN, int nArgM )
978 {
979 int nWidth = nArgN + nArgM + 1;
980 int Length = (nArgM + 1) / 2;
981 int i, k, iLit;
982
983 Vec_Int_t * vPPs = Vec_IntAlloc( nWidth * (Length + 1) );
984 Vec_Int_t * vArgN = Vec_IntAlloc( nArgN + 2 );
985 Vec_Int_t * vArgM = Vec_IntAlloc( nArgM + 2 );
986 int * pArgN = Vec_IntArray( vArgN );
987 int * pArgM = Vec_IntArray( vArgM );
988
989 Gia_Man_t * pTemp, * pNew;
990 pNew = Gia_ManStart( 1000 );
991 pNew->pName = Abc_UtilStrsav( "booth" );
992
993 Vec_IntPush( vArgN, 0 );
994 for ( i = 0; i < nArgN; i++ )
995 Vec_IntPush( vArgN, Gia_ManAppendCi(pNew) );
996 Vec_IntPush( vArgN, Vec_IntEntryLast(vArgN) );
997
998 Vec_IntPush( vArgM, 0 );
999 for ( i = 0; i < nArgM; i++ )
1000 Vec_IntPush( vArgM, Gia_ManAppendCi(pNew) );
1001 Vec_IntPush( vArgM, Vec_IntEntryLast(vArgM) );
1002
1003 for ( i = 0; i < nWidth; i++ )
1004 Vec_IntPush( vPPs, (i%2 == 0 && i/2 < Length) ? pArgM[i+2] : 0 );
1005
1006 Gia_ManHashAlloc( pNew );
1007 for ( k = 0; k < 2*Length; k += 2 )
1008 {
1009 for ( i = 0; i < k; i++ )
1010 Vec_IntPush( vPPs, 0 );
1011 for ( i = 0; i <= nArgN; i++ )
1012 {
1013 iLit = Abc_GenSignedBoothPP( pNew, pArgN[i], pArgN[i+1], pArgM[k], pArgM[k+1], pArgM[k+2] );
1014 Vec_IntPush( vPPs, Abc_LitNotCond( iLit, k > 0 && i == nArgN ) );
1015 }
1016 iLit = Vec_IntEntryLast(vPPs);
1017 Vec_IntPush( vPPs, k > 0 ? 1 : iLit );
1018 for ( i = k+nArgN+2; i < nWidth; i++ )
1019 Vec_IntPush( vPPs, (k > 0 || i > k+nArgN+2) ? 0 : Abc_LitNot(iLit) );
1020 }
1021 Gia_ManHashStop( pNew );
1022
1023 for ( k = 0; k <= Length; k++ )
1024 for ( i = 0; i < nArgN+nArgM; i++ )
1025 Gia_ManAppendCo( pNew, Vec_IntEntry(vPPs, k*(nArgN+nArgM+1) + i) );
1026 Vec_IntFree( vPPs );
1027 Vec_IntFree( vArgN );
1028 Vec_IntFree( vArgM );
1029
1030 pNew = Gia_ManCleanup( pTemp = pNew );
1031 Gia_ManStop( pTemp );
1032 return pNew;
1033 }
Abc_GenSignedBoothMini(int nArgN,int nArgM)1034 Mini_Aig_t * Abc_GenSignedBoothMini( int nArgN, int nArgM )
1035 {
1036 extern Mini_Aig_t * Gia_ManToMiniAig( Gia_Man_t * pGia );
1037 Gia_Man_t * pGia = Abc_GenSignedBooth( nArgN, nArgM );
1038 Mini_Aig_t * pMini = Gia_ManToMiniAig( pGia );
1039 Gia_ManStop( pGia );
1040 return pMini;
1041 }
1042
1043
1044 /**Function*************************************************************
1045
1046 Synopsis []
1047
1048 Description []
1049
1050 SideEffects []
1051
1052 SeeAlso []
1053
1054 ***********************************************************************/
Abc_WriteBoothPartialProducts(FILE * pFile,int nVars)1055 void Abc_WriteBoothPartialProducts( FILE * pFile, int nVars )
1056 {
1057 Mini_Aig_t * p = Abc_GenSignedBoothMini( nVars, nVars );
1058 int i, nNodes = Mini_AigNodeNum(p);
1059 int nDigits = Abc_Base10Log( nVars );
1060 int nDigits2 = Abc_Base10Log( 2*nVars );
1061 int nDigits3 = Abc_Base10Log( nNodes );
1062 int nOut = 0;
1063 fprintf( pFile, ".names pp%0*d\n", nDigits3, 0 );
1064 for ( i = 1; i < nNodes; i++ )
1065 {
1066 if ( Mini_AigNodeIsPi( p, i ) )
1067 {
1068 if ( i > 0 && i <= nVars )
1069 fprintf( pFile, ".names a%0*d pp%0*d\n1 1\n", nDigits, i-1, nDigits3, i );
1070 else if ( i > nVars && i <= 2*nVars )
1071 fprintf( pFile, ".names b%0*d pp%0*d\n1 1\n", nDigits, i-1-nVars, nDigits3, i );
1072 else assert( 0 );
1073 }
1074 else if ( Mini_AigNodeIsPo( p, i ) )
1075 {
1076 int Lit = Mini_AigNodeFanin0( p, i );
1077 fprintf( pFile, ".names pp%0*d y%0*d_%0*d\n%d 1\n", nDigits3, Abc_Lit2Var(Lit), nDigits, nOut/(2*nVars), nDigits2, nOut%(2*nVars), !Abc_LitIsCompl(Lit) );
1078 nOut++;
1079 }
1080 else if ( Mini_AigNodeIsAnd( p, i ) )
1081 {
1082 int Lit0 = Mini_AigNodeFanin0( p, i );
1083 int Lit1 = Mini_AigNodeFanin1( p, i );
1084 fprintf( pFile, ".names pp%0*d pp%0*d pp%0*d\n%d%d 1\n",
1085 nDigits3, Abc_Lit2Var(Lit0), nDigits3, Abc_Lit2Var(Lit1), nDigits3, i, !Abc_LitIsCompl(Lit0), !Abc_LitIsCompl(Lit1) );
1086 }
1087 else assert( 0 );
1088 }
1089 Mini_AigStop( p );
1090 }
Abc_WriteBooth(FILE * pFile,int nVars)1091 void Abc_WriteBooth( FILE * pFile, int nVars )
1092 {
1093 int i, k, nDigits = Abc_Base10Log( nVars ), nDigits2 = Abc_Base10Log( 2*nVars );
1094 int Length = 1+(nVars + 1)/2;
1095
1096 assert( nVars > 0 );
1097 fprintf( pFile, ".model Multi%d\n", nVars );
1098
1099 fprintf( pFile, ".inputs" );
1100 for ( i = 0; i < nVars; i++ )
1101 fprintf( pFile, " a%0*d", nDigits, i );
1102 for ( i = 0; i < nVars; i++ )
1103 fprintf( pFile, " b%0*d", nDigits, i );
1104 fprintf( pFile, "\n" );
1105
1106 fprintf( pFile, ".outputs" );
1107 for ( i = 0; i < 2*nVars; i++ )
1108 fprintf( pFile, " m%0*d", nDigits2, i );
1109 fprintf( pFile, "\n" );
1110
1111 Abc_WriteBoothPartialProducts( pFile, nVars );
1112
1113 for ( i = 0; i < 2*nVars; i++ )
1114 fprintf( pFile, ".names x%0*d_%0*d\n", nDigits, 0, nDigits2, i );
1115 for ( k = 0; k < Length; k++ )
1116 {
1117 fprintf( pFile, ".subckt ADD%d", 2*nVars );
1118 for ( i = 0; i < 2*nVars; i++ )
1119 fprintf( pFile, " a%0*d=x%0*d_%0*d", nDigits2, i, nDigits, k, nDigits2, i );
1120 for ( i = 0; i < 2*nVars; i++ )
1121 fprintf( pFile, " b%0*d=y%0*d_%0*d", nDigits2, i, nDigits, k, nDigits2, i );
1122 for ( i = 0; i <= 2*nVars; i++ )
1123 fprintf( pFile, " s%0*d=x%0*d_%0*d", nDigits2, i, nDigits, k+1, nDigits2, i );
1124 fprintf( pFile, "\n" );
1125 }
1126 for ( i = 0; i < 2 * nVars; i++ )
1127 fprintf( pFile, ".names x%0*d_%0*d m%0*d\n1 1\n", nDigits, k, nDigits2, i, nDigits2, i );
1128 fprintf( pFile, ".end\n" );
1129 fprintf( pFile, "\n" );
1130 Abc_WriteAdder( pFile, 2*nVars );
1131 }
Abc_GenBooth(char * pFileName,int nVars)1132 void Abc_GenBooth( char * pFileName, int nVars )
1133 {
1134 FILE * pFile;
1135 assert( nVars > 0 );
1136 pFile = fopen( pFileName, "w" );
1137 fprintf( pFile, "# %d-bit signed Booth multiplier generated by ABC on %s\n", nVars, Extra_TimeStamp() );
1138 Abc_WriteBooth( pFile, nVars );
1139 fclose( pFile );
1140 }
1141
1142
1143
1144 ////////////////////////////////////////////////////////////////////////
1145 /// END OF FILE ///
1146 ////////////////////////////////////////////////////////////////////////
1147
1148
1149 ABC_NAMESPACE_IMPL_END
1150
1151