@@ -426,6 +426,8 @@ static int Abc_CommandAbc9WriteVer ( Abc_Frame_t * pAbc, int argc, cha
426426static int Abc_CommandAbc9Write ( Abc_Frame_t * pAbc, int argc, char ** argv );
427427static int Abc_CommandAbc9WriteLut ( Abc_Frame_t * pAbc, int argc, char ** argv );
428428static int Abc_CommandAbc9Ps ( Abc_Frame_t * pAbc, int argc, char ** argv );
429+ static int Abc_CommandAbc9Origins ( Abc_Frame_t * pAbc, int argc, char ** argv );
430+ static int Abc_CommandAbc9OriginsId ( Abc_Frame_t * pAbc, int argc, char ** argv );
429431static int Abc_CommandAbc9PFan ( Abc_Frame_t * pAbc, int argc, char ** argv );
430432static int Abc_CommandAbc9Pms ( Abc_Frame_t * pAbc, int argc, char ** argv );
431433static int Abc_CommandAbc9PSig ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -1268,6 +1270,8 @@ void Abc_Init( Abc_Frame_t * pAbc )
12681270 Cmd_CommandAdd( pAbc, "ABC9", "&write", Abc_CommandAbc9Write, 0 );
12691271 Cmd_CommandAdd( pAbc, "ABC9", "&wlut", Abc_CommandAbc9WriteLut, 0 );
12701272 Cmd_CommandAdd( pAbc, "ABC9", "&ps", Abc_CommandAbc9Ps, 0 );
1273+ Cmd_CommandAdd( pAbc, "ABC9", "&origins", Abc_CommandAbc9Origins, 0 );
1274+ Cmd_CommandAdd( pAbc, "ABC9", "&origins_id", Abc_CommandAbc9OriginsId, 0 );
12711275 Cmd_CommandAdd( pAbc, "ABC9", "&pfan", Abc_CommandAbc9PFan, 0 );
12721276 Cmd_CommandAdd( pAbc, "ABC9", "&pms", Abc_CommandAbc9Pms, 0 );
12731277 Cmd_CommandAdd( pAbc, "ABC9", "&psig", Abc_CommandAbc9PSig, 0 );
@@ -35515,6 +35519,145 @@ int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
3551535519 return 1;
3551635520}
3551735521
35522+ /**Function*************************************************************
35523+
35524+ Synopsis [Prints multi-origin statistics.]
35525+
35526+ Description [Shows how many objects have origins, total origin count,
35527+ average/max per node, overflow count, and a histogram. Origins are
35528+ populated either by reading an XAIGER file with a "y" extension
35529+ (normal abc9 flow) or by the &origins_id command (testing).]
35530+
35531+ SideEffects []
35532+
35533+ SeeAlso []
35534+
35535+ ***********************************************************************/
35536+ int Abc_CommandAbc9Origins( Abc_Frame_t * pAbc, int argc, char ** argv )
35537+ {
35538+ Gia_Man_t * pGia = pAbc->pGia;
35539+ int c;
35540+ Extra_UtilGetoptReset();
35541+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
35542+ {
35543+ switch ( c )
35544+ {
35545+ case 'h':
35546+ goto usage;
35547+ default:
35548+ goto usage;
35549+ }
35550+ }
35551+ if ( pGia == NULL )
35552+ {
35553+ Abc_Print( -1, "Abc_CommandAbc9Origins(): There is no AIG.\n" );
35554+ return 0;
35555+ }
35556+ if ( pGia->vOrigins == NULL )
35557+ {
35558+ Abc_Print( 1, "No origin tracking data.\n" );
35559+ return 0;
35560+ }
35561+ {
35562+ int i, nObjs = Gia_ManObjNum(pGia);
35563+ int nEntries = 0, nOrigins = 0, nMaxOrigins = 0;
35564+ int nOverflow = 0;
35565+ int histogram[16];
35566+ memset( histogram, 0, sizeof(histogram) );
35567+ for ( i = 0; i < nObjs; i++ )
35568+ {
35569+ int nOrig = Gia_ObjOriginsNum( pGia, i );
35570+ if ( nOrig > 0 )
35571+ {
35572+ nEntries++;
35573+ nOrigins += nOrig;
35574+ if ( nOrig > nMaxOrigins )
35575+ nMaxOrigins = nOrig;
35576+ if ( nOrig < 16 )
35577+ histogram[nOrig]++;
35578+ else
35579+ histogram[15]++;
35580+ if ( nOrig > GIA_ORIGINS_INLINE )
35581+ nOverflow++;
35582+ }
35583+ }
35584+ Abc_Print( 1, "Origins: %d entries, %d total origins (%.2fx avg), max %d, overflow %d\n",
35585+ nEntries, nOrigins,
35586+ nEntries > 0 ? (double)nOrigins / nEntries : 0.0,
35587+ nMaxOrigins, nOverflow );
35588+ Abc_Print( 1, " Histogram: " );
35589+ for ( i = 1; i < 16; i++ )
35590+ if ( histogram[i] > 0 )
35591+ Abc_Print( 1, "%s%d=%d", i > 1 ? " " : "", i, histogram[i] );
35592+ Abc_Print( 1, "\n" );
35593+ }
35594+ return 0;
35595+
35596+ usage:
35597+ Abc_Print( -2, "usage: &origins [-h]\n" );
35598+ Abc_Print( -2, "\t prints multi-origin tracking statistics\n" );
35599+ Abc_Print( -2, "\t-h : print the command usage\n");
35600+ return 1;
35601+ }
35602+
35603+ /**Function*************************************************************
35604+
35605+ Synopsis [Initialize identity origins for testing/debugging.]
35606+
35607+ Description [Sets each AND node's origin to itself. This is a testing
35608+ convenience for exercising origin propagation in standalone ABC sessions.
35609+ In the normal abc9 flow, origins are supplied by Yosys via the XAIGER
35610+ "y" extension and this command is not needed.]
35611+
35612+ SideEffects []
35613+
35614+ SeeAlso []
35615+
35616+ ***********************************************************************/
35617+ int Abc_CommandAbc9OriginsId( Abc_Frame_t * pAbc, int argc, char ** argv )
35618+ {
35619+ Gia_Man_t * pGia = pAbc->pGia;
35620+ int c;
35621+ Extra_UtilGetoptReset();
35622+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
35623+ {
35624+ switch ( c )
35625+ {
35626+ case 'h':
35627+ goto usage;
35628+ default:
35629+ goto usage;
35630+ }
35631+ }
35632+ if ( pGia == NULL )
35633+ {
35634+ Abc_Print( -1, "Abc_CommandAbc9OriginsId(): There is no AIG.\n" );
35635+ return 0;
35636+ }
35637+ if ( pGia->vOrigins != NULL )
35638+ {
35639+ Abc_Print( 1, "Origins already present (%d entries). Use without existing origins.\n",
35640+ Vec_IntSize(pGia->vOrigins) / GIA_ORIGINS_STRIDE );
35641+ return 0;
35642+ }
35643+ {
35644+ int i, nObjs = Gia_ManObjNum(pGia);
35645+ Gia_Obj_t * pObj;
35646+ pGia->vOrigins = Gia_ManOriginsAlloc( nObjs );
35647+ Gia_ManForEachAnd( pGia, pObj, i )
35648+ Gia_ObjSetOrigin( pGia, i, i );
35649+ Abc_Print( 1, "Initialized identity origins for %d AND nodes.\n", Gia_ManAndNum(pGia) );
35650+ }
35651+ return 0;
35652+
35653+ usage:
35654+ Abc_Print( -2, "usage: &origins_id [-h]\n" );
35655+ Abc_Print( -2, "\t sets identity origins for testing (each AND node -> itself)\n" );
35656+ Abc_Print( -2, "\t in normal abc9 flow, origins come from XAIGER \"y\" extension\n" );
35657+ Abc_Print( -2, "\t-h : print the command usage\n");
35658+ return 1;
35659+ }
35660+
3551835661/**Function*************************************************************
3551935662
3552035663 Synopsis []
0 commit comments