Commit 21b847a8 by Alan Mishchenko

Updating truth table computation for GIA to work for internal nodes as well.

parent ff0ec52d
...@@ -945,7 +945,7 @@ extern Vec_Int_t * Gia_VtaConvertToGla( Gia_Man_t * p, Vec_Int_t * vVta ...@@ -945,7 +945,7 @@ extern Vec_Int_t * Gia_VtaConvertToGla( Gia_Man_t * p, Vec_Int_t * vVta
extern Vec_Int_t * Gia_VtaConvertFromGla( Gia_Man_t * p, Vec_Int_t * vGla, int nFrames ); extern Vec_Int_t * Gia_VtaConvertFromGla( Gia_Man_t * p, Vec_Int_t * vGla, int nFrames );
extern Vec_Int_t * Gia_FlaConvertToGla( Gia_Man_t * p, Vec_Int_t * vFla ); extern Vec_Int_t * Gia_FlaConvertToGla( Gia_Man_t * p, Vec_Int_t * vFla );
extern Vec_Int_t * Gia_GlaConvertToFla( Gia_Man_t * p, Vec_Int_t * vGla ); extern Vec_Int_t * Gia_GlaConvertToFla( Gia_Man_t * p, Vec_Int_t * vGla );
extern unsigned * Gia_ManComputePoTt( Gia_Man_t * p, Gia_Obj_t * pObj ); extern unsigned * Gia_ObjComputeTruthTable( Gia_Man_t * p, Gia_Obj_t * pObj );
/*=== giaCTas.c ===========================================================*/ /*=== giaCTas.c ===========================================================*/
typedef struct Tas_Man_t_ Tas_Man_t; typedef struct Tas_Man_t_ Tas_Man_t;
......
...@@ -1510,15 +1510,15 @@ unsigned * Gia_ManComputePoTruthTables( Gia_Man_t * p, int nBytesMax ) ...@@ -1510,15 +1510,15 @@ unsigned * Gia_ManComputePoTruthTables( Gia_Man_t * p, int nBytesMax )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Gia_ManComputePoTt_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) int Gia_ObjComputeTruthTable_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
{ {
word * pTruth0, * pTruth1, * pTruth, * pTruthL; word * pTruth0, * pTruth1, * pTruth, * pTruthL;
if ( Gia_ObjIsTravIdCurrent(p, pObj) ) if ( Gia_ObjIsTravIdCurrent(p, pObj) )
return pObj->Value; return pObj->Value;
Gia_ObjSetTravIdCurrent(p, pObj); Gia_ObjSetTravIdCurrent(p, pObj);
assert( Gia_ObjIsAnd(pObj) ); assert( Gia_ObjIsAnd(pObj) );
pTruth0 = Vec_WrdArray(p->vTtMemory) + p->nTtWords * Gia_ManComputePoTt_rec( p, Gia_ObjFanin0(pObj) ); pTruth0 = Vec_WrdArray(p->vTtMemory) + p->nTtWords * Gia_ObjComputeTruthTable_rec( p, Gia_ObjFanin0(pObj) );
pTruth1 = Vec_WrdArray(p->vTtMemory) + p->nTtWords * Gia_ManComputePoTt_rec( p, Gia_ObjFanin1(pObj) ); pTruth1 = Vec_WrdArray(p->vTtMemory) + p->nTtWords * Gia_ObjComputeTruthTable_rec( p, Gia_ObjFanin1(pObj) );
assert( p->nTtWords * p->iTtNum < Vec_WrdSize(p->vTtMemory) ); assert( p->nTtWords * p->iTtNum < Vec_WrdSize(p->vTtMemory) );
pTruth = Vec_WrdArray(p->vTtMemory) + p->nTtWords * p->iTtNum++; pTruth = Vec_WrdArray(p->vTtMemory) + p->nTtWords * p->iTtNum++;
pTruthL = Vec_WrdArray(p->vTtMemory) + p->nTtWords * p->iTtNum; pTruthL = Vec_WrdArray(p->vTtMemory) + p->nTtWords * p->iTtNum;
...@@ -1542,13 +1542,12 @@ int Gia_ManComputePoTt_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) ...@@ -1542,13 +1542,12 @@ int Gia_ManComputePoTt_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
} }
return p->iTtNum-1; return p->iTtNum-1;
} }
unsigned * Gia_ManComputePoTt( Gia_Man_t * p, Gia_Obj_t * pObj ) unsigned * Gia_ObjComputeTruthTable( Gia_Man_t * p, Gia_Obj_t * pObj )
{ {
Gia_Obj_t * pTemp; Gia_Obj_t * pTemp;
word * pTruth; word * pTruth;
int i, k; int i, k;
// this procedure works only for primary outputs // this procedure works only for primary outputs
assert( Gia_ObjIsCo(pObj) );
if ( p->vTtMemory == NULL ) if ( p->vTtMemory == NULL )
{ {
word Truth6[7] = { word Truth6[7] = {
...@@ -1584,16 +1583,21 @@ unsigned * Gia_ManComputePoTt( Gia_Man_t * p, Gia_Obj_t * pObj ) ...@@ -1584,16 +1583,21 @@ unsigned * Gia_ManComputePoTt( Gia_Man_t * p, Gia_Obj_t * pObj )
} }
p->iTtNum = 7; p->iTtNum = 7;
// compute truth table for the fanin node // compute truth table for the fanin node
pTruth = Vec_WrdArray(p->vTtMemory) + p->nTtWords * Gia_ManComputePoTt_rec(p, Gia_ObjFanin0(pObj)); if ( Gia_ObjIsCo(pObj) )
// complement if needed
if ( Gia_ObjFaninC0(pObj) )
{ {
word * pTemp = pTruth; pTruth = Vec_WrdArray(p->vTtMemory) + p->nTtWords * Gia_ObjComputeTruthTable_rec(p, Gia_ObjFanin0(pObj));
assert( p->nTtWords * p->iTtNum < Vec_WrdSize(p->vTtMemory) ); // complement if needed
pTruth = Vec_WrdArray(p->vTtMemory) + p->nTtWords * p->iTtNum; if ( Gia_ObjFaninC0(pObj) )
for ( k = 0; k < p->nTtWords; k++ ) {
pTruth[k] = ~pTemp[k]; word * pTemp = pTruth;
assert( p->nTtWords * p->iTtNum < Vec_WrdSize(p->vTtMemory) );
pTruth = Vec_WrdArray(p->vTtMemory) + p->nTtWords * p->iTtNum;
for ( k = 0; k < p->nTtWords; k++ )
pTruth[k] = ~pTemp[k];
}
} }
else
pTruth = Vec_WrdArray(p->vTtMemory) + p->nTtWords * Gia_ObjComputeTruthTable_rec(p, pObj);
return (unsigned *)pTruth; return (unsigned *)pTruth;
} }
...@@ -1608,7 +1612,7 @@ unsigned * Gia_ManComputePoTt( Gia_Man_t * p, Gia_Obj_t * pObj ) ...@@ -1608,7 +1612,7 @@ unsigned * Gia_ManComputePoTt( Gia_Man_t * p, Gia_Obj_t * pObj )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Gia_ManComputePoTtTest( Gia_Man_t * p ) void Gia_ObjComputeTruthTableTest( Gia_Man_t * p )
{ {
Gia_Obj_t * pObj; Gia_Obj_t * pObj;
unsigned * pTruth; unsigned * pTruth;
...@@ -1616,7 +1620,7 @@ void Gia_ManComputePoTtTest( Gia_Man_t * p ) ...@@ -1616,7 +1620,7 @@ void Gia_ManComputePoTtTest( Gia_Man_t * p )
int i; int i;
Gia_ManForEachPo( p, pObj, i ) Gia_ManForEachPo( p, pObj, i )
{ {
pTruth = Gia_ManComputePoTt( p, pObj ); pTruth = Gia_ObjComputeTruthTable( p, pObj );
// Extra_PrintHex( stdout, pTruth, Gia_ManPiNum(p) ); printf( "\n" ); // Extra_PrintHex( stdout, pTruth, Gia_ManPiNum(p) ); printf( "\n" );
} }
Abc_PrintTime( 1, "Time", clock() - clk ); Abc_PrintTime( 1, "Time", clock() - clk );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment