70 if ( HexChar >=
'0' && HexChar <=
'9' )
72 if ( HexChar >=
'A' && HexChar <=
'F' )
73 return HexChar -
'A' + 10;
74 if ( HexChar >=
'a' && HexChar <=
'f' )
75 return HexChar -
'a' + 10;
83 assert( HexDigit >= 0 && HexDigit < 16 );
85 fprintf( pFile,
"%d", HexDigit );
87 fprintf( pFile,
"%c",
'A' + HexDigit-10 );
93 int nWords = (nVars < 7)? 1 : (1 << (nVars-6));
94 int k, Digit, nDigits = (nWords << 4);
97 if ( pString[0] ==
'0' && pString[1] ==
'x' )
100 EndSymbol = pString[nDigits];
104 assert( EndSymbol ==
' ' || EndSymbol ==
'\n' || EndSymbol ==
'\r' || EndSymbol ==
'\0' );
107 for ( k = 0; k < nDigits; k++ )
110 assert( Digit >= 0 && Digit < 16 );
118 int nDigits, Digit, k;
119 nDigits = (1 << (nVars-2));
120 for ( k = 0; k < nDigits; k++ )
123 assert( Digit >= 0 && Digit < 16 );
146 p->
nWords = (nVars < 7) ? 1 : (1 << (nVars-6));
154 for ( i = 1; i < p->
nFuncs; i++ )
164 p->
nWords = (nVars < 7) ? 1 : (1 << (nVars-6));
171 for ( i = 1; i < p->
nFuncs; i++ )
198 pFile = fopen( pFileName,
"rb" );
201 printf(
"Cannot open file \"%s\" for reading.\n", pFileName );
206 nFileSize = ftell( pFile );
226 int nFileSize, RetValue;
227 pFile = fopen( pFileName,
"rb" );
230 printf(
"Cannot open file \"%s\" for reading.\n", pFileName );
235 nFileSize = ftell( pFile );
239 pBuffer = (
char *)
malloc( nFileSize + 3 );
240 RetValue = fread( pBuffer, nFileSize, 1, pFile );
243 pBuffer[ nFileSize + 0] =
'\n';
244 pBuffer[ nFileSize + 1] =
'\n';
246 pBuffer[ nFileSize + 2] =
'\0';
265 int i, nVars, nLines;
273 if ( pContents == NULL )
277 for ( i = 0; pContents[i]; i++ )
278 if ( pContents[i] ==
' ' || pContents[i] ==
'\n' || pContents[i] ==
'\r' )
280 if ( pContents[i] == 0 )
281 printf(
"Strange, the input file does not have spaces and new-lines...\n" );
284 if ( pContents[0] ==
'0' && pContents[1] ==
'x' )
288 for ( nVars = 0; nVars < 32; nVars++ )
289 if ( 4 * i == (1 << nVars) )
291 if ( nVars < 2 || nVars > 16 )
293 printf(
"Does not look like the input file contains truth tables...\n" );
301 for ( i = 0; pContents[i]; i++ )
302 nLines += (pContents[i] ==
'\n');
325 if ( pContents == NULL )
332 for ( nLines = i = 0; pContents[i] !=
'\n'; )
338 while ( pContents[i++] !=
'\n' );
363 pFile = fopen( pFileName,
"wb" );
366 printf(
"Cannot open file \"%s\" for writing.\n", pFileName );
369 for ( i = 0; i < p->
nFuncs; i++ )
372 fwrite( p->
pFuncs[i], nBytes, 1, pFile );
377 fprintf( pFile,
"%s\n", pBuffer );
403 if ( nVars < 2 || nVars > 16 || nTruths == 0 )
414 int nBytes = (1 << (nVarNum-3));
415 int nTruths = nFileSize / nBytes;
416 if ( nFileSize == -1 )
419 if ( nFileSize % nBytes != 0 )
420 Abc_Print( 0,
"The file size (%d) is divided by the truth table size (%d) with remainder (%d).\n",
421 nFileSize, nBytes, nFileSize % nBytes );
444 char * pFileInput = pFileName;
445 char * pFileOutput =
"out.txt";
457 printf(
"Input file \"%s\" was copied into output file \"%s\".\n", pFileInput, pFileOutput );
476 char * pAlgoName = NULL;
478 pAlgoName =
"factoring";
479 else if ( DecType == 2 )
480 pAlgoName =
"bi-decomp";
481 else if ( DecType == 3 )
483 else if ( DecType == 4 )
484 pAlgoName =
"fast DSD";
485 else if ( DecType == 5 )
486 pAlgoName =
"analysis";
489 printf(
"Applying %-10s to %8d func%s of %2d vars... ",
503 for ( i = 0; i < p->
nFuncs; i++ )
510 printf(
"%7d : ", i );
521 else if ( DecType == 2 )
528 for ( i = 0; i < p->
nFuncs; i++ )
531 printf(
"%7d : ", i );
539 else if ( DecType == 3 )
544 for ( i = 0; i < p->
nFuncs; i++ )
547 printf(
"%7d : ", i );
555 else if ( DecType == 4 )
558 for ( i = 0; i < p->
nFuncs; i++ )
561 printf(
"%7d : ", i );
564 printf(
"%s\n", pDsd );
568 else if ( DecType == 5 )
570 for ( i = 0; i < p->
nFuncs; i++ )
575 printf(
"%7d : ", i );
583 printf(
"AIG nodes =%9d ", nNodes );
604 if ( p == NULL )
return;
626 int Abc_DecTest(
char * pFileName,
int DecType,
int nVarNum,
int fVerbose )
629 printf(
"Using truth tables from file \"%s\"...\n", pFileName );
632 else if ( DecType >= 1 && DecType <= 5 )
635 printf(
"Unknown decomposition type value (%d).\n", DecType );
void Abc_TtStoreWrite(char *pFileName, Abc_TtStore_t *p, int fBinary)
static void Abc_TruthXorBit(word *p, int i)
void Bdc_ManDecPrint(Bdc_Man_t *p)
void Abc_TtStoreTest(char *pFileName)
void Abc_TtStoreFree(Abc_TtStore_t *p, int nVarNum)
static int Dec_GraphNodeNum(Dec_Graph_t *pGraph)
static int Abc_TruthGetBit(word *p, int i)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static int Abc_TruthReadHexDigit(char HexChar)
FUNCTION DEFINITIONS ///.
char * Kit_PlaFromTruthNew(unsigned *pTruth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vStr)
static int Abc_Truth6WordNum(int nVars)
Kit_DsdNtk_t * Kit_DsdDecomposeMux(unsigned *pTruth, int nVars, int nDecMux)
Bdc_Man_t * Bdc_ManAlloc(Bdc_Par_t *pPars)
MACRO DEFINITIONS ///.
int Abc_DecTest(char *pFileName, int DecType, int nVarNum, int fVerbose)
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
Dec_Graph_t * Dec_Factor(char *pSop)
FUNCTION DECLARATIONS ///.
static Vec_Str_t * Vec_StrAlloc(int nCap)
int Bdc_ManDecompose(Bdc_Man_t *p, unsigned *puFunc, unsigned *puCare, int nVars, Vec_Ptr_t *vDivs, int nNodesMax)
static abctime Abc_Clock()
int Kit_DsdCountAigNodes(Kit_DsdNtk_t *pNtk)
void Dau_DecTrySets(word *pInit, int nVars, int fVerbose)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Abc_TtStore_t * Abc_TruthStoreAlloc2(int nVars, int nFuncs, word *pBuffer)
static void Abc_TruthXorHex(word *p, int k, int d)
void Dec_GraphPrint(FILE *pFile, Dec_Graph_t *pGraph, char *pNamesIn[], char *pNameOut)
FUNCTION DEFINITIONS ///.
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static void Abc_TruthWriteHexDigit(FILE *pFile, int HexDigit)
void Abc_TruthGetParams(char *pFileName, int *pnVars, int *pnTruths)
Abc_TtStore_t * Abc_TruthStoreAlloc(int nVars, int nFuncs)
static void Vec_StrFree(Vec_Str_t *p)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static void Abc_Print(int level, const char *format,...)
int Bdc_ManAndNum(Bdc_Man_t *p)
char * Abc_FileRead(char *pFileName)
#define ABC_NAMESPACE_IMPL_START
Abc_TtStore_t * Abc_TtStoreLoad(char *pFileName, int nVarNum)
void Abc_TruthStoreRead(char *pFileName, Abc_TtStore_t *p)
void Abc_TruthDecTest(char *pFileName, int DecType, int nVarNum, int fVerbose)
static void Abc_TruthSetHex(word *p, int k, int d)
int Abc_FileSize(char *pFileName)
static int Abc_TtSupportSize(word *t, int nVars)
static void Dec_GraphFree(Dec_Graph_t *pGraph)
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
void Bdc_ManFree(Bdc_Man_t *p)
int Dau_DsdCountAnds(char *pDsd)
static void Vec_IntFree(Vec_Int_t *p)
static int Abc_TruthGetHex(word *p, int k)
void Abc_TruthWriteHex(FILE *pFile, word *pTruth, int nVars)
static void Abc_TruthSetBit(word *p, int i)
void Abc_TruthReadHex(word *pTruth, char *pString, int nVars)
void Kit_DsdPrintExpanded(Kit_DsdNtk_t *pNtk)
void Abc_TruthDecPerform(Abc_TtStore_t *p, int DecType, int fVerbose)