42static inline int Abc_TruthGetBit(
word *
p,
int i) {
43 return (
int) (
p[i >> 6] >> (i & 63)) & 1;
46static inline void Abc_TruthSetBit(
word *
p,
int i) {
47 p[i >> 6] |= (((
word) 1) << (i & 63));
50static inline void Abc_TruthXorBit(
word *
p,
int i) {
51 p[i >> 6] ^= (((
word) 1) << (i & 63));
56static inline int Abc_TruthGetHex(
word *
p,
int k) {
57 return (
int) (
p[k >> 4] >> ((k << 2) & 63)) & 15;
60static inline void Abc_TruthSetHex(
word *
p,
int k,
int d) {
61 p[k >> 4] |= (((
word) d) << ((k << 2) & 63));
64static inline void Abc_TruthXorHex(
word *
p,
int k,
int d) {
65 p[k >> 4] ^= (((
word) d) << ((k << 2) & 63));
74static inline int Abc_TruthReadHexDigit(
char HexChar) {
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;
87static inline void Abc_TruthWriteHexDigit(FILE * pFile,
int HexDigit) {
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 = (nVars < 7) ? (1 << (nVars-2)) : (
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++) {
113 Digit = Abc_TruthReadHexDigit(pString[nDigits - 1 - k]);
114 assert(Digit >= 0 && Digit < 16);
115 Abc_TruthSetHex(pTruth, k, Digit);
122 int nDigits, Digit, k;
123 nDigits = (1 << (nVars - 2));
124 for (k = 0; k < nDigits; k++) {
125 Digit = Abc_TruthGetHex(pTruth, k);
126 assert(Digit >= 0 && Digit < 16);
127 Abc_TruthWriteHexDigit(pFile, Digit);
149 p->nWords = (nVars < 7) ? 1 : (1 << (nVars - 6));
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');
275 int i, nBytes = 8 * Abc_Truth6WordNum(
p->nVars);
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++) {
360 Abc_Print(-2,
"%d: ", i+1);
366 Abc_Print(-2,
"Solution : %s\n",
lit->expression->pArray);
367 Abc_Print(-2,
"\n\n");
373 Abc_Print(-2,
"null\n");
374 Abc_Print(-2,
"\n\n");
378 percent = (rpoCount * 100.0) /
p->nFuncs;
379 Abc_Print(-2,
"%d of %d (%.2f %%) functions are RPO.\n", rpoCount,
p->nFuncs,percent);
380 Abc_PrintTime(1,
"Time", clock() - clk);
404 Abc_Print(-2,
"Number of variables = %d\n",
p->nVars);
425int Abc_RpoTest(
char * pFileName,
int nVarNum,
int nThreshold,
int fVerbose) {
427 printf(
"Using truth tables from file \"%s\"...\n", pFileName);
void Abc_TruthWriteHex(FILE *pFile, word *pTruth, int nVars)
void Abc_TruthStoreRead(char *pFileName, Abc_TtStore_t *p)
void Abc_TruthReadHex(word *pTruth, char *pString, int nVars)
Abc_TtStore_t * Abc_TruthStoreAlloc2(int nVars, int nFuncs, word *pBuffer)
void Abc_TtStoreWrite(char *pFileName, Abc_TtStore_t *p, int fBinary)
void Abc_TtStoreFree(Abc_TtStore_t *p, int nVarNum)
Abc_TtStore_t * Abc_TtStoreLoad(char *pFileName, int nVarNum)
Abc_TtStore_t * Abc_TruthStoreAlloc(int nVars, int nFuncs)
void Abc_TruthRpoTest(char *pFileName, int nVarNum, int nThreshold, int fVerbose)
int Abc_FileSize(char *pFileName)
void Abc_TruthGetParams(char *pFileName, int *pnVars, int *pnTruths)
typedefABC_NAMESPACE_IMPL_START struct Rpo_TtStore_t_ Rpo_TtStore_t
char * Abc_FileRead(char *pFileName)
int Abc_RpoTest(char *pFileName, int nVarNum, int nThreshold, int fVerbose)
void Abc_TruthRpoPerform(Rpo_TtStore_t *p, int nThreshold, int fVerbose)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
struct Literal_t_ Literal_t
unsigned __int64 word
DECLARATIONS ///.
Literal_t * Rpo_Factorize(unsigned *target, int nVars, int nThreshold, int verbose)
for(p=first;p->value< newval;p=p->next)