diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2013-08-16 13:13:38 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2013-08-16 13:13:38 -0700 |
commit | 3459683e3b5ee9bb3f155fff3bf1041c840266c4 (patch) | |
tree | 67500383a384eaea0120d138eac28e69b0b6646e /src/base/abc/abcNtk.c | |
parent | 7013e0b672a881a979ef05f504ba3b2fb3dfdaf4 (diff) | |
download | abc-3459683e3b5ee9bb3f155fff3bf1041c840266c4.tar.gz abc-3459683e3b5ee9bb3f155fff3bf1041c840266c4.tar.bz2 abc-3459683e3b5ee9bb3f155fff3bf1041c840266c4.zip |
Extending 'permute' to handle user-specified flop permutation.
Diffstat (limited to 'src/base/abc/abcNtk.c')
-rw-r--r-- | src/base/abc/abcNtk.c | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/src/base/abc/abcNtk.c b/src/base/abc/abcNtk.c index 5631902b..e1ec89df 100644 --- a/src/base/abc/abcNtk.c +++ b/src/base/abc/abcNtk.c @@ -1878,15 +1878,72 @@ void Abc_NtkRemovePo( Abc_Ntk_t * pNtk, int iOutput, int fRemoveConst0 ) SeeAlso [] ***********************************************************************/ -void Abc_NtkPermute( Abc_Ntk_t * pNtk, int fInputs, int fOutputs, int fFlops ) +Vec_Int_t * Abc_NtkReadFlopPerm( char * pFileName, int nFlops ) +{ + char Buffer[1000]; + FILE * pFile; + Vec_Int_t * vFlops; + int iFlop; + pFile = fopen( pFileName, "rb" ); + if ( pFile == NULL ) + { + printf( "Cannot open input file \"%s\".\n", pFileName ); + return NULL; + } + vFlops = Vec_IntAlloc( nFlops ); + while ( fgets( Buffer, 1000, pFile ) != NULL ) + { + if ( Buffer[0] == ' ' || Buffer[0] == '\r' || Buffer[0] == '\n' ) + continue; + iFlop = atoi( Buffer ); + if ( iFlop < 0 || iFlop >= nFlops ) + { + printf( "Flop ID (%d) is out of range.\n", iFlop ); + fclose( pFile ); + Vec_IntFree( vFlops ); + return NULL; + } + Vec_IntPush( vFlops, iFlop ); + } + fclose( pFile ); + if ( Vec_IntSize(vFlops) != nFlops ) + { + printf( "The number of flops read in from file (%d) is different from the number of flops in the circuit (%d).\n", iFlop, nFlops ); + Vec_IntFree( vFlops ); + return NULL; + } + return vFlops; +} +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Abc_NtkPermute( Abc_Ntk_t * pNtk, int fInputs, int fOutputs, int fFlops, char * pFlopPermFile ) { Abc_Obj_t * pTemp; Vec_Int_t * vInputs, * vOutputs, * vFlops, * vTemp; int i, k, Entry; // start permutation arrays + if ( pFlopPermFile ) + { + vFlops = Abc_NtkReadFlopPerm( pFlopPermFile, Abc_NtkLatchNum(pNtk) ); + if ( vFlops == NULL ) + return; + fInputs = 0; + fOutputs = 0; + fFlops = 0; + } + else + vFlops = Vec_IntStartNatural( Abc_NtkLatchNum(pNtk) ); vInputs = Vec_IntStartNatural( Abc_NtkPiNum(pNtk) ); vOutputs = Vec_IntStartNatural( Abc_NtkPoNum(pNtk) ); - vFlops = Vec_IntStartNatural( Abc_NtkLatchNum(pNtk) ); // permute inputs if ( fInputs ) for ( i = 0; i < Abc_NtkPiNum(pNtk); i++ ) |