49 static word uTruth, uTruths6[3] = {
54 assert( Abc_ObjIsNode(pObj) );
68 if ( uTruth == 0 )
return "Const0T";
69 if ( uTruth == ~(
word)0 )
return "Const1T";
70 if ( uTruth == uTruths6[0] )
return "BufT";
71 if ( uTruth == ~uTruths6[0] )
return "InvT";
72 if ( uTruth == (uTruths6[0] & uTruths6[1]) )
return "AndT";
73 if ( uTruth ==~(uTruths6[0] & uTruths6[1]) )
return "NandT";
74 if ( uTruth == (uTruths6[0] | uTruths6[1]) )
return "OrT";
75 if ( uTruth ==~(uTruths6[0] | uTruths6[1]) )
return "NorT";
76 if ( uTruth == (uTruths6[0] ^ uTruths6[1]) )
return "XorT";
77 if ( uTruth ==~(uTruths6[0] ^ uTruths6[1]) )
return "XnorT";
96 if ( Abc_ObjIsNet(pObj) || Abc_ObjIsBox(pObj) )
98 if ( Abc_ObjIsCi(pObj) || Abc_ObjIsNode(pObj) )
100 if ( Abc_ObjIsCo(pObj) )
105static int Ptr_CheckArray(
Vec_Ptr_t * vArray )
107 assert( Vec_PtrSize(vArray) == Vec_PtrCap(vArray) );
113 Vec_Ptr_t * vNode = Vec_PtrAllocExact( 2 + 2 * (1 + Abc_ObjFaninNum(pObj)) );
114 assert( Abc_ObjIsNode(pObj) );
115 if ( Abc_NtkHasAig(pObj->
pNtk) )
117 else if ( Abc_NtkHasSop(pObj->
pNtk) )
118 Vec_PtrPush( vNode, Ptr_SopToTypeName((
char *)pObj->
pData) );
121 assert( Abc_ObjFaninNum(pObj) <= 2 );
124 Vec_PtrPush( vNode, (
void*)(i ?
"r" :
"l") );
127 Vec_PtrPush( vNode, (
void*)(
"o") );
129 assert( Ptr_CheckArray(vNode) );
136 Vec_Ptr_t * vBox = Vec_PtrAllocExact( 2 + 2 * Abc_ObjFaninNum(pObj) + 2 * Abc_ObjFanoutNum(pObj) );
137 assert( Abc_ObjIsBox(pObj) );
138 Vec_PtrPush( vBox, Abc_NtkName(pNtk) );
150 assert( Ptr_CheckArray(vBox) );
156 Vec_Ptr_t * vBoxes = Vec_PtrAllocExact( Abc_NtkBoxNum(pNtk) + Abc_NtkNodeNum(pNtk) );
161 assert( Ptr_CheckArray(vBoxes) );
168 Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Abc_NtkPiNum(pNtk) );
171 assert( Ptr_CheckArray(vSigs) );
177 Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Abc_NtkPoNum(pNtk) );
180 assert( Ptr_CheckArray(vSigs) );
185 Vec_Ptr_t * vNtk = Vec_PtrAllocExact( 5 );
186 Vec_PtrPush( vNtk, Abc_NtkName(pNtk) );
189 Vec_PtrPush( vNtk, Vec_PtrAllocExact(0) );
191 assert( Ptr_CheckArray(vNtk) );
202 assert( Ptr_CheckArray(vDes) );
222 printf(
"Converting to Ptr: Memory = %6.3f MB ", 1.0*
Bac_PtrMemory(vDes)/(1<<20) );
223 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
225 printf(
"Finished writing output file \"%s\". ", pFileName );
226 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
241static inline int Ptr_NameToType(
char * pSop )
262 assert( Vec_PtrSize(vNodes) == 0 );
263 Counter += Vec_PtrSize(vInputs);
264 Counter += Vec_PtrSize(vOutputs);
266 Counter += Vec_PtrSize(vBox)/2;
271 int ModuleId = Bac_ManNtkFindId( pNtk->
pDesign, pBoxNtk );
274 return Bac_NtkPoNumAlloc( Bac_ManNtk(pNtk->
pDesign, ModuleId) );
278 char * pName, * pModuleName = (
char *)Vec_PtrEntry(vNtk, 0);
282 int i, k, iObj, iTerm, NameId;
285 assert( Bac_NtkNameId(pNtk) == NameId );
290 if ( Vec_IntGetEntryFull(vMap, NameId) != -1 )
291 { printf(
"PI with name \"%s\" is not unique module \"%s\".\n", pName, pModuleName );
return 0; }
293 Bac_ObjSetName( pNtk, iObj, Abc_Var2Lit2(NameId,
BAC_NAME_BIN) );
294 Vec_IntSetEntryFull( vMap, NameId, iObj );
295 Bac_NtkAddInfo( pNtk, Abc_Var2Lit2(NameId, 1), -1, -1 );
298 Vec_IntClear( vBox2Id );
301 char * pBoxNtk = (
char *)Vec_PtrEntry(vBox, 0);
302 char * pBoxName = (
char *)Vec_PtrEntry(vBox, 1);
304 int nInputs = Vec_PtrSize(vBox)/2 - nOutputs - 1;
305 int NtkId = Bac_ManNtkFindId( pNtk->
pDesign, pBoxNtk );
306 assert( Vec_PtrSize(vBox) % 2 == 0 );
307 assert( nOutputs > 0 && 2*(nOutputs + 1) <= Vec_PtrSize(vBox) );
308 iObj = Bac_BoxAlloc( pNtk, (
Bac_ObjType_t)Ptr_NameToType(pBoxNtk), nInputs, nOutputs, NtkId );
310 Bac_NtkSetHost( Bac_ManNtk(pNtk->
pDesign, NtkId), Bac_NtkId(pNtk), iObj );
314 pName = (
char *)Vec_PtrEntry( vBox, Vec_PtrSize(vBox) - 2*(nOutputs - k) + 1 );
316 if ( Vec_IntGetEntryFull(vMap, NameId) != -1 )
317 { printf(
"Signal \"%s\" has multiple drivers in module \"%s\".\n", pName, pModuleName );
return 0; }
318 Bac_ObjSetName( pNtk, iTerm, Abc_Var2Lit2(NameId,
BAC_NAME_BIN) );
319 Vec_IntSetEntryFull( vMap, NameId, iTerm );
321 Vec_IntPush( vBox2Id, iObj );
323 assert( Vec_IntSize(vBox2Id) == Vec_PtrSize(vBoxes) );
327 iObj = Vec_IntEntry( vBox2Id, i );
330 pName = (
char *)Vec_PtrEntry( vBox, 2*(k + 1) + 1 );
332 if ( Vec_IntGetEntryFull(vMap, NameId) == -1 )
333 printf(
"Signal \"%s\" in not driven in module \"%s\".\n", pName, pModuleName );
334 Bac_ObjSetFanin( pNtk, iTerm, Vec_IntGetEntryFull(vMap, NameId) );
341 if ( Vec_IntGetEntryFull(vMap, NameId) == -1 )
342 printf(
"PO with name \"%s\" in not driven in module \"%s\".\n", pName, pModuleName );
343 iObj = Bac_ObjAlloc( pNtk,
BAC_OBJ_PO, Vec_IntGetEntryFull(vMap, NameId) );
344 Bac_NtkAddInfo( pNtk, Abc_Var2Lit2(NameId, 2), -1, -1 );
348 Vec_IntSetEntryFull( vMap, Bac_ObjNameId(pNtk, iObj), -1 );
352 assert( Bac_NtkObjNum(pNtk) == Vec_StrCap(&pNtk->
vType) );
357 char * pName = (
char *)Vec_PtrEntry(vDes, 0);
358 Bac_Man_t * pNew = Bac_ManAlloc( pName, Vec_PtrSize(vDes) - 1 );
359 Vec_Int_t * vMap = Vec_IntStartFull( 1000 );
360 Vec_Int_t * vBox2Id = Vec_IntAlloc( 1000 );
369 Bac_NtkAlloc( pNtk, NameId, Vec_PtrSize(vInputs), Vec_PtrSize(vOutputs),
Ptr_ManCountNtk(vNtk) );
370 Bac_NtkStartNames( pNtk );
379 if ( i <= Bac_ManNtkNum(pNew) )
380 Bac_ManFree(pNew), pNew = NULL;
381 Vec_IntFree( vBox2Id );
400 int i, iTerm, fUser = Bac_ObjIsBoxUser(
p, iBox );
404 Vec_Ptr_t * vBox = Vec_PtrAllocExact( 2*Bac_BoxSize(
p, iBox) );
405 Vec_PtrPush( vBox, Bac_BoxNtkName(
p, iBox) );
406 Vec_PtrPush( vBox, Bac_ObjNameStr(
p, iBox) );
409 Vec_PtrPush( vBox, fUser ? Bac_ObjNameStr(pBoxNtk, Bac_NtkPi(pBoxNtk, i)) :
Mio_GateReadPinName(pGate, i) );
410 Vec_PtrPush( vBox, Bac_ObjNameStr(
p, iTerm) );
414 Vec_PtrPush( vBox, fUser ? Bac_ObjNameStr(pBoxNtk, Bac_NtkPo(pBoxNtk, i)) :
Mio_GateReadOutName(pGate) );
415 Vec_PtrPush( vBox, Bac_ObjNameStr(
p, iTerm) );
417 assert( Ptr_CheckArray(vBox) );
423 Vec_Ptr_t * vBoxes = Vec_PtrAllocExact( Bac_NtkBoxNum(
p) );
426 assert( Ptr_CheckArray(vBoxes) );
433 Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Bac_NtkPiNum(
p) );
435 Vec_PtrPush( vSigs, Bac_ObjNameStr(
p, iTerm) );
436 assert( Ptr_CheckArray(vSigs) );
442 Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Bac_NtkPoNum(
p) );
444 Vec_PtrPush( vSigs, Bac_ObjNameStr(
p, iTerm) );
445 assert( Ptr_CheckArray(vSigs) );
451 Vec_PtrPush( vNtk, Bac_NtkName(
p) );
454 Vec_PtrPush( vNtk, Vec_PtrAllocExact(0) );
456 assert( Ptr_CheckArray(vNtk) );
465 if (
p->pMioLib == NULL )
467 printf(
"Cannot transform CBA network into Ptr because it is not mapped.\n" );
471 vDes = Vec_PtrAllocExact( 1 + Bac_ManNtkNum(
p) );
472 Vec_PtrPush( vDes,
p->pName );
475 assert( Ptr_CheckArray(vDes) );
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachPo(pNtk, pPo, i)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
#define Abc_NtkForEachPi(pNtk, pPi, i)
#define Abc_NtkForEachBox(pNtk, pObj, i)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_CONST(number)
PARAMETERS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Vec_Ptr_t * Ptr_AbcDeriveNode(Abc_Obj_t *pObj)
Vec_Ptr_t * Ptr_AbcDeriveOutputs(Abc_Ntk_t *pNtk)
Vec_Ptr_t * Ptr_AbcDeriveBox(Abc_Obj_t *pObj)
int Bac_BoxCountOutputs(Bac_Ntk_t *pNtk, char *pBoxNtk)
int Bac_NtkDeriveFromPtr(Bac_Ntk_t *pNtk, Vec_Ptr_t *vNtk, Vec_Int_t *vMap, Vec_Int_t *vBox2Id)
Vec_Ptr_t * Bac_NtkTransformToPtrBoxes(Bac_Ntk_t *p)
int Ptr_ManCountNtk(Vec_Ptr_t *vNtk)
Vec_Ptr_t * Ptr_AbcDeriveNtk(Abc_Ntk_t *pNtk)
Vec_Ptr_t * Ptr_AbcDeriveInputs(Abc_Ntk_t *pNtk)
char * Ptr_AbcObjName(Abc_Obj_t *pObj)
Vec_Ptr_t * Bac_NtkTransformToPtr(Bac_Ntk_t *p)
Vec_Ptr_t * Bac_NtkTransformToPtrBox(Bac_Ntk_t *p, int iBox)
Bac_Man_t * Bac_PtrTransformToCba(Vec_Ptr_t *vDes)
ABC_NAMESPACE_IMPL_START char * Ptr_HopToType(Abc_Obj_t *pObj)
DECLARATIONS ///.
Vec_Ptr_t * Bac_NtkTransformToPtrInputs(Bac_Ntk_t *p)
Vec_Ptr_t * Bac_NtkTransformToPtrOutputs(Bac_Ntk_t *p)
Vec_Ptr_t * Ptr_AbcDeriveBoxes(Abc_Ntk_t *pNtk)
Vec_Ptr_t * Bac_PtrDeriveFromCba(Bac_Man_t *p)
void Ptr_ManExperiment(Abc_Ntk_t *pNtk)
Vec_Ptr_t * Ptr_AbcDeriveDes(Abc_Ntk_t *pNtk)
void Bac_PtrFree(Vec_Ptr_t *vDes)
struct Bac_Man_t_ Bac_Man_t
struct Bac_Ntk_t_ Bac_Ntk_t
#define Bac_BoxForEachBo(p, iBox, iTerm, i)
#define Bac_NtkForEachPi(p, iObj, i)
#define Bac_NtkForEachCi(p, i)
void Bac_ManAssignInternWordNames(Bac_Man_t *p)
#define Bac_BoxForEachBi(p, iBox, iTerm, i)
int Bac_PtrMemory(Vec_Ptr_t *vDes)
#define Bac_NtkForEachPo(p, iObj, i)
void Bac_PtrDumpBlif(char *pFileName, Vec_Ptr_t *vDes)
#define Bac_ManForEachNtk(p, pNtk, i)
MACRO DEFINITIONS ///.
#define Bac_NtkForEachBox(p, i)
Bac_ObjType_t
INCLUDES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
word Hop_ManComputeTruth6(Hop_Man_t *p, Hop_Obj_t *pObj, int nVars)
struct Hop_Obj_t_ Hop_Obj_t
unsigned __int64 word
DECLARATIONS ///.
struct Mio_LibraryStruct_t_ Mio_Library_t
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
char * Mio_GateReadPinName(Mio_Gate_t *pGate, int iPin)
char * Mio_GateReadOutName(Mio_Gate_t *pGate)
struct Mio_GateStruct_t_ Mio_Gate_t
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.