summaryrefslogtreecommitdiffstats
path: root/src/base/io/ioReadAiger.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2007-08-17 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2007-08-17 08:01:00 -0700
commit9e4213e202b516c6c920d7e0faaf603273d1795d (patch)
treef29fe0c95d664127730a4c8c21523884fd1f0cdf /src/base/io/ioReadAiger.c
parent29c9b0c0c4c66cb09b7c00c5c7290141be2af6a0 (diff)
downloadabc-9e4213e202b516c6c920d7e0faaf603273d1795d.tar.gz
abc-9e4213e202b516c6c920d7e0faaf603273d1795d.tar.bz2
abc-9e4213e202b516c6c920d7e0faaf603273d1795d.zip
Version abc70817
Diffstat (limited to 'src/base/io/ioReadAiger.c')
-rw-r--r--src/base/io/ioReadAiger.c123
1 files changed, 70 insertions, 53 deletions
diff --git a/src/base/io/ioReadAiger.c b/src/base/io/ioReadAiger.c
index 23b5b350..be80dc82 100644
--- a/src/base/io/ioReadAiger.c
+++ b/src/base/io/ioReadAiger.c
@@ -121,8 +121,7 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck )
Abc_ObjAddFanin( pNode1, pObj );
Vec_PtrPush( vNodes, pNode1 );
// assign names to latch and its input
- Abc_ObjAssignName( pObj, Abc_ObjNameDummy("_L", i, nDigits), NULL );
-
+// Abc_ObjAssignName( pObj, Abc_ObjNameDummy("_L", i, nDigits), NULL );
// printf( "Creating latch %s with input %d and output %d.\n", Abc_ObjName(pObj), pNode0->Id, pNode1->Id );
}
@@ -142,7 +141,7 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck )
uLit = ((i + 1 + nInputs + nLatches) << 1);
uLit1 = uLit - Io_ReadAigerDecode( &pCur );
uLit0 = uLit1 - Io_ReadAigerDecode( &pCur );
- assert( uLit1 > uLit0 );
+// assert( uLit1 > uLit0 );
pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
pNode1 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
assert( Vec_PtrSize(vNodes) == i + 1 + nInputs + nLatches );
@@ -171,66 +170,84 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck )
pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
Abc_ObjAddFanin( pObj, pNode0 );
}
-
+
// read the names if present
pCur = pSymbols;
- while ( pCur < pContents + nFileSize && *pCur != 'c' )
+ if ( *pCur != 'c' )
{
- // get the terminal type
- pType = pCur;
- if ( *pCur == 'i' )
- vTerms = pNtkNew->vPis;
- else if ( *pCur == 'l' )
- vTerms = pNtkNew->vBoxes;
- else if ( *pCur == 'o' )
- vTerms = pNtkNew->vPos;
- else
+ int Counter = 0;
+ while ( pCur < pContents + nFileSize && *pCur != 'c' )
+ {
+ // get the terminal type
+ pType = pCur;
+ if ( *pCur == 'i' )
+ vTerms = pNtkNew->vPis;
+ else if ( *pCur == 'l' )
+ vTerms = pNtkNew->vBoxes;
+ else if ( *pCur == 'o' )
+ vTerms = pNtkNew->vPos;
+ else
+ {
+ fprintf( stdout, "Wrong terminal type.\n" );
+ return NULL;
+ }
+ // get the terminal number
+ iTerm = atoi( ++pCur ); while ( *pCur++ != ' ' );
+ // get the node
+ if ( iTerm >= Vec_PtrSize(vTerms) )
+ {
+ fprintf( stdout, "The number of terminal is out of bound.\n" );
+ return NULL;
+ }
+ pObj = Vec_PtrEntry( vTerms, iTerm );
+ if ( *pType == 'l' )
+ pObj = Abc_ObjFanout0(pObj);
+ // assign the name
+ pName = pCur; while ( *pCur++ != '\n' );
+ // assign this name
+ *(pCur-1) = 0;
+ Abc_ObjAssignName( pObj, pName, NULL );
+ if ( *pType == 'l' )
+ {
+ Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjName(pObj), "L" );
+ Abc_ObjAssignName( Abc_ObjFanin0(Abc_ObjFanin0(pObj)), Abc_ObjName(pObj), "_in" );
+ }
+ // mark the node as named
+ pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
+ }
+
+ // assign the remaining names
+ Abc_NtkForEachPi( pNtkNew, pObj, i )
{
- fprintf( stdout, "Wrong terminal type.\n" );
- return NULL;
+ if ( pObj->pCopy ) continue;
+ Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
+ Counter++;
}
- // get the terminal number
- iTerm = atoi( ++pCur ); while ( *pCur++ != ' ' );
- // get the node
- if ( iTerm >= Vec_PtrSize(vTerms) )
+ Abc_NtkForEachLatchOutput( pNtkNew, pObj, i )
{
- fprintf( stdout, "The number of terminal is out of bound.\n" );
- return NULL;
+ if ( pObj->pCopy ) continue;
+ Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
+ Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjName(pObj), "L" );
+ Abc_ObjAssignName( Abc_ObjFanin0(Abc_ObjFanin0(pObj)), Abc_ObjName(pObj), "_in" );
+ Counter++;
}
- pObj = Vec_PtrEntry( vTerms, iTerm );
- if ( *pType == 'l' )
- pObj = Abc_ObjFanout0(pObj);
- // assign the name
- pName = pCur; while ( *pCur++ != '\n' );
- // assign this name
- *(pCur-1) = 0;
- Abc_ObjAssignName( pObj, pName, NULL );
- if ( *pType == 'l' )
- Abc_ObjAssignName( Abc_ObjFanin0(Abc_ObjFanin0(pObj)), Abc_ObjName(pObj), "L" );
- // mark the node as named
- pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
- }
- // skipping the comments
- free( pContents );
- Vec_PtrFree( vNodes );
-
- // assign the remaining names
- Abc_NtkForEachPi( pNtkNew, pObj, i )
- {
- if ( pObj->pCopy ) continue;
- Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
- }
- Abc_NtkForEachLatchOutput( pNtkNew, pObj, i )
- {
- if ( pObj->pCopy ) continue;
- Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
- Abc_ObjAssignName( Abc_ObjFanin0(Abc_ObjFanin0(pObj)), Abc_ObjName(pObj), NULL );
+ Abc_NtkForEachPo( pNtkNew, pObj, i )
+ {
+ if ( pObj->pCopy ) continue;
+ Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
+ Counter++;
+ }
+ if ( Counter )
+ printf( "Io_ReadAiger(): Added %d default names for nameless I/O/register objects.\n", Counter );
}
- Abc_NtkForEachPo( pNtkNew, pObj, i )
+ else
{
- if ( pObj->pCopy ) continue;
- Abc_ObjAssignName( pObj, Abc_ObjName(pObj), NULL );
+// printf( "Io_ReadAiger(): I/O/register names are not given. Generating short names.\n" );
+ Abc_NtkShortNames( pNtkNew );
}
+ // skipping the comments
+ free( pContents );
+ Vec_PtrFree( vNodes );
// remove the extra nodes
Abc_AigCleanup( pNtkNew->pManFunc );