summaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2011-08-14 19:22:30 +0700
committerAlan Mishchenko <alanmi@berkeley.edu>2011-08-14 19:22:30 +0700
commit3344a46b2631e042822a3477a22b0d1836cdbcb1 (patch)
treeb9670b57ad3a36e837fa7fc57b26a9b085975334 /src/base
parent94726c981bc970ca4cd8e9e064d9ffbc0857d192 (diff)
downloadabc-3344a46b2631e042822a3477a22b0d1836cdbcb1.tar.gz
abc-3344a46b2631e042822a3477a22b0d1836cdbcb1.tar.bz2
abc-3344a46b2631e042822a3477a22b0d1836cdbcb1.zip
Added switch '-t' to 'miter' to create regular miter from dual-output miter.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/abc/abc.h1
-rw-r--r--src/base/abc/abcNtk.c55
-rw-r--r--src/base/abci/abc.c26
3 files changed, 79 insertions, 3 deletions
diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h
index 6e107be5..e7b8beb6 100644
--- a/src/base/abc/abc.h
+++ b/src/base/abc/abc.h
@@ -704,6 +704,7 @@ extern ABC_DLL void Abc_NtkFinalize( Abc_Ntk_t * pNtk, Abc_Ntk_t *
extern ABC_DLL Abc_Ntk_t * Abc_NtkStartRead( char * pName );
extern ABC_DLL void Abc_NtkFinalizeRead( Abc_Ntk_t * pNtk );
extern ABC_DLL Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk );
+extern ABC_DLL Abc_Ntk_t * Abc_NtkDupTransformMiter( Abc_Ntk_t * pNtk );
extern ABC_DLL Abc_Ntk_t * Abc_NtkCreateCone( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, char * pNodeName, int fUseAllCis );
extern ABC_DLL Abc_Ntk_t * Abc_NtkCreateConeArray( Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots, int fUseAllCis );
extern ABC_DLL void Abc_NtkAppendToCone( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots );
diff --git a/src/base/abc/abcNtk.c b/src/base/abc/abcNtk.c
index 956cb591..6f8d11cf 100644
--- a/src/base/abc/abcNtk.c
+++ b/src/base/abc/abcNtk.c
@@ -394,6 +394,61 @@ Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
+Abc_Ntk_t * Abc_NtkDupTransformMiter( Abc_Ntk_t * pNtk )
+{
+ Abc_Ntk_t * pNtkNew;
+ Abc_Obj_t * pObj, * pObj2, * pMiter;
+ int i;
+ assert( Abc_NtkIsStrash(pNtk) );
+ // start the network
+ pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
+ pNtkNew->nConstrs = pNtk->nConstrs;
+ // duplicate the name and the spec
+ pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
+ pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
+ // clean the node copy fields
+ Abc_NtkCleanCopy( pNtk );
+ // map the constant nodes
+ Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
+ // clone CIs/CIs/boxes
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ Abc_NtkDupObj( pNtkNew, pObj, 1 );
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ Abc_NtkDupObj( pNtkNew, pObj, 1 ), i++;
+ Abc_NtkForEachBox( pNtk, pObj, i )
+ Abc_NtkDupBox( pNtkNew, pObj, 1 );
+ // copy the AND gates
+ Abc_AigForEachAnd( pNtk, pObj, i )
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ // create new miters
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ {
+ pObj2 = Abc_NtkPo( pNtk, ++i );
+ pMiter = Abc_AigXor( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild0Copy(pObj2) );
+ Abc_ObjAddFanin( pObj->pCopy, pMiter );
+ }
+ Abc_NtkForEachLatchInput( pNtk, pObj, i )
+ Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
+ // cleanup
+ Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );
+ // check that the CI/CO/latches are copied correctly
+ assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
+ assert( Abc_NtkPoNum(pNtk) == 2*Abc_NtkPoNum(pNtkNew) );
+ assert( Abc_NtkLatchNum(pNtk) == Abc_NtkLatchNum(pNtkNew) );
+ return pNtkNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicate the network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
Abc_Ntk_t * Abc_NtkDouble( Abc_Ntk_t * pNtk )
{
char Buffer[500];
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 4e1f3fea..5f680144 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -5470,6 +5470,7 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
int fImplic;
int fMulti;
int nPartSize;
+ int fTrans;
pNtk = Abc_FrameReadNtk(pAbc);
@@ -5479,8 +5480,9 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
fImplic = 0;
fMulti = 0;
nPartSize = 0;
+ fTrans = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "Pcmih" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "Pcmith" ) ) != EOF )
{
switch ( c )
{
@@ -5504,11 +5506,28 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'i':
fImplic ^= 1;
break;
+ case 't':
+ fTrans ^= 1;
+ break;
default:
goto usage;
}
}
+ if ( fTrans )
+ {
+ if ( (Abc_NtkPoNum(pNtk) & 1) == 1 )
+ {
+ Abc_Print( -1, "Abc_CommandMiter(): The number of outputs should be even.\n" );
+ return 0;
+ }
+ // replace the current network
+ pNtkRes = Abc_NtkDupTransformMiter( pNtk );
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+ Abc_Print( 1, "The miter (current network) is transformed by XORing POs pair-wise.\n" );
+ return 0;
+ }
+
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
@@ -5533,12 +5552,13 @@ usage:
strcpy( Buffer, "unused" );
else
sprintf( Buffer, "%d", nPartSize );
- Abc_Print( -2, "usage: miter [-P <num>] [-cimh] <file1> <file2>\n" );
+ Abc_Print( -2, "usage: miter [-P <num>] [-cimth] <file1> <file2>\n" );
Abc_Print( -2, "\t computes the miter of the two circuits\n" );
Abc_Print( -2, "\t-P <num> : output partition size [default = %s]\n", Buffer );
Abc_Print( -2, "\t-c : toggles deriving combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
Abc_Print( -2, "\t-i : toggles deriving implication miter (file1 => file2) [default = %s]\n", fImplic? "yes": "no" );
Abc_Print( -2, "\t-m : toggles creating multi-output miter [default = %s]\n", fMulti? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle XORing pair-wise POs of the miter [default = %s]\n", fTrans? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
Abc_Print( -2, "\tfile1 : (optional) the file with the first network\n");
Abc_Print( -2, "\tfile2 : (optional) the file with the second network\n");
@@ -26277,7 +26297,7 @@ int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv )
}
pAbc->pGia = Gia_ManTransformMiter( pAux = pAbc->pGia );
Gia_ManStop( pAux );
- Abc_Print( -1, "The miter (current AIG) is transformed by XORing POs pair-wise.\n" );
+ Abc_Print( 1, "The miter (current AIG) is transformed by XORing POs pair-wise.\n" );
return 0;
}