#include "abc.h"
Go to the source code of this file.
Functions | |
void | Abc_WriteLayer (FILE *pFile, int nVars, int fSkip1) |
void | Abc_WriteComp (FILE *pFile) |
void | Abc_WriteFullAdder (FILE *pFile) |
void | Abc_GenAdder (char *pFileName, int nVars) |
void | Abc_GenSorter (char *pFileName, int nVars) |
void | Abc_WriteCell (FILE *pFile) |
void | Abc_GenMesh (char *pFileName, int nVars) |
void | Abc_WriteKLut (FILE *pFile, int nLutSize) |
void | Abc_GenFpga (char *pFileName, int nLutSize, int nLuts, int nVars) |
void Abc_GenAdder | ( | char * | pFileName, | |
int | nVars | |||
) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 49 of file abcGen.c.
00050 { 00051 FILE * pFile; 00052 int i; 00053 00054 assert( nVars > 0 ); 00055 00056 pFile = fopen( pFileName, "w" ); 00057 fprintf( pFile, "# %d-bit ripple-carry adder generated by ABC on %s\n", nVars, Extra_TimeStamp() ); 00058 fprintf( pFile, ".model Adder%02d\n", nVars ); 00059 00060 fprintf( pFile, ".inputs" ); 00061 for ( i = 0; i < nVars; i++ ) 00062 fprintf( pFile, " a%02d", i ); 00063 for ( i = 0; i < nVars; i++ ) 00064 fprintf( pFile, " b%02d", i ); 00065 fprintf( pFile, "\n" ); 00066 00067 fprintf( pFile, ".outputs" ); 00068 for ( i = 0; i <= nVars; i++ ) 00069 fprintf( pFile, " y%02d", i ); 00070 fprintf( pFile, "\n" ); 00071 00072 fprintf( pFile, ".names c\n" ); 00073 if ( nVars == 1 ) 00074 fprintf( pFile, ".subckt FA a=a00 b=b00 cin=c s=y00 cout=y01\n" ); 00075 else 00076 { 00077 fprintf( pFile, ".subckt FA a=a00 b=b00 cin=c s=y00 cout=%02d\n", 0 ); 00078 for ( i = 1; i < nVars-1; i++ ) 00079 fprintf( pFile, ".subckt FA a=a%02d b=b%02d cin=%02d s=y%02d cout=%02d\n", i, i, i-1, i, i ); 00080 fprintf( pFile, ".subckt FA a=a%02d b=b%02d cin=%02d s=y%02d cout=y%02d\n", i, i, i-1, i, i+1 ); 00081 } 00082 fprintf( pFile, ".end\n" ); 00083 fprintf( pFile, "\n" ); 00084 00085 Abc_WriteFullAdder( pFile ); 00086 fclose( pFile ); 00087 }
void Abc_GenFpga | ( | char * | pFileName, | |
int | nLutSize, | |||
int | nLuts, | |||
int | nVars | |||
) |
Function*************************************************************
Synopsis [Generates structure of L K-LUTs implementing an N-var function.]
Description []
SideEffects []
SeeAlso []
Definition at line 422 of file abcGen.c.
00423 { 00424 FILE * pFile; 00425 int nVarsLut = (1 << nLutSize); // the number of LUT variables 00426 int nVarsLog = Extra_Base2Log( nVars + nLuts - 1 ); // the number of encoding vars 00427 int nVarsDeg = (1 << nVarsLog); // the number of LUT variables (total) 00428 int nParsLut = nLuts * (1 << nLutSize); // the number of LUT params 00429 int nParsVar = nLuts * nLutSize * nVarsLog; // the number of var params 00430 int i, j, k; 00431 00432 assert( nVars > 0 ); 00433 00434 pFile = fopen( pFileName, "w" ); 00435 fprintf( pFile, "# Structure with %d %d-LUTs for %d-var function generated by ABC on %s\n", nLuts, nLutSize, nVars, Extra_TimeStamp() ); 00436 fprintf( pFile, ".model struct%dx%d_%d\n", nLuts, nLutSize, nVars ); 00437 00438 fprintf( pFile, ".inputs" ); 00439 for ( i = 0; i < nParsLut; i++ ) 00440 fprintf( pFile, " pl%02d", i ); 00441 fprintf( pFile, "\n" ); 00442 00443 fprintf( pFile, ".inputs" ); 00444 for ( i = 0; i < nParsVar; i++ ) 00445 fprintf( pFile, " pv%02d", i ); 00446 fprintf( pFile, "\n" ); 00447 00448 fprintf( pFile, ".inputs" ); 00449 for ( i = 0; i < nVars; i++ ) 00450 fprintf( pFile, " v%02d", i ); 00451 fprintf( pFile, "\n" ); 00452 00453 fprintf( pFile, ".outputs" ); 00454 fprintf( pFile, " v%02d", nVars + nLuts - 1 ); 00455 fprintf( pFile, "\n" ); 00456 fprintf( pFile, ".names Gnd\n" ); 00457 fprintf( pFile, " 0\n" ); 00458 00459 // generate LUTs 00460 for ( i = 0; i < nLuts; i++ ) 00461 { 00462 fprintf( pFile, ".subckt lut%d", nLutSize ); 00463 // generate config parameters 00464 for ( k = 0; k < nVarsLut; k++ ) 00465 fprintf( pFile, " p%02d=pl%02d", k, i * nVarsLut + k ); 00466 // generate the inputs 00467 for ( k = 0; k < nLutSize; k++ ) 00468 fprintf( pFile, " i%d=s%02d", k, i * nLutSize + k ); 00469 // generate the output 00470 fprintf( pFile, " o=v%02d", nVars + i ); 00471 fprintf( pFile, "\n" ); 00472 } 00473 00474 // generate LUT inputs 00475 for ( i = 0; i < nLuts; i++ ) 00476 { 00477 for ( j = 0; j < nLutSize; j++ ) 00478 { 00479 fprintf( pFile, ".subckt lut%d", nVarsLog ); 00480 // generate config parameters 00481 for ( k = 0; k < nVarsDeg; k++ ) 00482 { 00483 if ( k < nVars + nLuts - 1 && k < nVars + i ) 00484 fprintf( pFile, " p%02d=v%02d", k, k ); 00485 else 00486 fprintf( pFile, " p%02d=Gnd", k ); 00487 } 00488 // generate the inputs 00489 for ( k = 0; k < nVarsLog; k++ ) 00490 fprintf( pFile, " i%d=pv%02d", k, (i * nLutSize + j) * nVarsLog + k ); 00491 // generate the output 00492 fprintf( pFile, " o=s%02d", i * nLutSize + j ); 00493 fprintf( pFile, "\n" ); 00494 } 00495 } 00496 00497 fprintf( pFile, ".end\n" ); 00498 fprintf( pFile, "\n" ); 00499 00500 // generate LUTs 00501 Abc_WriteKLut( pFile, nLutSize ); 00502 if ( nVarsLog != nLutSize ) 00503 Abc_WriteKLut( pFile, nVarsLog ); 00504 fclose( pFile ); 00505 }
void Abc_GenMesh | ( | char * | pFileName, | |
int | nVars | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 303 of file abcGen.c.
00304 { 00305 FILE * pFile; 00306 int i, k; 00307 00308 assert( nVars > 0 ); 00309 00310 pFile = fopen( pFileName, "w" ); 00311 fprintf( pFile, "# %dx%d mesh generated by ABC on %s\n", nVars, nVars, Extra_TimeStamp() ); 00312 fprintf( pFile, ".model mesh%d\n", nVars ); 00313 00314 for ( i = 0; i < nVars; i++ ) 00315 for ( k = 0; k < nVars; k++ ) 00316 { 00317 fprintf( pFile, ".inputs" ); 00318 fprintf( pFile, " p%d%dx1", i, k ); 00319 fprintf( pFile, " p%d%dx2", i, k ); 00320 fprintf( pFile, " p%d%dy1", i, k ); 00321 fprintf( pFile, " p%d%dy2", i, k ); 00322 fprintf( pFile, "\n" ); 00323 } 00324 fprintf( pFile, ".inputs" ); 00325 for ( i = 0; i < nVars; i++ ) 00326 fprintf( pFile, " v%02d v%02d", 2*i, 2*i+1 ); 00327 fprintf( pFile, "\n" ); 00328 00329 fprintf( pFile, ".outputs" ); 00330 fprintf( pFile, " fx00" ); 00331 fprintf( pFile, "\n" ); 00332 00333 for ( i = 0; i < nVars; i++ ) // horizontal 00334 for ( k = 0; k < nVars; k++ ) // vertical 00335 { 00336 fprintf( pFile, ".subckt cell" ); 00337 fprintf( pFile, " px1=p%d%dx1", i, k ); 00338 fprintf( pFile, " px2=p%d%dx2", i, k ); 00339 fprintf( pFile, " py1=p%d%dy1", i, k ); 00340 fprintf( pFile, " py2=p%d%dy2", i, k ); 00341 if ( k == nVars - 1 ) 00342 fprintf( pFile, " x=v%02d", i ); 00343 else 00344 fprintf( pFile, " x=fx%d%d", i, k+1 ); 00345 if ( i == nVars - 1 ) 00346 fprintf( pFile, " y=v%02d", nVars+k ); 00347 else 00348 fprintf( pFile, " y=fy%d%d", i+1, k ); 00349 // outputs 00350 fprintf( pFile, " fx=fx%d%d", i, k ); 00351 fprintf( pFile, " fy=fy%d%d", i, k ); 00352 fprintf( pFile, "\n" ); 00353 } 00354 fprintf( pFile, ".end\n" ); 00355 fprintf( pFile, "\n" ); 00356 fprintf( pFile, "\n" ); 00357 00358 Abc_WriteCell( pFile ); 00359 fclose( pFile ); 00360 }
void Abc_GenSorter | ( | char * | pFileName, | |
int | nVars | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 100 of file abcGen.c.
00101 { 00102 FILE * pFile; 00103 int i, k, Counter, nDigits; 00104 00105 assert( nVars > 1 ); 00106 00107 pFile = fopen( pFileName, "w" ); 00108 fprintf( pFile, "# %d-bit sorter generated by ABC on %s\n", nVars, Extra_TimeStamp() ); 00109 fprintf( pFile, ".model Sorter%02d\n", nVars ); 00110 00111 fprintf( pFile, ".inputs" ); 00112 for ( i = 0; i < nVars; i++ ) 00113 fprintf( pFile, " x%02d", i ); 00114 fprintf( pFile, "\n" ); 00115 00116 fprintf( pFile, ".outputs" ); 00117 for ( i = 0; i < nVars; i++ ) 00118 fprintf( pFile, " y%02d", i ); 00119 fprintf( pFile, "\n" ); 00120 00121 Counter = 0; 00122 nDigits = Extra_Base10Log( (nVars-2)*nVars ); 00123 if ( nVars == 2 ) 00124 fprintf( pFile, ".subckt Comp a=x00 b=x01 x=y00 y=y01\n" ); 00125 else 00126 { 00127 fprintf( pFile, ".subckt Layer0" ); 00128 for ( k = 0; k < nVars; k++ ) 00129 fprintf( pFile, " x%02d=x%02d", k, k ); 00130 for ( k = 0; k < nVars; k++ ) 00131 fprintf( pFile, " y%02d=%0*d", k, nDigits, Counter++ ); 00132 fprintf( pFile, "\n" ); 00133 Counter -= nVars; 00134 for ( i = 1; i < nVars-2; i++ ) 00135 { 00136 fprintf( pFile, ".subckt Layer%d", (i&1) ); 00137 for ( k = 0; k < nVars; k++ ) 00138 fprintf( pFile, " x%02d=%0*d", k, nDigits, Counter++ ); 00139 for ( k = 0; k < nVars; k++ ) 00140 fprintf( pFile, " y%02d=%0*d", k, nDigits, Counter++ ); 00141 fprintf( pFile, "\n" ); 00142 Counter -= nVars; 00143 } 00144 fprintf( pFile, ".subckt Layer%d", (i&1) ); 00145 for ( k = 0; k < nVars; k++ ) 00146 fprintf( pFile, " x%02d=%0*d", k, nDigits, Counter++ ); 00147 for ( k = 0; k < nVars; k++ ) 00148 fprintf( pFile, " y%02d=y%02d", k, k ); 00149 fprintf( pFile, "\n" ); 00150 } 00151 fprintf( pFile, ".end\n" ); 00152 fprintf( pFile, "\n" ); 00153 00154 Abc_WriteLayer( pFile, nVars, 0 ); 00155 Abc_WriteLayer( pFile, nVars, 1 ); 00156 Abc_WriteComp( pFile ); 00157 fclose( pFile ); 00158 }
void Abc_WriteCell | ( | FILE * | pFile | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 269 of file abcGen.c.
00270 { 00271 fprintf( pFile, ".model cell\n" ); 00272 fprintf( pFile, ".inputs px1 px2 py1 py2 x y\n" ); 00273 fprintf( pFile, ".outputs fx fy\n" ); 00274 fprintf( pFile, ".names x y a\n" ); 00275 fprintf( pFile, "11 1\n" ); 00276 fprintf( pFile, ".names px1 a x nx\n" ); 00277 fprintf( pFile, "11- 1\n" ); 00278 fprintf( pFile, "0-1 1\n" ); 00279 fprintf( pFile, ".names py1 a y ny\n" ); 00280 fprintf( pFile, "11- 1\n" ); 00281 fprintf( pFile, "0-1 1\n" ); 00282 fprintf( pFile, ".names px2 nx fx\n" ); 00283 fprintf( pFile, "10 1\n" ); 00284 fprintf( pFile, "01 1\n" ); 00285 fprintf( pFile, ".names py2 ny fy\n" ); 00286 fprintf( pFile, "10 1\n" ); 00287 fprintf( pFile, "01 1\n" ); 00288 fprintf( pFile, ".end\n" ); 00289 fprintf( pFile, "\n" ); 00290 }
void Abc_WriteComp | ( | FILE * | pFile | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 213 of file abcGen.c.
00214 { 00215 fprintf( pFile, ".model Comp\n" ); 00216 fprintf( pFile, ".inputs a b\n" ); 00217 fprintf( pFile, ".outputs x y\n" ); 00218 fprintf( pFile, ".names a b x\n" ); 00219 fprintf( pFile, "11 1\n" ); 00220 fprintf( pFile, ".names a b y\n" ); 00221 fprintf( pFile, "1- 1\n" ); 00222 fprintf( pFile, "-1 1\n" ); 00223 fprintf( pFile, ".end\n" ); 00224 fprintf( pFile, "\n" ); 00225 }
void Abc_WriteFullAdder | ( | FILE * | pFile | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 238 of file abcGen.c.
00239 { 00240 fprintf( pFile, ".model FA\n" ); 00241 fprintf( pFile, ".inputs a b cin\n" ); 00242 fprintf( pFile, ".outputs s cout\n" ); 00243 fprintf( pFile, ".names a b k\n" ); 00244 fprintf( pFile, "10 1\n" ); 00245 fprintf( pFile, "01 1\n" ); 00246 fprintf( pFile, ".names k cin s\n" ); 00247 fprintf( pFile, "10 1\n" ); 00248 fprintf( pFile, "01 1\n" ); 00249 fprintf( pFile, ".names a b cin cout\n" ); 00250 fprintf( pFile, "11- 1\n" ); 00251 fprintf( pFile, "1-1 1\n" ); 00252 fprintf( pFile, "-11 1\n" ); 00253 fprintf( pFile, ".end\n" ); 00254 fprintf( pFile, "\n" ); 00255 }
void Abc_WriteKLut | ( | FILE * | pFile, | |
int | nLutSize | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 374 of file abcGen.c.
00375 { 00376 int i, iVar, iNext, nPars = (1 << nLutSize); 00377 fprintf( pFile, "\n" ); 00378 fprintf( pFile, ".model lut%d\n", nLutSize ); 00379 fprintf( pFile, ".inputs" ); 00380 for ( i = 0; i < nPars; i++ ) 00381 fprintf( pFile, " p%02d", i ); 00382 fprintf( pFile, "\n" ); 00383 fprintf( pFile, ".inputs" ); 00384 for ( i = 0; i < nLutSize; i++ ) 00385 fprintf( pFile, " i%d", i ); 00386 fprintf( pFile, "\n" ); 00387 fprintf( pFile, ".outputs o\n" ); 00388 fprintf( pFile, ".names n01 o\n" ); 00389 fprintf( pFile, "1 1\n" ); 00390 // write internal MUXes 00391 iVar = 0; 00392 iNext = 2; 00393 for ( i = 1; i < nPars; i++ ) 00394 { 00395 if ( i == iNext ) 00396 { 00397 iNext *= 2; 00398 iVar++; 00399 } 00400 if ( iVar == nLutSize - 1 ) 00401 fprintf( pFile, ".names i%d p%02d p%02d n%02d\n", iVar, 2*(i-nPars/2), 2*(i-nPars/2)+1, i ); 00402 else 00403 fprintf( pFile, ".names i%d n%02d n%02d n%02d\n", iVar, 2*i, 2*i+1, i ); 00404 fprintf( pFile, "01- 1\n" ); 00405 fprintf( pFile, "1-1 1\n" ); 00406 } 00407 fprintf( pFile, ".end\n" ); 00408 fprintf( pFile, "\n" ); 00409 }
void Abc_WriteLayer | ( | FILE * | pFile, | |
int | nVars, | |||
int | fSkip1 | |||
) |
CFile****************************************************************
FileName [abc_.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Network and node package.]
Synopsis []
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [
] DECLARATIONS ///
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 171 of file abcGen.c.
00172 { 00173 int i; 00174 fprintf( pFile, ".model Layer%d\n", fSkip1 ); 00175 fprintf( pFile, ".inputs" ); 00176 for ( i = 0; i < nVars; i++ ) 00177 fprintf( pFile, " x%02d", i ); 00178 fprintf( pFile, "\n" ); 00179 fprintf( pFile, ".outputs" ); 00180 for ( i = 0; i < nVars; i++ ) 00181 fprintf( pFile, " y%02d", i ); 00182 fprintf( pFile, "\n" ); 00183 if ( fSkip1 ) 00184 { 00185 fprintf( pFile, ".names x00 y00\n" ); 00186 fprintf( pFile, "1 1\n" ); 00187 i = 1; 00188 } 00189 else 00190 i = 0; 00191 for ( ; i + 1 < nVars; i += 2 ) 00192 fprintf( pFile, ".subckt Comp a=x%02d b=x%02d x=y%02d y=y%02d\n", i, i+1, i, i+1 ); 00193 if ( i < nVars ) 00194 { 00195 fprintf( pFile, ".names x%02d y%02d\n", i, i ); 00196 fprintf( pFile, "1 1\n" ); 00197 } 00198 fprintf( pFile, ".end\n" ); 00199 fprintf( pFile, "\n" ); 00200 }