Commit 3459683e by Alan Mishchenko

Extending 'permute' to handle user-specified flop permutation.

parent 7013e0b6
......@@ -600,7 +600,7 @@ Aig_Man_t * Iso_ManTest888( Aig_Man_t * pAig1, int fVerbose )
Vec_Int_t * vMap;
pNtk = Abc_NtkFromAigPhase( pAig1 );
Abc_NtkPermute( pNtk, 1, 0, 1 );
Abc_NtkPermute( pNtk, 1, 0, 1, NULL );
pAig2 = Abc_NtkToDar( pNtk, 0, 1 );
Abc_NtkDelete( pNtk );
......
......@@ -737,7 +737,7 @@ extern ABC_DLL Abc_Ntk_t * Abc_NtkCreateWithNode( char * pSop );
extern ABC_DLL void Abc_NtkDelete( Abc_Ntk_t * pNtk );
extern ABC_DLL void Abc_NtkFixNonDrivenNets( Abc_Ntk_t * pNtk );
extern ABC_DLL void Abc_NtkMakeComb( Abc_Ntk_t * pNtk, int fRemoveLatches );
extern ABC_DLL void Abc_NtkPermute( Abc_Ntk_t * pNtk, int fInputs, int fOutputs, int fFlops );
extern ABC_DLL void Abc_NtkPermute( Abc_Ntk_t * pNtk, int fInputs, int fOutputs, int fFlops, char * pFlopPermFile );
extern ABC_DLL void Abc_NtkUnpermute( Abc_Ntk_t * pNtk );
/*=== abcObj.c ==========================================================*/
extern ABC_DLL Abc_Obj_t * Abc_ObjAlloc( Abc_Ntk_t * pNtk, Abc_ObjType_t Type );
......
......@@ -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++ )
......
......@@ -19404,16 +19404,26 @@ int Abc_CommandPermute( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern Abc_Ntk_t * Abc_NtkRestrashRandom( Abc_Ntk_t * pNtk );
Abc_Ntk_t * pNtk = pAbc->pNtkCur, * pNtkRes = NULL;
char * pFlopPermFile = NULL;
int fInputs = 1;
int fOutputs = 1;
int fFlops = 1;
int fNodes = 1;
int c;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "iofnh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "Fiofnh" ) ) != EOF )
{
switch ( c )
{
case 'F':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-F\" should be followed by a file name.\n" );
goto usage;
}
pFlopPermFile = argv[globalUtilOptind];
globalUtilOptind++;
break;
case 'i':
fInputs ^= 1;
break;
......@@ -19452,18 +19462,19 @@ int Abc_CommandPermute( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Command \"permute\" has failed.\n" );
return 1;
}
Abc_NtkPermute( pNtkRes, fInputs, fOutputs, fFlops );
Abc_NtkPermute( pNtkRes, fInputs, fOutputs, fFlops, pFlopPermFile );
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
Abc_Print( -2, "usage: permute [-iofnh]\n" );
Abc_Print( -2, "\t performs random permutation of inputs/outputs/flops\n" );
Abc_Print( -2, "\t-i : toggle permuting primary inputs [default = %s]\n", fInputs? "yes": "no" );
Abc_Print( -2, "\t-o : toggle permuting primary outputs [default = %s]\n", fOutputs? "yes": "no" );
Abc_Print( -2, "\t-f : toggle permuting flip-flops [default = %s]\n", fFlops? "yes": "no" );
Abc_Print( -2, "\t-n : toggle deriving new topological ordering of nodes [default = %s]\n", fNodes? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
Abc_Print( -2, "usage: permute [-iofnh] [-F filename]\n" );
Abc_Print( -2, "\t performs random permutation of inputs/outputs/flops\n" );
Abc_Print( -2, "\t-i : toggle permuting primary inputs [default = %s]\n", fInputs? "yes": "no" );
Abc_Print( -2, "\t-o : toggle permuting primary outputs [default = %s]\n", fOutputs? "yes": "no" );
Abc_Print( -2, "\t-f : toggle permuting flip-flops [default = %s]\n", fFlops? "yes": "no" );
Abc_Print( -2, "\t-n : toggle deriving new topological ordering of nodes [default = %s]\n", fNodes? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
Abc_Print( -2, "\t-F <filename> : (optional) file with the flop permutation\n" );
return 1;
}
......@@ -23227,7 +23238,7 @@ int Abc_CommandBm2( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
Abc_NtkPermute(pNtk2, 1, 1, 0 );
Abc_NtkPermute(pNtk2, 1, 1, 0, NULL );
Abc_NtkShortNames(pNtk2);
Abc_NtkForEachCi( pNtk1, pObj, i ) {
......@@ -894,7 +894,7 @@ void Ifd_ComputeSignature( word uTruth, int pCounts[6] )
}
Vec_IntSelectSort( pCounts, 6 );
}
int Ifd_ManDsdTest()
int Ifd_ManDsdTest33()
{
int nVars = 6;
Vec_Wrd_t * vTruths = Ifd_ManDsdTruths( nVars );
......@@ -926,7 +926,7 @@ int Ifd_ManDsdTest()
SeeAlso []
***********************************************************************/
int Ifd_ManDsdTest33()
int Ifd_ManDsdTest()
{
int nVars = 6;
FILE * pFile;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment