Version abc60916

This commit is contained in:
Alan Mishchenko 2006-09-16 08:01:00 -07:00
parent aab0c478e4
commit 370578bf1c
38 changed files with 5351 additions and 73 deletions

26
abc.dsp
View File

@ -1006,7 +1006,7 @@ SOURCE=.\src\sat\msat\msatMem.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatOrderJ.c
SOURCE=.\src\sat\msat\msatOrderH.c
# End Source File
# Begin Source File
@ -1762,6 +1762,10 @@ SOURCE=.\src\misc\vec\vec.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecFlt.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecInt.h
# End Source File
# Begin Source File
@ -2054,6 +2058,10 @@ SOURCE=.\src\temp\ivy\ivyFastMap.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\ivyFraig.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\ivyHaig.c
# End Source File
# Begin Source File
@ -2104,6 +2112,22 @@ SOURCE=.\src\temp\ivy\ivyTable.c
SOURCE=.\src\temp\ivy\ivyUtil.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\satSolver.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\satSolver.h
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\satUtil.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\satVec.h
# End Source File
# End Group
# Begin Group "player"

8
abc.rc
View File

@ -2,8 +2,8 @@
#set check # checks intermediate networks
#set checkfio # prints warnings when fanins/fanouts are duplicated
#set checkread # checks new networks after reading from file
set backup # saves backup networks retrived by "undo" and "recall"
set savesteps 1 # sets the maximum number of backup networks to save
#set backup # saves backup networks retrived by "undo" and "recall"
#set savesteps 1 # sets the maximum number of backup networks to save
set progressbar # display the progress bar
# program names for internal calls
@ -99,6 +99,8 @@ alias src_rws "st; rw -l; rs -K 6 -N 2 -l; rwz -l; rs -K 9 -N 2 -l; rwz -l;
alias compress2rs "b -l; rs -K 6 -l; rw -l; rs -K 6 -N 2 -l; rf -l; rs -K 8 -l; b -l; rs -K 8 -N 2 -l; rw -l; rs -K 10 -l; rwz -l; rs -K 10 -N 2 -l; b -l; rs -K 12 -l; rfz -l; rs -K 12 -N 2 -l; rwz -l; b -l"
# temporaries
alias test "rvl th/lib.v; rvv th/t2.v"
#alias test "rvl th/lib.v; rvv th/t2.v"
alias test "so c/pure_sat/test.c"

View File

@ -516,7 +516,7 @@ extern bool Abc_NtkCheck( Abc_Ntk_t * pNtk );
extern bool Abc_NtkCheckRead( Abc_Ntk_t * pNtk );
extern bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk );
extern bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj );
extern bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
extern bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fOnlyPis, int fComb );
/*=== abcCollapse.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fVerbose );
/*=== abcCut.c ==========================================================*/
@ -589,7 +589,6 @@ extern Abc_Ntk_t * Abc_NtkMiterQuantify( Abc_Ntk_t * pNtk, int In, int fE
extern Abc_Ntk_t * Abc_NtkMiterQuantifyPis( Abc_Ntk_t * pNtk );
extern int Abc_NtkMiterIsConstant( Abc_Ntk_t * pMiter );
extern void Abc_NtkMiterReport( Abc_Ntk_t * pMiter );
extern int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 );
extern Abc_Ntk_t * Abc_NtkFrames( Abc_Ntk_t * pNtk, int nFrames, int fInitial );
/*=== abcObj.c ==========================================================*/
extern Abc_Obj_t * Abc_ObjAlloc( Abc_Ntk_t * pNtk, Abc_ObjType_t Type );
@ -743,7 +742,7 @@ extern char * Abc_SopFromTruthHex( char * pTruth );
/*=== abcStrash.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes, bool fCleanup );
extern Abc_Obj_t * Abc_NodeStrash( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode );
extern int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 );
extern int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fAddPos );
extern Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels );
/*=== abcSweep.c ==========================================================*/
extern int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose );

View File

@ -709,16 +709,19 @@ bool Abc_NtkCompareBoxes( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
SeeAlso []
***********************************************************************/
bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fOnlyPis, int fComb )
{
Abc_NtkOrderObjsByName( pNtk1, fComb );
Abc_NtkOrderObjsByName( pNtk2, fComb );
if ( !Abc_NtkCompareBoxes( pNtk1, pNtk2, fComb ) )
return 0;
if ( !Abc_NtkComparePis( pNtk1, pNtk2, fComb ) )
return 0;
if ( !Abc_NtkComparePos( pNtk1, pNtk2, fComb ) )
return 0;
if ( !fOnlyPis )
{
if ( !Abc_NtkCompareBoxes( pNtk1, pNtk2, fComb ) )
return 0;
if ( !Abc_NtkComparePos( pNtk1, pNtk2, fComb ) )
return 0;
}
return 1;
}

View File

@ -71,6 +71,7 @@ static int Abc_CommandLogic ( Abc_Frame_t * pAbc, int argc, char ** arg
static int Abc_CommandMiter ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDemiter ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandOrPos ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAppend ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandFrames ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSop ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandBdd ( Abc_Frame_t * pAbc, int argc, char ** argv );
@ -96,6 +97,7 @@ static int Abc_CommandICut ( Abc_Frame_t * pAbc, int argc, char ** arg
static int Abc_CommandIRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIRewriteSeq ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIResyn ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIFraig ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandHaig ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandMini ( Abc_Frame_t * pAbc, int argc, char ** argv );
@ -196,6 +198,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Various", "miter", Abc_CommandMiter, 1 );
Cmd_CommandAdd( pAbc, "Various", "demiter", Abc_CommandDemiter, 1 );
Cmd_CommandAdd( pAbc, "Various", "orpos", Abc_CommandOrPos, 1 );
Cmd_CommandAdd( pAbc, "Various", "append", Abc_CommandAppend, 1 );
Cmd_CommandAdd( pAbc, "Various", "frames", Abc_CommandFrames, 1 );
Cmd_CommandAdd( pAbc, "Various", "sop", Abc_CommandSop, 0 );
Cmd_CommandAdd( pAbc, "Various", "bdd", Abc_CommandBdd, 0 );
@ -221,6 +224,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "New AIG", "irw", Abc_CommandIRewrite, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "irws", Abc_CommandIRewriteSeq, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "iresyn", Abc_CommandIResyn, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "ifraig", Abc_CommandIFraig, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "haig", Abc_CommandHaig, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "mini", Abc_CommandMini, 1 );
@ -3265,6 +3269,105 @@ usage:
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandAppend( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr, * pFile;
Abc_Ntk_t * pNtk, * pNtk2;
char * FileName;
int fComb;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
{
switch ( c )
{
case 'c':
fComb ^= 1;
break;
default:
goto usage;
}
}
// get the second network
if ( argc != globalUtilOptind + 1 )
{
fprintf( pErr, "The network to append is not given.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
fprintf( pErr, "The base network should be strashed for the appending to work.\n" );
return 1;
}
// get the input file name
FileName = argv[globalUtilOptind];
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// read the second network
pNtk2 = Io_Read( FileName, 1 );
if ( pNtk2 == NULL )
{
fprintf( pAbc->Err, "Reading network from file has failed.\n" );
return 1;
}
// check if the second network is combinational
if ( Abc_NtkLatchNum(pNtk2) )
{
fprintf( pErr, "The second network has latches. Appending does not work for such networks.\n" );
return 1;
}
// get the new network
if ( !Abc_NtkAppend( pNtk, pNtk2, 1 ) )
{
Abc_NtkDelete( pNtk2 );
fprintf( pErr, "Appending the networks failed.\n" );
return 1;
}
Abc_NtkDelete( pNtk2 );
// replace the current network
// Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
fprintf( pErr, "usage: append [-h] <file>\n" );
fprintf( pErr, "\t appends a combinational network on top of the current network\n" );
// fprintf( pErr, "\t-c : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
fprintf( pErr, "\t<file> : file name with the second network\n");
return 1;
}
/**Function*************************************************************
Synopsis []
@ -4810,13 +4913,13 @@ int Abc_CommandXyz( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( pErr, "Only works for strashed networks.\n" );
return 1;
}
/*
if ( nLutMax < 2 || nLutMax > 12 || nPlaMax < 8 || nPlaMax > 128 )
{
fprintf( pErr, "Incorrect LUT/PLA parameters.\n" );
return 1;
}
*/
// run the command
// pNtkRes = Abc_NtkXyz( pNtk, nPlaMax, 1, 0, fInvs, fVerbose );
pNtkRes = Abc_NtkPlayer( pNtk, nLutMax, nPlaMax, RankCost, fFastMode, fRewriting, fSynthesis, fVerbose );
@ -5327,6 +5430,79 @@ usage:
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, fUpdateLevel, fVerbose;
extern Abc_Ntk_t * Abc_NtkIvyFraig( Abc_Ntk_t * pNtk );
pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set defaults
fUpdateLevel = 1;
fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "lzvh" ) ) != EOF )
{
switch ( c )
{
case 'l':
fUpdateLevel ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pNtk == NULL )
{
fprintf( pErr, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsSeq(pNtk) )
{
fprintf( pErr, "Only works for non-sequential networks.\n" );
return 1;
}
pNtkRes = Abc_NtkIvyFraig( pNtk );
if ( pNtkRes == NULL )
{
fprintf( pErr, "Command has failed.\n" );
return 0;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
fprintf( pErr, "usage: ifraig [-h]\n" );
fprintf( pErr, "\t performs fraiging using a new method\n" );
// fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
// fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
return 1;
}
/**Function*************************************************************
Synopsis []

View File

@ -209,7 +209,8 @@ Abc_Ntk_t * Abc_NtkFromFpga( Fpga_Man_t * pMan, Abc_Ntk_t * pNtk )
Abc_NtkForEachCi( pNtk, pNode, i )
Fpga_NodeSetData0( Fpga_ManReadInputs(pMan)[i], (char *)pNode->pCopy );
// set the constant node
Fpga_NodeSetData0( Fpga_ManReadConst1(pMan), (char *)Abc_NodeCreateConst1(pNtkNew) );
// if ( Fpga_NodeReadRefs(Fpga_ManReadConst1(pMan)) > 0 )
Fpga_NodeSetData0( Fpga_ManReadConst1(pMan), (char *)Abc_NodeCreateConst1(pNtkNew) );
// process the nodes in topological order
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
Abc_NtkForEachCo( pNtk, pNode, i )
@ -222,6 +223,10 @@ Abc_Ntk_t * Abc_NtkFromFpga( Fpga_Man_t * pMan, Abc_Ntk_t * pNtk )
Extra_ProgressBarStop( pProgress );
// finalize the new network
Abc_NtkFinalize( pNtk, pNtkNew );
// remove the constant node if not used
pNodeNew = (Abc_Obj_t *)Fpga_NodeReadData0(Fpga_ManReadConst1(pMan));
if ( Abc_ObjFanoutNum(pNodeNew) == 0 )
Abc_NtkDeleteObj( pNodeNew );
// decouple the PO driver nodes to reduce the number of levels
nDupGates = Abc_NtkLogicMakeSimpleCos( pNtkNew, 1 );
// if ( nDupGates && Fpga_ManReadVerbose(pMan) )

View File

@ -679,7 +679,7 @@ int Abc_NtkFraigStore( Abc_Ntk_t * pNtk )
{
// add the new network to storage
nAndsOld = Abc_NtkNodeNum( pStore );
if ( !Abc_NtkAppend( pStore, pNtk ) )
if ( !Abc_NtkAppend( pStore, pNtk, 0 ) )
{
printf( "The current network cannot be appended to the stored network.\n" );
return 0;

View File

@ -277,6 +277,31 @@ Abc_Ntk_t * Abc_NtkIvyRewriteSeq( Abc_Ntk_t * pNtk, int fUseZeroCost, int fVerbo
return pNtkAig;
}
/**Function*************************************************************
Synopsis [Gives the current ABC network to AIG manager for processing.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkIvyResyn0( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose )
{
Abc_Ntk_t * pNtkAig;
Ivy_Man_t * pMan, * pTemp;
pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
if ( pMan == NULL )
return NULL;
pMan = Ivy_ManResyn0( pTemp = pMan, fUpdateLevel, fVerbose );
Ivy_ManStop( pTemp );
pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
Ivy_ManStop( pMan );
return pNtkAig;
}
/**Function*************************************************************
Synopsis [Gives the current ABC network to AIG manager for processing.]
@ -302,6 +327,33 @@ Abc_Ntk_t * Abc_NtkIvyResyn( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose )
return pNtkAig;
}
/**Function*************************************************************
Synopsis [Gives the current ABC network to AIG manager for processing.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkIvyFraig( Abc_Ntk_t * pNtk )
{
Ivy_FraigParams_t Params, * pParams = &Params;
Abc_Ntk_t * pNtkAig;
Ivy_Man_t * pMan, * pTemp;
pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
if ( pMan == NULL )
return NULL;
Ivy_FraigParamsDefault( pParams );
pMan = Ivy_FraigPerform( pTemp = pMan, pParams );
Ivy_ManStop( pTemp );
pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
Ivy_ManStop( pMan );
return pNtkAig;
}
/**Function*************************************************************
Synopsis [Gives the current ABC network to AIG manager for processing.]
@ -538,12 +590,12 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig
if ( fHaig && pNode->pEquiv && Ivy_ObjRefs(pNode) > 0 )
{
pFaninNew = Abc_EdgeToNode( pNtk, pNode->TravId );
pFaninNew->fPhase = 0;
// pFaninNew->fPhase = 0;
assert( !Ivy_IsComplement(pNode->pEquiv) );
for ( pTemp = pNode->pEquiv; pTemp != pNode; pTemp = Ivy_Regular(pTemp->pEquiv) )
{
pFaninNew1 = Abc_EdgeToNode( pNtk, pTemp->TravId );
pFaninNew1->fPhase = Ivy_IsComplement( pTemp->pEquiv );
// pFaninNew1->fPhase = Ivy_IsComplement( pTemp->pEquiv );
pFaninNew->pData = pFaninNew1;
pFaninNew = pFaninNew1;
}

View File

@ -57,7 +57,7 @@ Abc_Ntk_t * Abc_NtkMiter( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
assert( Abc_NtkHasOnlyLatchBoxes(pNtk1) );
assert( Abc_NtkHasOnlyLatchBoxes(pNtk2) );
// check that the networks have the same PIs/POs/latches
if ( !Abc_NtkCompareSignals( pNtk1, pNtk2, fComb ) )
if ( !Abc_NtkCompareSignals( pNtk1, pNtk2, 0, fComb ) )
return NULL;
// make sure the circuits are strashed
fRemove1 = (!Abc_NtkIsStrash(pNtk1)) && (pNtk1 = Abc_NtkStrash(pNtk1, 0, 0));

View File

@ -122,8 +122,24 @@ int Abc_NtkMiterProve( Abc_Ntk_t ** ppNtk, void * pPars )
{
clk = clock();
Counter = (int)(pParams->nRewritingLimitStart * pow(pParams->nRewritingLimitMulti,nIter));
// Counter = 1;
while ( 1 )
{
/*
extern Abc_Ntk_t * Abc_NtkIvyResyn( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose );
pNtk = Abc_NtkIvyResyn( pNtkTemp = pNtk, 0, 0 ); Abc_NtkDelete( pNtkTemp );
if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
break;
if ( --Counter == 0 )
break;
*/
/*
Abc_NtkRewrite( pNtk, 0, 0, 0 );
if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
break;
if ( --Counter == 0 )
break;
*/
Abc_NtkRewrite( pNtk, 0, 0, 0 );
if ( (RetValue = Abc_NtkMiterIsConstant(pNtk)) >= 0 )
break;

View File

@ -429,7 +429,7 @@ int Abc_NtkMiterSatCreateInt( solver * pSat, Abc_Ntk_t * pNtk, int fJFront )
{
Abc_Obj_t * pNode, * pFanin, * pNodeC, * pNodeT, * pNodeE;
Vec_Ptr_t * vNodes, * vSuper;
// Vec_Int_t * vLevels;
Vec_Flt_t * vFactors;
Vec_Int_t * vVars, * vFanio;
Vec_Vec_t * vCircuit;
int i, k, fUseMuxes = 1;
@ -588,6 +588,23 @@ int Abc_NtkMiterSatCreateInt( solver * pSat, Abc_Ntk_t * pNtk, int fJFront )
// Asat_JManStop( pSat );
// PRT( "Total", clock() - clk1 );
}
Abc_NtkStartReverseLevels( pNtk );
vFactors = Vec_FltStart( solver_nvars(pSat) );
Abc_NtkForEachNode( pNtk, pNode, i )
if ( pNode->fMarkA )
Vec_FltWriteEntry( vFactors, (int)pNode->pCopy, (float)pow(0.97, Abc_NodeReadReverseLevel(pNode)) );
Abc_NtkForEachCi( pNtk, pNode, i )
if ( pNode->fMarkA )
Vec_FltWriteEntry( vFactors, (int)pNode->pCopy, (float)pow(0.97, nLevelsMax+1) );
// set the PI levels
// Abc_NtkForEachObj( pNtk, pNode, i )
// if ( pNode->fMarkA )
// printf( "(%d) %.3f ", Abc_NodeReadReverseLevel(pNode), Vec_FltEntry(vFactors, (int)pNode->pCopy) );
// printf( "\n" );
Asat_SolverSetFactors( pSat, Vec_FltReleaseArray(vFactors) );
Vec_FltFree( vFactors );
/*
// create factors
vLevels = Vec_IntStart( Vec_PtrSize(vNodes) ); // the reverse levels of the nodes

View File

@ -144,7 +144,7 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes, bool fCleanup )
SeeAlso []
***********************************************************************/
int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fAddPos )
{
Abc_Obj_t * pObj;
int i;
@ -158,7 +158,7 @@ int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
}
// check that the networks have the same PIs
// reorder PIs of pNtk2 according to pNtk1
if ( !Abc_NtkCompareSignals( pNtk1, pNtk2, 1 ) )
if ( !Abc_NtkCompareSignals( pNtk1, pNtk2, 1, 1 ) )
return 0;
// perform strashing
Abc_NtkCleanCopy( pNtk2 );
@ -170,6 +170,16 @@ int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
else
Abc_NtkForEachNode( pNtk2, pObj, i )
pObj->pCopy = Abc_AigAnd( pNtk1->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// add the COs of the second network
if ( fAddPos )
{
Abc_NtkForEachPo( pNtk2, pObj, i )
{
Abc_NtkDupObj( pNtk1, pObj, 0 );
Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj->pCopy), NULL );
}
}
// make sure that everything is okay
if ( !Abc_NtkCheck( pNtk1 ) )
{

View File

@ -105,6 +105,7 @@ extern int Fpga_LibReadLutMax( Fpga_LutLib_t * pLib );
extern char * Fpga_NodeReadData0( Fpga_Node_t * p );
extern Fpga_Node_t * Fpga_NodeReadData1( Fpga_Node_t * p );
extern int Fpga_NodeReadRefs( Fpga_Node_t * p );
extern int Fpga_NodeReadNum( Fpga_Node_t * p );
extern int Fpga_NodeReadLevel( Fpga_Node_t * p );
extern Fpga_Cut_t * Fpga_NodeReadCuts( Fpga_Node_t * p );

View File

@ -97,6 +97,7 @@ int Fpga_LibReadLutMax( Fpga_LutLib_t * pLib ) { return pLib->LutMa
***********************************************************************/
char * Fpga_NodeReadData0( Fpga_Node_t * p ) { return p->pData0; }
Fpga_Node_t * Fpga_NodeReadData1( Fpga_Node_t * p ) { return p->pLevel; }
int Fpga_NodeReadRefs( Fpga_Node_t * p ) { return p->nRefs; }
int Fpga_NodeReadNum( Fpga_Node_t * p ) { return p->Num; }
int Fpga_NodeReadLevel( Fpga_Node_t * p ) { return Fpga_Regular(p)->Level; }
Fpga_Cut_t * Fpga_NodeReadCuts( Fpga_Node_t * p ) { return p->pCuts; }

View File

@ -220,7 +220,7 @@ void Asat_SolverSetPrefVars(solver * s, int * pPrefVars, int nPrefVars)
SeeAlso []
***********************************************************************/
void Asat_SolverSetFactors(solver * s, int * pFactors)
void Asat_SolverSetFactors(solver * s, float * pFactors)
{
assert( s->factors == NULL );
s->factors = pFactors;

View File

@ -253,12 +253,11 @@ static inline void act_var_rescale(solver* s) {
static inline void act_var_bump(solver* s, int v) {
double* activity = s->activity;
if ((activity[v] += s->var_inc) > 1e100)
// if ((activity[v] += s->var_inc*s->factors[v]/100000000) > 1e100)
activity[v] += s->var_inc;
// activity[v] += s->var_inc * s->factors[v];
if (activity[v] > 1e100)
act_var_rescale(s);
//printf("bump %d %f\n", v-1, activity[v]);
if ( s->pJMan == NULL && s->orderpos[v] != -1 )
order_update(s,v);
@ -842,6 +841,7 @@ static lbool solver_search(solver* s, int nof_conflicts, int nof_learnts)
int conflictC = 0;
veci learnt_clause;
int i;
assert(s->root_level == solver_dlevel(s));
@ -851,6 +851,12 @@ static lbool solver_search(solver* s, int nof_conflicts, int nof_learnts)
veci_resize(&s->model,0);
veci_new(&learnt_clause);
// reset the activities
if ( s->factors )
for ( i = 0; i < s->size; i++ )
s->activity[i] = (double)s->factors[i];
// s->activity[i] = 1.0;
for (;;){
clause* confl = solver_propagate(s);
if (confl != 0){

View File

@ -89,7 +89,7 @@ extern void Asat_SolverWriteDimacs( solver * pSat, char * pFileName,
int incrementVars);
extern void Asat_SatPrintStats( FILE * pFile, solver * p );
extern void Asat_SolverSetPrefVars( solver * s, int * pPrefVars, int nPrefVars );
extern void Asat_SolverSetFactors( solver * s, int * pFactors );
extern void Asat_SolverSetFactors( solver * s, float * pFactors );
// J-frontier support
extern Asat_JMan_t * Asat_JManStart( solver * pSat, void * vCircuit );
@ -128,7 +128,7 @@ struct solver_t
vec* wlists; //
double* activity; // A heuristic measurement of the activity of a variable.
int * factors; // the factor of variable activity
float * factors; // the factor of variable activity
lbool* assigns; // Current values of variables.
int* orderpos; // Index in variable order.
clause** reasons; //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,137 @@
/**************************************************************************************************
MiniSat -- Copyright (c) 2005, Niklas Sorensson
http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************************************/
// Modified to compile with MS Visual Studio 6.0 by Alan Mishchenko
#ifndef solver_h
#define solver_h
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
#endif
#include "vec.h"
//=================================================================================================
// Simple types:
// does not work for c++
typedef int bool;
static const bool true = 1;
static const bool false = 0;
typedef int lit;
typedef char lbool;
#ifdef _WIN32
typedef signed __int64 uint64; // compatible with MS VS 6.0
#else
typedef unsigned long long uint64;
#endif
static const int var_Undef = -1;
static const lit lit_Undef = -2;
static const lbool l_Undef = 0;
static const lbool l_True = 1;
static const lbool l_False = -1;
static inline lit toLit (int v) { return v + v; }
static inline lit lit_neg (lit l) { return l ^ 1; }
static inline int lit_var (lit l) { return l >> 1; }
static inline int lit_sign(lit l) { return (l & 1); }
//=================================================================================================
// Public interface:
struct solver_t;
typedef struct solver_t solver;
extern solver* solver_new(void);
extern void solver_delete(solver* s);
extern bool solver_addclause(solver* s, lit* begin, lit* end);
extern bool solver_simplify(solver* s);
extern bool solver_solve(solver* s, lit* begin, lit* end);
extern int solver_nvars(solver* s);
extern int solver_nclauses(solver* s);
extern int solver_nconflicts(solver* s);
extern void solver_setnvars(solver* s,int n);
struct stats_t
{
uint64 starts, decisions, propagations, inspects, conflicts;
uint64 clauses, clauses_literals, learnts, learnts_literals, max_literals, tot_literals;
};
typedef struct stats_t stats;
//=================================================================================================
// Solver representation:
struct clause_t;
typedef struct clause_t clause;
struct solver_t
{
int size; // nof variables
int cap; // size of varmaps
int qhead; // Head index of queue.
int qtail; // Tail index of queue.
// clauses
vecp clauses; // List of problem constraints. (contains: clause*)
vecp learnts; // List of learnt clauses. (contains: clause*)
// activities
double var_inc; // Amount to bump next variable with.
double var_decay; // INVERSE decay factor for variable activity: stores 1/decay.
float cla_inc; // Amount to bump next clause with.
float cla_decay; // INVERSE decay factor for clause activity: stores 1/decay.
vecp* wlists; //
double* activity; // A heuristic measurement of the activity of a variable.
lbool* assigns; // Current values of variables.
int* orderpos; // Index in variable order.
clause** reasons; //
int* levels; //
lit* trail;
clause* binary; // A temporary binary clause
lbool* tags; //
veci tagged; // (contains: var)
veci stack; // (contains: var)
veci order; // Variable order. (heap) (contains: var)
veci trail_lim; // Separator indices for different decision levels in 'trail'. (contains: int)
veci model; // If problem is solved, this vector contains the model (contains: lbool).
int root_level; // Level of first proper decision.
int simpdb_assigns;// Number of top-level assignments at last 'simplifyDB()'.
int simpdb_props; // Number of propagations before next 'simplifyDB()'.
double random_seed;
double progress_estimate;
int verbosity; // Verbosity level. 0=silent, 1=some progress report, 2=everything
stats stats;
};
#endif

View File

@ -463,6 +463,10 @@ Fraig_NodeVec_t * Fraig_FeedBackCoveringStart( Fraig_Man_t * p )
Fraig_NodeVecPush( p->vCones, pEntD );
if ( p->vCones->nSize == 1 )
continue;
//////////////////////////////// bug fix by alanmi, September 14, 2006
if ( p->vCones->nSize > 20 )
continue;
////////////////////////////////
for ( k = 0; k < p->vCones->nSize; k++ )
for ( m = k+1; m < p->vCones->nSize; m++ )

View File

@ -34,6 +34,7 @@ static void Fraig_SupergateAddClausesExor( Fraig_Man_t * pMan, Fraig_Node_t * pN
static void Fraig_SupergateAddClausesMux( Fraig_Man_t * pMan, Fraig_Node_t * pNode );
//static void Fraig_DetectFanoutFreeCone( Fraig_Man_t * pMan, Fraig_Node_t * pNode );
static void Fraig_DetectFanoutFreeConeMux( Fraig_Man_t * pMan, Fraig_Node_t * pNode );
static void Fraig_SetActivity( Fraig_Man_t * pMan, Fraig_Node_t * pOld, Fraig_Node_t * pNew );
extern void * Msat_ClauseVecReadEntry( void * p, int i );
@ -355,6 +356,9 @@ if ( fVerbose )
printf( "%d(%d) - ", Fraig_CountPis(p,p->vVarsInt), Msat_IntVecReadSize(p->vVarsInt) );
// prepare variable activity
Fraig_SetActivity( p, pOld, pNew );
// get the complemented attribute
fComp = Fraig_NodeComparePhase( pOld, pNew );
//Msat_SolverPrintClauses( p->pSat );
@ -1396,6 +1400,40 @@ printf( "%d(%d)", vFanins->nSize, nCubes );
}
/**Function*************************************************************
Synopsis [Collect variables using their proximity from the nodes.]
Description [This procedure creates a variable order based on collecting
first the nodes that are the closest to the given two target nodes.]
SideEffects []
SeeAlso []
***********************************************************************/
void Fraig_SetActivity( Fraig_Man_t * pMan, Fraig_Node_t * pOld, Fraig_Node_t * pNew )
{
Fraig_Node_t * pNode;
int i, Number, MaxLevel;
float * pFactors = Msat_SolverReadFactors(pMan->pSat);
if ( pFactors == NULL )
return;
MaxLevel = FRAIG_MAX( pOld->Level, pNew->Level );
// create the variable order
for ( i = 0; i < Msat_IntVecReadSize(pMan->vVarsInt); i++ )
{
// get the new node on the frontier
Number = Msat_IntVecReadEntry(pMan->vVarsInt, i);
pNode = pMan->vNodes->pArray[Number];
pFactors[pNode->Num] = (float)pow( 0.97, MaxLevel - pNode->Level );
// if ( pNode->Num % 50 == 0 )
// printf( "(%d) %.2f ", MaxLevel - pNode->Level, pFactors[pNode->Num] );
}
// printf( "\n" );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////

View File

@ -104,6 +104,7 @@ extern void Msat_SolverSetVarTypeA( Msat_Solver_t * p, int Var );
extern void Msat_SolverSetVarMap( Msat_Solver_t * p, Msat_IntVec_t * vVarMap );
extern void Msat_SolverMarkLastClauseTypeA( Msat_Solver_t * p );
extern void Msat_SolverMarkClausesStart( Msat_Solver_t * p );
extern float * Msat_SolverReadFactors( Msat_Solver_t * p );
// returns the solution after incremental solving
extern int Msat_SolverReadSolutions( Msat_Solver_t * p );
extern int * Msat_SolverReadSolutionsArray( Msat_Solver_t * p );

View File

@ -45,8 +45,9 @@ void Msat_SolverVarBumpActivity( Msat_Solver_t * p, Msat_Lit_t Lit )
if ( p->dVarDecay < 0 ) // (negative decay means static variable order -- don't bump)
return;
Var = MSAT_LIT2VAR(Lit);
if ( (p->pdActivity[Var] += p->dVarInc) > 1e100 )
// if ( (p->pdActivity[Var] += p->dVarInc * (1.0 + 0.005*p->pActLevels[Var])) > 1e100 )
p->pdActivity[Var] += p->dVarInc;
// p->pdActivity[Var] += p->dVarInc * p->pFactors[Var];
if ( p->pdActivity[Var] > 1e100 )
Msat_SolverVarRescaleActivity( p );
Msat_OrderUpdate( p->pOrder, Var );
}

View File

@ -119,7 +119,7 @@ struct Msat_Solver_t_
double dClaDecay; // INVERSE decay factor for clause activity: stores 1/decay.
double * pdActivity; // A heuristic measurement of the activity of a variable.
int * pActLevels; // the levels of the variables
float * pFactors; // the multiplicative factors of variable activity
double dVarInc; // Amount to bump next variable with.
double dVarDecay; // INVERSE decay factor for variable activity: stores 1/decay. Use negative value for static variable order.
Msat_Order_t * pOrder; // Keeps track of the decision variable order.

View File

@ -64,6 +64,7 @@ void Msat_SolverClausesIncrementL( Msat_Solver_t * p ) {
void Msat_SolverClausesDecrementL( Msat_Solver_t * p ) { p->nClausesAllocL--; }
void Msat_SolverMarkLastClauseTypeA( Msat_Solver_t * p ) { Msat_ClauseSetTypeA( Msat_ClauseVecReadEntry( p->vClauses, Msat_ClauseVecReadSize(p->vClauses)-1 ), 1 ); }
void Msat_SolverMarkClausesStart( Msat_Solver_t * p ) { p->nClausesStart = Msat_ClauseVecReadSize(p->vClauses); }
float * Msat_SolverReadFactors( Msat_Solver_t * p ) { return p->pFactors; }
/**Function*************************************************************
@ -174,11 +175,11 @@ Msat_Solver_t * Msat_SolverAlloc( int nVarsAlloc,
p->dVarDecay = dVarDecay;
p->pdActivity = ALLOC( double, p->nVarsAlloc );
p->pActLevels = ALLOC( int, p->nVarsAlloc );
p->pFactors = ALLOC( float, p->nVarsAlloc );
for ( i = 0; i < p->nVarsAlloc; i++ )
{
p->pdActivity[i] = 0;
p->pActLevels[i] = 0;
p->pdActivity[i] = 0.0;
p->pFactors[i] = 1.0;
}
p->pAssigns = ALLOC( int, p->nVarsAlloc );
@ -243,9 +244,12 @@ void Msat_SolverResize( Msat_Solver_t * p, int nVarsAlloc )
p->nVarsAlloc = nVarsAlloc;
p->pdActivity = REALLOC( double, p->pdActivity, p->nVarsAlloc );
p->pActLevels = REALLOC( int, p->pActLevels, p->nVarsAlloc );
p->pFactors = REALLOC( float, p->pFactors, p->nVarsAlloc );
for ( i = nVarsAllocOld; i < p->nVarsAlloc; i++ )
p->pdActivity[i] = 0;
{
p->pdActivity[i] = 0.0;
p->pFactors[i] = 1.0;
}
p->pAssigns = REALLOC( int, p->pAssigns, p->nVarsAlloc );
p->pModel = REALLOC( int, p->pModel, p->nVarsAlloc );
@ -399,7 +403,7 @@ void Msat_SolverFree( Msat_Solver_t * p )
Msat_ClauseVecFree( p->vLearned );
FREE( p->pdActivity );
FREE( p->pActLevels );
FREE( p->pFactors );
Msat_OrderFree( p->pOrder );
for ( i = 0; i < 2 * p->nVarsAlloc; i++ )

View File

@ -534,12 +534,18 @@ Msat_Type_t Msat_SolverSearch( Msat_Solver_t * p, int nConfLimit, int nLearnedLi
Msat_Clause_t * pConf;
Msat_Var_t Var;
int nLevelBack, nConfs, nAssigns, Value;
int i;
assert( Msat_SolverReadDecisionLevel(p) == p->nLevelRoot );
p->Stats.nStarts++;
p->dVarDecay = 1 / pPars->dVarDecay;
p->dClaDecay = 1 / pPars->dClaDecay;
// reset the activities
for ( i = 0; i < p->nVars; i++ )
p->pdActivity[i] = (double)p->pFactors[i];
// p->pdActivity[i] = 0.0;
nConfs = 0;
while ( 1 )
{

View File

@ -43,6 +43,7 @@ extern "C" {
typedef struct Ivy_Man_t_ Ivy_Man_t;
typedef struct Ivy_Obj_t_ Ivy_Obj_t;
typedef int Ivy_Edge_t;
typedef struct Ivy_FraigParams_t_ Ivy_FraigParams_t;
// object types
typedef enum {
@ -70,13 +71,14 @@ struct Ivy_Obj_t_ // 24 bytes (32-bit) or 32 bytes (64-bit) // 10 words - 16
{
int Id; // integer ID
int TravId; // traversal ID
unsigned Type : 4; // object type
unsigned fPhase : 1; // value under 000...0 pattern
unsigned fMarkA : 1; // multipurpose mask
unsigned fMarkB : 1; // multipurpose mask
unsigned fExFan : 1; // set to 1 if last fanout added is EXOR
unsigned Init : 2; // latch initial value
unsigned Level : 22; // logic level
unsigned Type : 4; // object type
unsigned fMarkA : 1; // multipurpose mask
unsigned fMarkB : 1; // multipurpose mask
unsigned fExFan : 1; // set to 1 if last fanout added is EXOR
unsigned fPhase : 1; // value under 000...0 pattern
unsigned fFailTfo : 1; // the TFO of the failed node
unsigned Init : 2; // latch initial value
unsigned Level : 21; // logic level
int nRefs; // reference counter
Ivy_Obj_t * pFanin0; // fanin
Ivy_Obj_t * pFanin1; // fanin
@ -124,6 +126,12 @@ struct Ivy_Man_t_
int time2;
};
struct Ivy_FraigParams_t_
{
int nSimWords; // the number of words in the simulation info
double SimSatur; // the ratio of refined classes when saturation is reached
};
#define IVY_CUT_LIMIT 256
#define IVY_CUT_INPUT 6
@ -249,6 +257,8 @@ static inline Ivy_Obj_t * Ivy_ObjChild0Equiv( Ivy_Obj_t * pObj ) { assert( !Ivy
static inline Ivy_Obj_t * Ivy_ObjChild1Equiv( Ivy_Obj_t * pObj ) { assert( !Ivy_IsComplement(pObj) ); return Ivy_ObjFanin1(pObj)? Ivy_NotCond(Ivy_ObjFanin1(pObj)->pEquiv, Ivy_ObjFaninC1(pObj)) : NULL; }
static inline int Ivy_ObjLevel( Ivy_Obj_t * pObj ) { return pObj->Level; }
static inline int Ivy_ObjLevelNew( Ivy_Obj_t * pObj ) { return 1 + Ivy_ObjIsExor(pObj) + IVY_MAX(Ivy_ObjFanin0(pObj)->Level, Ivy_ObjFanin1(pObj)->Level); }
static inline int Ivy_ObjFaninPhase( Ivy_Obj_t * pObj ) { return Ivy_IsComplement(pObj)? !Ivy_Regular(pObj)->fPhase : pObj->fPhase; }
static inline void Ivy_ObjClean( Ivy_Obj_t * pObj )
{
int IdSaved = pObj->Id;
@ -430,6 +440,9 @@ extern void Ivy_FastMapPerform( Ivy_Man_t * pAig, int nLimit );
extern void Ivy_FastMapStop( Ivy_Man_t * pAig );
extern void Ivy_FastMapReadSupp( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, Vec_Int_t * vLeaves );
extern void Ivy_FastMapReverseLevel( Ivy_Man_t * pAig );
/*=== ivyFraig.c ==========================================================*/
extern Ivy_Man_t * Ivy_FraigPerform( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams );
extern void Ivy_FraigParamsDefault( Ivy_FraigParams_t * pParams );
/*=== ivyHaig.c ==========================================================*/
extern void Ivy_ManHaigStart( Ivy_Man_t * p, int fVerbose );
extern void Ivy_ManHaigTrasfer( Ivy_Man_t * p, Ivy_Man_t * pNew );
@ -442,6 +455,7 @@ extern void Ivy_ManHaigSimulate( Ivy_Man_t * p );
extern int Ivy_TruthIsop( unsigned * puTruth, int nVars, Vec_Int_t * vCover, int fTryBoth );
/*=== ivyMan.c ==========================================================*/
extern Ivy_Man_t * Ivy_ManStart();
extern Ivy_Man_t * Ivy_ManStartFrom( Ivy_Man_t * p );
extern Ivy_Man_t * Ivy_ManDup( Ivy_Man_t * p );
extern void Ivy_ManStop( Ivy_Man_t * p );
extern int Ivy_ManCleanup( Ivy_Man_t * p );
@ -487,7 +501,7 @@ extern int Ivy_ManRewritePre( Ivy_Man_t * p, int fUpdateLevel, int f
/*=== ivySeq.c =========================================================*/
extern int Ivy_ManRewriteSeq( Ivy_Man_t * p, int fUseZeroCost, int fVerbose );
/*=== ivyShow.c =========================================================*/
extern void Ivy_ManShow( Ivy_Man_t * pMan, int fHaig );
extern void Ivy_ManShow( Ivy_Man_t * pMan, int fHaig, Vec_Ptr_t * vBold );
/*=== ivyTable.c ========================================================*/
extern Ivy_Obj_t * Ivy_TableLookup( Ivy_Man_t * p, Ivy_Obj_t * pObj );
extern void Ivy_TableInsert( Ivy_Man_t * p, Ivy_Obj_t * pObj );

View File

@ -17,7 +17,7 @@
Revision [$Id: ivyBalance.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
#include "ivy.h"
////////////////////////////////////////////////////////////////////////
@ -73,7 +73,9 @@ Ivy_Man_t * Ivy_ManBalance( Ivy_Man_t * p, int fUpdateLevel )
}
Vec_VecFree( vStore );
if ( i = Ivy_ManCleanup( pNew ) )
printf( "Cleanup after balancing removed %d dangling nodes.\n", i );
{
// printf( "Cleanup after balancing removed %d dangling nodes.\n", i );
}
// check the resulting AIG
if ( !Ivy_ManCheck(pNew) )
printf( "Ivy_ManBalance(): The check has failed.\n" );

View File

@ -68,13 +68,16 @@ static int Ivy_FastMapPrint( Ivy_Man_t * pAig, int Time );
static int Ivy_FastMapDelay( Ivy_Man_t * pAig );
static int Ivy_FastMapArea( Ivy_Man_t * pAig );
static void Ivy_FastMapNode( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit );
static void Ivy_FastMapNodeArea( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit );
static int Ivy_FastMapMerge( Ivy_Supp_t * pSupp0, Ivy_Supp_t * pSupp1, Ivy_Supp_t * pSupp, int nLimit );
static void Ivy_FastMapRequired( Ivy_Man_t * pAig, int Delay );
static void Ivy_FastMapRequired( Ivy_Man_t * pAig, int Delay, int fSetInter );
static void Ivy_FastMapRecover( Ivy_Man_t * pAig, int nLimit );
static int Ivy_FastMapNodeDelay( Ivy_Man_t * pAig, Ivy_Obj_t * pObj );
static int Ivy_FastMapNodeAreaRefed( Ivy_Man_t * pAig, Ivy_Obj_t * pObj );
static int Ivy_FastMapNodeAreaDerefed( Ivy_Man_t * pAig, Ivy_Obj_t * pObj );
static void Ivy_FastMapNodeRecover( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront, Vec_Ptr_t * vFrontOld );
static int Ivy_FastMapNodeRef( Ivy_Man_t * pAig, Ivy_Obj_t * pObj );
static int Ivy_FastMapNodeDeref( Ivy_Man_t * pAig, Ivy_Obj_t * pObj );
extern int s_MappingTime;
@ -108,6 +111,7 @@ void Ivy_FastMapPerform( Ivy_Man_t * pAig, int nLimit )
pMan->nObjs = Ivy_ManObjIdMax(pAig) + 1;
pMan->nSize = sizeof(Ivy_Supp_t) + nLimit * sizeof(int);
pMan->pMem = (char *)malloc( pMan->nObjs * pMan->nSize );
memset( pMan->pMem, 0, pMan->nObjs * pMan->nSize );
pMan->vLuts = Vec_VecAlloc( 100 );
pAig->pData = pMan;
clk = clock();
@ -122,28 +126,43 @@ clk = clock();
printf( "Delay oriented mapping: " );
Delay = Ivy_FastMapPrint( pAig, clock() - clk );
// perform area recovery
clk = clock();
Ivy_FastMapRequired( pAig, Delay );
// PRT( "Required time computation", clock() - clk );
// 2-1-2 (doing 2-1-2-1-2 improves 0.5%)
clk = clock();
Ivy_FastMapRequired( pAig, Delay, 0 );
// remap the nodes
Ivy_FastMapRecover( pAig, nLimit );
printf( "Area recovery : " );
printf( "Area recovery 2 : " );
Delay = Ivy_FastMapPrint( pAig, clock() - clk );
// perform area recovery
clk = clock();
Ivy_FastMapRequired( pAig, Delay );
// PRT( "Required time computation", clock() - clk );
Ivy_FastMapRequired( pAig, Delay, 0 );
// iterate through all nodes in the topological order
Ivy_ManForEachNode( pAig, pObj, i )
Ivy_FastMapNodeArea( pAig, pObj, nLimit );
printf( "Area recovery 1 : " );
Delay = Ivy_FastMapPrint( pAig, clock() - clk );
clk = clock();
Ivy_FastMapRequired( pAig, Delay, 0 );
// remap the nodes
Ivy_FastMapRecover( pAig, nLimit );
printf( "Area recovery : " );
printf( "Area recovery 2 : " );
Delay = Ivy_FastMapPrint( pAig, clock() - clk );
s_MappingTime = clock() - clkTotal;
s_MappingMem = pMan->nObjs * pMan->nSize;
/*
{
Vec_Ptr_t * vNodes;
vNodes = Vec_PtrAlloc( 100 );
Vec_VecForEachEntry( pMan->vLuts, pObj, i, k )
Vec_PtrPush( vNodes, pObj );
Ivy_ManShow( pAig, 0, vNodes );
Vec_PtrFree( vNodes );
}
*/
}
/**Function*************************************************************
@ -272,6 +291,257 @@ int Ivy_FastMapArea( Ivy_Man_t * pAig )
return Counter;
}
/**Function*************************************************************
Synopsis [Performs fast mapping for one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline Ivy_ObjIsNodeInt1( Ivy_Obj_t * pObj )
{
return Ivy_ObjIsNode(pObj) && Ivy_ObjRefs(pObj) == 1;
}
/**Function*************************************************************
Synopsis [Performs fast mapping for one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline Ivy_ObjIsNodeInt2( Ivy_Obj_t * pObj )
{
return Ivy_ObjIsNode(pObj) && Ivy_ObjRefs(pObj) <= 2;
}
/**Function*************************************************************
Synopsis [Performs fast mapping for one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Vec_IntSelectSort( int * pArray, int nSize )
{
int temp, i, j, best_i;
for ( i = 0; i < nSize-1; i++ )
{
best_i = i;
for ( j = i+1; j < nSize; j++ )
if ( pArray[j] < pArray[best_i] )
best_i = j;
temp = pArray[i];
pArray[i] = pArray[best_i];
pArray[best_i] = temp;
}
}
/**Function*************************************************************
Synopsis [Performs fast mapping for one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Vec_IntRemoveDup( int * pArray, int nSize )
{
int i, k;
if ( nSize < 2 )
return nSize;
for ( i = k = 1; i < nSize; i++ )
if ( pArray[i] != pArray[i-1] )
pArray[k++] = pArray[i];
return k;
}
/**Function*************************************************************
Synopsis [Performs fast mapping for one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ivy_FastMapNodeArea2( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit )
{
static int Store[32], StoreSize;
static char Supp0[16], Supp1[16];
static Ivy_Supp_t * pTemp0 = (Ivy_Supp_t *)Supp0;
static Ivy_Supp_t * pTemp1 = (Ivy_Supp_t *)Supp1;
Ivy_Obj_t * pFanin0, * pFanin1;
Ivy_Supp_t * pSupp0, * pSupp1, * pSupp;
int RetValue, DelayOld;
assert( nLimit <= 32 );
assert( Ivy_ObjIsNode(pObj) );
// get the fanins
pFanin0 = Ivy_ObjFanin0(pObj);
pFanin1 = Ivy_ObjFanin1(pObj);
// get the supports
pSupp0 = Ivy_ObjSupp( pAig, pFanin0 );
pSupp1 = Ivy_ObjSupp( pAig, pFanin1 );
pSupp = Ivy_ObjSupp( pAig, pObj );
assert( pSupp->fMark == 0 );
// get the old delay of the node
DelayOld = Ivy_FastMapNodeDelay(pAig, pObj);
assert( DelayOld <= pSupp->DelayR );
// copy the current cut
memcpy( Store, pSupp->pArray, sizeof(int) * pSupp->nSize );
StoreSize = pSupp->nSize;
// get the fanin support
if ( Ivy_ObjRefs(pFanin0) > 1 && pSupp0->Delay < pSupp->DelayR )
{
pSupp0 = pTemp0;
pSupp0->nSize = 1;
pSupp0->pArray[0] = Ivy_ObjFaninId0(pObj);
}
// get the fanin support
if ( Ivy_ObjRefs(pFanin1) > 1 && pSupp1->Delay < pSupp->DelayR )
{
pSupp1 = pTemp1;
pSupp1->nSize = 1;
pSupp1->pArray[0] = Ivy_ObjFaninId1(pObj);
}
// merge the cuts
if ( pSupp0->nSize < pSupp1->nSize )
RetValue = Ivy_FastMapMerge( pSupp1, pSupp0, pSupp, nLimit );
else
RetValue = Ivy_FastMapMerge( pSupp0, pSupp1, pSupp, nLimit );
if ( !RetValue )
{
pSupp->nSize = 2;
pSupp->pArray[0] = Ivy_ObjFaninId0(pObj);
pSupp->pArray[1] = Ivy_ObjFaninId1(pObj);
}
// check the resulting delay
pSupp->Delay = Ivy_FastMapNodeDelay(pAig, pObj);
if ( pSupp->Delay > pSupp->DelayR )
{
pSupp->nSize = StoreSize;
memcpy( pSupp->pArray, Store, sizeof(int) * pSupp->nSize );
pSupp->Delay = DelayOld;
}
}
/**Function*************************************************************
Synopsis [Performs fast mapping for one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ivy_FastMapNodeArea( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit )
{
static int Store[32], StoreSize;
static char Supp0[16], Supp1[16];
static Ivy_Supp_t * pTemp0 = (Ivy_Supp_t *)Supp0;
static Ivy_Supp_t * pTemp1 = (Ivy_Supp_t *)Supp1;
Ivy_Obj_t * pFanin0, * pFanin1;
Ivy_Supp_t * pSupp0, * pSupp1, * pSupp;
int RetValue, DelayOld, RefsOld;
int AreaBef, AreaAft;
assert( nLimit <= 32 );
assert( Ivy_ObjIsNode(pObj) );
// get the fanins
pFanin0 = Ivy_ObjFanin0(pObj);
pFanin1 = Ivy_ObjFanin1(pObj);
// get the supports
pSupp0 = Ivy_ObjSupp( pAig, pFanin0 );
pSupp1 = Ivy_ObjSupp( pAig, pFanin1 );
pSupp = Ivy_ObjSupp( pAig, pObj );
assert( pSupp->fMark == 0 );
// get the area
if ( pSupp->nRefs == 0 )
AreaBef = Ivy_FastMapNodeAreaDerefed( pAig, pObj );
else
AreaBef = Ivy_FastMapNodeAreaRefed( pAig, pObj );
// if ( AreaBef == 1 )
// return;
// deref the cut if the node is refed
if ( pSupp->nRefs != 0 )
Ivy_FastMapNodeDeref( pAig, pObj );
// get the old delay of the node
DelayOld = Ivy_FastMapNodeDelay(pAig, pObj);
assert( DelayOld <= pSupp->DelayR );
// copy the current cut
memcpy( Store, pSupp->pArray, sizeof(int) * pSupp->nSize );
StoreSize = pSupp->nSize;
// get the fanin support
if ( Ivy_ObjRefs(pFanin0) > 2 && pSupp0->Delay < pSupp->DelayR )
// if ( pSupp0->nRefs > 0 && pSupp0->Delay < pSupp->DelayR ) // this leads to 2% worse results
{
pSupp0 = pTemp0;
pSupp0->nSize = 1;
pSupp0->pArray[0] = Ivy_ObjFaninId0(pObj);
}
// get the fanin support
if ( Ivy_ObjRefs(pFanin1) > 2 && pSupp1->Delay < pSupp->DelayR )
// if ( pSupp1->nRefs > 0 && pSupp1->Delay < pSupp->DelayR )
{
pSupp1 = pTemp1;
pSupp1->nSize = 1;
pSupp1->pArray[0] = Ivy_ObjFaninId1(pObj);
}
// merge the cuts
if ( pSupp0->nSize < pSupp1->nSize )
RetValue = Ivy_FastMapMerge( pSupp1, pSupp0, pSupp, nLimit );
else
RetValue = Ivy_FastMapMerge( pSupp0, pSupp1, pSupp, nLimit );
if ( !RetValue )
{
pSupp->nSize = 2;
pSupp->pArray[0] = Ivy_ObjFaninId0(pObj);
pSupp->pArray[1] = Ivy_ObjFaninId1(pObj);
}
// check the resulting delay
pSupp->Delay = Ivy_FastMapNodeDelay(pAig, pObj);
RefsOld = pSupp->nRefs; pSupp->nRefs = 0;
AreaAft = Ivy_FastMapNodeAreaDerefed( pAig, pObj );
pSupp->nRefs = RefsOld;
if ( AreaAft > AreaBef || pSupp->Delay > pSupp->DelayR )
// if ( pSupp->Delay > pSupp->DelayR )
{
pSupp->nSize = StoreSize;
memcpy( pSupp->pArray, Store, sizeof(int) * pSupp->nSize );
pSupp->Delay = DelayOld;
// printf( "-" );
}
// else
// printf( "+" );
if ( pSupp->nRefs != 0 )
Ivy_FastMapNodeRef( pAig, pObj );
}
/**Function*************************************************************
Synopsis [Performs fast mapping for one node.]
@ -286,6 +556,7 @@ int Ivy_FastMapArea( Ivy_Man_t * pAig )
void Ivy_FastMapNode( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit )
{
Ivy_Supp_t * pSupp0, * pSupp1, * pSupp;
int fFaninParam = 2;
int RetValue;
assert( Ivy_ObjIsNode(pObj) );
// get the supports
@ -316,9 +587,123 @@ void Ivy_FastMapNode( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit )
if ( !RetValue )
{
pSupp->Delay++;
pSupp->nSize = 2;
pSupp->pArray[0] = Ivy_ObjFaninId0(pObj);
pSupp->pArray[1] = Ivy_ObjFaninId1(pObj);
if ( fFaninParam == 2 )
{
pSupp->nSize = 2;
pSupp->pArray[0] = Ivy_ObjFaninId0(pObj);
pSupp->pArray[1] = Ivy_ObjFaninId1(pObj);
}
else if ( fFaninParam == 3 )
{
Ivy_Obj_t * pFanin0, * pFanin1, * pFaninA, * pFaninB;
pFanin0 = Ivy_ObjFanin0(pObj);
pFanin1 = Ivy_ObjFanin1(pObj);
pSupp->nSize = 0;
// process the first fanin
if ( Ivy_ObjIsNodeInt1(pFanin0) )
{
pFaninA = Ivy_ObjFanin0(pFanin0);
pFaninB = Ivy_ObjFanin1(pFanin0);
if ( Ivy_ObjIsNodeInt1(pFaninA) && Ivy_ObjIsNodeInt1(pFaninB) )
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin0);
else
{
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninA);
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninB);
}
}
else
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin0);
// process the second fanin
if ( Ivy_ObjIsNodeInt1(pFanin1) )
{
pFaninA = Ivy_ObjFanin0(pFanin1);
pFaninB = Ivy_ObjFanin1(pFanin1);
if ( Ivy_ObjIsNodeInt1(pFaninA) && Ivy_ObjIsNodeInt1(pFaninB) )
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin1);
else
{
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninA);
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninB);
}
}
else
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin1);
// sort the fanins
Vec_IntSelectSort( pSupp->pArray, pSupp->nSize );
pSupp->nSize = Vec_IntRemoveDup( pSupp->pArray, pSupp->nSize );
assert( pSupp->pArray[0] < pSupp->pArray[1] );
}
else if ( fFaninParam == 4 )
{
Ivy_Obj_t * pFanin0, * pFanin1, * pFaninA, * pFaninB;
pFanin0 = Ivy_ObjFanin0(pObj);
pFanin1 = Ivy_ObjFanin1(pObj);
pSupp->nSize = 0;
// consider the case when exactly one of them is internal
if ( Ivy_ObjIsNodeInt1(pFanin0) ^ Ivy_ObjIsNodeInt1(pFanin1) )
{
pSupp0 = Ivy_ObjSupp( pAig, Ivy_ObjFanin0(pObj) );
pSupp1 = Ivy_ObjSupp( pAig, Ivy_ObjFanin1(pObj) );
if ( Ivy_ObjIsNodeInt1(pFanin0) && pSupp0->nSize < nLimit )
{
pSupp->Delay = IVY_MAX( pSupp0->Delay, pSupp1->Delay + 1 );
pSupp1 = Ivy_ObjSupp( pAig, Ivy_ManConst1(pAig) );
pSupp1->pArray[0] = Ivy_ObjId(pFanin1);
// merge the cuts
RetValue = Ivy_FastMapMerge( pSupp0, pSupp1, pSupp, nLimit );
assert( RetValue );
assert( pSupp->nSize > 1 );
return;
}
if ( Ivy_ObjIsNodeInt1(pFanin1) && pSupp1->nSize < nLimit )
{
pSupp->Delay = IVY_MAX( pSupp1->Delay, pSupp0->Delay + 1 );
pSupp0 = Ivy_ObjSupp( pAig, Ivy_ManConst1(pAig) );
pSupp0->pArray[0] = Ivy_ObjId(pFanin0);
// merge the cuts
RetValue = Ivy_FastMapMerge( pSupp1, pSupp0, pSupp, nLimit );
assert( RetValue );
assert( pSupp->nSize > 1 );
return;
}
}
// process the first fanin
if ( Ivy_ObjIsNodeInt1(pFanin0) )
{
pFaninA = Ivy_ObjFanin0(pFanin0);
pFaninB = Ivy_ObjFanin1(pFanin0);
if ( Ivy_ObjIsNodeInt1(pFaninA) && Ivy_ObjIsNodeInt1(pFaninB) )
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin0);
else
{
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninA);
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninB);
}
}
else
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin0);
// process the second fanin
if ( Ivy_ObjIsNodeInt1(pFanin1) )
{
pFaninA = Ivy_ObjFanin0(pFanin1);
pFaninB = Ivy_ObjFanin1(pFanin1);
if ( Ivy_ObjIsNodeInt1(pFaninA) && Ivy_ObjIsNodeInt1(pFaninB) )
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin1);
else
{
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninA);
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFaninB);
}
}
else
pSupp->pArray[pSupp->nSize++] = Ivy_ObjId(pFanin1);
// sort the fanins
Vec_IntSelectSort( pSupp->pArray, pSupp->nSize );
pSupp->nSize = Vec_IntRemoveDup( pSupp->pArray, pSupp->nSize );
assert( pSupp->pArray[0] < pSupp->pArray[1] );
assert( pSupp->nSize > 1 );
}
}
assert( pSupp->Delay > 0 );
}
@ -429,6 +814,29 @@ void Ivy_FastMapReadSupp( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, Vec_Int_t * vLeave
vLeaves->pArray = pSupp->pArray;
}
/**Function*************************************************************
Synopsis [Sets the required times of the intermediate nodes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ivy_FastMapRequired_rec( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, Ivy_Obj_t * pRoot, int DelayR )
{
Ivy_Supp_t * pSupp;
pSupp = Ivy_ObjSupp( pAig, pObj );
if ( pObj != pRoot && (pSupp->nRefs > 0 || Ivy_ObjIsCi(pObj)) )
return;
Ivy_FastMapRequired_rec( pAig, Ivy_ObjFanin0(pObj), pRoot, DelayR );
Ivy_FastMapRequired_rec( pAig, Ivy_ObjFanin1(pObj), pRoot, DelayR );
// assert( pObj == pRoot || pSupp->DelayR == IVY_INFINITY );
pSupp->DelayR = DelayR;
}
/**Function*************************************************************
Synopsis [Computes the required times for each node.]
@ -440,7 +848,7 @@ void Ivy_FastMapReadSupp( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, Vec_Int_t * vLeave
SeeAlso []
***********************************************************************/
void Ivy_FastMapRequired( Ivy_Man_t * pAig, int Delay )
void Ivy_FastMapRequired( Ivy_Man_t * pAig, int Delay, int fSetInter )
{
Vec_Vec_t * vLuts;
Vec_Ptr_t * vNodes;
@ -491,6 +899,23 @@ void Ivy_FastMapRequired( Ivy_Man_t * pAig, int Delay )
}
printf( "\n" );
*/
if ( fSetInter )
{
// set the required times of the intermediate nodes
Vec_VecForEachLevelReverse( vLuts, vNodes, i )
Vec_PtrForEachEntry( vNodes, pObj, k )
{
pSupp = Ivy_ObjSupp( pAig, pObj );
Ivy_FastMapRequired_rec( pAig, pObj, pObj, pSupp->DelayR );
}
// make sure that all required times are assigned
Ivy_ManForEachNode( pAig, pObj, i )
{
pSupp = Ivy_ObjSupp( pAig, pObj );
assert( pSupp->DelayR < IVY_INFINITY );
}
}
}
/**Function*************************************************************
@ -688,7 +1113,7 @@ int Ivy_FastMapCutCost( Ivy_Man_t * pAig, Vec_Ptr_t * vFront )
Vec_PtrForEachEntry( vFront, pFanin, i )
{
pSuppF = Ivy_ObjSupp( pAig, pFanin );
if ( pSuppF->nRefs == 1 )
if ( pSuppF->nRefs == 0 )
Counter++;
}
return Counter;
@ -754,17 +1179,17 @@ int Ivy_FastMapNodeFaninCost( Ivy_Man_t * pAig, Ivy_Obj_t * pObj )
assert( Ivy_ObjIsNode(pObj) );
// check if the node has external refs
pSuppF = Ivy_ObjSupp( pAig, pObj );
if ( pSuppF->nRefs == 1 )
if ( pSuppF->nRefs == 0 )
Counter--;
// increment the number of fanins without external refs
pFanin = Ivy_ObjFanin0(pObj);
pSuppF = Ivy_ObjSupp( pAig, pFanin );
if ( !Ivy_ObjIsTravIdCurrent(pAig, pFanin) && pSuppF->nRefs == 1 )
if ( !Ivy_ObjIsTravIdCurrent(pAig, pFanin) && pSuppF->nRefs == 0 )
Counter++;
// increment the number of fanins without external refs
pFanin = Ivy_ObjFanin1(pObj);
pSuppF = Ivy_ObjSupp( pAig, pFanin );
if ( !Ivy_ObjIsTravIdCurrent(pAig, pFanin) && pSuppF->nRefs == 1 )
if ( !Ivy_ObjIsTravIdCurrent(pAig, pFanin) && pSuppF->nRefs == 0 )
Counter++;
return Counter;
}
@ -1055,13 +1480,79 @@ void Ivy_FastMapNodeRecover( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec
Ivy_Supp_t * pSupp;
int CostBef, CostAft;
int AreaBef, AreaAft;
int DelayOld;
pSupp = Ivy_ObjSupp( pAig, pObj );
DelayOld = pSupp->Delay = Ivy_FastMapNodeDelay( pAig, pObj );
assert( pSupp->Delay <= pSupp->DelayR );
if ( pSupp->nRefs == 0 )
return;
// get the area
AreaBef = Ivy_FastMapNodeAreaRefed( pAig, pObj );
// if ( AreaBef == 1 )
// return;
if ( pObj->Id == 102 )
{
int x = 0;
}
// the cut is non-trivial
Ivy_FastMapNodePrepare( pAig, pObj, nLimit, vFront, vFrontOld );
// iteratively modify the cut
Ivy_FastMapNodeDeref( pAig, pObj );
CostBef = Ivy_FastMapCutCost( pAig, vFront );
Ivy_FastMapNodeFaninCompact( pAig, pObj, nLimit, vFront );
CostAft = Ivy_FastMapCutCost( pAig, vFront );
Ivy_FastMapNodeRef( pAig, pObj );
assert( CostBef >= CostAft );
// update the node
Ivy_FastMapNodeUpdate( pAig, pObj, vFront );
pSupp->Delay = Ivy_FastMapNodeDelay( pAig, pObj );
// get the new area
AreaAft = Ivy_FastMapNodeAreaRefed( pAig, pObj );
if ( AreaAft > AreaBef || pSupp->Delay > pSupp->DelayR )
{
Ivy_FastMapNodeUpdate( pAig, pObj, vFrontOld );
AreaAft = Ivy_FastMapNodeAreaRefed( pAig, pObj );
assert( AreaAft == AreaBef );
pSupp->Delay = DelayOld;
}
}
/**Function*************************************************************
Synopsis [Performs area recovery for each node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Ivy_FastMapNodeRecover4( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront, Vec_Ptr_t * vFrontOld )
{
Ivy_Supp_t * pSupp;
int CostBef, CostAft;
int AreaBef, AreaAft;
int DelayOld;
pSupp = Ivy_ObjSupp( pAig, pObj );
DelayOld = pSupp->Delay = Ivy_FastMapNodeDelay( pAig, pObj );
assert( pSupp->Delay <= pSupp->DelayR );
// if ( pSupp->nRefs == 0 )
// return;
// AreaBef = Ivy_FastMapNodeAreaRefed( pAig, pObj );
// get the area
if ( pSupp->nRefs == 0 )
AreaBef = Ivy_FastMapNodeAreaDerefed( pAig, pObj );
else
AreaBef = Ivy_FastMapNodeAreaRefed( pAig, pObj );
if ( AreaBef == 1 )
return;
if ( pSupp->nRefs == 0 )
{
pSupp->nRefs = 1000000;
Ivy_FastMapNodeRef( pAig, pObj );
}
// the cut is non-trivial
Ivy_FastMapNodePrepare( pAig, pObj, nLimit, vFront, vFrontOld );
// iteratively modify the cut
@ -1071,13 +1562,20 @@ void Ivy_FastMapNodeRecover( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Vec
assert( CostBef >= CostAft );
// update the node
Ivy_FastMapNodeUpdate( pAig, pObj, vFront );
pSupp->Delay = Ivy_FastMapNodeDelay( pAig, pObj );
// get the new area
AreaAft = Ivy_FastMapNodeAreaRefed( pAig, pObj );
if ( AreaAft > AreaBef )
if ( AreaAft > AreaBef || pSupp->Delay > pSupp->DelayR )
{
Ivy_FastMapNodeUpdate( pAig, pObj, vFrontOld );
AreaAft = Ivy_FastMapNodeAreaRefed( pAig, pObj );
assert( AreaAft == AreaBef );
pSupp->Delay = DelayOld;
}
if ( pSupp->nRefs == 1000000 )
{
pSupp->nRefs = 0;
Ivy_FastMapNodeDeref( pAig, pObj );
}
}

1445
src/temp/ivy/ivyFraig.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -58,7 +58,7 @@ Ivy_Man_t * Ivy_ManStart()
Ivy_ManStartMemory( p );
// create the constant node
p->pConst1 = Ivy_ManFetchMemory( p );
// p->pConst1->fPhase = 1;
p->pConst1->fPhase = 1;
Vec_PtrPush( p->vObjs, p->pConst1 );
p->nCreated = 1;
// start the table
@ -68,6 +68,31 @@ Ivy_Man_t * Ivy_ManStart()
return p;
}
/**Function*************************************************************
Synopsis [Duplicates the AIG manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ivy_Man_t * Ivy_ManStartFrom( Ivy_Man_t * p )
{
Ivy_Man_t * pNew;
Ivy_Obj_t * pObj;
int i;
// create the new manager
pNew = Ivy_ManStart();
// create the PIs
Ivy_ManConst1(p)->pEquiv = Ivy_ManConst1(pNew);
Ivy_ManForEachPi( p, pObj, i )
pObj->pEquiv = Ivy_ObjCreatePi(pNew);
return pNew;
}
/**Function*************************************************************
Synopsis [Duplicates the AIG manager.]

View File

@ -96,6 +96,14 @@ Ivy_Obj_t * Ivy_ObjCreate( Ivy_Man_t * p, Ivy_Obj_t * pGhost )
pObj->Level = Ivy_ObjFanin0(pObj)->Level;
else if ( !Ivy_ObjIsPi(pObj) )
assert( 0 );
// create phase
if ( Ivy_ObjIsNode(pObj) )
pObj->fPhase = Ivy_ObjFaninPhase(Ivy_ObjChild0(pObj)) & Ivy_ObjFaninPhase(Ivy_ObjChild1(pObj));
else if ( Ivy_ObjIsOneFanin(pObj) )
pObj->fPhase = Ivy_ObjFaninPhase(Ivy_ObjChild0(pObj));
// set the fail TFO flag
if ( Ivy_ObjIsNode(pObj) )
pObj->fFailTfo = Ivy_ObjFanin0(pObj)->fFailTfo | Ivy_ObjFanin1(pObj)->fFailTfo;
// mark the fanins in a special way if the node is EXOR
if ( Ivy_ObjIsExor(pObj) )
{

View File

@ -24,7 +24,7 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig );
static void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig, Vec_Ptr_t * vBold );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@ -41,7 +41,7 @@ static void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig );
SeeAlso []
***********************************************************************/
void Ivy_ManShow( Ivy_Man_t * pMan, int fHaig )
void Ivy_ManShow( Ivy_Man_t * pMan, int fHaig, Vec_Ptr_t * vBold )
{
extern void Abc_ShowFile( char * FileNameDot );
static Counter = 0;
@ -58,7 +58,7 @@ void Ivy_ManShow( Ivy_Man_t * pMan, int fHaig )
}
fclose( pFile );
// generate the file
Ivy_WriteDotAig( pMan, FileNameDot, fHaig );
Ivy_WriteDotAig( pMan, FileNameDot, fHaig, vBold );
// visualize the file
Abc_ShowFile( FileNameDot );
}
@ -75,7 +75,7 @@ void Ivy_ManShow( Ivy_Man_t * pMan, int fHaig )
SeeAlso []
***********************************************************************/
void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig )
void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig, Vec_Ptr_t * vBold )
{
FILE * pFile;
Ivy_Obj_t * pNode, * pTemp, * pPrev;
@ -92,6 +92,11 @@ void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig )
return;
}
// mark the nodes
if ( vBold )
Vec_PtrForEachEntry( vBold, pNode, i )
pNode->fMarkB = 1;
// compute levels
LevelMax = 1 + Ivy_ManSetLevels( pMan, fHaig );
@ -218,6 +223,8 @@ void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig )
fprintf( pFile, " Node%d [label = \"%d(%d%s)\"", pNode->Id, pNode->Id,
Ivy_Regular(pNode->pEquiv)->Id, Ivy_IsComplement(pNode->pEquiv)? "\'":"" );
fprintf( pFile, ", shape = ellipse" );
if ( vBold && pNode->fMarkB )
fprintf( pFile, ", style = filled" );
fprintf( pFile, "];\n" );
}
fprintf( pFile, "}" );
@ -316,6 +323,11 @@ void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig )
fprintf( pFile, "\n" );
fprintf( pFile, "\n" );
fclose( pFile );
// unmark nodes
if ( vBold )
Vec_PtrForEachEntry( vBold, pNode, i )
pNode->fMarkB = 0;
}

1194
src/temp/ivy/satSolver.c Normal file

File diff suppressed because it is too large Load Diff

141
src/temp/ivy/satSolver.h Normal file
View File

@ -0,0 +1,141 @@
/**************************************************************************************************
MiniSat -- Copyright (c) 2005, Niklas Sorensson
http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************************************/
// Modified to compile with MS Visual Studio 6.0 by Alan Mishchenko
#ifndef satSolver_h
#define satSolver_h
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
#endif
#include "satVec.h"
//=================================================================================================
// Simple types:
// does not work for c++
typedef int bool;
static const bool true = 1;
static const bool false = 0;
typedef int lit;
typedef char lbool;
#ifdef _WIN32
typedef signed __int64 sint64; // compatible with MS VS 6.0
#else
typedef long long sint64;
#endif
static const int var_Undef = -1;
static const lit lit_Undef = -2;
static const lbool l_Undef = 0;
static const lbool l_True = 1;
static const lbool l_False = -1;
static inline lit toLit (int v) { return v + v; }
static inline lit toLitCond(int v, int c) { return v + v + (c != 0); }
static inline lit lit_neg (lit l) { return l ^ 1; }
static inline int lit_var (lit l) { return l >> 1; }
static inline int lit_sign (lit l) { return l & 1; }
//=================================================================================================
// Public interface:
struct sat_solver_t;
typedef struct sat_solver_t sat_solver;
extern sat_solver* sat_solver_new(void);
extern void sat_solver_delete(sat_solver* s);
extern bool sat_solver_addclause(sat_solver* s, lit* begin, lit* end);
extern bool sat_solver_simplify(sat_solver* s);
extern int sat_solver_solve(sat_solver* s, lit* begin, lit* end);
extern int sat_solver_nvars(sat_solver* s);
extern int sat_solver_nclauses(sat_solver* s);
extern int sat_solver_nconflicts(sat_solver* s);
extern void sat_solver_setnvars(sat_solver* s,int n);
struct stats_t
{
sint64 starts, decisions, propagations, inspects, conflicts;
sint64 clauses, clauses_literals, learnts, learnts_literals, max_literals, tot_literals;
};
typedef struct stats_t stats;
extern void Sat_SolverWriteDimacs( sat_solver * p, char * pFileName, lit* assumptionsBegin, lit* assumptionsEnd, int incrementVars );
extern void Sat_SolverPrintStats( FILE * pFile, sat_solver * p );
//=================================================================================================
// Solver representation:
struct clause_t;
typedef struct clause_t clause;
struct sat_solver_t
{
int size; // nof variables
int cap; // size of varmaps
int qhead; // Head index of queue.
int qtail; // Tail index of queue.
// clauses
vecp clauses; // List of problem constraints. (contains: clause*)
vecp learnts; // List of learnt clauses. (contains: clause*)
// activities
double var_inc; // Amount to bump next variable with.
double var_decay; // INVERSE decay factor for variable activity: stores 1/decay.
float cla_inc; // Amount to bump next clause with.
float cla_decay; // INVERSE decay factor for clause activity: stores 1/decay.
vecp* wlists; //
double* activity; // A heuristic measurement of the activity of a variable.
lbool* assigns; // Current values of variables.
int* orderpos; // Index in variable order.
clause** reasons; //
int* levels; //
lit* trail;
clause* binary; // A temporary binary clause
lbool* tags; //
veci tagged; // (contains: var)
veci stack; // (contains: var)
veci order; // Variable order. (heap) (contains: var)
veci trail_lim; // Separator indices for different decision levels in 'trail'. (contains: int)
veci model; // If problem is solved, this vector contains the model (contains: lbool).
int root_level; // Level of first proper decision.
int simpdb_assigns;// Number of top-level assignments at last 'simplifyDB()'.
int simpdb_props; // Number of propagations before next 'simplifyDB()'.
double random_seed;
double progress_estimate;
int verbosity; // Verbosity level. 0=silent, 1=some progress report, 2=everything
stats stats;
};
#endif

161
src/temp/ivy/satUtil.c Normal file
View File

@ -0,0 +1,161 @@
/**CFile****************************************************************
FileName [satUtil.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [C-language MiniSat solver.]
Synopsis [Additional SAT solver procedures.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: satUtil.c,v 1.4 2005/09/16 22:55:03 casem Exp $]
***********************************************************************/
#include <stdio.h>
#include <assert.h>
#include "satSolver.h"
#include "extra.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
struct clause_t
{
int size_learnt;
lit lits[0];
};
static inline int clause_size( clause* c ) { return c->size_learnt >> 1; }
static inline lit* clause_begin( clause* c ) { return c->lits; }
static void Sat_SolverClauseWriteDimacs( FILE * pFile, clause * pC, bool fIncrement );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Write the clauses in the solver into a file in DIMACS format.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Sat_SolverWriteDimacs( sat_solver * p, char * pFileName, lit* assumptionsBegin, lit* assumptionsEnd, int incrementVars )
{
FILE * pFile;
void ** pClauses;
int nClauses, i;
// count the number of clauses
nClauses = p->clauses.size + p->learnts.size;
for ( i = 0; i < p->size; i++ )
if ( p->levels[i] == 0 && p->assigns[i] != l_Undef )
nClauses++;
// start the file
pFile = fopen( pFileName, "wb" );
if ( pFile == NULL )
{
printf( "Sat_SolverWriteDimacs(): Cannot open the ouput file.\n" );
return;
}
fprintf( pFile, "c CNF generated by ABC on %s\n", Extra_TimeStamp() );
fprintf( pFile, "p cnf %d %d\n", p->size, nClauses );
// write the original clauses
nClauses = p->clauses.size;
pClauses = p->clauses.ptr;
for ( i = 0; i < nClauses; i++ )
Sat_SolverClauseWriteDimacs( pFile, pClauses[i], incrementVars );
// write the learned clauses
nClauses = p->learnts.size;
pClauses = p->learnts.ptr;
for ( i = 0; i < nClauses; i++ )
Sat_SolverClauseWriteDimacs( pFile, pClauses[i], incrementVars );
// write zero-level assertions
for ( i = 0; i < p->size; i++ )
if ( p->levels[i] == 0 && p->assigns[i] != l_Undef )
fprintf( pFile, "%s%d%s\n",
(p->assigns[i] == l_False)? "-": "",
i + (int)(incrementVars>0),
(incrementVars) ? " 0" : "");
// write the assumptions
if (assumptionsBegin) {
for (; assumptionsBegin != assumptionsEnd; assumptionsBegin++) {
fprintf( pFile, "%s%d%s\n",
lit_sign(*assumptionsBegin)? "-": "",
lit_var(*assumptionsBegin) + (int)(incrementVars>0),
(incrementVars) ? " 0" : "");
}
}
fprintf( pFile, "\n" );
fclose( pFile );
}
/**Function*************************************************************
Synopsis [Writes the given clause in a file in DIMACS format.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Sat_SolverClauseWriteDimacs( FILE * pFile, clause * pC, bool fIncrement )
{
lit * pLits = clause_begin(pC);
int nLits = clause_size(pC);
int i;
for ( i = 0; i < nLits; i++ )
fprintf( pFile, "%s%d ", (lit_sign(pLits[i])? "-": ""), lit_var(pLits[i]) + (int)(fIncrement>0) );
if ( fIncrement )
fprintf( pFile, "0" );
fprintf( pFile, "\n" );
}
/**Function*************************************************************
Synopsis [Writes the given clause in a file in DIMACS format.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Sat_SolverPrintStats( FILE * pFile, sat_solver * p )
{
printf( "starts : %d\n", (int)p->stats.starts );
printf( "conflicts : %d\n", (int)p->stats.conflicts );
printf( "decisions : %d\n", (int)p->stats.decisions );
printf( "propagations : %d\n", (int)p->stats.propagations );
printf( "inspects : %d\n", (int)p->stats.inspects );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////

83
src/temp/ivy/satVec.h Normal file
View File

@ -0,0 +1,83 @@
/**************************************************************************************************
MiniSat -- Copyright (c) 2005, Niklas Sorensson
http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************************************/
// Modified to compile with MS Visual Studio 6.0 by Alan Mishchenko
#ifndef satVec_h
#define satVec_h
#include <stdlib.h>
// vector of 32-bit intergers (added for 64-bit portability)
struct veci_t {
int size;
int cap;
int* ptr;
};
typedef struct veci_t veci;
static inline void veci_new (veci* v) {
v->size = 0;
v->cap = 4;
v->ptr = (int*)malloc(sizeof(int)*v->cap);
}
static inline void veci_delete (veci* v) { free(v->ptr); }
static inline int* veci_begin (veci* v) { return v->ptr; }
static inline int veci_size (veci* v) { return v->size; }
static inline void veci_resize (veci* v, int k) { v->size = k; } // only safe to shrink !!
static inline void veci_push (veci* v, int e)
{
if (v->size == v->cap) {
int newsize = v->cap * 2+1;
v->ptr = (int*)realloc(v->ptr,sizeof(int)*newsize);
v->cap = newsize; }
v->ptr[v->size++] = e;
}
// vector of 32- or 64-bit pointers
struct vecp_t {
int size;
int cap;
void** ptr;
};
typedef struct vecp_t vecp;
static inline void vecp_new (vecp* v) {
v->size = 0;
v->cap = 4;
v->ptr = (void**)malloc(sizeof(void*)*v->cap);
}
static inline void vecp_delete (vecp* v) { free(v->ptr); }
static inline void** vecp_begin (vecp* v) { return v->ptr; }
static inline int vecp_size (vecp* v) { return v->size; }
static inline void vecp_resize (vecp* v, int k) { v->size = k; } // only safe to shrink !!
static inline void vecp_push (vecp* v, void* e)
{
if (v->size == v->cap) {
int newsize = v->cap * 2+1;
v->ptr = (void**)realloc(v->ptr,sizeof(void*)*newsize);
v->cap = newsize; }
v->ptr[v->size++] = e;
}
#endif

View File

@ -91,6 +91,7 @@ void * Abc_NtkPlayer( void * pNtk, int nLutMax, int nPlaMax, int RankCost, int f
Ivy_FastMapPerform( pMan, nLutMax );
// convert from the extended AIG manager into an SOP network
pNtkNew = Ivy_ManToAbc( pNtk, pMan, NULL, fFastMode );
// pNtkNew = NULL;
Ivy_FastMapStop( pMan );
}
else
@ -104,7 +105,7 @@ void * Abc_NtkPlayer( void * pNtk, int nLutMax, int nPlaMax, int RankCost, int f
}
Ivy_ManStop( pMan );
// chech the resulting network
if ( !Abc_NtkCheck( pNtkNew ) )
if ( pNtkNew && !Abc_NtkCheck( pNtkNew ) )
{
printf( "Abc_NtkPlayer: The network check has failed.\n" );
Abc_NtkDelete( pNtkNew );