43 return (
int) (p[i >> 6] >> (i & 63)) & 1;
47 p[i >> 6] |= (((
word) 1) << (i & 63));
51 p[i >> 6] ^= (((
word) 1) << (i & 63));
57 return (
int) (p[k >> 4] >> ((k << 2) & 63)) & 15;
61 p[k >> 4] |= (((
word) d) << ((k << 2) & 63));
65 p[k >> 4] ^= (((
word) d) << ((k << 2) & 63));
75 if (HexChar >=
'0' && HexChar <=
'9')
77 if (HexChar >=
'A' && HexChar <=
'F')
78 return HexChar -
'A' + 10;
79 if (HexChar >=
'a' && HexChar <=
'f')
80 return HexChar -
'a' + 10;
88 assert(HexDigit >= 0 && HexDigit < 16);
90 fprintf(pFile,
"%d", HexDigit);
92 fprintf(pFile,
"%c",
'A' + HexDigit - 10);
98 int nWords = (nVars < 7) ? 1 : (1 << (nVars - 6));
99 int k, Digit, nDigits = (nWords << 4);
102 if (pString[0] ==
'0' && pString[1] ==
'x')
105 EndSymbol = pString[nDigits];
109 assert(EndSymbol ==
' ' || EndSymbol ==
'\n' || EndSymbol ==
'\r' || EndSymbol ==
'\0');
112 for (k = 0; k < nDigits; k++) {
114 assert(Digit >= 0 && Digit < 16);
122 int nDigits, Digit, k;
123 nDigits = (1 << (nVars - 2));
124 for (k = 0; k < nDigits; k++) {
126 assert(Digit >= 0 && Digit < 16);
149 p->nWords = (nVars < 7) ? 1 : (1 << (nVars - 6));
152 p->pFuncs = (
word **)
malloc((
sizeof (
word *) +
sizeof (
word) * p->nWords) * p->nFuncs);
154 p->pFuncs[0] = (
word *) (p->pFuncs + p->nFuncs);
155 memset(p->pFuncs[0], 0, sizeof (
word) * p->nWords * p->nFuncs);
157 for (i = 1; i < p->nFuncs; i++)
158 p->pFuncs[i] = p->pFuncs[i - 1] + p->nWords;
167 p->nWords = (nVars < 7) ? 1 : (1 << (nVars - 6));
172 p->pFuncs[0] = pBuffer;
174 for (i = 1; i < p->nFuncs; i++)
175 p->pFuncs[i] = p->pFuncs[i - 1] + p->nWords;
241 if (pContents == NULL)
248 for (nLines = i = 0; pContents[i] !=
'\n';) {
253 while (pContents[i++] !=
'\n');
257 assert(p->nFuncs >= nLines);
276 pFile = fopen(pFileName,
"wb");
278 printf(
"Cannot open file \"%s\" for writing.\n", pFileName);
281 for (i = 0; i < p->nFuncs; i++) {
283 fwrite(p->pFuncs[i], nBytes, 1, pFile);
307 if (nVars < 2 || nVars > 16 || nTruths == 0)
316 int nBytes = (1 << (nVarNum - 3));
317 int nTruths = nFileSize / nBytes;
322 if (nFileSize % nBytes != 0)
323 Abc_Print(0,
"The file size (%d) is divided by the truth table size (%d) with remainder (%d).\n",
324 nFileSize, nBytes, nFileSize % nBytes);
346 clock_t clk = clock();
351 for (i = 0; i < p->nFuncs; i++) {
363 lit =
Rpo_Factorize((
unsigned *) p->pFuncs[i], p->nVars, nThreshold, fVerbose);
378 percent = (rpoCount * 100.0) / p->nFuncs;
379 Abc_Print(-2,
"%d of %d (%.2f %%) functions are RPO.\n", rpoCount,p->nFuncs,percent);
404 Abc_Print(-2,
"Number of variables = %d\n", p->nVars);
425 int Abc_RpoTest(
char * pFileName,
int nVarNum,
int nThreshold,
int fVerbose) {
427 printf(
"Using truth tables from file \"%s\"...\n", pFileName);
static int Abc_TruthGetHex(word *p, int k)
int Abc_RpoTest(char *pFileName, int nVarNum, int nThreshold, int fVerbose)
char * Abc_FileRead(char *pFileName)
static void Abc_TtStoreFree(Rpo_TtStore_t *p, int nVarNum)
void Abc_TruthRpoPerform(Rpo_TtStore_t *p, int nThreshold, int fVerbose)
static void Abc_TruthWriteHex(FILE *pFile, word *pTruth, int nVars)
static int Abc_Truth6WordNum(int nVars)
static int Abc_TruthReadHexDigit(char HexChar)
FUNCTION DEFINITIONS ///.
static void Abc_TruthStoreRead(char *pFileName, Rpo_TtStore_t *p)
int Abc_FileSize(char *pFileName)
static void Lit_Free(Literal_t *lit)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
void Abc_TruthGetParams(char *pFileName, int *pnVars, int *pnTruths)
typedefABC_NAMESPACE_IMPL_START struct Rpo_TtStore_t_ Rpo_TtStore_t
Literal_t * Rpo_Factorize(unsigned *target, int nVars, int nThreshold, int verbose)
static Rpo_TtStore_t * Abc_TruthStoreAlloc(int nVars, int nFuncs)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static void Abc_TruthXorBit(word *p, int i)
static int Abc_TruthGetBit(word *p, int i)
static void Abc_TruthWriteHexDigit(FILE *pFile, int HexDigit)
static void Abc_TtStoreWrite(char *pFileName, Rpo_TtStore_t *p, int fBinary)
static void Abc_Print(int level, const char *format,...)
#define ABC_NAMESPACE_IMPL_START
static void Abc_TruthReadHex(word *pTruth, char *pString, int nVars)
static void Abc_TruthSetBit(word *p, int i)
void Abc_TruthRpoTest(char *pFileName, int nVarNum, int nThreshold, int fVerbose)
static void Abc_TruthXorHex(word *p, int k, int d)
static Rpo_TtStore_t * Abc_TruthStoreAlloc2(int nVars, int nFuncs, word *pBuffer)
static Rpo_TtStore_t * Abc_TtStoreLoad(char *pFileName, int nVarNum)
static void Abc_TruthSetHex(word *p, int k, int d)