diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2021-03-11 17:45:01 -1000 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2021-03-11 17:45:01 -1000 |
commit | b2ca83752154bf8366fa767244c886f24f674f41 (patch) | |
tree | a8e8f5ba46dedb86c8fbd314193caf525b11b9da /src/base/abci | |
parent | f87c8b434a3024972c6bc85c072d80adbed3e778 (diff) | |
download | abc-b2ca83752154bf8366fa767244c886f24f674f41.tar.gz abc-b2ca83752154bf8366fa767244c886f24f674f41.tar.bz2 abc-b2ca83752154bf8366fa767244c886f24f674f41.zip |
Adding a random seed to control randomness in 'permute'.
Diffstat (limited to 'src/base/abci')
-rw-r--r-- | src/base/abci/abc.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 7aef638d..3ad5ff18 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -23681,12 +23681,24 @@ int Abc_CommandPermute( Abc_Frame_t * pAbc, int argc, char ** argv ) int fFlops = 1; int fNodes = 1; int fFanout = 0; + int Seed = -1; int c; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Fiofnxh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "SFiofnxh" ) ) != EOF ) { switch ( c ) { + case 'S': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" ); + goto usage; + } + Seed = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( Seed < 0 ) + goto usage; + break; case 'F': if ( globalUtilOptind >= argc ) { @@ -23747,13 +23759,16 @@ int Abc_CommandPermute( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Command \"permute\" has failed.\n" ); return 1; } + if ( Seed >= 0 ) + srand( (unsigned)Seed ); Abc_NtkPermute( pNtkRes, fInputs, fOutputs, fFlops, pFlopPermFile ); Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: - Abc_Print( -2, "usage: permute [-iofnxh] [-F filename]\n" ); + Abc_Print( -2, "usage: permute [-S num] [-iofnxh] [-F filename]\n" ); Abc_Print( -2, "\t performs random permutation of inputs/outputs/flops\n" ); + Abc_Print( -2, "\t-S num : the random seed to generate permutations (0 <= num < INT_MAX) [default = %d]\n", Seed ); 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" ); |