Commit ee261ef3 by Alan Mishchenko

Other changes to enable new features in the mapper (bug fix).

parent bb86d914
......@@ -212,6 +212,7 @@ struct Abc_Ntk_t_
float * pLutTimes; // arrivals/requireds/slacks using LUT-delay model
Vec_Ptr_t * vOnehots; // names of one-hot-encoded registers
Vec_Int_t * vObjPerm; // permutation saved
Vec_Vec_t * vRealPos; // additional PO info
// node attributes
Vec_Ptr_t * vAttrs; // managers of various node attributes (node functionality, global BDDs, etc)
};
......
......@@ -111,6 +111,7 @@ Abc_Ntk_t * Abc_NtkStartFrom( Abc_Ntk_t * pNtk, Abc_NtkType_t Type, Abc_NtkFunc_
pNtkNew = Abc_NtkAlloc( Type, Func, 1 );
pNtkNew->nConstrs = pNtk->nConstrs;
pNtkNew->nRealPos = pNtk->nRealPos;
pNtkNew->vRealPos = pNtk->vRealPos ? Vec_VecDup( pNtk->vRealPos ) : NULL;
// duplicate the name and the spec
pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
......@@ -165,6 +166,7 @@ Abc_Ntk_t * Abc_NtkStartFromNoLatches( Abc_Ntk_t * pNtk, Abc_NtkType_t Type, Abc
pNtkNew = Abc_NtkAlloc( Type, Func, 1 );
pNtkNew->nConstrs = pNtk->nConstrs;
pNtkNew->nRealPos = pNtk->nRealPos;
pNtkNew->vRealPos = pNtk->vRealPos ? Vec_VecDup( pNtk->vRealPos ) : NULL;
// duplicate the name and the spec
pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
......@@ -1045,6 +1047,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
Vec_VecFree( (Vec_Vec_t *)pNtk->vOnehots );
Vec_PtrFreeP( &pNtk->vLtlProperties );
Vec_IntFreeP( &pNtk->vObjPerm );
Vec_VecFreeP( &pNtk->vRealPos );
ABC_FREE( pNtk );
}
......
......@@ -120,6 +120,8 @@ static Io_MvVar_t * Abc_NtkMvVarDup( Abc_Ntk_t * pNtk, Io_MvVar_t * pVar );
static int Io_MvCharIsSpace( char s ) { return s == ' ' || s == '\t' || s == '\r' || s == '\n'; }
static int Io_MvCharIsMvSymb( char s ) { return s == '(' || s == ')' || s == '{' || s == '}' || s == '-' || s == ',' || s == '!'; }
static Vec_Vec_t * Io_MvExtractBoxInfo( Abc_Ntk_t * pNtk );
extern void Abc_NtkStartMvVars( Abc_Ntk_t * pNtk );
////////////////////////////////////////////////////////////////////////
......@@ -233,6 +235,8 @@ Abc_Ntk_t * Io_ReadBlifMv( char * pFileName, int fBlifMv, int fCheck )
Vec_PtrForEachEntry( char *, vGlobalLtlArray, pLtlProp, i )
Vec_PtrPush( pNtk->vLtlProperties, pLtlProp );
Vec_PtrFreeP( &vGlobalLtlArray );
pNtk->vRealPos = Io_MvExtractBoxInfo( pNtk );
return pNtk;
}
......@@ -2105,6 +2109,106 @@ static int Io_MvParseLineGateBlif( Io_MvMod_t * p, Vec_Ptr_t * vTokens )
return 1;
}
/**Function*************************************************************
Synopsis [Box mapping procedures.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Abc_MapBoxSetPrevNext( Vec_Ptr_t * vDrivers, Vec_Int_t * vMapIn, Vec_Int_t * vMapOut, int Id )
{
Abc_Obj_t * pNode;
pNode = (Abc_Obj_t *)Vec_PtrEntry(vDrivers, Id+2);
Vec_IntWriteEntry( vMapIn, Abc_ObjId(Abc_ObjFanin0(Abc_ObjFanin0(pNode))), Id );
pNode = (Abc_Obj_t *)Vec_PtrEntry(vDrivers, Id+4);
Vec_IntWriteEntry( vMapOut, Abc_ObjId(Abc_ObjFanin0(Abc_ObjFanin0(pNode))), Id );
}
static inline int Abc_MapBox2Next( Vec_Ptr_t * vDrivers, Vec_Int_t * vMapIn, Vec_Int_t * vMapOut, int Id )
{
Abc_Obj_t * pNode = (Abc_Obj_t *)Vec_PtrEntry(vDrivers, Id+4);
return Vec_IntEntry( vMapIn, Abc_ObjId(Abc_ObjFanin0(Abc_ObjFanin0(pNode))) );
}
static inline int Abc_MapBox2Prev( Vec_Ptr_t * vDrivers, Vec_Int_t * vMapIn, Vec_Int_t * vMapOut, int Id )
{
Abc_Obj_t * pNode = (Abc_Obj_t *)Vec_PtrEntry(vDrivers, Id+2);
return Vec_IntEntry( vMapOut, Abc_ObjId(Abc_ObjFanin0(Abc_ObjFanin0(pNode))) );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static Vec_Vec_t * Io_MvExtractBoxInfo( Abc_Ntk_t * pNtk )
{
Vec_Int_t * vMapIn, * vMapOut, * vList;
Vec_Ptr_t * vBoxInfo, * vDrivers;
Abc_Obj_t * pObj;
int i, boxId;
// quit if there is no boxes
if ( pNtk->nRealPos == 0 || (Abc_NtkPoNum(pNtk) - pNtk->nRealPos) % 5 != 0 )
return NULL;
// allocate
vBoxInfo = Vec_PtrAlloc( 10 );
vDrivers = Vec_PtrAlloc( Abc_NtkPoNum(pNtk) );
vMapIn = Vec_IntStartFull( Abc_NtkObjNumMax(pNtk) );
vMapOut = Vec_IntStartFull( Abc_NtkObjNumMax(pNtk) );
// collect drivers
Abc_NtkForEachPo( pNtk, pObj, i )
Vec_PtrPush( vDrivers, Abc_ObjFanin0(Abc_ObjFanin0(pObj)) );
// map box signals into box numbers
for ( i = pNtk->nRealPos; i < Abc_NtkPoNum(pNtk); i += 5 )
{
// int k;
// for ( k = 0; k < 5; k++ )
// printf( "%d ", Abc_ObjFanin0(Abc_ObjFanin0(Abc_ObjFanin0(Abc_NtkPo(pNtk,i+k))))->Id );
// printf( "\n" );
Abc_MapBoxSetPrevNext( vDrivers, vMapIn, vMapOut, i );
}
// find those that do not have input mapped
for ( i = pNtk->nRealPos; i < Abc_NtkPoNum(pNtk); i += 5 )
{
if ( Abc_MapBox2Prev( vDrivers, vMapIn, vMapOut, i ) != ~0 )
continue;
// create new list
vList = Vec_IntAlloc( 32 );
boxId = i;
while ( boxId != ~0 )
{
Vec_IntPush( vList, boxId );
boxId = Abc_MapBox2Next( vDrivers, vMapIn, vMapOut, boxId );
}
Vec_PtrPush( vBoxInfo, vList );
//printf( " %d", Vec_IntSize(vList) );
}
//printf( "\n" );
if ( 5 * Vec_VecSizeSize((Vec_Vec_t *)vBoxInfo) != (Abc_NtkPoNum(pNtk) - pNtk->nRealPos) )
printf( "Mismatch in the number of boxes!!!\n" );
// clean up
Vec_IntFree( vMapIn );
Vec_IntFree( vMapOut );
Vec_PtrFree( vDrivers );
return (Vec_Vec_t *)vBoxInfo;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -231,7 +231,8 @@ struct If_Obj_t_
unsigned fVisit : 1; // multipurpose mark
unsigned fSpec : 1; // multipurpose mark
unsigned fDriver : 1; // multipurpose mark
unsigned Level : 20; // logic level of the node
unsigned fSkipCut: 1; // multipurpose mark
unsigned Level : 19; // logic level of the node
int Id; // integer ID
int IdPio; // integer ID of PIs/POs
int nRefs; // the number of references
......
......@@ -94,8 +94,11 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
If_Cut_t * pCut0, * pCut1, * pCut;
int i, k;
assert( p->pPars->fSeqMap || !If_ObjIsAnd(pObj->pFanin0) || pObj->pFanin0->pCutSet->nCuts > 1 );
assert( p->pPars->fSeqMap || !If_ObjIsAnd(pObj->pFanin1) || pObj->pFanin1->pCutSet->nCuts > 1 );
// assert( p->pPars->fSeqMap || !If_ObjIsAnd(pObj->pFanin0) || pObj->pFanin0->pCutSet->nCuts > 1 );
// assert( p->pPars->fSeqMap || !If_ObjIsAnd(pObj->pFanin1) || pObj->pFanin1->pCutSet->nCuts > 1 );
assert( p->pPars->fSeqMap || !If_ObjIsAnd(pObj->pFanin0) || pObj->pFanin0->pCutSet->nCuts > 0 );
assert( p->pPars->fSeqMap || !If_ObjIsAnd(pObj->pFanin1) || pObj->pFanin1->pCutSet->nCuts > 0 );
// prepare
if ( !p->pPars->fSeqMap )
......@@ -232,8 +235,11 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
assert( pCutSet->nCuts > 0 );
// add the trivial cut to the set
If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
if ( !pObj->fSkipCut )
{
If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
}
// update the best cut
if ( !fPreprocess || pCutSet->ppCuts[0]->Delay <= pObj->Required + p->fEpsilon )
......@@ -325,8 +331,11 @@ void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fP
assert( pCutSet->nCuts > 0 );
// add the trivial cut to the set
If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
if ( !pObj->fSkipCut )
{
If_ManSetupCutTriv( p, pCutSet->ppCuts[pCutSet->nCuts++], pObj->Id );
assert( pCutSet->nCuts <= pCutSet->nCutsMax+1 );
}
// update the best cut
if ( !fPreprocess || pCutSet->ppCuts[0]->Delay <= pObj->Required + p->fEpsilon )
......
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