52 int nInputs, nOutputs, nLatches, nAnds, nFileSize, Num, i;
53 char * pContents, * pName, * pCur;
54 unsigned * pBufferNode;
59 pFile = fopen( pFileName,
"rb" );
61 RetValue = fread( pContents, nFileSize, 1, pFile );
65 for ( pCur = pContents; *pCur ==
'#'; )
66 while ( *pCur++ !=
'\n' );
69 pName = pCur;
while ( *pCur++ );
71 nInputs = atoi( pCur );
while ( *pCur++ );
73 nOutputs = atoi( pCur );
while ( *pCur++ );
75 nLatches = atoi( pCur );
while ( *pCur++ );
77 nAnds = atoi( pCur );
while ( *pCur++ );
85 vNodes = Vec_PtrAlloc( 1 + nInputs + nLatches + nAnds );
89 for ( i = 0; i < nInputs; i++ )
91 pObj = Abc_NtkCreatePi(pNtkNew);
93 Vec_PtrPush( vNodes, pObj );
96 for ( i = 0; i < nOutputs; i++ )
98 pObj = Abc_NtkCreatePo(pNtkNew);
102 for ( i = 0; i < nLatches; i++ )
104 pObj = Abc_NtkCreateLatch(pNtkNew);
107 pNode0 = Abc_NtkCreateBi(pNtkNew);
110 pNode1 = Abc_NtkCreateBo(pNtkNew);
112 Vec_PtrPush( vNodes, pNode1 );
119 pBufferNode = (
unsigned *)(pContents + (nFileSize - (2 * nAnds + nOutputs + nLatches) *
sizeof(
int)) );
121 if ( pBufferNode != (
unsigned *)pCur )
124 Vec_PtrFree( vNodes );
126 printf(
"Warning: Internal reader error.\n" );
132 for ( i = 0; i < nAnds; i++ )
134 Extra_ProgressBarUpdate( pProgress, i, NULL );
135 pNode0 = Abc_ObjNotCond( (
Abc_Obj_t *)Vec_PtrEntry(vNodes, pBufferNode[2*i+0] >> 1), pBufferNode[2*i+0] & 1 );
136 pNode1 = Abc_ObjNotCond( (
Abc_Obj_t *)Vec_PtrEntry(vNodes, pBufferNode[2*i+1] >> 1), pBufferNode[2*i+1] & 1 );
144 Num = pBufferNode[2*nAnds+i];
145 if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
147 Abc_ObjSetData( Abc_ObjFanout0(pObj), (
void *)(ABC_PTRINT_T)(Num & 3) );
150 pNode0 = Abc_ObjNotCond( (
Abc_Obj_t *)Vec_PtrEntry(vNodes, Num >> 1), Num & 1 );
154 Vec_PtrFree( vNodes );
162 printf(
"Io_ReadBaf: The network check has failed.\n" );