diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-06-22 23:04:43 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-06-22 23:04:43 -0700 |
commit | 70697f868a263930e971c062e5b46e64fbb1ee18 (patch) | |
tree | 7ecd062ec16b58d5a625fe3591589728f705814c /src/base/io/ioReadBlif.c | |
parent | d5b0fdee741dbc64bcfe75c54420219a7cbeac1a (diff) | |
download | abc-70697f868a263930e971c062e5b46e64fbb1ee18.tar.gz abc-70697f868a263930e971c062e5b46e64fbb1ee18.tar.bz2 abc-70697f868a263930e971c062e5b46e64fbb1ee18.zip |
Version abc90528
committer: Baruch Sterin <baruchs@gmail.com>
Diffstat (limited to 'src/base/io/ioReadBlif.c')
-rw-r--r-- | src/base/io/ioReadBlif.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/base/io/ioReadBlif.c b/src/base/io/ioReadBlif.c index b6eb29e3..f2c3e8c2 100644 --- a/src/base/io/ioReadBlif.c +++ b/src/base/io/ioReadBlif.c @@ -535,6 +535,71 @@ int Io_ReadBlifNetworkNames( Io_ReadBlif_t * p, Vec_Ptr_t ** pvTokens ) SeeAlso [] ***********************************************************************/ +int Io_ReadBlifReorderFormalNames( Vec_Ptr_t * vTokens, Mio_Gate_t * pGate ) +{ + Mio_Pin_t * pGatePin; + char * pName, * pNamePin; + int i, k, nSize, Length; + nSize = Vec_PtrSize(vTokens); + if ( nSize - 3 != Mio_GateReadInputs(pGate) ) + return 0; + // check if the names are in order + for ( pGatePin = Mio_GateReadPins(pGate), i = 0; pGatePin; pGatePin = Mio_PinReadNext(pGatePin), i++ ) + { + pNamePin = Mio_PinReadName(pGatePin); + Length = strlen(pNamePin); + pName = Vec_PtrEntry(vTokens, i+2); + if ( !strncmp( pNamePin, pName, Length ) && pName[Length] == '=' ) + continue; + break; + } + if ( i == nSize - 3 ) + return 1; + // reorder the pins + for ( pGatePin = Mio_GateReadPins(pGate), i = 0; pGatePin; pGatePin = Mio_PinReadNext(pGatePin), i++ ) + { + pNamePin = Mio_PinReadName(pGatePin); + Length = strlen(pNamePin); + for ( k = 2; k < nSize; k++ ) + { + pName = Vec_PtrEntry(vTokens, k); + if ( !strncmp( pNamePin, pName, Length ) && pName[Length] == '=' ) + { + Vec_PtrPush( vTokens, pName ); + break; + } + } + } + pNamePin = Mio_GateReadOutName(pGate); + Length = strlen(pNamePin); + for ( k = 2; k < nSize; k++ ) + { + pName = Vec_PtrEntry(vTokens, k); + if ( !strncmp( pNamePin, pName, Length ) && pName[Length] == '=' ) + { + Vec_PtrPush( vTokens, pName ); + break; + } + } + if ( Vec_PtrSize(vTokens) - nSize != nSize - 2 ) + return 0; + Vec_PtrForEachEntryStart( vTokens, pName, k, nSize ) + Vec_PtrWriteEntry( vTokens, k - nSize + 2, pName ); + Vec_PtrShrink( vTokens, nSize ); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ int Io_ReadBlifNetworkGate( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens ) { Mio_Library_t * pGenlib; @@ -581,6 +646,16 @@ int Io_ReadBlifNetworkGate( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens ) p->pNtkCur->pManFunc = pGenlib; } + // reorder the formal inputs to be in the same order as in the gate + if ( !Io_ReadBlifReorderFormalNames( vTokens, pGate ) ) + { + p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0); + sprintf( p->sError, "Mismatch in the fanins of gate \"%s\".", (char*)vTokens->pArray[1] ); + Io_ReadBlifPrintErrorMessage( p ); + return 1; + } + + // remove the formal parameter names for ( i = 2; i < vTokens->nSize; i++ ) { |