Commit 6d606b51 by Alan Mishchenko

Updates to arithmetic verification.

parent 1a39fb39
......@@ -52,7 +52,7 @@ void Gia_ShowPath( Gia_Man_t * p, char * pFileName )
Gia_Obj_t * pNode;
Vec_Bit_t * vPath = Vec_BitStart( Gia_ManObjNum(p) );
int i, k, iFan, LevelMax, nLevels, * pLevels, Level, Prev;
int nLuts = 0, nNodes = 0, nEdges = 0, nEdgesAll = 0;
int nLuts = 0, nNodes = 0, nEdges = 0;
assert( Gia_ManHasMapping(p) );
// set critical CO drivers
......@@ -670,7 +670,7 @@ int Gia_ShowAddOut( Vec_Int_t * vAdds, Vec_Int_t * vMapAdds, int Node )
return Vec_IntEntry( vAdds, 6*iBox+4 );
return Node;
}
void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_Int_t * vXors, Vec_Int_t * vMapAdds, Vec_Int_t * vMapXors, Vec_Int_t * vOrder )
void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vBold, Vec_Int_t * vAdds, Vec_Int_t * vXors, Vec_Int_t * vMapAdds, Vec_Int_t * vMapXors, Vec_Int_t * vOrder )
{
FILE * pFile;
Gia_Obj_t * pNode;//, * pTemp, * pPrev;
......@@ -689,6 +689,11 @@ void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_In
return;
}
// mark the nodes
if ( vBold )
Gia_ManForEachObjVec( vBold, p, pNode, i )
pNode->fMark0 = 1;
// compute levels
LevelMax = 1 + p->nLevels;
Gia_ManForEachCo( p, pNode, i )
......@@ -819,7 +824,7 @@ void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_In
else
fprintf( pFile, ", shape = ellipse" );
*/
if ( Vec_IntEntry(vMapAdds, iNode) >= 0 )
if ( !pNode->fMark0 && Vec_IntEntry(vMapAdds, iNode) >= 0 )
{
int iBox = Vec_IntEntry(vMapAdds, iNode);
fprintf( pFile, " Node%d [label = \"%d_%d\"", Gia_ShowAddOut(vAdds, vMapAdds, iNode), Vec_IntEntry(vAdds, 6*iBox+3), Vec_IntEntry(vAdds, 6*iBox+4) );
......@@ -848,8 +853,8 @@ void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_In
fprintf( pFile, " Node%d [label = \"%d\"", iNode, iNode );
fprintf( pFile, ", shape = ellipse" );
}
// if ( pNode->fMark0 )
// fprintf( pFile, ", style = filled" );
if ( pNode->fMark0 )
fprintf( pFile, ", style = filled" );
fprintf( pFile, "];\n" );
}
fprintf( pFile, "}" );
......@@ -920,8 +925,6 @@ void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_In
Gia_ManForEachObjVec( vOrder, p, pNode, i )
{
int iNode = Gia_ObjId( p, pNode );
// if ( !Gia_ObjIsAnd(pNode) && !Gia_ObjIsCo(pNode) && !Gia_ObjIsBuf(pNode) )
// continue;
if ( Vec_IntEntry(vMapAdds, Gia_ObjId(p, pNode)) >= 0 )
{
int k, iBox = Vec_IntEntry(vMapAdds, iNode);
......@@ -990,6 +993,11 @@ void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_In
fprintf( pFile, "\n" );
fclose( pFile );
// unmark nodes
if ( vBold )
Gia_ManForEachObjVec( vBold, p, pNode, i )
pNode->fMark0 = 0;
Vec_IntFreeP( &p->vLevels );
}
......@@ -1093,12 +1101,12 @@ Vec_Int_t * Gia_ShowCollectObjs( Gia_Man_t * p, Vec_Int_t * vAdds, Vec_Int_t * v
SeeAlso []
***********************************************************************/
void Gia_ShowProcess( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_Int_t * vXors, int fFadds )
void Gia_ShowProcess( Gia_Man_t * p, char * pFileName, Vec_Int_t * vBold, Vec_Int_t * vAdds, Vec_Int_t * vXors, int fFadds )
{
Vec_Int_t * vMapAdds = Gia_ShowMapAdds( p, vAdds, fFadds );
Vec_Int_t * vMapXors = Gia_ShowMapXors( p, vXors );
Vec_Int_t * vOrder = Gia_ShowCollectObjs( p, vAdds, vXors, vMapAdds, vMapXors );
Gia_WriteDotAig( p, pFileName, vAdds, vXors, vMapAdds, vMapXors, vOrder );
Gia_WriteDotAig( p, pFileName, vBold, vAdds, vXors, vMapAdds, vMapXors, vOrder );
Vec_IntFree( vMapAdds );
Vec_IntFree( vMapXors );
Vec_IntFree( vOrder );
......@@ -1121,7 +1129,7 @@ void Gia_ManShow( Gia_Man_t * pMan, Vec_Int_t * vBold, int fAdders, int fFadds,
if ( fPath )
Gia_ShowPath( pMan, FileNameDot );
else if ( fAdders )
Gia_ShowProcess( pMan, FileNameDot, vAdds, vXors, fFadds );
Gia_ShowProcess( pMan, FileNameDot, vBold, vAdds, vXors, fFadds );
else
Gia_WriteDotAigSimple( pMan, FileNameDot, vBold );
// visualize the file
......
......@@ -645,12 +645,22 @@ void Wlc_IntInsert( Vec_Int_t * vProd, Vec_Int_t * vLevel, int Node, int Level )
}
void Wlc_BlastPrintMatrix( Gia_Man_t * p, Vec_Wec_t * vProds )
{
int fVerbose = 0;
Vec_Int_t * vSupp = Vec_IntAlloc( 100 );
Vec_Wrd_t * vTemp = Vec_WrdStart( Gia_ManObjNum(p) );
Vec_Int_t * vLevel; word Truth;
int i, k, iLit;
Vec_WecForEachLevel( vProds, vLevel, i )
Vec_IntForEachEntry( vLevel, iLit, k )
if ( Gia_ObjIsAnd(Gia_ManObj(p, Abc_Lit2Var(iLit))) )
Vec_IntPushUnique( vSupp, Abc_Lit2Var(iLit) );
printf( "Booth partial products: %d pps, %d unique, %d nodes.\n",
Vec_WecSizeSize(vProds), Vec_IntSize(vSupp), Gia_ManAndNum(p) );
Vec_IntPrint( vSupp );
if ( fVerbose )
Vec_WecForEachLevel( vProds, vLevel, i )
Vec_IntForEachEntry( vLevel, iLit, k )
{
printf( "Obj = %4d : ", Abc_Lit2Var(iLit) );
printf( "Compl = %d ", Abc_LitIsCompl(iLit) );
......
......@@ -42,13 +42,10 @@ struct Acec_Box_t_
{
Gia_Man_t * pGia; // AIG manager
Vec_Wec_t * vAdds; // adders by rank
Vec_Wec_t * vLeafs; // leaf literals by rank
Vec_Wec_t * vRoots; // root literals by rank
Vec_Wec_t * vLeafLits; // leaf literals by rank
Vec_Wec_t * vRootLits; // root literals by rank
Vec_Wec_t * vShared; // shared leaves
Vec_Wec_t * vUnique; // unique leaves
Vec_Bit_t * vInvHadds; // complemented half adders
};
////////////////////////////////////////////////////////////////////////
......
......@@ -20,6 +20,7 @@
#include "acecInt.h"
#include "misc/extra/extra.h"
#include "misc/util/utilTruth.h"
ABC_NAMESPACE_IMPL_START
......@@ -400,6 +401,15 @@ Vec_Int_t * Acec_MultDetectInputs( Gia_Man_t * p, Vec_Wec_t * vLeafLits, Vec_Wec
if ( Vec_IntSize(vSupp) <= 2 ) printf( " " );
printf( " " );
Vec_IntPrint( vSupp );
/*
if ( Truth == 0xF335ACC0F335ACC0 )
{
int iObj = Abc_Lit2Var(iLit);
Gia_Man_t * pGia0 = Gia_ManDupAndCones( p, &iObj, 1, 1 );
Gia_ManShow( pGia0, NULL, 0, 0, 0 );
Gia_ManStop( pGia0 );
}
*/
}
// support rank counts
Vec_IntForEachEntry( vSupp, Entry, j )
......@@ -423,6 +433,103 @@ Vec_Int_t * Acec_MultDetectInputs( Gia_Man_t * p, Vec_Wec_t * vLeafLits, Vec_Wec
return vInputs;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Acec_MultFindPPs_rec( Gia_Man_t * p, int iObj, Vec_Int_t * vBold )
{
Gia_Obj_t * pObj;
pObj = Gia_ManObj( p, iObj );
if ( pObj->fMark0 )
return;
pObj->fMark0 = 1;
if ( !Gia_ObjIsAnd(pObj) )
return;
Acec_MultFindPPs_rec( p, Gia_ObjFaninId0(pObj, iObj), vBold );
Acec_MultFindPPs_rec( p, Gia_ObjFaninId1(pObj, iObj), vBold );
Vec_IntPush( vBold, iObj );
}
Vec_Int_t * Acec_MultFindPPs( Gia_Man_t * p )
{
word Saved[32] = {
ABC_CONST(0xF335ACC0F335ACC0),
ABC_CONST(0x35C035C035C035C0),
ABC_CONST(0xD728D728D728D728),
ABC_CONST(0xFD80FD80FD80FD80),
ABC_CONST(0xACC0ACC0ACC0ACC0),
ABC_CONST(0x7878787878787878),
ABC_CONST(0x2828282828282828),
ABC_CONST(0xD0D0D0D0D0D0D0D0),
ABC_CONST(0x8080808080808080),
ABC_CONST(0x8888888888888888),
ABC_CONST(0xAAAAAAAAAAAAAAAA),
ABC_CONST(0x5555555555555555),
ABC_CONST(0xD5A8D5A8D5A8D5A8),
ABC_CONST(0x2A572A572A572A57),
ABC_CONST(0xF3C0F3C0F3C0F3C0),
ABC_CONST(0x5858585858585858),
ABC_CONST(0xA7A7A7A7A7A7A7A7),
ABC_CONST(0x2727272727272727),
ABC_CONST(0xD8D8D8D8D8D8D8D8)
};
Vec_Int_t * vBold = Vec_IntAlloc( 100 );
Vec_Int_t * vSupp = Vec_IntAlloc( 100 );
Vec_Wrd_t * vTemp = Vec_WrdStart( Gia_ManObjNum(p) );
int i, iObj, nProds = 0;
Gia_ManCleanMark0(p);
Gia_ManForEachAndId( p, iObj )
{
word Truth = Gia_ObjComputeTruth6Cis( p, Abc_Var2Lit(iObj, 0), vSupp, vTemp );
vSupp->nSize = Abc_Tt6MinBase( &Truth, vSupp->pArray, vSupp->nSize );
if ( Vec_IntSize(vSupp) > 5 )
continue;
for ( i = 0; i < 32; i++ )
{
if ( Saved[i] == 0 )
break;
if ( Truth == Saved[i] || Truth == ~Saved[i] )
{
//Vec_IntPush( vBold, iObj );
Acec_MultFindPPs_rec( p, iObj, vBold );
printf( "%d ", iObj );
nProds++;
break;
}
}
/*
Extra_PrintHex( stdout, (unsigned*)&Truth, Vec_IntSize(vSupp) );
if ( Vec_IntSize(vSupp) == 4 ) printf( " " );
if ( Vec_IntSize(vSupp) == 3 ) printf( " " );
if ( Vec_IntSize(vSupp) <= 2 ) printf( " " );
printf( " " );
Vec_IntPrint( vSupp );
*/
}
printf( "\n" );
Gia_ManCleanMark0(p);
printf( "Collected %d pps and %d nodes.\n", nProds, Vec_IntSize(vBold) );
Vec_IntFree( vSupp );
Vec_WrdFree( vTemp );
return vBold;
}
void Acec_MultFindPPsTest( Gia_Man_t * p )
{
Vec_Int_t * vBold = Acec_MultFindPPs( p );
Gia_ManShow( p, vBold, 1, 0, 0 );
Vec_IntFree( vBold );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
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