Commit 3344a46b by Alan Mishchenko

Added switch '-t' to 'miter' to create regular miter from dual-output miter.

parent 94726c98
...@@ -704,6 +704,7 @@ extern ABC_DLL void Abc_NtkFinalize( Abc_Ntk_t * pNtk, Abc_Ntk_t * ...@@ -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 Abc_Ntk_t * Abc_NtkStartRead( char * pName );
extern ABC_DLL void Abc_NtkFinalizeRead( Abc_Ntk_t * pNtk ); 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_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_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 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 ); extern ABC_DLL void Abc_NtkAppendToCone( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots );
......
...@@ -394,6 +394,61 @@ Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk ) ...@@ -394,6 +394,61 @@ Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk )
SeeAlso [] 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 ) Abc_Ntk_t * Abc_NtkDouble( Abc_Ntk_t * pNtk )
{ {
char Buffer[500]; char Buffer[500];
......
...@@ -5470,6 +5470,7 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5470,6 +5470,7 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
int fImplic; int fImplic;
int fMulti; int fMulti;
int nPartSize; int nPartSize;
int fTrans;
pNtk = Abc_FrameReadNtk(pAbc); pNtk = Abc_FrameReadNtk(pAbc);
...@@ -5479,8 +5480,9 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5479,8 +5480,9 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
fImplic = 0; fImplic = 0;
fMulti = 0; fMulti = 0;
nPartSize = 0; nPartSize = 0;
fTrans = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Pcmih" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "Pcmith" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -5504,11 +5506,28 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5504,11 +5506,28 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'i': case 'i':
fImplic ^= 1; fImplic ^= 1;
break; break;
case 't':
fTrans ^= 1;
break;
default: default:
goto usage; 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; pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind; nArgcNew = argc - globalUtilOptind;
if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) ) if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
...@@ -5533,12 +5552,13 @@ usage: ...@@ -5533,12 +5552,13 @@ usage:
strcpy( Buffer, "unused" ); strcpy( Buffer, "unused" );
else else
sprintf( Buffer, "%d", nPartSize ); 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 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-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-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-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-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, "\t-h : print the command usage\n");
Abc_Print( -2, "\tfile1 : (optional) the file with the first network\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"); 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 ) ...@@ -26277,7 +26297,7 @@ int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
pAbc->pGia = Gia_ManTransformMiter( pAux = pAbc->pGia ); pAbc->pGia = Gia_ManTransformMiter( pAux = pAbc->pGia );
Gia_ManStop( pAux ); 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; return 0;
} }
......
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