51 if (
p->pMioLib == NULL )
62 p->ppGraphs = (
void **)ppGraphs;
67 if (
p->pMioLib == NULL )
90 if ( iRes == 0 || iRes == 1 )
93 if ( vMap && Abc_Lit2Var(iRes) < Vec_IntSize(vMap) && (iIdLit = Vec_IntEntry(vMap, Abc_Lit2Var(iRes))) >= 0 &&
94 Vec_IntEntry(&
p->vBuf2LeafNtk, Abc_Lit2Var(iIdLit)) == iLNtk && Vec_IntEntry(&
p->vBuf2RootNtk, Abc_Lit2Var(iIdLit)) == iRNtk )
95 return Abc_LitNotCond( Vec_IntEntry(pNew->
vBarBufs, Abc_Lit2Var(iIdLit)), Abc_LitIsCompl(iRes) ^ Abc_LitIsCompl(iIdLit) );
96 assert( Bac_ManNtkIsOk(
p, iLNtk) && Bac_ManNtkIsOk(
p, iRNtk) );
97 Vec_IntPush( &
p->vBuf2LeafNtk, iLNtk );
98 Vec_IntPush( &
p->vBuf2LeafObj, iLObj );
99 Vec_IntPush( &
p->vBuf2RootNtk, iRNtk );
100 Vec_IntPush( &
p->vBuf2RootObj, iRObj );
101 iBufLit = Gia_ManAppendBuf( pNew, iRes );
104 Vec_IntSetEntryFull( vMap, Abc_Lit2Var(iRes), Abc_Var2Lit(Vec_IntSize(pNew->
vBarBufs), Abc_LitIsCompl(iRes)) );
105 Vec_IntPush( pNew->
vBarBufs, iBufLit );
111 int iRes = Bac_ObjCopy(
p, i );
114 if ( Bac_ObjIsCo(
p, i) )
116 else if ( Bac_ObjIsPi(
p, i) )
119 int iObj = Bac_BoxBi( pHost, Bac_NtkHostObj(
p), Bac_ObjIndex(
p, i) );
122 iRes =
Bac_ManAddBarbuf( pNew, iRes,
p->pDesign, Bac_NtkId(
p), i, Bac_NtkId(pHost), iObj, vMap );
124 else if ( Bac_ObjIsBo(
p, i) )
126 int iBox = Bac_BoxBoBox(
p, i);
127 if ( Bac_ObjIsBoxUser(
p, iBox) )
130 int iObj = Bac_NtkPo( pBox, Bac_ObjIndex(
p, i) );
133 iRes =
Bac_ManAddBarbuf( pNew, iRes,
p->pDesign, Bac_NtkId(
p), i, Bac_NtkId(pBox), iObj, vMap );
137 int iFanin, nLits, pLits[16];
138 assert( Bac_ObjIsBoxPrim(
p, iBox) );
142 if (
p->pDesign->ppGraphs )
146 Vec_Int_t Leaves = { nLits, nLits, pLits };
161 else if ( nLits == 1 )
166 iRes = Abc_LitNot( pLits[0] );
169 else if ( nLits == 2 )
178 iRes = Abc_LitNot(
Gia_ManHashOr( pNew, pLits[0], pLits[1] ) );
189 else if ( nLits == 3 )
199 assert( Bac_BoxBoNum(
p, iBox) == 2 );
200 if ( Bac_BoxBo(
p, iBox, 0) == i )
202 else if ( Bac_BoxBo(
p, iBox, 1) == i )
213 Bac_ObjSetCopy(
p, i, iRes );
223 Vec_IntClear( &
p->vBuf2LeafNtk );
224 Vec_IntClear( &
p->vBuf2LeafObj );
225 Vec_IntClear( &
p->vBuf2RootNtk );
226 Vec_IntClear( &
p->vBuf2RootObj );
230 Bac_NtkDeriveIndex( pNtk );
231 Bac_NtkStartCopies( pNtk );
236 pNew->
pName = Abc_UtilStrsav(
p->pName);
237 pNew->
pSpec = Abc_UtilStrsav(
p->pSpec);
241 Bac_ObjSetCopy( pRoot, iObj, Gia_ManAppendCi(pNew) );
245 pNew->
vBarBufs = Vec_IntAlloc( 10000 );
246 vMap = Vec_IntStartFull( 10000 );
251 Vec_IntFreeP( &vMap );
256 Gia_ManAppendCo( pNew, Bac_ObjCopy(pRoot, iObj) );
280 assert( Vec_IntSize(&
p->vBuf2LeafNtk) == Gia_ManBufNum(pGia) );
281 Gia_ManConst0(pGia)->Value = 1;
286 if ( Gia_ObjIsBuf(pObj) )
287 pObj->
Value = Vec_IntEntry( &
p->vBuf2LeafNtk, Count++ );
290 pObj->
Value = Gia_ObjFanin0(pObj)->Value;
291 assert( pObj->
Value == Gia_ObjFanin1(pObj)->Value );
294 assert( Count == Gia_ManBufNum(pGia) );
297 assert( Gia_ObjFanin0(pObj)->Value == 1 );
312 pNtk = Bac_ManNtk(
p, Vec_IntEntry(&
p->vBuf2LeafNtk, i) );
313 Vec_IntWriteEntry( &pNew->
vBuf2LeafObj, i, Bac_ObjCopy(pNtk, Entry) );
317 pNtk = Bac_ManNtk(
p, Vec_IntEntry(&
p->vBuf2RootNtk, i) );
318 Vec_IntWriteEntry( &pNew->
vBuf2RootObj, i, Bac_ObjCopy(pNtk, Entry) );
324 if ( pGia && Gia_ObjFaninId0p(pGia, pObj) > 0 )
326 iObj = Bac_ObjAlloc(
p,
BAC_OBJ_BI, Gia_ObjFanin0(pObj)->Value );
334 Bac_ObjSetFanin(
p, iTerm, iObj );
339 int i, j, k, iBox, iTerm, Count = 0;
342 Gia_ManConst0(pGia)->Value = ~0;
344 pObj->
Value = Bac_NtkPi( pRoot, i );
347 if ( Gia_ObjIsBuf(pObj) )
349 pNtk = Bac_ManNtk(
p, Vec_IntEntry(&
p->vBuf2RootNtk, Count) );
350 iTerm = Vec_IntEntry( &
p->vBuf2RootObj, Count );
351 assert( Bac_ObjIsCo(pNtk, iTerm) );
352 if ( Bac_ObjFanin(pNtk, iTerm) == -1 )
355 pObj->
Value = Vec_IntEntry( &
p->vBuf2LeafObj, Count++ );
359 int iLit0 = Gia_ObjFanin0(pObj)->Value;
360 int iLit1 = Gia_ObjFanin1(pObj)->Value;
362 pNtk = Bac_ManNtk(
p, pObj->
Value );
363 if ( Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) )
365 else if ( Gia_ObjFaninC1(pObj) )
367 else if ( Gia_ObjFaninC0(pObj) )
375 iTerm = Bac_ObjAlloc( pNtk,
BAC_OBJ_BI, iLit1 );
376 iTerm = Bac_ObjAlloc( pNtk,
BAC_OBJ_BI, iLit0 );
377 Bac_ObjAlloc( pNtk, Type, -1 );
381 assert( Count == Gia_ManBufNum(pGia) );
388 if ( Bac_ObjFanin(pNtk, iTerm) == -1 )
391 if ( pNtk != pRoot && Bac_ObjFanin(pNtk, iTerm) == -1 )
396 if ( Bac_ObjFanin(pRoot, Bac_NtkPo(pRoot, i)) == -1 )
405 Bac_ManMoveNames( pNew,
p );
439static inline int Abc_NodeIsSeriousGate(
Abc_Obj_t *
p )
441 return Abc_ObjIsNode(
p) && Abc_ObjFaninNum(
p) > 0 && !Abc_ObjIsBarBuf(
p);
445 Abc_Obj_t * pObj, * pFanin;
int i, k, Count = 0;
451 if ( Abc_ObjIsBarBuf(pObj) )
452 pObj->
iTemp = Vec_IntEntry( &
p->vBuf2LeafNtk, Count++ );
453 else if ( Abc_NodeIsSeriousGate(pObj) )
455 pObj->
iTemp = Abc_ObjFanin0(pObj)->iTemp;
462 if ( !Abc_NodeIsSeriousGate(Abc_ObjFanin0(pObj)) )
464 assert( Abc_ObjFanin0(pObj)->iTemp == 1 );
465 pObj->
iTemp = Abc_ObjFanin0(pObj)->iTemp;
472 if ( pFanin && Abc_NodeIsSeriousGate(pFanin) )
474 iObj = pFanin->
iTemp;
476 else if ( pFanin && (Abc_ObjIsPi(pFanin) || Abc_ObjIsBarBuf(pFanin) || Abc_NodeIsSeriousGate(pFanin)) )
488 Bac_ObjSetFanin(
p, iTerm, iObj );
496 if ( !pGate0 || !pGate1 || !pGate2 )
498 printf(
"The library does not have one of the elementary gates.\n" );
505 if ( pGate != pGate0 && pGate != pGate1 && pGate != pGate2 )
514 printf(
"The standard cell library is not available.\n" ), RetValue = 0;
522 Bac_Ntk_t * pCbaNtk, * pRoot = Bac_ManRoot(
p );
523 int i, j, k, iBox, iTerm, Count = 0;
525 assert( Abc_NtkHasMapping(pNtk) );
530 pObj->
iTemp = Bac_NtkPi( pRoot, i );
533 if ( Abc_ObjIsBarBuf(pObj) )
535 pCbaNtk = Bac_ManNtk(
p, Vec_IntEntry(&
p->vBuf2RootNtk, Count) );
536 iTerm = Vec_IntEntry( &
p->vBuf2RootObj, Count );
537 assert( Bac_ObjIsCo(pCbaNtk, iTerm) );
538 if ( Bac_ObjFanin(pCbaNtk, iTerm) == -1 )
541 pObj->
iTemp = Vec_IntEntry( &
p->vBuf2LeafObj, Count++ );
543 else if ( Abc_NodeIsSeriousGate(pObj) )
545 pCbaNtk = Bac_ManNtk(
p, pObj->
iTemp );
546 for ( k = Abc_ObjFaninNum(pObj)-1; k >= 0; k-- )
547 iTerm = Bac_ObjAlloc( pCbaNtk,
BAC_OBJ_BI, Abc_ObjFanin(pObj, k)->iTemp );
559 if ( Bac_ObjFanin(pCbaNtk, iTerm) == -1 )
562 if ( pCbaNtk != pRoot && Bac_ObjFanin(pCbaNtk, iTerm) == -1 )
567 if ( Bac_ObjFanin(pRoot, Bac_NtkPo(pRoot, i)) == -1 )
577 Bac_ManMoveNames( pNew,
p );
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachPo(pNtk, pPo, i)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL int Abc_NodeIsConst0(Abc_Obj_t *pNode)
#define Abc_NtkForEachPi(pNtk, pPi, i)
ABC_DLL int Abc_NodeIsConst1(Abc_Obj_t *pNode)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_SWAP(Type, a, b)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Gia_Man_t * Bac_ManExtract(Bac_Man_t *p, int fBuffers, int fVerbose)
int Bac_ManExtract_rec(Gia_Man_t *pNew, Bac_Ntk_t *p, int i, int fBuffers, Vec_Int_t *vMap)
void Bac_NtkPrepareLibrary(Bac_Man_t *p, Mio_Library_t *pLib)
Bac_Man_t * Bac_ManInsertGia(Bac_Man_t *p, Gia_Man_t *pGia)
void Bac_ManRemapBarbufs(Bac_Man_t *pNew, Bac_Man_t *p)
int Bac_NtkBuildLibrary(Bac_Man_t *p)
void Bac_NtkCreateAndConnectBuffer(Gia_Man_t *pGia, Gia_Obj_t *pObj, Bac_Ntk_t *p, int iTerm)
void Bac_NtkInsertNtk(Bac_Man_t *p, Abc_Ntk_t *pNtk)
int Bac_ManAddBarbuf(Gia_Man_t *pNew, int iRes, Bac_Man_t *p, int iLNtk, int iLObj, int iRNtk, int iRObj, Vec_Int_t *vMap)
ABC_NAMESPACE_IMPL_START void Bac_ManPrepareGates(Bac_Man_t *p)
DECLARATIONS ///.
void Bac_ManMarkNodesAbc(Bac_Man_t *p, Abc_Ntk_t *pNtk)
Bac_Man_t * Bac_ManBlastTest(Bac_Man_t *p)
void Bac_ManUndoGates(Bac_Man_t *p)
void * Bac_ManInsertAbc(Bac_Man_t *p, void *pAbc)
void Bac_ManMarkNodesGia(Bac_Man_t *p, Gia_Man_t *pGia)
void Bac_NtkInsertGia(Bac_Man_t *p, Gia_Man_t *pGia)
void Bac_NtkCreateOrConnectFanin(Abc_Obj_t *pFanin, Bac_Ntk_t *p, int iTerm)
struct Bac_Man_t_ Bac_Man_t
struct Bac_Ntk_t_ Bac_Ntk_t
#define Bac_NtkForEachPi(p, iObj, i)
#define Bac_BoxForEachFanin(p, iBox, iFanin, i)
#define Bac_BoxForEachBi(p, iBox, iTerm, i)
#define Bac_NtkForEachPo(p, iObj, i)
#define Bac_ManForEachNtk(p, pNtk, i)
MACRO DEFINITIONS ///.
#define Bac_NtkForEachBox(p, i)
Bac_ObjType_t
INCLUDES ///.
ABC_DLL void * Abc_FrameReadLibGen()
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Dec_Graph_t * Dec_Factor(char *pSop)
FUNCTION DECLARATIONS ///.
struct Dec_Graph_t_ Dec_Graph_t
int Gia_ManFactorGraph(Gia_Man_t *p, Dec_Graph_t *pFForm, Vec_Int_t *vLeaves)
void Gia_ManStop(Gia_Man_t *p)
#define Gia_ManForEachPo(p, pObj, i)
#define Gia_ManForEachAnd(p, pObj, i)
void Gia_ManHashAlloc(Gia_Man_t *p)
#define Gia_ManForEachPi(p, pObj, i)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
struct Gia_Obj_t_ Gia_Obj_t
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
struct Gia_Man_t_ Gia_Man_t
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
void Gia_ManHashStop(Gia_Man_t *p)
int Gia_ManHashMaj(Gia_Man_t *p, int iData0, int iData1, int iData2)
Mio_Gate_t * Mio_LibraryReadConst0(Mio_Library_t *pLib)
struct Mio_LibraryStruct_t_ Mio_Library_t
char * Mio_GateReadSop(Mio_Gate_t *pGate)
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
char * Mio_GateReadName(Mio_Gate_t *pGate)
Mio_Gate_t * Mio_LibraryReadConst1(Mio_Library_t *pLib)
struct Mio_GateStruct_t_ Mio_Gate_t
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
int Abc_NamStrFind(Abc_Nam_t *p, char *pStr)
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
int Abc_NamObjNumMax(Abc_Nam_t *p)
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.