ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcSop.c File Reference
#include "abc.h"
#include "bool/kit/kit.h"
Include dependency graph for abcSop.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START char * Abc_SopRegister (Mem_Flex_t *pMan, const char *pName)
 DECLARATIONS ///.
 
char * Abc_SopStart (Mem_Flex_t *pMan, int nCubes, int nVars)
 
char * Abc_SopCreateConst1 (Mem_Flex_t *pMan)
 
char * Abc_SopCreateConst0 (Mem_Flex_t *pMan)
 
char * Abc_SopCreateAnd2 (Mem_Flex_t *pMan, int fCompl0, int fCompl1)
 
char * Abc_SopCreateAnd (Mem_Flex_t *pMan, int nVars, int *pfCompl)
 
char * Abc_SopCreateNand (Mem_Flex_t *pMan, int nVars)
 
char * Abc_SopCreateOr (Mem_Flex_t *pMan, int nVars, int *pfCompl)
 
char * Abc_SopCreateOrMultiCube (Mem_Flex_t *pMan, int nVars, int *pfCompl)
 
char * Abc_SopCreateNor (Mem_Flex_t *pMan, int nVars)
 
char * Abc_SopCreateXor (Mem_Flex_t *pMan, int nVars)
 
char * Abc_SopCreateXorSpecial (Mem_Flex_t *pMan, int nVars)
 
char * Abc_SopCreateNxor (Mem_Flex_t *pMan, int nVars)
 
char * Abc_SopCreateMux (Mem_Flex_t *pMan)
 
char * Abc_SopCreateInv (Mem_Flex_t *pMan)
 
char * Abc_SopCreateBuf (Mem_Flex_t *pMan)
 
char * Abc_SopCreateFromTruth (Mem_Flex_t *pMan, int nVars, unsigned *pTruth)
 
char * Abc_SopCreateFromIsop (Mem_Flex_t *pMan, int nVars, Vec_Int_t *vCover)
 
char * Abc_SopCreateFromTruthIsop (Mem_Flex_t *pMan, int nVars, word *pTruth, Vec_Int_t *vCover)
 
void Abc_SopToIsop (char *pSop, Vec_Int_t *vCover)
 
int Abc_SopGetCubeNum (char *pSop)
 
int Abc_SopGetLitNum (char *pSop)
 
int Abc_SopGetVarNum (char *pSop)
 
int Abc_SopGetPhase (char *pSop)
 
int Abc_SopGetIthCareLit (char *pSop, int i)
 
void Abc_SopComplement (char *pSop)
 
void Abc_SopComplementVar (char *pSop, int iVar)
 
int Abc_SopIsComplement (char *pSop)
 
int Abc_SopIsConst0 (char *pSop)
 
int Abc_SopIsConst1 (char *pSop)
 
int Abc_SopIsBuf (char *pSop)
 
int Abc_SopIsInv (char *pSop)
 
int Abc_SopIsAndType (char *pSop)
 
int Abc_SopIsOrType (char *pSop)
 
int Abc_SopIsExorType (char *pSop)
 
int Abc_SopCheck (char *pSop, int nFanins)
 
int Abc_SopCheckReadTruth (Vec_Ptr_t *vRes, char *pToken, int fHex)
 
char * Abc_SopFromTruthBin (char *pTruth)
 
Vec_Ptr_tAbc_SopFromTruthsBin (char *pTruth)
 
char * Abc_SopFromTruthHex (char *pTruth)
 
Vec_Ptr_tAbc_SopFromTruthsHex (char *pTruth)
 
Vec_Ptr_tAbc_SopGenerateCounters (int nVars)
 
char * Abc_SopEncoderPos (Mem_Flex_t *pMan, int iValue, int nValues)
 
char * Abc_SopEncoderLog (Mem_Flex_t *pMan, int iBit, int nValues)
 
char * Abc_SopDecoderPos (Mem_Flex_t *pMan, int nValues)
 
char * Abc_SopDecoderLog (Mem_Flex_t *pMan, int nValues)
 
word Abc_SopToTruth (char *pSop, int nInputs)
 
void Abc_SopToTruth7 (char *pSop, int nInputs, word r[2])
 
void Abc_SopToTruthBig (char *pSop, int nInputs, word **pVars, word *pCube, word *pRes)
 

Function Documentation

◆ Abc_SopCheck()

int Abc_SopCheck ( char * pSop,
int nFanins )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 871 of file abcSop.c.

872{
873 char * pCubes, * pCubesOld;
874 int fFound0 = 0, fFound1 = 0;
875
876 // check the logic function of the node
877 for ( pCubes = pSop; *pCubes; pCubes++ )
878 {
879 // get the end of the next cube
880 for ( pCubesOld = pCubes; *pCubes != ' '; pCubes++ );
881 // compare the distance
882 if ( pCubes - pCubesOld != nFanins )
883 {
884 fprintf( stdout, "Abc_SopCheck: SOP has a mismatch between its cover size (%d) and its fanin number (%d).\n",
885 (int)(ABC_PTRDIFF_T)(pCubes - pCubesOld), nFanins );
886 return 0;
887 }
888 // check the output values for this cube
889 pCubes++;
890 if ( *pCubes == '0' )
891 fFound0 = 1;
892 else if ( *pCubes == '1' )
893 fFound1 = 1;
894 else if ( *pCubes != 'x' && *pCubes != 'n' )
895 {
896 fprintf( stdout, "Abc_SopCheck: SOP has a strange character (%c) in the output part of its cube.\n", *pCubes );
897 return 0;
898 }
899 // check the last symbol (new line)
900 pCubes++;
901 if ( *pCubes != '\n' )
902 {
903 fprintf( stdout, "Abc_SopCheck: SOP has a cube without new line in the end.\n" );
904 return 0;
905 }
906 }
907 if ( fFound0 && fFound1 )
908 {
909 fprintf( stdout, "Abc_SopCheck: SOP has cubes in both phases.\n" );
910 return 0;
911 }
912 return 1;
913}

◆ Abc_SopCheckReadTruth()

int Abc_SopCheckReadTruth ( Vec_Ptr_t * vRes,
char * pToken,
int fHex )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 926 of file abcSop.c.

927{
928 char * pBase; int nVars;
929 int Log2 = Abc_Base2Log( strlen(pToken) );
930 if ( fHex && strlen(pToken) == 1 )
931 Log2 = 0;
932 if ( (1 << Log2) != (int)strlen(pToken) )
933 {
934 printf( "The truth table length (%d) is not power-of-2.\n", (int)strlen(pToken) );
935 Vec_PtrFreeData( vRes );
936 Vec_PtrShrink( vRes, 0 );
937 return 0;
938 }
939 if ( Vec_PtrSize(vRes) == 0 )
940 return 1;
941 pBase = (char *)Vec_PtrEntry( vRes, 0 );
942 nVars = Abc_SopGetVarNum( pBase );
943 if ( nVars != Log2+2*fHex )
944 {
945 printf( "Truth table #1 has %d vars while truth table #%d has %d vars.\n", nVars, Vec_PtrSize(vRes)+1, Log2+2*fHex );
946 Vec_PtrFreeData( vRes );
947 Vec_PtrShrink( vRes, 0 );
948 return 0;
949 }
950 return 1;
951}
int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
int strlen()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopComplement()

void Abc_SopComplement ( char * pSop)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 648 of file abcSop.c.

649{
650 char * pCur;
651 for ( pCur = pSop; *pCur; pCur++ )
652 if ( *pCur == '\n' )
653 {
654 if ( *(pCur - 1) == '0' )
655 *(pCur - 1) = '1';
656 else if ( *(pCur - 1) == '1' )
657 *(pCur - 1) = '0';
658 else if ( *(pCur - 1) == 'x' )
659 *(pCur - 1) = 'n';
660 else if ( *(pCur - 1) == 'n' )
661 *(pCur - 1) = 'x';
662 else
663 assert( 0 );
664 }
665}
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Abc_SopComplementVar()

void Abc_SopComplementVar ( char * pSop,
int iVar )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 678 of file abcSop.c.

679{
680 char * pCube;
681 int nVars = Abc_SopGetVarNum(pSop);
682 assert( iVar < nVars );
683 Abc_SopForEachCube( pSop, nVars, pCube )
684 {
685 if ( pCube[iVar] == '0' )
686 pCube[iVar] = '1';
687 else if ( pCube[iVar] == '1' )
688 pCube[iVar] = '0';
689 }
690}
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition abc.h:538
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateAnd()

char * Abc_SopCreateAnd ( Mem_Flex_t * pMan,
int nVars,
int * pfCompl )

Function*************************************************************

Synopsis [Creates the multi-input AND cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 168 of file abcSop.c.

169{
170 char * pSop;
171 int i;
172 pSop = Abc_SopStart( pMan, 1, nVars );
173 for ( i = 0; i < nVars; i++ )
174 pSop[i] = '1' - (pfCompl? pfCompl[i] : 0);
175 pSop[nVars + 1] = '1';
176 return pSop;
177}
char * Abc_SopStart(Mem_Flex_t *pMan, int nCubes, int nVars)
Definition abcSop.c:82
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateAnd2()

char * Abc_SopCreateAnd2 ( Mem_Flex_t * pMan,
int fCompl0,
int fCompl1 )

Function*************************************************************

Synopsis [Creates the AND2 cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file abcSop.c.

146{
147 char Buffer[6];
148 Buffer[0] = '1' - fCompl0;
149 Buffer[1] = '1' - fCompl1;
150 Buffer[2] = ' ';
151 Buffer[3] = '1';
152 Buffer[4] = '\n';
153 Buffer[5] = 0;
154 return Abc_SopRegister( pMan, Buffer );
155}
ABC_NAMESPACE_IMPL_START char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
Here is the call graph for this function:

◆ Abc_SopCreateBuf()

char * Abc_SopCreateBuf ( Mem_Flex_t * pMan)

Function*************************************************************

Synopsis [Creates the buf cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 367 of file abcSop.c.

368{
369 return Abc_SopRegister(pMan, "1 1\n");
370}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateConst0()

char * Abc_SopCreateConst0 ( Mem_Flex_t * pMan)

Function*************************************************************

Synopsis [Creates the constant 1 cover with 0 variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 129 of file abcSop.c.

130{
131 return Abc_SopRegister( pMan, " 0\n" );
132}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateConst1()

char * Abc_SopCreateConst1 ( Mem_Flex_t * pMan)

Function*************************************************************

Synopsis [Creates the constant 1 cover with 0 variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 113 of file abcSop.c.

114{
115 return Abc_SopRegister( pMan, " 1\n" );
116}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateFromIsop()

char * Abc_SopCreateFromIsop ( Mem_Flex_t * pMan,
int nVars,
Vec_Int_t * vCover )

Function*************************************************************

Synopsis [Creates the cover from the ISOP computed from TT.]

Description []

SideEffects []

SeeAlso []

Definition at line 424 of file abcSop.c.

425{
426 char * pSop, * pCube;
427 int i, k, Entry, Literal;
428 assert( Vec_IntSize(vCover) > 0 );
429 if ( Vec_IntSize(vCover) == 0 )
430 return NULL;
431 // start the cover
432 pSop = Abc_SopStart( pMan, Vec_IntSize(vCover), nVars );
433 // create cubes
434 Vec_IntForEachEntry( vCover, Entry, i )
435 {
436 pCube = pSop + i * (nVars + 3);
437 for ( k = 0; k < nVars; k++ )
438 {
439 Literal = 3 & (Entry >> (k << 1));
440 if ( Literal == 1 )
441 pCube[k] = '0';
442 else if ( Literal == 2 )
443 pCube[k] = '1';
444 else if ( Literal != 0 )
445 assert( 0 );
446 }
447 }
448 return pSop;
449}
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateFromTruth()

char * Abc_SopCreateFromTruth ( Mem_Flex_t * pMan,
int nVars,
unsigned * pTruth )

Function*************************************************************

Synopsis [Creates the arbitrary cover from the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 383 of file abcSop.c.

384{
385 char * pSop, * pCube;
386 int nMints, Counter, i, k;
387 if ( nVars == 0 )
388 return pTruth[0] ? Abc_SopCreateConst1(pMan) : Abc_SopCreateConst0(pMan);
389 // count the number of true minterms
390 Counter = 0;
391 nMints = (1 << nVars);
392 for ( i = 0; i < nMints; i++ )
393 Counter += ((pTruth[i>>5] & (1 << (i&31))) > 0);
394 // SOP is not well-defined if the truth table is constant 0
395 assert( Counter > 0 );
396 if ( Counter == 0 )
397 return NULL;
398 // start the cover
399 pSop = Abc_SopStart( pMan, Counter, nVars );
400 // create true minterms
401 Counter = 0;
402 for ( i = 0; i < nMints; i++ )
403 if ( (pTruth[i>>5] & (1 << (i&31))) > 0 )
404 {
405 pCube = pSop + Counter * (nVars + 3);
406 for ( k = 0; k < nVars; k++ )
407 pCube[k] = '0' + ((i & (1 << k)) > 0);
408 Counter++;
409 }
410 return pSop;
411}
char * Abc_SopCreateConst1(Mem_Flex_t *pMan)
Definition abcSop.c:113
ABC_DLL char * Abc_SopCreateConst0(Mem_Flex_t *pMan)
Definition abcSop.c:129
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateFromTruthIsop()

char * Abc_SopCreateFromTruthIsop ( Mem_Flex_t * pMan,
int nVars,
word * pTruth,
Vec_Int_t * vCover )

Function*************************************************************

Synopsis [Creates the cover from the ISOP computed from TT.]

Description []

SideEffects []

SeeAlso []

Definition at line 462 of file abcSop.c.

463{
464 char * pSop = NULL;
465 int w, nWords = Abc_Truth6WordNum( nVars );
466 assert( nVars < 16 );
467
468 for ( w = 0; w < nWords; w++ )
469 if ( pTruth[w] )
470 break;
471 if ( w == nWords )
472 return Abc_SopRegister( pMan, " 0\n" );
473
474 for ( w = 0; w < nWords; w++ )
475 if ( ~pTruth[w] )
476 break;
477 if ( w == nWords )
478 return Abc_SopRegister( pMan, " 1\n" );
479
480 {
481 int RetValue = Kit_TruthIsop( (unsigned *)pTruth, nVars, vCover, 1 );
482 assert( nVars > 0 );
483 assert( RetValue == 0 || RetValue == 1 );
484 pSop = Abc_SopCreateFromIsop( pMan, nVars, vCover );
485 if ( RetValue )
486 Abc_SopComplement( pSop );
487 }
488 return pSop;
489}
int nWords
Definition abcNpn.c:127
void Abc_SopComplement(char *pSop)
Definition abcSop.c:648
char * Abc_SopCreateFromIsop(Mem_Flex_t *pMan, int nVars, Vec_Int_t *vCover)
Definition abcSop.c:424
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
Definition kitIsop.c:134
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateInv()

char * Abc_SopCreateInv ( Mem_Flex_t * pMan)

Function*************************************************************

Synopsis [Creates the inv cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 351 of file abcSop.c.

352{
353 return Abc_SopRegister(pMan, "0 1\n");
354}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateMux()

char * Abc_SopCreateMux ( Mem_Flex_t * pMan)

Function*************************************************************

Synopsis [Creates the MUX cover.]

Description [The first input of MUX is the control. The second input is DATA1. The third input is DATA0.]

SideEffects []

SeeAlso []

Definition at line 335 of file abcSop.c.

336{
337 return Abc_SopRegister(pMan, "11- 1\n0-1 1\n");
338}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateNand()

char * Abc_SopCreateNand ( Mem_Flex_t * pMan,
int nVars )

Function*************************************************************

Synopsis [Creates the multi-input NAND cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file abcSop.c.

191{
192 char * pSop;
193 int i;
194 pSop = Abc_SopStart( pMan, 1, nVars );
195 for ( i = 0; i < nVars; i++ )
196 pSop[i] = '1';
197 pSop[nVars + 1] = '0';
198 return pSop;
199}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateNor()

char * Abc_SopCreateNor ( Mem_Flex_t * pMan,
int nVars )

Function*************************************************************

Synopsis [Creates the multi-input NOR cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 259 of file abcSop.c.

260{
261 char * pSop;
262 int i;
263 pSop = Abc_SopStart( pMan, 1, nVars );
264 for ( i = 0; i < nVars; i++ )
265 pSop[i] = '0';
266 return pSop;
267}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateNxor()

char * Abc_SopCreateNxor ( Mem_Flex_t * pMan,
int nVars )

Function*************************************************************

Synopsis [Creates the multi-input XNOR cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file abcSop.c.

318{
319 assert( nVars == 2 );
320 return Abc_SopRegister(pMan, "11 1\n00 1\n");
321}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateOr()

char * Abc_SopCreateOr ( Mem_Flex_t * pMan,
int nVars,
int * pfCompl )

Function*************************************************************

Synopsis [Creates the multi-input OR cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 212 of file abcSop.c.

213{
214 char * pSop;
215 int i;
216 pSop = Abc_SopStart( pMan, 1, nVars );
217 for ( i = 0; i < nVars; i++ )
218 pSop[i] = '0' + (pfCompl? pfCompl[i] : 0);
219 pSop[nVars + 1] = '0';
220 return pSop;
221}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateOrMultiCube()

char * Abc_SopCreateOrMultiCube ( Mem_Flex_t * pMan,
int nVars,
int * pfCompl )

Function*************************************************************

Synopsis [Creates the multi-input OR cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 234 of file abcSop.c.

235{
236 char * pSop, * pCube;
237 int i;
238 pSop = Abc_SopStart( pMan, nVars, nVars );
239 i = 0;
240 Abc_SopForEachCube( pSop, nVars, pCube )
241 {
242 pCube[i] = '1' - (pfCompl? pfCompl[i] : 0);
243 i++;
244 }
245 return pSop;
246}
Here is the call graph for this function:

◆ Abc_SopCreateXor()

char * Abc_SopCreateXor ( Mem_Flex_t * pMan,
int nVars )

Function*************************************************************

Synopsis [Creates the multi-input XOR cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 280 of file abcSop.c.

281{
282 assert( nVars == 2 );
283 return Abc_SopRegister(pMan, "01 1\n10 1\n");
284}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopCreateXorSpecial()

char * Abc_SopCreateXorSpecial ( Mem_Flex_t * pMan,
int nVars )

Function*************************************************************

Synopsis [Creates the multi-input XOR cover (special case).]

Description []

SideEffects []

SeeAlso []

Definition at line 297 of file abcSop.c.

298{
299 char * pSop;
300 pSop = Abc_SopCreateAnd( pMan, nVars, NULL );
301 pSop[nVars+1] = 'x';
302 assert( pSop[nVars+2] == '\n' );
303 return pSop;
304}
char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition abcSop.c:168
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopDecoderLog()

char * Abc_SopDecoderLog ( Mem_Flex_t * pMan,
int nValues )

Function*************************************************************

Synopsis [Creates the decover node.]

Description [Produces MV-SOP for BLIF-MV representation.]

SideEffects []

SeeAlso []

Definition at line 1280 of file abcSop.c.

1281{
1282 char * pResult;
1283 Vec_Str_t * vSop;
1284 int i, b, nBits = Abc_Base2Log(nValues);
1285 assert( nValues > 1 && nValues <= (1<<nBits) );
1286 vSop = Vec_StrAlloc( 100 );
1287 for ( i = 0; i < nValues; i++ )
1288 {
1289 for ( b = 0; b < nBits; b++ )
1290 {
1291 Vec_StrPrintNum( vSop, (int)((i & (1 << b)) > 0) );
1292 Vec_StrPush( vSop, ' ' );
1293 }
1294 Vec_StrPrintNum( vSop, i );
1295 Vec_StrPush( vSop, '\n' );
1296 }
1297 Vec_StrPush( vSop, 0 );
1298 pResult = Abc_SopRegister( pMan, Vec_StrArray(vSop) );
1299 Vec_StrFree( vSop );
1300 return pResult;
1301}
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopDecoderPos()

char * Abc_SopDecoderPos ( Mem_Flex_t * pMan,
int nValues )

Function*************************************************************

Synopsis [Creates the decoder node.]

Description [Produces MV-SOP for BLIF-MV representation.]

SideEffects []

SeeAlso []

Definition at line 1244 of file abcSop.c.

1245{
1246 char * pResult;
1247 Vec_Str_t * vSop;
1248 int i, k;
1249 assert( nValues > 1 );
1250 vSop = Vec_StrAlloc( 100 );
1251 for ( i = 0; i < nValues; i++ )
1252 {
1253 for ( k = 0; k < nValues; k++ )
1254 {
1255 if ( k == i )
1256 Vec_StrPrintStr( vSop, "1 " );
1257 else
1258 Vec_StrPrintStr( vSop, "- " );
1259 }
1260 Vec_StrPrintNum( vSop, i );
1261 Vec_StrPush( vSop, '\n' );
1262 }
1263 Vec_StrPush( vSop, 0 );
1264 pResult = Abc_SopRegister( pMan, Vec_StrArray(vSop) );
1265 Vec_StrFree( vSop );
1266 return pResult;
1267}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopEncoderLog()

char * Abc_SopEncoderLog ( Mem_Flex_t * pMan,
int iBit,
int nValues )

Function*************************************************************

Synopsis [Creates one encoder node.]

Description [Produces MV-SOP for BLIF-MV representation.]

SideEffects []

SeeAlso []

Definition at line 1200 of file abcSop.c.

1201{
1202 char * pResult;
1203 Vec_Str_t * vSop;
1204 int v, Counter, fFirst = 1, nBits = Abc_Base2Log(nValues);
1205 assert( iBit < nBits );
1206 // count the number of literals
1207 Counter = 0;
1208 for ( v = 0; v < nValues; v++ )
1209 Counter += ( (v & (1 << iBit)) > 0 );
1210 // create the cover
1211 vSop = Vec_StrAlloc( 100 );
1212 Vec_StrPrintStr( vSop, "d0\n" );
1213 if ( Counter > 1 )
1214 Vec_StrPrintStr( vSop, "(" );
1215 for ( v = 0; v < nValues; v++ )
1216 if ( v & (1 << iBit) )
1217 {
1218 if ( fFirst )
1219 fFirst = 0;
1220 else
1221 Vec_StrPush( vSop, ',' );
1222 Vec_StrPrintNum( vSop, v );
1223 }
1224 if ( Counter > 1 )
1225 Vec_StrPrintStr( vSop, ")" );
1226 Vec_StrPrintStr( vSop, " 1\n" );
1227 Vec_StrPush( vSop, 0 );
1228 pResult = Abc_SopRegister( pMan, Vec_StrArray(vSop) );
1229 Vec_StrFree( vSop );
1230 return pResult;
1231}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopEncoderPos()

char * Abc_SopEncoderPos ( Mem_Flex_t * pMan,
int iValue,
int nValues )

Function*************************************************************

Synopsis [Creates one encoder node.]

Description [Produces MV-SOP for BLIF-MV representation.]

SideEffects []

SeeAlso []

Definition at line 1181 of file abcSop.c.

1182{
1183 char Buffer[32];
1184 assert( iValue < nValues );
1185 sprintf( Buffer, "d0\n%d 1\n", iValue );
1186 return Abc_SopRegister( pMan, Buffer );
1187}
char * sprintf()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopFromTruthBin()

char * Abc_SopFromTruthBin ( char * pTruth)

Function*************************************************************

Synopsis [Derives SOP from the truth table representation.]

Description [Truth table is expected to be in the hexadecimal notation.]

SideEffects []

SeeAlso []

Definition at line 964 of file abcSop.c.

965{
966 char * pSopCover, * pCube;
967 int nTruthSize, nVars, Digit, Length, Mint, i, b;
968 Vec_Int_t * vMints;
969
970 // get the number of variables
971 nTruthSize = strlen(pTruth);
972 nVars = Abc_Base2Log( nTruthSize );
973 if ( nTruthSize != (1 << (nVars)) )
974 {
975 printf( "String %s does not look like a truth table of a %d-variable function.\n", pTruth, nVars );
976 return NULL;
977 }
978
979 // collect the on-set minterms
980 vMints = Vec_IntAlloc( 100 );
981 for ( i = 0; i < nTruthSize; i++ )
982 {
983 if ( pTruth[i] >= '0' && pTruth[i] <= '1' )
984 Digit = pTruth[i] - '0';
985 else
986 {
987 Vec_IntFree( vMints );
988 printf( "String %s does not look like a binary representation of the truth table.\n", pTruth );
989 return NULL;
990 }
991 if ( Digit == 1 )
992 Vec_IntPush( vMints, nTruthSize - 1 - i );
993 }
994/*
995 if ( Vec_IntSize( vMints ) == 0 || Vec_IntSize( vMints ) == nTruthSize )
996 {
997 Vec_IntFree( vMints );
998 printf( "Cannot create constant function.\n" );
999 return NULL;
1000 }
1001*/
1002 if ( Vec_IntSize(vMints) == 0 || Vec_IntSize(vMints) == (1 << nVars) )
1003 {
1004 pSopCover = ABC_ALLOC( char, 4 );
1005 pSopCover[0] = ' ';
1006 pSopCover[1] = '0' + (Vec_IntSize(vMints) > 0);
1007 pSopCover[2] = '\n';
1008 pSopCover[3] = 0;
1009 }
1010 else
1011 {
1012 // create the SOP representation of the minterms
1013 Length = Vec_IntSize(vMints) * (nVars + 3);
1014 pSopCover = ABC_ALLOC( char, Length + 1 );
1015 pSopCover[Length] = 0;
1016 Vec_IntForEachEntry( vMints, Mint, i )
1017 {
1018 pCube = pSopCover + i * (nVars + 3);
1019 for ( b = 0; b < nVars; b++ )
1020 // if ( Mint & (1 << (nVars-1-b)) )
1021 if ( Mint & (1 << b) )
1022 pCube[b] = '1';
1023 else
1024 pCube[b] = '0';
1025 pCube[nVars + 0] = ' ';
1026 pCube[nVars + 1] = '1';
1027 pCube[nVars + 2] = '\n';
1028 }
1029 }
1030 Vec_IntFree( vMints );
1031 return pSopCover;
1032}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopFromTruthHex()

char * Abc_SopFromTruthHex ( char * pTruth)

Function*************************************************************

Synopsis [Derives SOP from the truth table representation.]

Description [Truth table is expected to be in the hexadecimal notation.]

SideEffects []

SeeAlso []

Definition at line 1060 of file abcSop.c.

1061{
1062 char * pSopCover, * pCube;
1063 int nTruthSize, nVars, Digit, Length, Mint, i, b;
1064 Vec_Int_t * vMints;
1065
1066 // get the number of variables
1067 nTruthSize = strlen(pTruth);
1068 nVars = (nTruthSize < 2) ? 2 : Abc_Base2Log(nTruthSize) + 2;
1069 if ( nTruthSize != (1 << (nVars-2)) )
1070 {
1071 printf( "String %s does not look like a truth table of a %d-variable function.\n", pTruth, nVars );
1072 return NULL;
1073 }
1074
1075 // collect the on-set minterms
1076 vMints = Vec_IntAlloc( 100 );
1077 for ( i = 0; i < nTruthSize; i++ )
1078 {
1079 if ( pTruth[i] >= '0' && pTruth[i] <= '9' )
1080 Digit = pTruth[i] - '0';
1081 else if ( pTruth[i] >= 'a' && pTruth[i] <= 'f' )
1082 Digit = 10 + pTruth[i] - 'a';
1083 else if ( pTruth[i] >= 'A' && pTruth[i] <= 'F' )
1084 Digit = 10 + pTruth[i] - 'A';
1085 else
1086 {
1087 printf( "String %s does not look like a hexadecimal representation of the truth table.\n", pTruth );
1088 return NULL;
1089 }
1090 for ( b = 0; b < 4; b++ )
1091 if ( Digit & (1 << b) )
1092 Vec_IntPush( vMints, 4*(nTruthSize-1-i)+b );
1093 }
1094
1095 // create the SOP representation of the minterms
1096 if ( Vec_IntSize(vMints) == 0 || Vec_IntSize(vMints) == (1 << nVars) )
1097 {
1098 pSopCover = ABC_ALLOC( char, 4 );
1099 pSopCover[0] = ' ';
1100 pSopCover[1] = '0' + (Vec_IntSize(vMints) > 0);
1101 pSopCover[2] = '\n';
1102 pSopCover[3] = 0;
1103 }
1104 else
1105 {
1106 Length = Vec_IntSize(vMints) * (nVars + 3);
1107 pSopCover = ABC_ALLOC( char, Length + 1 );
1108 pSopCover[Length] = 0;
1109 Vec_IntForEachEntry( vMints, Mint, i )
1110 {
1111 pCube = pSopCover + i * (nVars + 3);
1112 for ( b = 0; b < nVars; b++ )
1113 // if ( Mint & (1 << (nVars-1-b)) )
1114 if ( Mint & (1 << b) )
1115 pCube[b] = '1';
1116 else
1117 pCube[b] = '0';
1118 pCube[nVars + 0] = ' ';
1119 pCube[nVars + 1] = '1';
1120 pCube[nVars + 2] = '\n';
1121 }
1122 }
1123
1124 Vec_IntFree( vMints );
1125 return pSopCover;
1126}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopFromTruthsBin()

Vec_Ptr_t * Abc_SopFromTruthsBin ( char * pTruth)

Definition at line 1033 of file abcSop.c.

1034{
1035 Vec_Ptr_t * vRes = Vec_PtrAlloc( 10 );
1036 char * pCopy = Abc_UtilStrsav(pTruth);
1037 char * pToken = strtok( pCopy, " \r\n\t|" );
1038 while ( pToken )
1039 {
1040 if ( !Abc_SopCheckReadTruth( vRes, pToken, 0 ) )
1041 break;
1042 Vec_PtrPush( vRes, Abc_SopFromTruthBin(pToken) );
1043 pToken = strtok( NULL, " \r\n\t|" );
1044 }
1045 ABC_FREE( pCopy );
1046 return vRes;
1047}
int Abc_SopCheckReadTruth(Vec_Ptr_t *vRes, char *pToken, int fHex)
Definition abcSop.c:926
char * Abc_SopFromTruthBin(char *pTruth)
Definition abcSop.c:964
#define ABC_FREE(obj)
Definition abc_global.h:267
char * strtok()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:

◆ Abc_SopFromTruthsHex()

Vec_Ptr_t * Abc_SopFromTruthsHex ( char * pTruth)

Definition at line 1127 of file abcSop.c.

1128{
1129 Vec_Ptr_t * vRes = Vec_PtrAlloc( 10 );
1130 char * pCopy = Abc_UtilStrsav(pTruth);
1131 char * pToken = strtok( pCopy, " \r\n\t|" );
1132 while ( pToken )
1133 {
1134 if ( pToken[0] == '0' && pToken[1] == 'x' )
1135 pToken += 2;
1136 if ( !Abc_SopCheckReadTruth( vRes, pToken, 1 ) )
1137 break;
1138 Vec_PtrPush( vRes, Abc_SopFromTruthHex(pToken) );
1139 pToken = strtok( NULL, " \r\n\t|" );
1140 }
1141 ABC_FREE( pCopy );
1142 return vRes;
1143}
char * Abc_SopFromTruthHex(char *pTruth)
Definition abcSop.c:1060
Here is the call graph for this function:

◆ Abc_SopGenerateCounters()

Vec_Ptr_t * Abc_SopGenerateCounters ( int nVars)

Definition at line 1145 of file abcSop.c.

1146{
1147 int m, i, o, nOuts = Abc_Base2Log( nVars + 1 );
1148 Vec_Ptr_t * vRes = Vec_PtrAlloc( nOuts );
1149 for ( o = 0; o < nOuts; o++ )
1150 {
1151 Vec_Str_t * vStr = Vec_StrAlloc( 1000 );
1152 for ( m = 0; m < (1 << nVars); m++ ) {
1153 int nOnes = __builtin_popcount(m);
1154 if ( !((nOnes >> o) & 1) )
1155 continue;
1156 for ( i = 0; i < nVars; i++ )
1157 Vec_StrPush( vStr, ((m >> i) & 1) ? '1' : '0' );
1158 Vec_StrPush( vStr, ' ' );
1159 Vec_StrPush( vStr, '1' );
1160 Vec_StrPush( vStr, '\n' );
1161 }
1162 Vec_StrPush( vStr, '\0' );
1163 //printf( "%s\n", Vec_StrArray(vStr) );
1164 Vec_PtrPush( vRes, Vec_StrReleaseArray(vStr) );
1165 Vec_StrFree( vStr );
1166 }
1167 return vRes;
1168}

◆ Abc_SopGetCubeNum()

int Abc_SopGetCubeNum ( char * pSop)

Function*************************************************************

Synopsis [Reads the number of cubes in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 537 of file abcSop.c.

538{
539 char * pCur;
540 int nCubes = 0;
541 if ( pSop == NULL )
542 return 0;
543 for ( pCur = pSop; *pCur; pCur++ )
544 nCubes += (*pCur == '\n');
545 return nCubes;
546}
Here is the caller graph for this function:

◆ Abc_SopGetIthCareLit()

int Abc_SopGetIthCareLit ( char * pSop,
int i )

Function*************************************************************

Synopsis [Returns the i-th literal of the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 626 of file abcSop.c.

627{
628 char * pCube;
629 int nVars;
630 nVars = Abc_SopGetVarNum( pSop );
631 Abc_SopForEachCube( pSop, nVars, pCube )
632 if ( pCube[i] != '-' )
633 return pCube[i] - '0';
634 return -1;
635}
Here is the call graph for this function:

◆ Abc_SopGetLitNum()

int Abc_SopGetLitNum ( char * pSop)

Function*************************************************************

Synopsis [Reads the number of SOP literals in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 559 of file abcSop.c.

560{
561 char * pCur;
562 int nLits = 0;
563 if ( pSop == NULL )
564 return 0;
565 for ( pCur = pSop; *pCur; pCur++ )
566 {
567 nLits -= (*pCur == '\n');
568 nLits += (*pCur == '0' || *pCur == '1');
569 }
570 return nLits;
571}
Here is the caller graph for this function:

◆ Abc_SopGetPhase()

int Abc_SopGetPhase ( char * pSop)

Function*************************************************************

Synopsis [Reads the phase of the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 604 of file abcSop.c.

605{
606 int nVars = Abc_SopGetVarNum( pSop );
607 if ( pSop[nVars+1] == '0' || pSop[nVars+1] == 'n' )
608 return 0;
609 if ( pSop[nVars+1] == '1' || pSop[nVars+1] == 'x' )
610 return 1;
611 assert( 0 );
612 return -1;
613}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopGetVarNum()

int Abc_SopGetVarNum ( char * pSop)

Function*************************************************************

Synopsis [Reads the number of variables in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 584 of file abcSop.c.

585{
586 char * pCur;
587 for ( pCur = pSop; *pCur != '\n'; pCur++ )
588 if ( *pCur == 0 )
589 return -1;
590 return pCur - pSop - 2;
591}
Here is the caller graph for this function:

◆ Abc_SopIsAndType()

int Abc_SopIsAndType ( char * pSop)

Function*************************************************************

Synopsis [Checks if the cover is AND with possibly complemented inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 796 of file abcSop.c.

797{
798 char * pCur;
799 if ( Abc_SopGetCubeNum(pSop) != 1 )
800 return 0;
801 for ( pCur = pSop; *pCur != ' '; pCur++ )
802 if ( *pCur == '-' )
803 return 0;
804 if ( pCur[1] != '1' )
805 return 0;
806 return 1;
807}
int Abc_SopGetCubeNum(char *pSop)
Definition abcSop.c:537
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopIsBuf()

int Abc_SopIsBuf ( char * pSop)

Function*************************************************************

Synopsis [Checks if the cover is constant 1.]

Description []

SideEffects []

SeeAlso []

Definition at line 756 of file abcSop.c.

757{
758 if ( pSop[4] != 0 )
759 return 0;
760 if ( (pSop[0] == '1' && pSop[2] == '1') || (pSop[0] == '0' && pSop[2] == '0') )
761 return 1;
762 return 0;
763}
Here is the caller graph for this function:

◆ Abc_SopIsComplement()

int Abc_SopIsComplement ( char * pSop)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 703 of file abcSop.c.

704{
705 char * pCur;
706 for ( pCur = pSop; *pCur; pCur++ )
707 if ( *pCur == '\n' )
708 return (int)(*(pCur - 1) == '0' || *(pCur - 1) == 'n');
709 assert( 0 );
710 return 0;
711}
Here is the caller graph for this function:

◆ Abc_SopIsConst0()

int Abc_SopIsConst0 ( char * pSop)

Function*************************************************************

Synopsis [Checks if the cover is constant 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 724 of file abcSop.c.

725{
726 return pSop[0] == ' ' && pSop[1] == '0';
727}
Here is the caller graph for this function:

◆ Abc_SopIsConst1()

int Abc_SopIsConst1 ( char * pSop)

Function*************************************************************

Synopsis [Checks if the cover is constant 1.]

Description []

SideEffects []

SeeAlso []

Definition at line 740 of file abcSop.c.

741{
742 return pSop[0] == ' ' && pSop[1] == '1';
743}
Here is the caller graph for this function:

◆ Abc_SopIsExorType()

int Abc_SopIsExorType ( char * pSop)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 850 of file abcSop.c.

851{
852 char * pCur;
853 for ( pCur = pSop; *pCur; pCur++ )
854 if ( *pCur == '\n' )
855 return (int)(*(pCur - 1) == 'x' || *(pCur - 1) == 'n');
856 assert( 0 );
857 return 0;
858}
Here is the caller graph for this function:

◆ Abc_SopIsInv()

int Abc_SopIsInv ( char * pSop)

Function*************************************************************

Synopsis [Checks if the cover is constant 1.]

Description []

SideEffects []

SeeAlso []

Definition at line 776 of file abcSop.c.

777{
778 if ( pSop[4] != 0 )
779 return 0;
780 if ( (pSop[0] == '0' && pSop[2] == '1') || (pSop[0] == '1' && pSop[2] == '0') )
781 return 1;
782 return 0;
783}
Here is the caller graph for this function:

◆ Abc_SopIsOrType()

int Abc_SopIsOrType ( char * pSop)

Function*************************************************************

Synopsis [Checks if the cover is OR with possibly complemented inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 820 of file abcSop.c.

821{
822 char * pCube, * pCur;
823 int nVars, nLits;
824 nVars = Abc_SopGetVarNum( pSop );
825 if ( nVars != Abc_SopGetCubeNum(pSop) )
826 return 0;
827 Abc_SopForEachCube( pSop, nVars, pCube )
828 {
829 // count the number of literals in the cube
830 nLits = 0;
831 for ( pCur = pCube; *pCur != ' '; pCur++ )
832 nLits += ( *pCur != '-' );
833 if ( nLits != 1 )
834 return 0;
835 }
836 return 1;
837}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopRegister()

ABC_NAMESPACE_IMPL_START char * Abc_SopRegister ( Mem_Flex_t * pMan,
const char * pName )

DECLARATIONS ///.

CFile****************************************************************

FileName [abcSop.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Implementation of a simple SOP representation of nodes.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
abcSop.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Registers the cube string with the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file abcSop.c.

63{
64 char * pRegName;
65 if ( pName == NULL ) return NULL;
66 pRegName = Mem_FlexEntryFetch( pMan, strlen(pName) + 1 );
67 strcpy( pRegName, pName );
68 return pRegName;
69}
char * Mem_FlexEntryFetch(Mem_Flex_t *p, int nBytes)
Definition mem.c:388
char * strcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopStart()

char * Abc_SopStart ( Mem_Flex_t * pMan,
int nCubes,
int nVars )

Function*************************************************************

Synopsis [Creates the constant 1 cover with the given number of variables and cubes.]

Description []

SideEffects []

SeeAlso []

Definition at line 82 of file abcSop.c.

83{
84 char * pSopCover, * pCube;
85 int i, Length;
86
87 Length = nCubes * (nVars + 3);
88 pSopCover = Mem_FlexEntryFetch( pMan, Length + 1 );
89 memset( pSopCover, '-', (size_t)Length );
90 pSopCover[Length] = 0;
91
92 for ( i = 0; i < nCubes; i++ )
93 {
94 pCube = pSopCover + i * (nVars + 3);
95 pCube[nVars + 0] = ' ';
96 pCube[nVars + 1] = '1';
97 pCube[nVars + 2] = '\n';
98 }
99 return pSopCover;
100}
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopToIsop()

void Abc_SopToIsop ( char * pSop,
Vec_Int_t * vCover )

Function*************************************************************

Synopsis [Creates the cover from the ISOP computed from TT.]

Description []

SideEffects []

SeeAlso []

Definition at line 502 of file abcSop.c.

503{
504 char * pCube;
505 int k, nVars, Entry;
506 nVars = Abc_SopGetVarNum( pSop );
507 assert( nVars > 0 );
508 // create cubes
509 Vec_IntClear( vCover );
510 for ( pCube = pSop; *pCube; pCube += nVars + 3 )
511 {
512 Entry = 0;
513 for ( k = nVars - 1; k >= 0; k-- )
514 if ( pCube[k] == '0' )
515 Entry = (Entry << 2) | 1;
516 else if ( pCube[k] == '1' )
517 Entry = (Entry << 2) | 2;
518 else if ( pCube[k] == '-' )
519 Entry = (Entry << 2);
520 else
521 assert( 0 );
522 Vec_IntPush( vCover, Entry );
523 }
524}
Here is the call graph for this function:

◆ Abc_SopToTruth()

word Abc_SopToTruth ( char * pSop,
int nInputs )

Function*************************************************************

Synopsis [Computes truth table of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 1314 of file abcSop.c.

1315{
1316 static word Truth[8] = {
1317 ABC_CONST(0xAAAAAAAAAAAAAAAA),
1318 ABC_CONST(0xCCCCCCCCCCCCCCCC),
1319 ABC_CONST(0xF0F0F0F0F0F0F0F0),
1320 ABC_CONST(0xFF00FF00FF00FF00),
1321 ABC_CONST(0xFFFF0000FFFF0000),
1322 ABC_CONST(0xFFFFFFFF00000000),
1323 ABC_CONST(0x0000000000000000),
1324 ABC_CONST(0xFFFFFFFFFFFFFFFF)
1325 };
1326 word Cube, Result = 0;
1327 int v, lit = 0;
1328 int nVars = Abc_SopGetVarNum(pSop);
1329 assert( nVars >= 0 && nVars <= 6 );
1330 assert( nVars == nInputs );
1331 do {
1332 Cube = Truth[7];
1333 for ( v = 0; v < nVars; v++, lit++ )
1334 {
1335 if ( pSop[lit] == '1' )
1336 Cube &= Truth[v];
1337 else if ( pSop[lit] == '0' )
1338 Cube &= ~Truth[v];
1339 else if ( pSop[lit] != '-' )
1340 assert( 0 );
1341 }
1342 Result |= Cube;
1343 assert( pSop[lit] == ' ' );
1344 lit++;
1345 lit++;
1346 assert( pSop[lit] == '\n' );
1347 lit++;
1348 } while ( pSop[lit] );
1349 if ( Abc_SopIsComplement(pSop) )
1350 Result = ~Result;
1351 return Result;
1352}
int Abc_SopIsComplement(char *pSop)
Definition abcSop.c:703
#define ABC_CONST(number)
PARAMETERS ///.
Definition abc_global.h:240
struct cube Cube
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int lit
Definition satVec.h:130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopToTruth7()

void Abc_SopToTruth7 ( char * pSop,
int nInputs,
word r[2] )

Function*************************************************************

Synopsis [Computes truth table of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 1365 of file abcSop.c.

1366{
1367 static word Truth[7][2] = {
1368 {ABC_CONST(0xAAAAAAAAAAAAAAAA),ABC_CONST(0xAAAAAAAAAAAAAAAA)},
1369 {ABC_CONST(0xCCCCCCCCCCCCCCCC),ABC_CONST(0xCCCCCCCCCCCCCCCC)},
1370 {ABC_CONST(0xF0F0F0F0F0F0F0F0),ABC_CONST(0xF0F0F0F0F0F0F0F0)},
1371 {ABC_CONST(0xFF00FF00FF00FF00),ABC_CONST(0xFF00FF00FF00FF00)},
1372 {ABC_CONST(0xFFFF0000FFFF0000),ABC_CONST(0xFFFF0000FFFF0000)},
1373 {ABC_CONST(0xFFFFFFFF00000000),ABC_CONST(0xFFFFFFFF00000000)},
1374 {ABC_CONST(0x0000000000000000),ABC_CONST(0xFFFFFFFFFFFFFFFF)},
1375 };
1376 word Cube[2];
1377 int v, lit = 0;
1378 int nVars = Abc_SopGetVarNum(pSop);
1379 assert( nVars >= 0 && nVars <= 7 );
1380 assert( nVars == nInputs );
1381 r[0] = r[1] = 0;
1382 do {
1383 Cube[0] = Cube[1] = ~(word)0;
1384 for ( v = 0; v < nVars; v++, lit++ )
1385 {
1386 if ( pSop[lit] == '1' )
1387 {
1388 Cube[0] &= Truth[v][0];
1389 Cube[1] &= Truth[v][1];
1390 }
1391 else if ( pSop[lit] == '0' )
1392 {
1393 Cube[0] &= ~Truth[v][0];
1394 Cube[1] &= ~Truth[v][1];
1395 }
1396 else if ( pSop[lit] != '-' )
1397 assert( 0 );
1398 }
1399 r[0] |= Cube[0];
1400 r[1] |= Cube[1];
1401 assert( pSop[lit] == ' ' );
1402 lit++;
1403 lit++;
1404 assert( pSop[lit] == '\n' );
1405 lit++;
1406 } while ( pSop[lit] );
1407 if ( Abc_SopIsComplement(pSop) )
1408 {
1409 r[0] = ~r[0];
1410 r[1] = ~r[1];
1411 }
1412}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SopToTruthBig()

void Abc_SopToTruthBig ( char * pSop,
int nInputs,
word ** pVars,
word * pCube,
word * pRes )

Function*************************************************************

Synopsis [Computes truth table of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 1425 of file abcSop.c.

1426{
1427 int nVars = Abc_SopGetVarNum(pSop);
1428 int nWords = nVars <= 6 ? 1 : 1 << (nVars-6);
1429 int v, i, lit = 0;
1430 assert( nVars >= 0 && nVars <= 16 );
1431 assert( nVars == nInputs );
1432 for ( i = 0; i < nWords; i++ )
1433 pRes[i] = 0;
1434 do {
1435 for ( i = 0; i < nWords; i++ )
1436 pCube[i] = ~(word)0;
1437 for ( v = 0; v < nVars; v++, lit++ )
1438 {
1439 if ( pSop[lit] == '1' )
1440 {
1441 for ( i = 0; i < nWords; i++ )
1442 pCube[i] &= pVars[v][i];
1443 }
1444 else if ( pSop[lit] == '0' )
1445 {
1446 for ( i = 0; i < nWords; i++ )
1447 pCube[i] &= ~pVars[v][i];
1448 }
1449 else if ( pSop[lit] != '-' )
1450 assert( 0 );
1451 }
1452 for ( i = 0; i < nWords; i++ )
1453 pRes[i] |= pCube[i];
1454 assert( pSop[lit] == ' ' );
1455 lit++;
1456 lit++;
1457 assert( pSop[lit] == '\n' );
1458 lit++;
1459 } while ( pSop[lit] );
1460 if ( Abc_SopIsComplement(pSop) )
1461 {
1462 for ( i = 0; i < nWords; i++ )
1463 pRes[i] = ~pRes[i];
1464 }
1465}
Here is the call graph for this function:
Here is the caller graph for this function: