Commit dd29ca30 by Alan Mishchenko

New technology mapper.

parent c0ac1598
......@@ -409,6 +409,7 @@ If_Man_t * Gia_ManToIf( Gia_Man_t * p, If_Par_t * pPars )
// create levels with choices
Gia_ManChoiceLevel( p );
// mark representative nodes
if ( p->pSibls )
Gia_ManMarkFanoutDrivers( p );
// start the mapping manager and set its parameters
pIfMan = If_ManStart( pPars );
......@@ -445,12 +446,13 @@ If_Man_t * Gia_ManToIf( Gia_Man_t * p, If_Par_t * pPars )
{
Gia_Obj_t * pSibl, * pPrev;
for ( pPrev = pObj, pSibl = Gia_ObjSiblObj(p, i); pSibl; pPrev = pSibl, pSibl = Gia_ObjSiblObj(p, Gia_ObjId(p, pSibl)) )
If_ObjSetChoice( If_ManObj(pIfMan, Gia_ObjValue(pObj)), If_ManObj(pIfMan, Gia_ObjValue(pSibl)) );
If_ObjSetChoice( If_ManObj(pIfMan, Gia_ObjValue(pPrev)), If_ManObj(pIfMan, Gia_ObjValue(pSibl)) );
If_ManCreateChoice( pIfMan, If_ManObj(pIfMan, Gia_ObjValue(pObj)) );
pPars->fExpRed = 0;
}
// assert( If_ObjLevel(pIfObj) == Gia_ObjLevel(pNode) );
}
if ( p->pSibls )
Gia_ManCleanMark0( p );
return pIfMan;
}
......
......@@ -339,6 +339,7 @@ void Gia_ManFillValue( Gia_Man_t * p )
***********************************************************************/
void Gia_ObjSetPhase( Gia_Obj_t * pObj )
{
assert( !Gia_ObjIsXor(pObj) );
if ( Gia_ObjIsAnd(pObj) )
pObj->fPhase = (Gia_ObjPhase(Gia_ObjFanin0(pObj)) ^ Gia_ObjFaninC0(pObj)) &
(Gia_ObjPhase(Gia_ObjFanin1(pObj)) ^ Gia_ObjFaninC1(pObj));
......@@ -1342,8 +1343,9 @@ void Gia_ManMarkFanoutDrivers( Gia_Man_t * p )
{
Gia_Obj_t * pObj;
int i;
Gia_ManCleanMark0( p );
Gia_ManForEachObj( p, pObj, i )
{
pObj->fMark0 = 0;
if ( Gia_ObjIsAnd(pObj) )
{
Gia_ObjFanin0(pObj)->fMark0 = 1;
......@@ -1351,6 +1353,7 @@ void Gia_ManMarkFanoutDrivers( Gia_Man_t * p )
}
else if ( Gia_ObjIsCo(pObj) )
Gia_ObjFanin0(pObj)->fMark0 = 1;
}
}
......
......@@ -29587,8 +29587,8 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->fMap4Cnf )
pPars->fUseDsd = 1;
if ( pPars->fCutMin )
// pPars->fUseTruth = 1;
pPars->fUseDsd = 1;
pPars->fUseTruth = 1;
// pPars->fUseDsd = 1;
// perform mapping
pNew = Mpm_ManMappingTest( pAbc->pGia, pPars );
Mpm_LibLutFree( pPars->pLib );
......@@ -43,6 +43,41 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
void Mig_ManCreateChoices( Mig_Man_t * pMig, Gia_Man_t * p )
{
Gia_Obj_t * pObj;
int i;
assert( Mig_ManObjNum(pMig) == Gia_ManObjNum(p) );
assert( Vec_IntSize(&pMig->vSibls) == 0 );
Vec_IntFill( &pMig->vSibls, Gia_ManObjNum(p), 0 );
Gia_ManMarkFanoutDrivers( p );
Gia_ManForEachObj( p, pObj, i )
{
Gia_ObjSetPhase( pObj );
assert( Abc_Lit2Var(pObj->Value) == i );
Mig_ObjSetPhase( Mig_ManObj(pMig, i), pObj->fPhase );
if ( Gia_ObjSibl(p, i) && pObj->fMark0 )
{
Gia_Obj_t * pSibl, * pPrev;
for ( pPrev = pObj, pSibl = Gia_ObjSiblObj(p, i); pSibl; pPrev = pSibl, pSibl = Gia_ObjSiblObj(p, Gia_ObjId(p, pSibl)) )
Mig_ObjSetSiblId( Mig_ManObj(pMig, Abc_Lit2Var(pPrev->Value)), Abc_Lit2Var(pSibl->Value) );
pMig->nChoices++;
}
}
Gia_ManCleanMark0( p );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Mig_ObjFanin0Copy( Gia_Obj_t * pObj ) { return Abc_LitNotCond( Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj) ); }
static inline int Mig_ObjFanin1Copy( Gia_Obj_t * pObj ) { return Abc_LitNotCond( Gia_ObjFanin1(pObj)->Value, Gia_ObjFaninC1(pObj) ); }
Mig_Man_t * Mig_ManCreate( void * pGia )
......@@ -51,11 +86,9 @@ Mig_Man_t * Mig_ManCreate( void * pGia )
Mig_Man_t * pNew;
Gia_Obj_t * pObj;
int i;
// create the new manager
pNew = Mig_ManStart();
pNew->pName = Abc_UtilStrsav( p->pName );
Gia_ManConst0(p)->Value = 0;
// create objects
Gia_ManForEachObj1( p, pObj, i )
{
if ( Gia_ObjIsMux(p, i) )
......@@ -71,6 +104,8 @@ Mig_Man_t * Mig_ManCreate( void * pGia )
else assert( 0 );
}
Mig_ManSetRegNum( pNew, Gia_ManRegNum(p) );
if ( p->pSibls )
Mig_ManCreateChoices( pNew, p );
return pNew;
}
......@@ -86,7 +121,7 @@ Mig_Man_t * Mig_ManCreate( void * pGia )
***********************************************************************/
static inline unsigned Mpm_CutDataInt( Mpm_Cut_t * pCut ) { return pCut->hNext; }
static inline void Mpm_CutSetDataInt( Mpm_Cut_t * pCut, unsigned Data ) { pCut->hNext = Data; }
static inline void Mpm_CutSetDataInt( Mpm_Cut_t * pCut, int Data ) { pCut->hNext = Data; }
int Mpm_ManNodeIfToGia_rec( Gia_Man_t * pNew, Mpm_Man_t * pMan, Mig_Obj_t * pObj, Vec_Ptr_t * vVisited, int fHash )
{
Mig_Obj_t * pTemp;
......
......@@ -156,7 +156,6 @@ struct Mpm_Man_t_
int nCutsMerged;
int nCutsMergedAll;
int nSmallSupp;
abctime timeFanin;
abctime timeDerive;
abctime timeMerge;
abctime timeEval;
......@@ -184,7 +183,6 @@ static inline void Mpm_ObjSetCutList( Mpm_Man_t * p, Mig_Obj_t * pObj, in
static inline int Mpm_CutLeafNum( Mpm_Cut_t * pCut ) { return pCut->nLeaves; }
static inline word * Mpm_CutTruth( Mpm_Man_t * p, int iFunc ) { return Vec_MemReadEntry(p->vTtMem, iFunc); }
static inline void Mpm_ManSetMigRefs( Mpm_Man_t * p ) { assert( Vec_IntSize(&p->vMigRefs) == Vec_IntSize(&p->pMig->vRefs) ); memcpy( Vec_IntArray(&p->vMigRefs), Vec_IntArray(&p->pMig->vRefs), sizeof(int) * Mig_ManObjNum(p->pMig) ); }
static inline int Mig_ObjMigRefNum( Mpm_Man_t * p, Mig_Obj_t * pObj ) { return Vec_IntEntry(&p->vMigRefs, Mig_ObjId(pObj)); }
static inline int Mig_ObjMigRefDec( Mpm_Man_t * p, Mig_Obj_t * pObj ) { return Vec_IntAddToEntry(&p->vMigRefs, Mig_ObjId(pObj), -1); }
......
......@@ -50,7 +50,7 @@ Mpm_Man_t * Mpm_ManStart( Mig_Man_t * pMig, Mpm_Par_t * pPars )
assert( pPars->nNumCuts <= MPM_CUT_MAX );
assert( !pPars->fUseTruth || pPars->pLib->LutMax <= 16 );
assert( !pPars->fUseDsd || pPars->pLib->LutMax <= 6 );
Mig_ManSetRefs( pMig, 1 );
Mig_ManSetRefs( pMig );
// alloc
p = ABC_CALLOC( Mpm_Man_t, 1 );
p->pMig = pMig;
......@@ -119,7 +119,7 @@ void Mpm_ManStop( Mpm_Man_t * p )
FILE * pFile = fopen( pFileName, "wb" );
Vec_MemDump( pFile, p->vTtMem );
fclose( pFile );
printf( "Dumpted %d %d-var truth tables into file \"%s\" (%.2f MB).\n",
printf( "Dumped %d %d-var truth tables into file \"%s\" (%.2f MB).\n",
Vec_MemEntryNum(p->vTtMem), p->nLutSize, pFileName,
(16.0 * p->nTruWords + 1.0) * Vec_MemEntryNum(p->vTtMem) / (1 << 20) );
}
......@@ -171,9 +171,8 @@ void Mpm_ManStop( Mpm_Man_t * p )
void Mpm_ManPrintStatsInit( Mpm_Man_t * p )
{
printf( "K = %d. C = %d. Cand = %d. XOR = %d. MUX = %d. Choice = %d. CutMin = %d. Truth = %d. DSD = %d.\n",
p->nLutSize, p->nNumCuts,
Mig_ManCiNum(p->pMig) + Mig_ManNodeNum(p->pMig),
Mig_ManXorNum(p->pMig), Mig_ManMuxNum(p->pMig), 0,
p->nLutSize, p->nNumCuts, Mig_ManCandNum(p->pMig),
Mig_ManXorNum(p->pMig), Mig_ManMuxNum(p->pMig), p->pMig->nChoices,
p->pPars->fCutMin, p->pPars->fUseTruth, p->pPars->fUseDsd );
}
void Mpm_ManPrintStats( Mpm_Man_t * p )
......@@ -189,10 +188,9 @@ void Mpm_ManPrintStats( Mpm_Man_t * p )
#ifdef MIG_RUNTIME
printf( "\n" );
p->timeTotal = Abc_Clock() - p->timeTotal;
p->timeOther = p->timeTotal - (p->timeFanin + p->timeDerive);
p->timeOther = p->timeTotal - p->timeDerive;
Abc_Print( 1, "Runtime breakdown:\n" );
ABC_PRTP( "Precomputing fanin info ", p->timeFanin , p->timeTotal );
ABC_PRTP( "Complete cut computation ", p->timeDerive , p->timeTotal );
ABC_PRTP( "- Merging cuts ", p->timeMerge , p->timeTotal );
ABC_PRTP( "- Evaluting cut parameters ", p->timeEval , p->timeTotal );
......
......@@ -120,23 +120,18 @@ int Mig_ManMuxNum( Mig_Man_t * p )
SeeAlso []
***********************************************************************/
void Mig_ManSetRefs( Mig_Man_t * p, int fSkipCos )
void Mig_ManSetRefs( Mig_Man_t * p )
{
Mig_Obj_t * pObj;
int i, iFanin;
// increment references
Vec_IntFill( &p->vRefs, Mig_ManObjNum(p), 0 );
Mig_ManForEachNode( p, pObj )
Mig_ManForEachObj( p, pObj )
{
Mig_ObjForEachFaninId( pObj, iFanin, i )
Vec_IntAddToEntry( &p->vRefs, iFanin, 1 );
if ( !fSkipCos )
{
// and CO references
Mig_ManForEachCo( p, pObj, i )
Vec_IntAddToEntry( &p->vRefs, Mig_ObjFaninId(pObj, 0), 1 );
// check that internal nodes have fanins
Mig_ManForEachNode( p, pObj )
assert( Vec_IntEntry(&p->vRefs, Mig_ObjId(pObj)) > 0 );
if ( Mig_ObjSiblId(pObj) )
Vec_IntAddToEntry( &p->vRefs, Mig_ObjSiblId(pObj), 1 );
}
}
......
......@@ -64,6 +64,7 @@ struct Mig_Man_t_
char * pName; // name
int nObjs; // number of objects
int nRegs; // number of flops
int nChoices; // number of choices
Vec_Ptr_t vPages; // memory pages
Vec_Int_t vCis; // CI IDs
Vec_Int_t vCos; // CO IDs
......@@ -109,6 +110,7 @@ static inline int Mig_ManRegNum( Mig_Man_t * p ) { return p->nRegs
static inline int Mig_ManObjNum( Mig_Man_t * p ) { return p->nObjs; }
static inline int Mig_ManNodeNum( Mig_Man_t * p ) { return p->nObjs - Vec_IntSize(&p->vCis) - Vec_IntSize(&p->vCos) - 1; }
static inline int Mig_ManCandNum( Mig_Man_t * p ) { return Mig_ManCiNum(p) + Mig_ManNodeNum(p); }
static inline int Mig_ManChoiceNum( Mig_Man_t * p ) { return p->nChoices; }
static inline void Mig_ManSetRegNum( Mig_Man_t * p, int v ) { p->nRegs = v; }
static inline Mig_Obj_t * Mig_ManPage( Mig_Man_t * p, int v ) { return (Mig_Obj_t *)Vec_PtrEntry(&p->vPages, Mig_IdPage(v)); }
......@@ -147,7 +149,7 @@ static inline void Mig_ObjSetId( Mig_Obj_t * p, int v ) {
static inline int Mig_ObjCioId( Mig_Obj_t * p ) { assert( Mig_ObjIsTerm(p) ); return Mig_FanId( p, 2 ); }
static inline void Mig_ObjSetCioId( Mig_Obj_t * p, int v ) { assert( Mig_FanIsNone(p, 1) ); Mig_FanSetId( p, 2, v ); }
static inline int Mig_ObjPhase( Mig_Obj_t * p ) { return Mig_FanCompl( p, 3 ); }
static inline void Mig_ObjSetPhase( Mig_Obj_t * p, int v ) { Mig_FanSetCompl( p, 3, 1 ); }
static inline void Mig_ObjSetPhase( Mig_Obj_t * p, int v ) { Mig_FanSetCompl( p, 3, v ); }
static inline Mig_Man_t * Mig_ObjMan( Mig_Obj_t * p ) { return *((Mig_Man_t**)(p - Mig_IdCell(Mig_ObjId(p)) - 1)); }
//static inline Mig_Obj_t ** Mig_ObjPageP( Mig_Obj_t * p ) { return *((Mig_Obj_t***)(p - Mig_IdCell(Mig_ObjId(p))) - 1);}
......@@ -185,8 +187,9 @@ static inline int Mig_ObjWhatFanin( Mig_Obj_t * p, int i ) {
static inline void Mig_ObjSetFaninLit( Mig_Obj_t * p, int i, int l ) { assert( l >= 0 && (l >> 1) < Mig_ObjId(p) ); Mig_FanSetId(p, i, Abc_Lit2Var(l)); Mig_FanSetCompl(p, i, Abc_LitIsCompl(l)); }
static inline int Mig_ObjSiblId( Mig_Obj_t * p ) { return Vec_IntSize(&Mig_ObjMan(p)->vSibls) == 0 ? 0: Vec_IntEntry(&Mig_ObjMan(p)->vSibls, Mig_ObjId(p)); }
static inline Mig_Obj_t * Mig_ObjSibl( Mig_Obj_t * p ) { return Mig_ObjSiblId(p) == 0 ? NULL: Mig_ObjObj(p, Mig_ObjSiblId(p)); }
static inline int Mig_ObjRefNum( Mig_Obj_t * p ) { return Vec_IntEntry(&Mig_ObjMan(p)->vRefs, Mig_ObjId(p)); }
static inline void Mig_ObjSetSiblId( Mig_Obj_t * p, int s ) { assert( s > 0 && Mig_ObjId(p) > s ); Vec_IntWriteEntry( &Mig_ObjMan(p)->vSibls, Mig_ObjId(p), s ); }
static inline Mig_Obj_t * Mig_ObjSibl( Mig_Obj_t * p ) { return Mig_ObjSiblId(p) == 0 ? NULL: Mig_ObjObj(p, Mig_ObjSiblId(p)); }
static inline int Mig_ObjRefNum( Mig_Obj_t * p ) { return Vec_IntEntry(&Mig_ObjMan(p)->vRefs, Mig_ObjId(p)); }
static inline void Mig_ManCleanCopy( Mig_Man_t * p ) { if ( p->vCopies.pArray == NULL ) Vec_IntFill( &p->vCopies, Mig_ManObjNum(p), -1 ); }
static inline int Mig_ObjCopy( Mig_Obj_t * p ) { return Vec_IntSize(&Mig_ObjMan(p)->vCopies) == 0 ? -1: Vec_IntEntry(&Mig_ObjMan(p)->vCopies, Mig_ObjId(p)); }
......@@ -341,7 +344,7 @@ static inline int Mig_ManAppendMaj( Mig_Man_t * p, int iLit0, int iLit1, int iLi
/*=== mpmMig.c ===========================================================*/
extern Mig_Man_t * Mig_ManStart();
extern void Mig_ManStop( Mig_Man_t * p );
extern void Mig_ManSetRefs( Mig_Man_t * p, int fSkipCos );
extern void Mig_ManSetRefs( Mig_Man_t * p );
extern int Mig_ManAndNum( Mig_Man_t * p );
extern int Mig_ManXorNum( Mig_Man_t * p );
extern int Mig_ManMuxNum( Mig_Man_t * p );
......
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