mirror of https://github.com/YosysHQ/abc.git
Converting AIG with MUXes into a logic network.
This commit is contained in:
parent
b94b7852d7
commit
4f940de518
|
|
@ -253,6 +253,92 @@ Vec_Ptr_t * Gia_ManOrderPios( Aig_Man_t * p, Gia_Man_t * pOrder )
|
|||
return vPios;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManDupFromBarBufs( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Int_t * vBufObjs;
|
||||
Gia_Man_t * pNew;
|
||||
Gia_Obj_t * pObj;
|
||||
int i, k = 0;
|
||||
assert( Gia_ManBufNum(p) > 0 );
|
||||
assert( Gia_ManRegNum(p) == 0 );
|
||||
assert( !Gia_ManHasChoices(p) );
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
Gia_ManFillValue(p);
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi( pNew );
|
||||
vBufObjs = Vec_IntAlloc( Gia_ManBufNum(p) );
|
||||
for ( i = 0; i < Gia_ManBufNum(p); i++ )
|
||||
Vec_IntPush( vBufObjs, Gia_ManAppendCi(pNew) );
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
{
|
||||
if ( Gia_ObjIsBarBuf(pObj) )
|
||||
{
|
||||
pObj->Value = Vec_IntEntry( vBufObjs, k );
|
||||
Vec_IntWriteEntry( vBufObjs, k++, Gia_ObjFanin0Copy(pObj) );
|
||||
}
|
||||
else
|
||||
pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
}
|
||||
assert( k == Gia_ManBufNum(p) );
|
||||
for ( i = 0; i < Gia_ManBufNum(p); i++ )
|
||||
Gia_ManAppendCo( pNew, Vec_IntEntry(vBufObjs, i) );
|
||||
Vec_IntFree( vBufObjs );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
|
||||
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
return pNew;
|
||||
}
|
||||
Gia_Man_t * Gia_ManDupToBarBufs( Gia_Man_t * p, int nBarBufs )
|
||||
{
|
||||
Gia_Man_t * pNew;
|
||||
Gia_Obj_t * pObj;
|
||||
int i, nPiReal = Gia_ManCiNum(p) - nBarBufs;
|
||||
int k, nPoReal = Gia_ManCoNum(p) - nBarBufs;
|
||||
assert( Gia_ManBufNum(p) == 0 );
|
||||
assert( Gia_ManRegNum(p) == 0 );
|
||||
assert( Gia_ManHasChoices(p) );
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
if ( Gia_ManHasChoices(p) )
|
||||
pNew->pSibls = ABC_CALLOC( int, Gia_ManObjNum(p) );
|
||||
Gia_ManFillValue(p);
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
for ( i = 0; i < nPiReal; i++ )
|
||||
Gia_ManCi(p, i)->Value = Gia_ManAppendCi( pNew );
|
||||
k = 0;
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
{
|
||||
while ( ~Gia_ObjFanin0Copy(Gia_ManCo(p, k)) )
|
||||
{
|
||||
Gia_ManCi(p, nPiReal + k)->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(Gia_ManCo(p, k)) );
|
||||
k++;
|
||||
}
|
||||
pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
|
||||
pNew->pSibls[Abc_Lit2Var(pObj->Value)] = Abc_Lit2Var(Gia_ObjSiblObj(p, Gia_ObjId(p, pObj))->Value);
|
||||
}
|
||||
assert( k == nBarBufs );
|
||||
for ( i = 0; i < nPoReal; i++ )
|
||||
Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(Gia_ManCo(p, nBarBufs+i)) );
|
||||
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
@ -345,10 +431,27 @@ Gia_Man_t * Gia_ManAigSynch2( Gia_Man_t * pInit, void * pPars0, int nLutSize )
|
|||
}
|
||||
if ( fVerbose ) Gia_ManPrintStats( pGia3, NULL );
|
||||
// perform choice computation
|
||||
if ( Gia_ManBufNum(pInit) )
|
||||
{
|
||||
assert( Gia_ManBufNum(pInit) == Gia_ManBufNum(pGia1) );
|
||||
pGia1 = Gia_ManDupFromBarBufs( pTemp = pGia1 );
|
||||
Gia_ManStop( pTemp );
|
||||
assert( Gia_ManBufNum(pInit) == Gia_ManBufNum(pGia2) );
|
||||
pGia2 = Gia_ManDupFromBarBufs( pTemp = pGia2 );
|
||||
Gia_ManStop( pTemp );
|
||||
assert( Gia_ManBufNum(pInit) == Gia_ManBufNum(pGia3) );
|
||||
pGia3 = Gia_ManDupFromBarBufs( pTemp = pGia3 );
|
||||
Gia_ManStop( pTemp );
|
||||
}
|
||||
pNew = Gia_ManAigSynch2Choices( pGia1, pGia2, pGia3, pParsDch );
|
||||
Gia_ManStop( pGia1 );
|
||||
Gia_ManStop( pGia2 );
|
||||
Gia_ManStop( pGia3 );
|
||||
if ( Gia_ManBufNum(pInit) )
|
||||
{
|
||||
pNew = Gia_ManDupToBarBufs( pTemp = pNew, Gia_ManBufNum(pInit) );
|
||||
Gia_ManStop( pTemp );
|
||||
}
|
||||
// copy names
|
||||
ABC_FREE( pNew->pName );
|
||||
ABC_FREE( pNew->pSpec );
|
||||
|
|
|
|||
|
|
@ -25821,7 +25821,7 @@ int Abc_CommandAbc9Put( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
Abc_Print( -1, "Empty network.\n" );
|
||||
return 1;
|
||||
}
|
||||
if ( Gia_ManHasMapping(pAbc->pGia) )
|
||||
if ( Gia_ManHasMapping(pAbc->pGia) || pAbc->pGia->pMuxes )
|
||||
{
|
||||
extern Abc_Ntk_t * Abc_NtkFromMappedGia( Gia_Man_t * p );
|
||||
pNtk = Abc_NtkFromMappedGia( pAbc->pGia );
|
||||
|
|
|
|||
|
|
@ -720,8 +720,8 @@ Abc_Ntk_t * Abc_NtkFromMappedGia( Gia_Man_t * p )
|
|||
Gia_Obj_t * pObj, * pObjLi, * pObjLo;
|
||||
Vec_Ptr_t * vReflect;
|
||||
int i, k, iFan, nDupGates;
|
||||
assert( Gia_ManHasMapping(p) );
|
||||
pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_AIG, 1 );
|
||||
assert( Gia_ManHasMapping(p) || p->pMuxes );
|
||||
pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, Gia_ManHasMapping(p) ? ABC_FUNC_AIG : ABC_FUNC_SOP, 1 );
|
||||
// duplicate the name and the spec
|
||||
pNtkNew->pName = Extra_UtilStrsav(p->pName);
|
||||
pNtkNew->pSpec = Extra_UtilStrsav(p->pSpec);
|
||||
|
|
@ -748,23 +748,60 @@ Abc_Ntk_t * Abc_NtkFromMappedGia( Gia_Man_t * p )
|
|||
Abc_LatchSetInit0( pObjNew );
|
||||
}
|
||||
// rebuild the AIG
|
||||
vReflect = Vec_PtrStart( Gia_ManObjNum(p) );
|
||||
Gia_ManForEachLut( p, i )
|
||||
if ( p->pMuxes )
|
||||
{
|
||||
pObj = Gia_ManObj(p, i);
|
||||
assert( pObj->Value == ~0 );
|
||||
if ( Gia_ObjLutSize(p, i) == 0 )
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
{
|
||||
pObj->Value = Abc_ObjId(pConst0);
|
||||
continue;
|
||||
pObjNew = Abc_NtkCreateNode( pNtkNew );
|
||||
if ( Gia_ObjIsMuxId(p, i) )
|
||||
{
|
||||
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin2(p, pObj))) );
|
||||
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin1(pObj))) );
|
||||
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin0(pObj))) );
|
||||
pObjNew->pData = Abc_SopCreateMux( (Mem_Flex_t *)pNtkNew->pManFunc );
|
||||
if ( Gia_ObjFaninC2(p, pObj) ) Abc_SopComplementVar( (char *)pObjNew->pData, 0 );
|
||||
if ( Gia_ObjFaninC1(pObj) ) Abc_SopComplementVar( (char *)pObjNew->pData, 1 );
|
||||
if ( Gia_ObjFaninC0(pObj) ) Abc_SopComplementVar( (char *)pObjNew->pData, 2 );
|
||||
}
|
||||
else if ( Gia_ObjIsXor(pObj) )
|
||||
{
|
||||
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin0(pObj))) );
|
||||
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin1(pObj))) );
|
||||
pObjNew->pData = Abc_SopCreateXor( (Mem_Flex_t *)pNtkNew->pManFunc, 2 );
|
||||
if ( Gia_ObjFaninC0(pObj) ) Abc_SopComplementVar( (char *)pObjNew->pData, 0 );
|
||||
if ( Gia_ObjFaninC1(pObj) ) Abc_SopComplementVar( (char *)pObjNew->pData, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin0(pObj))) );
|
||||
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin1(pObj))) );
|
||||
pObjNew->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, 2, NULL );
|
||||
if ( Gia_ObjFaninC0(pObj) ) Abc_SopComplementVar( (char *)pObjNew->pData, 0 );
|
||||
if ( Gia_ObjFaninC1(pObj) ) Abc_SopComplementVar( (char *)pObjNew->pData, 1 );
|
||||
}
|
||||
pObj->Value = Abc_ObjId( pObjNew );
|
||||
}
|
||||
pObjNew = Abc_NtkCreateNode( pNtkNew );
|
||||
Gia_LutForEachFanin( p, i, iFan, k )
|
||||
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ManObj(p, iFan))) );
|
||||
pObjNew->pData = Abc_ObjHopFromGia( (Hop_Man_t *)pNtkNew->pManFunc, p, i, vReflect );
|
||||
pObj->Value = Abc_ObjId( pObjNew );
|
||||
}
|
||||
Vec_PtrFree( vReflect );
|
||||
else
|
||||
{
|
||||
vReflect = Vec_PtrStart( Gia_ManObjNum(p) );
|
||||
Gia_ManForEachLut( p, i )
|
||||
{
|
||||
pObj = Gia_ManObj(p, i);
|
||||
assert( pObj->Value == ~0 );
|
||||
if ( Gia_ObjLutSize(p, i) == 0 )
|
||||
{
|
||||
pObj->Value = Abc_ObjId(pConst0);
|
||||
continue;
|
||||
}
|
||||
pObjNew = Abc_NtkCreateNode( pNtkNew );
|
||||
Gia_LutForEachFanin( p, i, iFan, k )
|
||||
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ManObj(p, iFan))) );
|
||||
pObjNew->pData = Abc_ObjHopFromGia( (Hop_Man_t *)pNtkNew->pManFunc, p, i, vReflect );
|
||||
pObj->Value = Abc_ObjId( pObjNew );
|
||||
}
|
||||
Vec_PtrFree( vReflect );
|
||||
}
|
||||
// connect the PO nodes
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue