Skip to content

Commit 1177cfa

Browse files
authored
Merge pull request #402 from chenjunhao0315/master
command rewire add external care
2 parents d271403 + 2179034 commit 1177cfa

File tree

6 files changed

+202
-79
lines changed

6 files changed

+202
-79
lines changed

src/base/abci/abc.c

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20773,15 +20773,17 @@ int Abc_CommandTimeScale( Abc_Frame_t * pAbc, int argc, char ** argv )
2077320773
***********************************************************************/
2077420774
int Abc_CommandRewire( Abc_Frame_t * pAbc, int argc, char ** argv )
2077520775
{
20776-
extern Abc_Ntk_t *Abc_ManRewire(Abc_Ntk_t *pNtk, int nIters, float levelGrowRatio, int nExpands, int nGrowth, int nDivs, int nFaninMax, int nTimeOut, int nMode, int nMappedMode, int nDist, int nSeed, int fVerbose);
20776+
extern Abc_Ntk_t *Abc_ManRewire(Abc_Ntk_t *pNtk, Gia_Man_t *pExc, int nIters, float levelGrowRatio, int nExpands, int nGrowth, int nDivs, int nFaninMax, int nTimeOut, int nMode, int nMappedMode, int nDist, int nSeed, int fCheck, int fVerbose);
2077720777
Abc_Ntk_t *pNtk, *pTemp;
20778-
int c, nIters = 100000, nExpands = 128, nGrowth = 4, nDivs = -1, nFaninMax = 8, nSeed = 1, nTimeOut = 0, nVerbose = 1, nMode = 0, nMappedMode = 0, nDist = 0;
20778+
Gia_Man_t *pExc = NULL;
20779+
FILE *pFile = NULL;
20780+
int c, nIters = 100000, nExpands = 128, nGrowth = 4, nDivs = -1, nFaninMax = 8, nSeed = 1, nTimeOut = 0, nVerbose = 1, nMode = 0, nMappedMode = 0, nDist = 0, fCheck = 0;
2077920781
float nLevelGrowRatio = 0;
2078020782
Extra_UtilGetoptReset();
2078120783

2078220784
pNtk = Abc_FrameReadNtk(pAbc);
2078320785

20784-
while ( ( c = Extra_UtilGetopt( argc, argv, "IEGDFSTMALRVh" ) ) != EOF ) {
20786+
while ( ( c = Extra_UtilGetopt( argc, argv, "IEGDFSTMALRCVch" ) ) != EOF ) {
2078520787
switch ( c ) {
2078620788
case 'I':
2078720789
if ( globalUtilOptind >= argc )
@@ -20882,6 +20884,22 @@ int Abc_CommandRewire( Abc_Frame_t * pAbc, int argc, char ** argv )
2088220884
nLevelGrowRatio = atof(argv[globalUtilOptind]);
2088320885
globalUtilOptind++;
2088420886
break;
20887+
case 'C':
20888+
pFile = fopen( argv[globalUtilOptind], "rb" );
20889+
if ( pFile == NULL )
20890+
{
20891+
Abc_Print( -1, "Cannot open input file \"%s\".\n", argv[globalUtilOptind] );
20892+
return 1;
20893+
}
20894+
fclose( pFile );
20895+
pExc = Gia_AigerRead( argv[globalUtilOptind], 0, 0, 0 );
20896+
if ( pExc == NULL )
20897+
{
20898+
Abc_Print( -1, "Reading AIGER has failed.\n" );
20899+
return 1;
20900+
}
20901+
globalUtilOptind++;
20902+
break;
2088520903
case 'V':
2088620904
if ( globalUtilOptind >= argc )
2088720905
{
@@ -20891,6 +20909,9 @@ int Abc_CommandRewire( Abc_Frame_t * pAbc, int argc, char ** argv )
2089120909
nVerbose = atoi(argv[globalUtilOptind]);
2089220910
globalUtilOptind++;
2089320911
break;
20912+
case 'c':
20913+
fCheck ^= 1;
20914+
break;
2089420915
case 'h':
2089520916
default:
2089620917
goto usage;
@@ -20906,13 +20927,20 @@ int Abc_CommandRewire( Abc_Frame_t * pAbc, int argc, char ** argv )
2090620927
Abc_Print( -1, "Empty network.\n" );
2090720928
return 1;
2090820929
}
20930+
if ( nMode == 0 && !Abc_NtkIsStrash(pNtk) )
20931+
{
20932+
Abc_Print( -1, "Rewiring works only for the AIG representation (run \"strash\").\n" );
20933+
return 1;
20934+
}
2090920935
if ( nMode >= 1 && Abc_FrameReadLibGen2() == NULL )
2091020936
{
2091120937
Abc_Print( -1, "Library is not available.\n" );
2091220938
return 1;
2091320939
}
2091420940

20915-
pTemp = Abc_ManRewire( pNtk, nIters, nLevelGrowRatio, nExpands, nGrowth, nDivs, nFaninMax, nTimeOut, nMode, nMappedMode, nDist, nSeed, nVerbose );
20941+
pTemp = Abc_ManRewire( pNtk, pExc, nIters, nLevelGrowRatio, nExpands, nGrowth, nDivs, nFaninMax, nTimeOut, nMode, nMappedMode, nDist, nSeed, fCheck, nVerbose );
20942+
if ( pExc )
20943+
Gia_ManStop( pExc );
2091620944
Abc_FrameReplaceCurrentNetwork( pAbc, pTemp );
2091720945
return 0;
2091820946

@@ -20927,9 +20955,11 @@ int Abc_CommandRewire( Abc_Frame_t * pAbc, int argc, char ** argv )
2092720955
Abc_Print( -2, "\t-R <num> : level constraint (0: unlimited, 1: preserve level) [default = %g]\n", nLevelGrowRatio);
2092820956
Abc_Print( -2, "\t-M <num> : optimization target [default = %s]\n", nMode ? "area" : "AIG node" );
2092920957
Abc_Print( -2, "\t-A <num> : mapper (0: amap, 1: &nf, 2: &simap) (experimental) [default = %d]\n", nMappedMode );
20958+
Abc_Print( -2, "\t-C <file> : AIGER specifying external cares\n");
2093020959
Abc_Print( -2, "\t-S <num> : the random seed (0: random, >= 1: user defined) [default = %d]\n", nSeed );
2093120960
Abc_Print( -2, "\t-T <num> : the timeout in seconds (0: unlimited) [default = %d]\n", nTimeOut );
2093220961
Abc_Print( -2, "\t-V <num> : the verbosity level [default = %d]\n", nVerbose );
20962+
Abc_Print( -2, "\t-c : check the equivalence [default = %s]\n", fCheck ? "yes" : "no" );
2093320963
Abc_Print( -2, "\t-h : prints the command usage\n" );
2093420964
Abc_Print( -2, "\n\tThis command was contributed by Jiun-Hao Chen from National Taiwan University.\n" );
2093520965
return 1;
@@ -46435,13 +46465,14 @@ int Abc_CommandAbc9Rrr( Abc_Frame_t * pAbc, int argc, char ** argv )
4643546465
***********************************************************************/
4643646466
int Abc_CommandAbc9Rewire( Abc_Frame_t * pAbc, int argc, char ** argv )
4643746467
{
46438-
extern Gia_Man_t *Gia_ManRewire(Gia_Man_t *pGia, int nIters, float levelGrowRatio, int nExpands, int nGrowth, int nDivs, int nFaninMax, int nTimeOut, int nMode, int nMappedMode, int nDist, int nSeed, int fVerbose);
46439-
Gia_Man_t *pTemp;
46440-
int c, nIters = 100000, nExpands = 128, nGrowth = 4, nDivs = -1, nFaninMax = 8, nSeed = 1, nTimeOut = 0, nVerbose = 1, nMode = 0, nMappedMode = 0, nDist = 0;
46468+
extern Gia_Man_t *Gia_ManRewire(Gia_Man_t *pGia, Gia_Man_t *pExc, int nIters, float levelGrowRatio, int nExpands, int nGrowth, int nDivs, int nFaninMax, int nTimeOut, int nMode, int nMappedMode, int nDist, int nSeed, int fCheck, int fVerbose);
46469+
FILE *pFile = NULL;
46470+
Gia_Man_t *pTemp, *pExc = NULL;
46471+
int c, nIters = 100000, nExpands = 128, nGrowth = 4, nDivs = -1, nFaninMax = 8, nSeed = 1, nTimeOut = 0, nVerbose = 1, nMode = 0, nMappedMode = 0, nDist = 0, fCheck = 0;
4644146472
float nLevelGrowRatio = 0;
4644246473
Extra_UtilGetoptReset();
4644346474

46444-
while ( ( c = Extra_UtilGetopt( argc, argv, "IEGDFSTMALRVh" ) ) != EOF ) {
46475+
while ( ( c = Extra_UtilGetopt( argc, argv, "IEGDFSTMALRCVch" ) ) != EOF ) {
4644546476
switch ( c ) {
4644646477
case 'I':
4644746478
if ( globalUtilOptind >= argc )
@@ -46542,6 +46573,22 @@ int Abc_CommandAbc9Rewire( Abc_Frame_t * pAbc, int argc, char ** argv )
4654246573
nLevelGrowRatio = atof(argv[globalUtilOptind]);
4654346574
globalUtilOptind++;
4654446575
break;
46576+
case 'C':
46577+
pFile = fopen( argv[globalUtilOptind], "rb" );
46578+
if ( pFile == NULL )
46579+
{
46580+
Abc_Print( -1, "Cannot open input file \"%s\".\n", argv[globalUtilOptind] );
46581+
return 1;
46582+
}
46583+
fclose( pFile );
46584+
pExc = Gia_AigerRead( argv[globalUtilOptind], 0, 0, 0 );
46585+
if ( pExc == NULL )
46586+
{
46587+
Abc_Print( -1, "Reading AIGER has failed.\n" );
46588+
return 1;
46589+
}
46590+
globalUtilOptind++;
46591+
break;
4654546592
case 'V':
4654646593
if ( globalUtilOptind >= argc )
4654746594
{
@@ -46551,6 +46598,9 @@ int Abc_CommandAbc9Rewire( Abc_Frame_t * pAbc, int argc, char ** argv )
4655146598
nVerbose = atoi(argv[globalUtilOptind]);
4655246599
globalUtilOptind++;
4655346600
break;
46601+
case 'c':
46602+
fCheck ^= 1;
46603+
break;
4655446604
case 'h':
4655546605
default:
4655646606
goto usage;
@@ -46572,9 +46622,9 @@ int Abc_CommandAbc9Rewire( Abc_Frame_t * pAbc, int argc, char ** argv )
4657246622
return 1;
4657346623
}
4657446624

46575-
pTemp = Gia_ManRewire( pAbc->pGia, nIters, nLevelGrowRatio, nExpands, nGrowth, nDivs, nFaninMax, nTimeOut, nMode, nMappedMode, nDist, nSeed, nVerbose );
46576-
if ( pTemp->pName == NULL )
46577-
pTemp->pName = Abc_UtilStrsav(Extra_FileNameWithoutPath(pAbc->pGia->pName));
46625+
pTemp = Gia_ManRewire( pAbc->pGia, pExc, nIters, nLevelGrowRatio, nExpands, nGrowth, nDivs, nFaninMax, nTimeOut, nMode, nMappedMode, nDist, nSeed, fCheck, nVerbose );
46626+
if ( pExc )
46627+
Gia_ManStop( pExc );
4657846628
Abc_FrameUpdateGia( pAbc, pTemp );
4657946629
return 0;
4658046630

@@ -46590,9 +46640,11 @@ int Abc_CommandAbc9Rewire( Abc_Frame_t * pAbc, int argc, char ** argv )
4659046640
Abc_Print( -2, "\t-R <num> : level constraint (0: unlimited, 1: preserve level) [default = %g]\n", nLevelGrowRatio);
4659146641
Abc_Print( -2, "\t-M <num> : optimization target [default = %s]\n", nMode ? "area" : "AIG node" );
4659246642
Abc_Print( -2, "\t-A <num> : mapper (0: amap, 1: &nf, 2: &simap) (experimental) [default = %d]\n", nMappedMode );
46643+
Abc_Print( -2, "\t-C <file> : AIGER specifying external cares\n");
4659346644
Abc_Print( -2, "\t-S <num> : the random seed (0: random, >= 1: user defined) [default = %d]\n", nSeed );
4659446645
Abc_Print( -2, "\t-T <num> : the timeout in seconds (0: unlimited) [default = %d]\n", nTimeOut );
4659546646
Abc_Print( -2, "\t-V <num> : the verbosity level [default = %d]\n", nVerbose );
46647+
Abc_Print( -2, "\t-c : check the equivalence [default = %s]\n", fCheck ? "yes" : "no" );
4659646648
Abc_Print( -2, "\t-h : prints the command usage\n" );
4659746649
Abc_Print( -2, "\n\tThis command was contributed by Jiun-Hao Chen from National Taiwan University.\n" );
4659846650
return 1;

0 commit comments

Comments
 (0)