summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2013-05-25 22:13:46 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2013-05-25 22:13:46 -0700
commit8e639c3d79224a471d14ac4a34a6a21902157eda (patch)
tree7f1d710ad80c8f551377ac96e13156fd69c4aa9f /src
parent94a75fe6d8f8709603dbf9e5bf959174dc3342ac (diff)
downloadabc-8e639c3d79224a471d14ac4a34a6a21902157eda.tar.gz
abc-8e639c3d79224a471d14ac4a34a6a21902157eda.tar.bz2
abc-8e639c3d79224a471d14ac4a34a6a21902157eda.zip
New command 'putontop' to concatenate networks for don't-care-based optimization.
Diffstat (limited to 'src')
-rw-r--r--src/base/abci/abc.c109
-rw-r--r--src/base/abci/abcMfs.c28
-rw-r--r--src/base/abci/abcPrint.c4
-rw-r--r--src/base/abci/abcStrash.c61
-rw-r--r--src/opt/sfm/sfm.h1
5 files changed, 196 insertions, 7 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index cb3e1f1e..a171ce66 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -134,6 +134,7 @@ static int Abc_CommandRemovePo ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandDropSat ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAddPi ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAppend ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPutOnTop ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandFrames ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDFrames ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSop ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -683,6 +684,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Various", "dropsat", Abc_CommandDropSat, 1 );
Cmd_CommandAdd( pAbc, "Various", "addpi", Abc_CommandAddPi, 1 );
Cmd_CommandAdd( pAbc, "Various", "append", Abc_CommandAppend, 1 );
+ Cmd_CommandAdd( pAbc, "Various", "putontop", Abc_CommandPutOnTop, 1 );
Cmd_CommandAdd( pAbc, "Various", "frames", Abc_CommandFrames, 1 );
Cmd_CommandAdd( pAbc, "Various", "dframes", Abc_CommandDFrames, 1 );
Cmd_CommandAdd( pAbc, "Various", "sop", Abc_CommandSop, 0 );
@@ -4473,7 +4475,7 @@ int Abc_CommandMfs2( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults
Sfm_ParSetDefault( pPars );
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMNCdlaevwh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMNCZdlaevwh" ) ) != EOF )
{
switch ( c )
{
@@ -4543,6 +4545,17 @@ int Abc_CommandMfs2( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nBTLimit < 0 )
goto usage;
break;
+ case 'Z':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-Z\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nFirstFixed = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nFirstFixed < 0 )
+ goto usage;
+ break;
case 'd':
pPars->fRrOnly ^= 1;
break;
@@ -4591,7 +4604,7 @@ int Abc_CommandMfs2( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- Abc_Print( -2, "usage: mfs2 [-WFDMNC <num>] [-dlaevwh]\n" );
+ Abc_Print( -2, "usage: mfs2 [-WFDMNCZ <num>] [-dlaevwh]\n" );
Abc_Print( -2, "\t performs don't-care-based optimization of logic networks\n" );
Abc_Print( -2, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nTfoLevMax );
Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutMax );
@@ -4599,6 +4612,7 @@ usage:
Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n", pPars->nWinSizeMax );
Abc_Print( -2, "\t-N <num> : the max number of divisors to consider (0 = no limit) [default = %d]\n", pPars->nDivNumMax );
Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-Z <num> : treat the first <num> logic nodes as fixed (0 = none) [default = %d]\n", pPars->nFirstFixed );
Abc_Print( -2, "\t-d : toggle performing redundancy removal [default = %s]\n", pPars->fRrOnly? "yes": "no" );
Abc_Print( -2, "\t-l : allow logic level to increase [default = %s]\n", !pPars->fFixLevel? "yes": "no" );
Abc_Print( -2, "\t-a : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" );
@@ -7049,6 +7063,97 @@ usage:
SeeAlso []
***********************************************************************/
+int Abc_CommandPutOnTop( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern Abc_Ntk_t * Abc_NtkPutOnTop( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtk2 );
+
+ Abc_Ntk_t * pNtk, * pNtk2, * pNtkRes;
+ char * FileName;
+ int fComb = 0;
+ int c;
+ pNtk = Abc_FrameReadNtk(pAbc);
+
+ // set defaults
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'c':
+ fComb ^= 1;
+ break;
+ default:
+ goto usage;
+ }
+ }
+
+ // get the second network
+ if ( argc != globalUtilOptind + 1 )
+ {
+ Abc_Print( -1, "The network to append is not given.\n" );
+ return 1;
+ }
+
+ if ( !Abc_NtkIsLogic(pNtk) )
+ {
+ Abc_Print( -1, "The base network should be in the logic form.\n" );
+ return 1;
+ }
+
+ // check if the second network is combinational
+ if ( Abc_NtkLatchNum(pNtk) )
+ {
+ Abc_Print( -1, "The current network has latches. This command does not work for such networks.\n" );
+ return 0;
+ }
+
+ // read the second network
+ FileName = argv[globalUtilOptind];
+ pNtk2 = Io_Read( FileName, Io_ReadFileType(FileName), 1 );
+ if ( pNtk2 == NULL )
+ return 1;
+
+ // check if the second network is combinational
+ if ( Abc_NtkLatchNum(pNtk2) )
+ {
+ Abc_NtkDelete( pNtk2 );
+ Abc_Print( -1, "The second network has latches. This command does not work for such networks.\n" );
+ return 0;
+ }
+ // compare inputs/outputs
+ if ( Abc_NtkPoNum(pNtk) != Abc_NtkPiNum(pNtk2) )
+ {
+ Abc_NtkDelete( pNtk2 );
+ Abc_Print( -1, "The PO count (%d) of the first network is not equal to PI count (%d) of the second network.\n", Abc_NtkPoNum(pNtk), Abc_NtkPiNum(pNtk2) );
+ return 0;
+ }
+
+ // get the new network
+ pNtkRes = Abc_NtkPutOnTop( pNtk, pNtk2 );
+ Abc_NtkDelete( pNtk2 );
+ // replace the current network
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: putontop [-h] <file>\n" );
+ Abc_Print( -2, "\t connects PIs of network in <file> to POs of current network\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : file name with the second network\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
int Abc_CommandFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk, * pNtkTemp, * pNtkRes;
diff --git a/src/base/abci/abcMfs.c b/src/base/abci/abcMfs.c
index 7953be15..3368fe5d 100644
--- a/src/base/abci/abcMfs.c
+++ b/src/base/abci/abcMfs.c
@@ -63,6 +63,24 @@ Vec_Ptr_t * Abc_NtkAssignIDs( Abc_Ntk_t * pNtk )
pObj->iTemp = Abc_NtkPiNum(pNtk) + Vec_PtrSize(vNodes) + i;
return vNodes;
}
+Vec_Ptr_t * Abc_NtkAssignIDs2( Abc_Ntk_t * pNtk )
+{
+ Vec_Ptr_t * vNodes;
+ Abc_Obj_t * pObj;
+ int i;
+ Abc_NtkCleanCopy( pNtk );
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ pObj->iTemp = i;
+ vNodes = Vec_PtrAlloc( Abc_NtkNodeNum(pNtk) );
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ {
+ Vec_PtrPush( vNodes, pObj );
+ pObj->iTemp = Abc_NtkPiNum(pNtk) + i;
+ }
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ pObj->iTemp = Abc_NtkPiNum(pNtk) + Vec_PtrSize(vNodes) + i;
+ return vNodes;
+}
/**Function*************************************************************
@@ -75,7 +93,7 @@ Vec_Ptr_t * Abc_NtkAssignIDs( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-Sfm_Ntk_t * Abc_NtkExtractMfs( Abc_Ntk_t * pNtk )
+Sfm_Ntk_t * Abc_NtkExtractMfs( Abc_Ntk_t * pNtk, int nFirstFixed )
{
Vec_Ptr_t * vNodes;
Vec_Wec_t * vFanins;
@@ -84,7 +102,7 @@ Sfm_Ntk_t * Abc_NtkExtractMfs( Abc_Ntk_t * pNtk )
Vec_Int_t * vArray;
Abc_Obj_t * pObj, * pFanin;
int i, k, nObjs;
- vNodes = Abc_NtkAssignIDs( pNtk );
+ vNodes = nFirstFixed ? Abc_NtkAssignIDs2(pNtk) : Abc_NtkAssignIDs(pNtk);
nObjs = Abc_NtkPiNum(pNtk) + Vec_PtrSize(vNodes) + Abc_NtkPoNum(pNtk);
vFanins = Vec_WecStart( nObjs );
vFixed = Vec_StrStart( nObjs );
@@ -105,6 +123,10 @@ Sfm_Ntk_t * Abc_NtkExtractMfs( Abc_Ntk_t * pNtk )
Vec_IntPush( vArray, pFanin->iTemp );
}
Vec_PtrFree( vNodes );
+ // update fixed
+ assert( nFirstFixed >= 0 && nFirstFixed < Abc_NtkNodeNum(pNtk) );
+ for ( i = Abc_NtkPiNum(pNtk); i < Abc_NtkPiNum(pNtk) + nFirstFixed; i++ )
+ Vec_StrWriteEntry( vFixed, i, (char)1 );
return Sfm_NtkConstruct( vFanins, Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk), vFixed, vTruths );
}
@@ -193,7 +215,7 @@ int Abc_NtkPerformMfs( Abc_Ntk_t * pNtk, Sfm_Par_t * pPars )
return 0;
}
// collect information
- p = Abc_NtkExtractMfs( pNtk );
+ p = Abc_NtkExtractMfs( pNtk, pPars->nFirstFixed );
// perform optimization
nNodes = Sfm_NtkPerform( p, pPars );
// call the fast extract procedure
diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c
index 913735c8..e27ae492 100644
--- a/src/base/abci/abcPrint.c
+++ b/src/base/abci/abcPrint.c
@@ -212,8 +212,8 @@ void Abc_NtkPrintStats( Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDum
Abc_Print( 1," i/o =%5d/%5d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) );
if ( Abc_NtkConstrNum(pNtk) )
Abc_Print( 1,"(c=%d)", Abc_NtkConstrNum(pNtk) );
- if ( pNtk->nRealPos )
- Abc_Print( 1,"(p=%d)", Abc_NtkPoNum(pNtk) - pNtk->nRealPos );
+// if ( pNtk->nRealPos )
+// Abc_Print( 1,"(p=%d)", Abc_NtkPoNum(pNtk) - pNtk->nRealPos );
Abc_Print( 1," lat =%5d", Abc_NtkLatchNum(pNtk) );
if ( Abc_NtkIsNetlist(pNtk) )
{
diff --git a/src/base/abci/abcStrash.c b/src/base/abci/abcStrash.c
index b53a27e4..2894003b 100644
--- a/src/base/abci/abcStrash.c
+++ b/src/base/abci/abcStrash.c
@@ -770,6 +770,67 @@ void Abc_NtkWriteAig( Abc_Ntk_t * pNtk, char * pFileName )
Vec_IntFree( vId2Num );
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Ntk_t * Abc_NtkPutOnTop( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtk2 )
+{
+ Vec_Ptr_t * vNodes;
+ Abc_Ntk_t * pNtkNew;
+ Abc_Obj_t * pObj, * pFanin;
+ int i, k;
+ assert( Abc_NtkIsLogic(pNtk) );
+ assert( Abc_NtkIsLogic(pNtk2) );
+ assert( Abc_NtkPoNum(pNtk) == Abc_NtkPiNum(pNtk2) );
+ // clean the node copy fields
+ Abc_NtkCleanCopy( pNtk );
+ Abc_NtkCleanCopy( pNtk2 );
+ // duplicate the name and the spec
+ pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
+ pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
+ pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
+ // clone CIs/CIs/boxes
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ Abc_NtkDupObj( pNtkNew, pObj, 1 );
+ // add internal nodes
+ vNodes = Abc_NtkDfs( pNtk, 0 );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ {
+ Abc_NtkDupObj( pNtkNew, pObj, 0 );
+ Abc_ObjForEachFanin( pObj, pFanin, k )
+ Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
+ }
+ Vec_PtrFree( vNodes );
+ // transfer to the POs
+ Abc_NtkForEachPi( pNtk2, pObj, i )
+ pObj->pCopy = Abc_ObjChild0Copy( Abc_NtkPo(pNtk, i) );
+ // add internal nodes
+ vNodes = Abc_NtkDfs( pNtk2, 0 );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ {
+ Abc_NtkDupObj( pNtkNew, pObj, 0 );
+ Abc_ObjForEachFanin( pObj, pFanin, k )
+ Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
+ }
+ Vec_PtrFree( vNodes );
+ // clone CIs/CIs/boxes
+ Abc_NtkForEachPo( pNtk2, pObj, i )
+ {
+ Abc_NtkDupObj( pNtkNew, pObj, 1 );
+ Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
+ }
+ if ( !Abc_NtkCheck( pNtkNew ) )
+ fprintf( stdout, "Abc_NtkPutOnTop(): Network check has failed.\n" );
+ return pNtkNew;
+}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
diff --git a/src/opt/sfm/sfm.h b/src/opt/sfm/sfm.h
index 31519c8e..025d0dfa 100644
--- a/src/opt/sfm/sfm.h
+++ b/src/opt/sfm/sfm.h
@@ -48,6 +48,7 @@ struct Sfm_Par_t_
int nWinSizeMax; // the maximum window size
int nDivNumMax; // the maximum number of divisors
int nBTLimit; // the maximum number of conflicts in one SAT run
+ int nFirstFixed; // the number of first nodes to be treated as fixed
int fFixLevel; // does not allow level to increase
int fRrOnly; // perform redundance removal
int fArea; // performs optimization for area