Commit eb2a5b43 by Alan Mishchenko

Version abc60812

parent 6b44b18e
......@@ -2102,6 +2102,10 @@ SOURCE=.\src\temp\ivy\ivyCut.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\ivyCutTrav.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\ivyDfs.c
# End Source File
# Begin Source File
......@@ -2114,6 +2118,10 @@ SOURCE=.\src\temp\ivy\ivyFanout.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\ivyHaig.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\ivy\ivyIsop.c
# End Source File
# Begin Source File
......@@ -2205,50 +2213,6 @@ SOURCE=.\src\temp\esop\esopMin.c
SOURCE=.\src\temp\esop\esopUtil.c
# End Source File
# End Group
# Begin Group "xyz"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\temp\xyz\xyz.h
# End Source File
# Begin Source File
SOURCE=.\src\temp\xyz\xyzBuild.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\xyz\xyzCore.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\xyz\xyzInt.h
# End Source File
# Begin Source File
SOURCE=.\src\temp\xyz\xyzMan.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\xyz\xyzMinEsop.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\xyz\xyzMinMan.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\xyz\xyzMinSop.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\xyz\xyzMinUtil.c
# End Source File
# Begin Source File
SOURCE=.\src\temp\xyz\xyzTest.c
# End Source File
# End Group
# Begin Group "rwt"
# PROP Default_Filter ""
......
......@@ -3,7 +3,8 @@
#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 savesteps 1 # sets the maximum number of backup networks to save
set progressbar # display the progress bar
# program names for internal calls
set dotwin dot.exe
......
......@@ -93,6 +93,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_CommandHaig ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandFraig ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandFraigTrust ( Abc_Frame_t * pAbc, int argc, char ** argv );
......@@ -210,6 +211,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", "haig", Abc_CommandHaig, 1 );
Cmd_CommandAdd( pAbc, "Fraiging", "fraig", Abc_CommandFraig, 1 );
Cmd_CommandAdd( pAbc, "Fraiging", "fraig_trust", Abc_CommandFraigTrust, 1 );
......@@ -5088,6 +5090,75 @@ usage:
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandHaig( 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_NtkIvyHaig( Abc_Ntk_t * pNtk, int fVerbose );
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, "zvh" ) ) != EOF )
{
switch ( c )
{
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_NtkIvyHaig( pNtk, fVerbose );
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: haig [-vh]\n" );
fprintf( pErr, "\t prints HAIG stats after one round of sequential rewriting\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*************************************************************
......
......@@ -179,6 +179,36 @@ Abc_Ntk_t * Abc_NtkIvyStrash( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkIvyHaig( Abc_Ntk_t * pNtk, int fVerbose )
{
Abc_Ntk_t * pNtkAig;
Ivy_Man_t * pMan;
pMan = Abc_NtkIvyBefore( pNtk, 1, 1 );
if ( pMan == NULL )
return NULL;
Ivy_ManHaigStart( pMan );
Ivy_ManRewriteSeq( pMan, 0, fVerbose );
Ivy_ManHaigPrintStats( pMan );
Ivy_ManHaigStop( pMan );
// pNtkAig = Abc_NtkIvyAfterHaig( pNtk, pMan, 1 );
pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 1 );
Ivy_ManStop( pMan );
return pNtkAig;
}
/**Function*************************************************************
Synopsis [Gives the current ABC network to AIG manager for processing.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkIvyCuts( Abc_Ntk_t * pNtk, int nInputs )
{
extern void Ivy_CutComputeAll( Ivy_Man_t * p, int nInputs );
......@@ -276,10 +306,10 @@ Abc_Ntk_t * Abc_NtkIvyResyn( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose )
***********************************************************************/
Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk )
{
Abc_Ntk_t * pNtkAig;
// Abc_Ntk_t * pNtkAig;
Ivy_Man_t * pMan;//, * pTemp;
int fCleanup = 1;
int nNodes;
// int nNodes;
int nLatches = Abc_NtkLatchNum(pNtk);
int * pInit = Abc_NtkCollectLatchValues( pNtk, 0 );
......@@ -329,6 +359,7 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk )
// Ivy_ManStop( pTemp );
// Ivy_ManTestCutsAll( pMan );
// Ivy_ManTestCutsTravAll( pMan );
// Ivy_ManPrintStats( pMan );
......@@ -344,7 +375,7 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk )
// Ivy_ManRequiredLevels( pMan );
// Pla_ManFastLutMap( pMan, 8 );
// Ivy_ManStop( pMan );
Ivy_ManStop( pMan );
return NULL;
......
......@@ -148,7 +148,6 @@ Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk )
void Abc_NtkBddToMuxesPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
{
ProgressBar * pProgress;
DdManager * dd = pNtk->pManFunc;
Abc_Obj_t * pNode, * pNodeNew;
Vec_Ptr_t * vNodes;
int i;
......
......@@ -111,7 +111,6 @@ Abc_Frame_t * Abc_FrameAllocate()
// set the starting step
p->nSteps = 1;
p->fBatchMode = 0;
p->fProgress = 1;
// initialize decomposition manager
define_cube_size(20);
set_espresso_flags();
......@@ -176,7 +175,7 @@ void Abc_FrameRestart( Abc_Frame_t * p )
***********************************************************************/
bool Abc_FrameShowProgress( Abc_Frame_t * p )
{
return p->fProgress;
return Abc_FrameIsFlagEnabled( "progressbar" );
}
......
......@@ -55,7 +55,6 @@ struct Abc_Frame_t_
int nSteps; // the counter of different network processed
int fAutoexac; // marks the autoexec mode
int fBatchMode; // are we invoked in batch mode?
int fProgress; // shows progress bars
// output streams
FILE * Out;
FILE * Err;
......
......@@ -27,6 +27,8 @@ extern "C" {
#include <stdlib.h>
#include "extra.h"
//#pragma warning( disable : 4514 )
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
......@@ -91,9 +93,9 @@ struct _reo_plane
struct _reo_hash
{
int Sign; // signature of the current cache operation
unsigned Arg1; // the first argument
unsigned Arg2; // the second argument
unsigned Arg3; // the second argument
reo_unit * Arg1; // the first argument
reo_unit * Arg2; // the second argument
reo_unit * Arg3; // the third argument
};
struct _reo_man
......
......@@ -330,7 +330,7 @@ void reoProfileWidthPrint( reo_man * p )
WidthMax = p->pPlanes[i].statsWidth;
TotalWidth += p->pPlanes[i].statsWidth;
}
assert( p->nWidthCur = TotalWidth );
assert( p->nWidthCur == TotalWidth );
printf( "WIDTH: " );
printf( "Maximum = %5d. ", WidthMax );
printf( "Total = %7d. ", p->nWidthCur );
......
......@@ -271,9 +271,9 @@ double reoReorderSwapAdjacentVars( reo_man * p, int lev0, int fMovingUp )
HKey = (HKey+1) % p->nTableSize );
assert( p->HTable[HKey].Sign != p->Signature );
p->HTable[HKey].Sign = p->Signature;
p->HTable[HKey].Arg1 = (unsigned)pUnitE;
p->HTable[HKey].Arg2 = (unsigned)pUnitT;
p->HTable[HKey].Arg3 = (unsigned)pUnit;
p->HTable[HKey].Arg1 = pUnitE;
p->HTable[HKey].Arg2 = pUnitT;
p->HTable[HKey].Arg3 = pUnit;
nNodesUpMovedDown++;
......@@ -512,10 +512,10 @@ double reoReorderSwapAdjacentVars( reo_man * p, int lev0, int fMovingUp )
for ( HKey = hashKey3(p->Signature, pNew1E, pNew1T, p->nTableSize);
p->HTable[HKey].Sign == p->Signature;
HKey = (HKey+1) % p->nTableSize )
if ( p->HTable[HKey].Arg1 == (unsigned)pNew1E && p->HTable[HKey].Arg2 == (unsigned)pNew1T )
if ( p->HTable[HKey].Arg1 == pNew1E && p->HTable[HKey].Arg2 == pNew1T )
{ // the entry is present
// assign this entry
pNewPlane20 = (reo_unit *)p->HTable[HKey].Arg3;
pNewPlane20 = p->HTable[HKey].Arg3;
assert( pNewPlane20->lev == lev1 );
fFound = 1;
p->HashSuccess++;
......@@ -549,9 +549,9 @@ double reoReorderSwapAdjacentVars( reo_man * p, int lev0, int fMovingUp )
// add this entry to cache
assert( p->HTable[HKey].Sign != p->Signature );
p->HTable[HKey].Sign = p->Signature;
p->HTable[HKey].Arg1 = (unsigned)pNew1E;
p->HTable[HKey].Arg2 = (unsigned)pNew1T;
p->HTable[HKey].Arg3 = (unsigned)pNewPlane20;
p->HTable[HKey].Arg1 = pNew1E;
p->HTable[HKey].Arg2 = pNew1T;
p->HTable[HKey].Arg3 = pNewPlane20;
nNodesUnrefAdded++;
......@@ -637,10 +637,10 @@ double reoReorderSwapAdjacentVars( reo_man * p, int lev0, int fMovingUp )
for ( HKey = hashKey3(p->Signature, pNew2E, pNew2T, p->nTableSize);
p->HTable[HKey].Sign == p->Signature;
HKey = (HKey+1) % p->nTableSize )
if ( p->HTable[HKey].Arg1 == (unsigned)pNew2E && p->HTable[HKey].Arg2 == (unsigned)pNew2T )
if ( p->HTable[HKey].Arg1 == pNew2E && p->HTable[HKey].Arg2 == pNew2T )
{ // the entry is present
// assign this entry
pNewPlane21 = (reo_unit *)p->HTable[HKey].Arg3;
pNewPlane21 = p->HTable[HKey].Arg3;
assert( pNewPlane21->lev == lev1 );
fFound = 1;
p->HashSuccess++;
......@@ -675,9 +675,9 @@ double reoReorderSwapAdjacentVars( reo_man * p, int lev0, int fMovingUp )
// add this entry to cache
assert( p->HTable[HKey].Sign != p->Signature );
p->HTable[HKey].Sign = p->Signature;
p->HTable[HKey].Arg1 = (unsigned)pNew2E;
p->HTable[HKey].Arg2 = (unsigned)pNew2T;
p->HTable[HKey].Arg3 = (unsigned)pNewPlane21;
p->HTable[HKey].Arg1 = pNew2E;
p->HTable[HKey].Arg2 = pNew2T;
p->HTable[HKey].Arg3 = pNewPlane21;
nNodesUnrefAdded++;
......
......@@ -51,9 +51,9 @@ reo_unit * reoTransferNodesToUnits_rec( reo_man * p, DdNode * F )
{
// search cache - use linear probing
for ( HKey = hashKey2(p->Signature,F,p->nTableSize); p->HTable[HKey].Sign == p->Signature; HKey = (HKey+1) % p->nTableSize )
if ( p->HTable[HKey].Arg1 == (unsigned)F )
if ( p->HTable[HKey].Arg1 == (reo_unit *)F )
{
pUnit = (reo_unit*) p->HTable[HKey].Arg2;
pUnit = p->HTable[HKey].Arg2;
assert( pUnit );
// increment the edge counter
pUnit->n++;
......@@ -93,8 +93,8 @@ reo_unit * reoTransferNodesToUnits_rec( reo_man * p, DdNode * F )
// might have been used. Make sure that its signature is different.
for ( ; p->HTable[HKey].Sign == p->Signature; HKey = (HKey+1) % p->nTableSize );
p->HTable[HKey].Sign = p->Signature;
p->HTable[HKey].Arg1 = (unsigned)F;
p->HTable[HKey].Arg2 = (unsigned)pUnit;
p->HTable[HKey].Arg1 = (reo_unit *)F;
p->HTable[HKey].Arg2 = pUnit;
}
// increment the counter of nodes
......@@ -126,7 +126,7 @@ DdNode * reoTransferUnitsToNodes_rec( reo_man * p, reo_unit * pUnit )
if ( pUnit->n != 1 )
{
for ( HKey = hashKey2(p->Signature,pUnit,p->nTableSize); p->HTable[HKey].Sign == p->Signature; HKey = (HKey+1) % p->nTableSize )
if ( p->HTable[HKey].Arg1 == (unsigned)pUnit )
if ( p->HTable[HKey].Arg1 == pUnit )
{
bRes = (DdNode*) p->HTable[HKey].Arg2;
assert( bRes );
......@@ -179,8 +179,8 @@ DdNode * reoTransferUnitsToNodes_rec( reo_man * p, reo_unit * pUnit )
// might have been used. Make sure that its signature is different.
for ( ; p->HTable[HKey].Sign == p->Signature; HKey = (HKey+1) % p->nTableSize );
p->HTable[HKey].Sign = p->Signature;
p->HTable[HKey].Arg1 = (unsigned)pUnit;
p->HTable[HKey].Arg2 = (unsigned)bRes;
p->HTable[HKey].Arg1 = pUnit;
p->HTable[HKey].Arg2 = (reo_unit *)bRes;
// add the DD to the referenced DD list in order to be able to store it in cache
p->pRefNodes[p->nRefNodes++] = bRes; Cudd_Ref( bRes );
......
......@@ -341,7 +341,7 @@ extern int Extra_MmStepReadMemUsage( Extra_MmStep_t * p );
/*=== extraUtilMisc.c ========================================================*/
/* finds the smallest integer larger of equal than the logarithm. */
/* finds the smallest integer larger or equal than the logarithm */
extern int Extra_Base2Log( unsigned Num );
extern int Extra_Base2LogDouble( double Num );
extern int Extra_Base10Log( unsigned Num );
......@@ -400,7 +400,15 @@ static inline void Extra_ProgressBarUpdate( ProgressBar * p, int nItemsCur, char
/*=== extraUtilTruth.c ================================================================*/
static inline int Extra_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
static inline int Extra_Float2Int( float Val ) { return *((int *)&Val); }
static inline float Extra_Int2Float( int Num ) { return *((float *)&Num); }
static inline int Extra_BitWordNum( int nBits ) { return nBits/(8*sizeof(unsigned)) + ((nBits%(8*sizeof(unsigned))) > 0); }
static inline int Extra_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
static inline void Extra_TruthSetBit( unsigned * p, int Bit ) { p[Bit>>5] |= (1<<(Bit & 31)); }
static inline void Extra_TruthXorBit( unsigned * p, int Bit ) { p[Bit>>5] ^= (1<<(Bit & 31)); }
static inline int Extra_TruthHasBit( unsigned * p, int Bit ) { return (p[Bit>>5] & (1<<(Bit & 31))) > 0; }
static inline int Extra_WordCountOnes( unsigned uWord )
{
uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555);
......@@ -409,6 +417,13 @@ static inline int Extra_WordCountOnes( unsigned uWord )
uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF);
return (uWord & 0x0000FFFF) + (uWord>>16);
}
static inline int Extra_TruthCountOnes( unsigned * pIn, int nVars )
{
int w, Counter = 0;
for ( w = Extra_TruthWordNum(nVars)-1; w >= 0; w-- )
Counter += Extra_WordCountOnes(pIn[w]);
return Counter;
}
static inline int Extra_TruthIsEqual( unsigned * pIn0, unsigned * pIn1, int nVars )
{
int w;
......@@ -504,18 +519,26 @@ extern void Extra_TruthForall( unsigned * pTruth, int nVars, int iVar );
extern void Extra_TruthMux( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar );
extern void Extra_TruthChangePhase( unsigned * pTruth, int nVars, int iVar );
extern int Extra_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin );
extern int Extra_TruthCountOnes( unsigned * pTruth, int nVars );
extern void Extra_TruthCountOnesInCofs( unsigned * pTruth, int nVars, short * pStore );
extern unsigned Extra_TruthHash( unsigned * pIn, int nWords );
extern unsigned Extra_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVars, char * pCanonPerm, short * pStore );
/*=== extraUtilUtil.c ================================================================*/
#ifndef ALLOC
#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))
#endif
#ifndef FREE
#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
#endif
#ifndef REALLOC
#define REALLOC(type, obj, num) \
((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
((type *) malloc(sizeof(type) * (num))))
#endif
extern long Extra_CpuTime();
extern int Extra_GetSoftDataLimit();
......
/**CFile****************************************************************
FileName [extraUtil.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [extra]
Synopsis [Various reusable software utilities.]
Description []
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: extraUtil.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef __EXTRA_UTIL_H__
#define __EXTRA_UTIL_H__
/*---------------------------------------------------------------------------*/
/* Nested includes */
/*---------------------------------------------------------------------------*/
#include <string.h>
#include <time.h>
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Stucture declarations */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Type declarations */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Variable declarations */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Macro declarations */
/*---------------------------------------------------------------------------*/
/*===========================================================================*/
/* Various Utilities */
/*===========================================================================*/
/**AutomaticEnd***************************************************************/
#endif /* __EXTRA_UTIL_H__ */
......@@ -782,26 +782,6 @@ void Extra_TruthChangePhase( unsigned * pTruth, int nVars, int iVar )
/**Function*************************************************************
Synopsis [Changes phase of the function w.r.t. one variable.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Extra_TruthCountOnes( unsigned * pTruth, int nVars )
{
int nWords = Extra_TruthWordNum( nVars );
int i, Counter = 0;
for ( i = 0; i < nWords; i++ )
Counter += Extra_WordCountOnes( pTruth[i] );
return Counter;
}
/**Function*************************************************************
Synopsis [Computes minimum overlap in supports of cofactors.]
Description []
......
......@@ -88,13 +88,13 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData )
printf( "The current network does not have SOPs to perform extraction.\n" );
return NULL;
}
/*
if ( nPairsStore > 10000000 )
{
printf( "The problem is too large to be solved by \"fxu\" (%d cubes and %d cube pairs)\n", nCubesTotal, nPairsStore );
return NULL;
}
*/
// start the matrix
p = Fxu_MatrixAllocate();
// create the column labels
......
......@@ -59,6 +59,9 @@ Ivy_Man_t * Ivy_ManBalance( Ivy_Man_t * p, int fUpdateLevel )
Ivy_ManConst1(p)->TravId = Ivy_EdgeFromNode( Ivy_ManConst1(pNew) );
Ivy_ManForEachPi( p, pObj, i )
pObj->TravId = Ivy_EdgeFromNode( Ivy_ObjCreatePi(pNew) );
// if HAIG is defined, trasfer the pointers to the PIs/latches
// if ( p->pHaig )
// Ivy_ManHaigTrasfer( p, pNew );
// balance the AIG
vStore = Vec_VecAlloc( 50 );
Ivy_ManForEachPo( p, pObj, i )
......@@ -327,10 +330,18 @@ void Ivy_NodeBalancePermute( Ivy_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, i
// get the two last nodes
pObj1 = Vec_PtrEntry( vSuper, RightBound + 1 );
pObj2 = Vec_PtrEntry( vSuper, RightBound );
if ( Ivy_Regular(pObj1) == p->pConst1 || Ivy_Regular(pObj2) == p->pConst1 )
return;
// find the first node that can be shared
for ( i = RightBound; i >= LeftBound; i-- )
{
pObj3 = Vec_PtrEntry( vSuper, i );
if ( Ivy_Regular(pObj3) == p->pConst1 )
{
Vec_PtrWriteEntry( vSuper, i, pObj2 );
Vec_PtrWriteEntry( vSuper, RightBound, pObj3 );
return;
}
pGhost = Ivy_ObjCreateGhost( p, pObj1, pObj3, fExor? IVY_EXOR : IVY_AND, IVY_INIT_NONE );
if ( Ivy_TableLookup( p, pGhost ) )
{
......
......@@ -889,7 +889,6 @@ Ivy_Store_t * Ivy_NodeFindCutsAll( Ivy_Man_t * p, Ivy_Obj_t * pObj, int nLeaves
{
static Ivy_Store_t CutStore, * pCutStore = &CutStore;
Ivy_Cut_t CutNew, * pCutNew = &CutNew, * pCut;
Ivy_Man_t * pMan = p;
Ivy_Obj_t * pLeaf;
int i, k, iLeaf0, iLeaf1;
......
......@@ -119,7 +119,7 @@ Vec_Int_t * Ivy_ManDfsSeq( Ivy_Man_t * p, Vec_Int_t ** pvLatches )
Ivy_ManForEachNodeVec( p, vNodes, pObj, i )
Ivy_ObjClearMarkA(pObj);
// make sure network does not have dangling nodes
assert( Vec_IntSize(vNodes) == Ivy_ManNodeNum(p) + Ivy_ManBufNum(p) );
// assert( Vec_IntSize(vNodes) == Ivy_ManNodeNum(p) + Ivy_ManBufNum(p) );
*pvLatches = vLatches;
return vNodes;
}
......
......@@ -70,6 +70,62 @@ Ivy_Man_t * Ivy_ManStart()
/**Function*************************************************************
Synopsis [Duplicates the AIG manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ivy_Man_t * Ivy_ManDup( Ivy_Man_t * p )
{
Vec_Int_t * vNodes, * vLatches;
Ivy_Man_t * pNew;
Ivy_Obj_t * pObj;
int i;
// collect latches and nodes in the DFS order
vNodes = Ivy_ManDfsSeq( p, &vLatches );
// 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);
// create the fake PIs for latches
Ivy_ManForEachNodeVec( p, vLatches, pObj, i )
pObj->pEquiv = Ivy_ObjCreatePi(pNew);
// duplicate internal nodes
Ivy_ManForEachNodeVec( p, vNodes, pObj, i )
pObj->pEquiv = Ivy_And( pNew, Ivy_ObjChild0Equiv(pObj), Ivy_ObjChild1Equiv(pObj) );
// add the POs
Ivy_ManForEachPo( p, pObj, i )
Ivy_ObjCreatePo( pNew, Ivy_ObjChild0Equiv(pObj) );
// transform additional PI nodes into latches and connect them
Ivy_ManForEachNodeVec( p, vLatches, pObj, i )
{
assert( !Ivy_ObjFaninC0(pObj) );
pObj->pEquiv->Type = IVY_LATCH;
pObj->pEquiv->Init = pObj->Init;
Ivy_ObjConnect( pNew, pObj->pEquiv, Ivy_ObjChild0Equiv(pObj), NULL );
}
// shrink the arrays
Vec_PtrShrink( pNew->vPis, Ivy_ManPiNum(p) );
// update the counters of different objects
pNew->nObjs[IVY_PI] -= Ivy_ManLatchNum(p);
pNew->nObjs[IVY_LATCH] += Ivy_ManLatchNum(p);
// free arrays
Vec_IntFree( vNodes );
Vec_IntFree( vLatches );
// check the resulting network
if ( !Ivy_ManCheck(pNew) )
printf( "Ivy_ManMakeSeq(): The check has failed.\n" );
return pNew;
}
/**Function*************************************************************
Synopsis [Stops the AIG manager.]
Description []
......@@ -81,6 +137,8 @@ Ivy_Man_t * Ivy_ManStart()
***********************************************************************/
void Ivy_ManStop( Ivy_Man_t * p )
{
if ( p->time1 ) { PRT( "Update lev ", p->time1 ); }
if ( p->time2 ) { PRT( "Update levR ", p->time2 ); }
// Ivy_TableProfile( p );
// if ( p->vFanouts ) Ivy_ManStopFanout( p );
if ( p->vChunks ) Ivy_ManStopMemory( p );
......
......@@ -89,7 +89,7 @@ void Ivy_ManAddMemory( Ivy_Man_t * p )
int i, nBytes;
assert( sizeof(Ivy_Obj_t) <= 64 );
assert( p->pListFree == NULL );
assert( (Ivy_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
// assert( (Ivy_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
// allocate new memory page
nBytes = sizeof(Ivy_Obj_t) * (1<<IVY_PAGE_SIZE) + 64;
pMemory = ALLOC( char, nBytes );
......
......@@ -294,45 +294,6 @@ int Ivy_MultiCover( Ivy_Man_t * p, Ivy_Eva_t * pEvals, int nLeaves, int nEvals,
}
}
/**Function*************************************************************
Synopsis [Constructs the well-balanced tree of gates.]
Description [Disregards levels and possible logic sharing.]
SideEffects []
SeeAlso []
***********************************************************************/
Ivy_Obj_t * Ivy_Multi_rec( Ivy_Man_t * p, Ivy_Obj_t ** ppObjs, int nObjs, Ivy_Type_t Type )
{
Ivy_Obj_t * pObj1, * pObj2;
if ( nObjs == 1 )
return ppObjs[0];
pObj1 = Ivy_Multi_rec( p, ppObjs, nObjs/2, Type );
pObj2 = Ivy_Multi_rec( p, ppObjs + nObjs/2, nObjs - nObjs/2, Type );
return Ivy_Oper( p, pObj1, pObj2, Type );
}
/**Function*************************************************************
Synopsis [Old code.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ivy_Obj_t * Ivy_Multi( Ivy_Man_t * p, Ivy_Obj_t ** pArgs, int nArgs, Ivy_Type_t Type )
{
assert( Type == IVY_AND || Type == IVY_EXOR );
assert( nArgs > 0 );
return Ivy_Multi_rec( p, pArgs, nArgs, Type );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -79,7 +79,6 @@ Ivy_Obj_t * Ivy_ObjCreate( Ivy_Man_t * p, Ivy_Obj_t * pGhost )
assert( Ivy_TableLookup(p, pGhost) == NULL );
// get memory for the new object
pObj = Ivy_ManFetchMemory( p );
//printf( "Reusing %p.\n", pObj );
assert( Ivy_ObjIsNone(pObj) );
pObj->Id = Vec_PtrSize(p->vObjs);
Vec_PtrPush( p->vObjs, pObj );
......@@ -115,6 +114,9 @@ Ivy_Obj_t * Ivy_ObjCreate( Ivy_Man_t * p, Ivy_Obj_t * pGhost )
// update node counters of the manager
p->nObjs[Ivy_ObjType(pObj)]++;
p->nCreated++;
// if HAIG is defined, create a corresponding node
if ( p->pHaig )
Ivy_ManHaigCreateObj( p, pObj );
return pObj;
}
......@@ -258,7 +260,6 @@ void Ivy_ObjDelete( Ivy_Man_t * p, Ivy_Obj_t * pObj, int fFreeTop )
// free the node
Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL );
Ivy_ManRecycleMemory( p, pObj );
//printf( "Recycling after delete %p.\n", pObj );
}
else
{
......@@ -312,7 +313,7 @@ void Ivy_ObjDelete_rec( Ivy_Man_t * p, Ivy_Obj_t * pObj, int fFreeTop )
***********************************************************************/
void Ivy_ObjReplace( Ivy_Man_t * p, Ivy_Obj_t * pObjOld, Ivy_Obj_t * pObjNew, int fDeleteOld, int fFreeTop, int fUpdateLevel )
{
int nRefsOld;
int nRefsOld;//, clk;
// the object to be replaced cannot be complemented
assert( !Ivy_IsComplement(pObjOld) );
// the object to be replaced cannot be a terminal
......@@ -321,12 +322,16 @@ void Ivy_ObjReplace( Ivy_Man_t * p, Ivy_Obj_t * pObjOld, Ivy_Obj_t * pObjNew, in
assert( !Ivy_ObjIsBuf(Ivy_Regular(pObjNew)) );
// the object cannot be the same
assert( pObjOld != Ivy_Regular(pObjNew) );
// if HAIG is defined, create the choice node
if ( p->pHaig )
Ivy_ManHaigCreateChoice( p, pObjOld, pObjNew );
// if the new object is complemented or already used, add the buffer
if ( Ivy_IsComplement(pObjNew) || Ivy_ObjIsLatch(pObjNew) || Ivy_ObjRefs(pObjNew) > 0 || Ivy_ObjIsPi(pObjNew) || Ivy_ObjIsConst1(pObjNew) )
pObjNew = Ivy_ObjCreate( p, Ivy_ObjCreateGhost(p, pObjNew, NULL, IVY_BUF, IVY_INIT_NONE) );
assert( !Ivy_IsComplement(pObjNew) );
if ( fUpdateLevel )
{
//clk = clock();
// if the new node's arrival time is different, recursively update arrival time of the fanouts
if ( p->fFanout && !Ivy_ObjIsBuf(pObjNew) && pObjOld->Level != pObjNew->Level )
{
......@@ -334,7 +339,9 @@ void Ivy_ObjReplace( Ivy_Man_t * p, Ivy_Obj_t * pObjOld, Ivy_Obj_t * pObjNew, in
pObjOld->Level = pObjNew->Level;
Ivy_ObjUpdateLevel_rec( p, pObjOld );
}
//p->time1 += clock() - clk;
// if the new node's required time has changed, recursively update required time of the fanins
//clk = clock();
if ( p->vRequired )
{
int ReqNew = Vec_IntEntry(p->vRequired, pObjOld->Id);
......@@ -344,6 +351,7 @@ void Ivy_ObjReplace( Ivy_Man_t * p, Ivy_Obj_t * pObjOld, Ivy_Obj_t * pObjNew, in
Ivy_ObjUpdateLevelR_rec( p, pObjNew, ReqNew );
}
}
//p->time2 += clock() - clk;
}
// delete the old object
if ( fDeleteOld )
......@@ -375,7 +383,6 @@ void Ivy_ObjReplace( Ivy_Man_t * p, Ivy_Obj_t * pObjOld, Ivy_Obj_t * pObjNew, in
// recycle the object that was taken over by pObjOld
Vec_PtrWriteEntry( p->vObjs, pObjNew->Id, NULL );
Ivy_ManRecycleMemory( p, pObjNew );
//printf( "Recycling after patch %p.\n", pObjNew );
// if the new node is the buffer propagate it
if ( p->fFanout && Ivy_ObjIsBuf(pObjOld) )
Vec_PtrPush( p->vBufs, pObjOld );
......
......@@ -210,6 +210,45 @@ Ivy_Obj_t * Ivy_Maj( Ivy_Man_t * p, Ivy_Obj_t * pA, Ivy_Obj_t * pB, Ivy_Obj_t *
/**Function*************************************************************
Synopsis [Constructs the well-balanced tree of gates.]
Description [Disregards levels and possible logic sharing.]
SideEffects []
SeeAlso []
***********************************************************************/
Ivy_Obj_t * Ivy_Multi_rec( Ivy_Man_t * p, Ivy_Obj_t ** ppObjs, int nObjs, Ivy_Type_t Type )
{
Ivy_Obj_t * pObj1, * pObj2;
if ( nObjs == 1 )
return ppObjs[0];
pObj1 = Ivy_Multi_rec( p, ppObjs, nObjs/2, Type );
pObj2 = Ivy_Multi_rec( p, ppObjs + nObjs/2, nObjs - nObjs/2, Type );
return Ivy_Oper( p, pObj1, pObj2, Type );
}
/**Function*************************************************************
Synopsis [Old code.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Ivy_Obj_t * Ivy_Multi( Ivy_Man_t * p, Ivy_Obj_t ** pArgs, int nArgs, Ivy_Type_t Type )
{
assert( Type == IVY_AND || Type == IVY_EXOR );
assert( nArgs > 0 );
return Ivy_Multi_rec( p, pArgs, nArgs, Type );
}
/**Function*************************************************************
Synopsis [Implements the miter.]
Description []
......
......@@ -80,10 +80,6 @@ int Ivy_ManRewriteSeq( Ivy_Man_t * p, int fUseZeroCost, int fVerbose )
// stop if all nodes have been tried once
if ( i > nNodes )
break;
if ( i == 8648 )
{
int x = 0;
}
// for each cut, try to resynthesize it
nGain = Ivy_NodeRewriteSeq( p, pManRwt, pNode, fUseZeroCost );
if ( nGain > 0 || nGain == 0 && fUseZeroCost )
......
......@@ -446,7 +446,7 @@ static inline int Abc_NodePlayerCost( int nFanins )
SeeAlso []
***********************************************************************/
static inline int Abc_NtkPlayerCostOne( int nCost, int RankCost )
static inline int Abc_NtkPlayerCostOneLevel( int nCost, int RankCost )
{
return (nCost / RankCost) + ((nCost % RankCost) > 0);
}
......@@ -466,7 +466,8 @@ int Abc_NtkPlayerCost( Abc_Ntk_t * pNtk, int RankCost, int fVerbose )
{
Abc_Obj_t * pObj;
int * pLevelCosts, * pLevelCostsR;
int nFanins, nLevels, LevelR, Cost, CostTotal, CostTotalR, nRanksTotal, nRanksTotalR, i;
int Cost, CostTotal, CostTotalR, nRanksTotal, nRanksTotalR;
int nFanins, nLevels, LevelR, i;
// compute the reverse levels
Abc_NtkStartReverseLevels( pNtk );
// compute the costs for each level
......@@ -491,17 +492,19 @@ int Abc_NtkPlayerCost( Abc_Ntk_t * pNtk, int RankCost, int fVerbose )
{
CostTotal += pLevelCosts[i];
CostTotalR += pLevelCostsR[i];
nRanksTotal += Abc_NtkPlayerCostOne( pLevelCosts[i], RankCost );
nRanksTotalR += Abc_NtkPlayerCostOne( pLevelCostsR[i], RankCost );
nRanksTotal += Abc_NtkPlayerCostOneLevel( pLevelCosts[i], RankCost );
nRanksTotalR += Abc_NtkPlayerCostOneLevel( pLevelCostsR[i], RankCost );
}
assert( CostTotal == CostTotalR );
// print out statistics
if ( fVerbose )
{
for ( i = 1; i <= nLevels; i++ )
{
printf( "Level %2d : Cost = %7d. Ranks = %6.3f. Cost = %7d. Ranks = %6.3f.\n", i,
pLevelCosts[i], ((double)pLevelCosts[i])/RankCost,
pLevelCostsR[nLevels+1-i], ((double)pLevelCostsR[nLevels+1-i])/RankCost );
}
printf( "TOTAL : Cost = %7d. Ranks = %6d. RanksR = %5d. RanksBest = %5d.\n",
CostTotal, nRanksTotal, nRanksTotalR, nLevels );
}
......
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