mirror of https://github.com/YosysHQ/abc.git
Adding printout of SOPs.
This commit is contained in:
parent
27b8cce3fe
commit
aefbac6b04
|
|
@ -1886,18 +1886,24 @@ usage:
|
|||
***********************************************************************/
|
||||
int Abc_CommandPrintFactor( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
{
|
||||
extern void Abc_NodePrintSop( FILE * pFile, Abc_Obj_t * pNode, int fUseRealNames );
|
||||
extern void Abc_NtkPrintSop( FILE * pFile, Abc_Ntk_t * pNtk, int fUseRealNames );
|
||||
|
||||
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
|
||||
Abc_Obj_t * pNode;
|
||||
int c;
|
||||
int c, fSop = 0;
|
||||
int fUseRealNames;
|
||||
|
||||
// set defaults
|
||||
fUseRealNames = 1;
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "snh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
case 's':
|
||||
fSop ^= 1;
|
||||
break;
|
||||
case 'n':
|
||||
fUseRealNames ^= 1;
|
||||
break;
|
||||
|
|
@ -1934,16 +1940,23 @@ int Abc_CommandPrintFactor( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
|
||||
return 1;
|
||||
}
|
||||
Abc_NodePrintFactor( stdout, pNode, fUseRealNames );
|
||||
if ( fSop )
|
||||
Abc_NodePrintSop( stdout, pNode, fUseRealNames );
|
||||
else
|
||||
Abc_NodePrintFactor( stdout, pNode, fUseRealNames );
|
||||
return 0;
|
||||
}
|
||||
// print the nodes
|
||||
Abc_NtkPrintFactor( stdout, pNtk, fUseRealNames );
|
||||
if ( fSop )
|
||||
Abc_NtkPrintSop( stdout, pNtk, fUseRealNames );
|
||||
else
|
||||
Abc_NtkPrintFactor( stdout, pNtk, fUseRealNames );
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: print_factor [-nh] <node>\n" );
|
||||
Abc_Print( -2, "\t prints the factored forms of nodes\n" );
|
||||
Abc_Print( -2, "usage: print_factor [-snh] <node>\n" );
|
||||
Abc_Print( -2, "\t prints the factored forms (FFs) of nodes\n" );
|
||||
Abc_Print( -2, "\t-s : toggles printing SOP instead of FF [default = %s]\n", fSop? "SOP": "FF" );
|
||||
Abc_Print( -2, "\t-n : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
|
||||
Abc_Print( -2, "\t-h : print the command usage\n");
|
||||
Abc_Print( -2, "\tnode : (optional) one node to consider\n");
|
||||
|
|
|
|||
|
|
@ -1069,26 +1069,6 @@ void Abc_NtkPrintMffc( FILE * pFile, Abc_Ntk_t * pNtk )
|
|||
Abc_NodeMffcConeSuppPrint( pNode );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Prints the factored form of one node.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Abc_NtkPrintFactor( FILE * pFile, Abc_Ntk_t * pNtk, int fUseRealNames )
|
||||
{
|
||||
Abc_Obj_t * pNode;
|
||||
int i;
|
||||
assert( Abc_NtkIsSopLogic(pNtk) );
|
||||
Abc_NtkForEachNode( pNtk, pNode, i )
|
||||
Abc_NodePrintFactor( pFile, pNode, fUseRealNames );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Prints the factored form of one node.]
|
||||
|
|
@ -1128,8 +1108,86 @@ void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode, int fUseRealNames )
|
|||
Dec_GraphPrint( stdout, pGraph, (char **)NULL, Abc_ObjName(pNode) );
|
||||
Dec_GraphFree( pGraph );
|
||||
}
|
||||
void Abc_NtkPrintFactor( FILE * pFile, Abc_Ntk_t * pNtk, int fUseRealNames )
|
||||
{
|
||||
Abc_Obj_t * pNode;
|
||||
int i;
|
||||
assert( Abc_NtkIsSopLogic(pNtk) );
|
||||
Abc_NtkForEachNode( pNtk, pNode, i )
|
||||
Abc_NodePrintFactor( pFile, pNode, fUseRealNames );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Prints the SOPs of one node.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Abc_NodePrintSop( FILE * pFile, Abc_Obj_t * pNode, int fUseRealNames )
|
||||
{
|
||||
Vec_Ptr_t * vNamesIn = NULL;
|
||||
char * pCube, * pCur, * pSop; int nVars;
|
||||
if ( Abc_ObjIsCo(pNode) )
|
||||
pNode = Abc_ObjFanin0(pNode);
|
||||
if ( Abc_ObjIsPi(pNode) )
|
||||
{
|
||||
fprintf( pFile, "Skipping the PI node.\n" );
|
||||
return;
|
||||
}
|
||||
if ( Abc_ObjIsLatch(pNode) )
|
||||
{
|
||||
fprintf( pFile, "Skipping the latch.\n" );
|
||||
return;
|
||||
}
|
||||
assert( Abc_ObjIsNode(pNode) );
|
||||
pSop = (char *)pNode->pData;
|
||||
nVars = Abc_SopGetVarNum( pSop );
|
||||
if ( nVars == 0 )
|
||||
{
|
||||
fprintf( pFile, "%s = ", Abc_ObjName(pNode) );
|
||||
fprintf( pFile, "Constant %d", Abc_SopGetPhase(pSop) );
|
||||
return;
|
||||
}
|
||||
if ( !Abc_SopGetPhase(pSop) )
|
||||
fprintf( pFile, "!" );
|
||||
fprintf( pFile, "%s = ", Abc_ObjName(pNode) );
|
||||
if ( fUseRealNames )
|
||||
vNamesIn = Abc_NodeGetFaninNames(pNode);
|
||||
Abc_SopForEachCube( pSop, nVars, pCube )
|
||||
{
|
||||
if ( pCube != pSop )
|
||||
fprintf( pFile, " +" );
|
||||
if ( vNamesIn )
|
||||
{
|
||||
for ( pCur = pCube; *pCur != ' '; pCur++ )
|
||||
if ( *pCur != '-' )
|
||||
fprintf( pFile, " %s%s", *pCur == '0' ? "!" : "", (char *)Vec_PtrEntry(vNamesIn, pCur-pCube) );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( pCur = pCube; *pCur != ' '; pCur++ )
|
||||
if ( *pCur != '-' )
|
||||
fprintf( pFile, " %s%c", *pCur == '0' ? "!" : "", 'a' + pCur-pCube );
|
||||
}
|
||||
}
|
||||
fprintf( pFile, "\n" );
|
||||
if ( vNamesIn )
|
||||
Abc_NodeFreeNames( vNamesIn );
|
||||
}
|
||||
void Abc_NtkPrintSop( FILE * pFile, Abc_Ntk_t * pNtk, int fUseRealNames )
|
||||
{
|
||||
Abc_Obj_t * pNode;
|
||||
int i;
|
||||
assert( Abc_NtkIsSopLogic(pNtk) );
|
||||
Abc_NtkForEachNode( pNtk, pNode, i )
|
||||
Abc_NodePrintSop( pFile, pNode, fUseRealNames );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Prints the level stats of the PO node.]
|
||||
|
|
|
|||
Loading…
Reference in New Issue