Commit 7e9f3f02 by Alan Mishchenko

Adding parameters and improvements to %blast.

parent 33971604
......@@ -5018,6 +5018,18 @@ SOURCE=.\src\aig\miniaig\minilut.h
SOURCE=.\src\aig\miniaig\ndr.h
# End Source File
# End Group
# Begin Group "uap"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\uap\uap.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\uap\uapSat.c
# End Source File
# End Group
# End Group
# Begin Group "bool"
......
......@@ -764,15 +764,15 @@ void Gia_ManPrintNpnClasses( Gia_Man_t * p )
nTotal += ClassCounts[i];
Abc_Print( 1, "NPN CLASS STATISTICS (for %d LUT4 present in the current mapping):\n", nTotal );
OtherClasses = 0;
for ( i = 0; i < 222; i++ )
for ( i = k = 0; i < 222; i++ )
{
if ( ClassCounts[i] == 0 )
continue;
// if ( 100.0 * ClassCounts[i] / (nTotal+1) < 0.1 ) // do not show anything below 0.1 percent
// continue;
OtherClasses += ClassCounts[i];
Abc_Print( 1, "Class %3d : Count = %6d (%7.2f %%) %s\n",
i, ClassCounts[i], 100.0 * ClassCounts[i] / (nTotal+1), pNames[i] );
Abc_Print( 1, "%3d: Class %3d : Count = %6d (%7.2f %%) %s\n",
++k, i, ClassCounts[i], 100.0 * ClassCounts[i] / (nTotal+1), pNames[i] );
}
OtherClasses = nTotal - OtherClasses;
Abc_Print( 1, "Other : Count = %6d (%7.2f %%)\n",
......
......@@ -190,6 +190,40 @@ struct Wlc_Par_t_
int (*pFuncStop)(int); // callback to terminate
};
typedef struct Wlc_BstPar_t_ Wlc_BstPar_t;
struct Wlc_BstPar_t_
{
int iOutput;
int nOutputRange;
int nAdderLimit;
int nMultLimit;
int fGiaSimple;
int fAddOutputs;
int fMulti;
int fBooth;
int fNoCleanup;
int fCreateMiter;
int fDecMuxes;
int fVerbose;
Vec_Int_t * vBoxIds;
};
static inline void Wlc_BstParDefault( Wlc_BstPar_t * pPar )
{
memset( pPar, 0, sizeof(Wlc_BstPar_t) );
pPar->iOutput = -1;
pPar->nOutputRange = 0;
pPar->nAdderLimit = 0;
pPar->nMultLimit = 0;
pPar->fGiaSimple = 0;
pPar->fAddOutputs = 0;
pPar->fMulti = 0;
pPar->fBooth = 0;
pPar->fCreateMiter = 0;
pPar->fDecMuxes = 0;
pPar->fVerbose = 0;
}
typedef struct Wla_Man_t_ Wla_Man_t;
struct Wla_Man_t_
{
......@@ -325,7 +359,7 @@ extern int Wlc_NtkPdrAbs( Wlc_Ntk_t * p, Wlc_Par_t * pPars );
/*=== wlcAbs2.c ========================================================*/
extern int Wlc_NtkAbsCore2( Wlc_Ntk_t * p, Wlc_Par_t * pPars );
/*=== wlcBlast.c ========================================================*/
extern Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int iOutput, int nRange, int fGiaSimple, int fAddOutputs, int fBooth, int fNoCleanup, int fCreateMiter, int fDecMuxes );
extern Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Wlc_BstPar_t * pPars );
/*=== wlcCom.c ========================================================*/
extern void Wlc_SetNtk( Abc_Frame_t * pAbc, Wlc_Ntk_t * pNtk );
/*=== wlcNdr.c ========================================================*/
......@@ -376,6 +410,7 @@ extern int Wlc_StdinProcessSmt( Abc_Frame_t * pAbc, char * pCmd );
/*=== wlcReadVer.c ========================================================*/
extern Wlc_Ntk_t * Wlc_ReadVer( char * pFileName, char * pStr );
/*=== wlcUif.c ========================================================*/
extern Vec_Int_t * Wlc_NtkCollectAddMult( Wlc_Ntk_t * p, Wlc_BstPar_t * pPar, int * pCountA, int * CountM );
extern int Wlc_NtkPairIsUifable( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, Wlc_Obj_t * pObj2 );
extern Vec_Int_t * Wlc_NtkCollectMultipliers( Wlc_Ntk_t * p );
extern Vec_Int_t * Wlc_NtkFindUifableMultiplierPairs( Wlc_Ntk_t * p );
......
......@@ -320,7 +320,7 @@ static Vec_Int_t * Wlc_NtkGetCoreSels( Gia_Man_t * pFrames, int nFrames, int fir
static Gia_Man_t * Wlc_NtkUnrollWoCex(Wlc_Ntk_t * pChoice, int nFrames, int first_sel_pi, int num_sel_pis)
{
Gia_Man_t * pGiaChoice = Wlc_NtkBitBlast( pChoice, NULL, -1, 0, 0, 0, 0, 0, 0, 0 );
Gia_Man_t * pGiaChoice = Wlc_NtkBitBlast( pChoice, NULL );
Gia_Man_t * pFrames = NULL, * pGia;
Gia_Obj_t * pObj, * pObjRi;
int f, i;
......@@ -366,7 +366,7 @@ static Gia_Man_t * Wlc_NtkUnrollWoCex(Wlc_Ntk_t * pChoice, int nFrames, int firs
static Gia_Man_t * Wlc_NtkUnrollWithCex(Wlc_Ntk_t * pChoice, Abc_Cex_t * pCex, int nbits_old_pis, int num_sel_pis, int * p_num_ppis, int sel_pi_first, int fUsePPI)
{
Gia_Man_t * pGiaChoice = Wlc_NtkBitBlast( pChoice, NULL, -1, 0, 0, 0, 0, 0, 0, 0 );
Gia_Man_t * pGiaChoice = Wlc_NtkBitBlast( pChoice, NULL );
int nbits_new_pis = Wlc_NtkNumPiBits( pChoice );
int num_ppis = nbits_new_pis - nbits_old_pis - num_sel_pis;
int num_undc_pis = Gia_ManPiNum(pGiaChoice) - nbits_new_pis;
......@@ -560,7 +560,7 @@ Wlc_Ntk_t * Wlc_NtkIntroduceChoices( Wlc_Ntk_t * pNtk, Vec_Int_t * vBlacks, Vec_
static Abc_Cex_t * Wlc_NtkCexIsReal( Wlc_Ntk_t * pOrig, Abc_Cex_t * pCex )
{
Gia_Man_t * pGiaOrig = Wlc_NtkBitBlast( pOrig, NULL, -1, 0, 0, 0, 0, 0, 0, 0 );
Gia_Man_t * pGiaOrig = Wlc_NtkBitBlast( pOrig, NULL );
int f, i;
Gia_Obj_t * pObj, * pObjRi;
Abc_Cex_t * pCexReal = Abc_CexAlloc( Gia_ManRegNum(pGiaOrig), Gia_ManPiNum(pGiaOrig), pCex->iFrame + 1 );
......@@ -1401,7 +1401,7 @@ Aig_Man_t * Wla_ManBitBlast( Wla_Man_t * pWla, Wlc_Ntk_t * pAbs )
Gia_Man_t * pTemp;
Aig_Man_t * pAig;
pWla->pGia = Wlc_NtkBitBlast( pAbs, NULL, -1, 0, 0, 0, 0, 0, 0, 0 );
pWla->pGia = Wlc_NtkBitBlast( pAbs, NULL );
// if the abstraction has flops with DC-init state,
// new PIs were introduced by bit-blasting at the end of the PI list
......@@ -1829,7 +1829,7 @@ int Wlc_NtkAbsCore( Wlc_Ntk_t * p, Wlc_Par_t * pPars )
pAbs = Wlc_NtkAbs( p, pPars, vUnmark, &vPisNew, NULL, pPars->fVerbose );
}
pGia = Wlc_NtkBitBlast( pAbs, NULL, -1, 0, 0, 0, 0, 0, 0, 0 );
pGia = Wlc_NtkBitBlast( pAbs, NULL );
// if the abstraction has flops with DC-init state,
// new PIs were introduced by bit-blasting at the end of the PI list
......
......@@ -328,7 +328,7 @@ int Wlc_NtkAbsCore2( Wlc_Ntk_t * p, Wlc_Par_t * pPars )
// get abstracted GIA and the set of pseudo-PIs (vPisNew)
pAbs = Wlc_NtkAbs( p, pPars, vUnmark, &vPisNew, pPars->fVerbose );
pGia = Wlc_NtkBitBlast( pAbs, NULL, -1, 0, 0, 0, 0, 0, 0, 0 );
pGia = Wlc_NtkBitBlast( pAbs, NULL );
// if the abstraction has flops with DC-init state,
// new PIs were introduced by bit-blasting at the end of the PI list
......
......@@ -888,11 +888,12 @@ usage:
int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Wlc_Ntk_t * pNtk = Wlc_AbcGetNtk(pAbc);
Vec_Int_t * vBoxIds = NULL;
Gia_Man_t * pNew = NULL;
int c, iOutput = -1, nOutputRange = 2, fGiaSimple = 0, fAddOutputs = 0, fMulti = 0, fBooth = 0, fCreateMiter = 0, fDecMuxes = 0, fVerbose = 0;
Gia_Man_t * pNew = NULL; int c;
Wlc_BstPar_t Par, * pPar = &Par;
Wlc_BstParDefault( pPar );
pPar->nOutputRange = 2;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ORcombdsvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "ORAMcombdsvh" ) ) != EOF )
{
switch ( c )
{
......@@ -902,9 +903,9 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
goto usage;
}
iOutput = atoi(argv[globalUtilOptind]);
pPar->iOutput = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( iOutput < 0 )
if ( pPar->iOutput < 0 )
goto usage;
break;
case 'R':
......@@ -913,31 +914,53 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
goto usage;
}
nOutputRange = atoi(argv[globalUtilOptind]);
pPar->nOutputRange = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPar->nOutputRange < 0 )
goto usage;
break;
case 'A':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
goto usage;
}
pPar->nAdderLimit = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPar->nAdderLimit < 0 )
goto usage;
break;
case 'M':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
goto usage;
}
pPar->nMultLimit = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nOutputRange < 0 )
if ( pPar->nMultLimit < 0 )
goto usage;
break;
case 'c':
fGiaSimple ^= 1;
pPar->fGiaSimple ^= 1;
break;
case 'o':
fAddOutputs ^= 1;
pPar->fAddOutputs ^= 1;
break;
case 'm':
fMulti ^= 1;
pPar->fMulti ^= 1;
break;
case 'b':
fBooth ^= 1;
pPar->fBooth ^= 1;
break;
case 'd':
fCreateMiter ^= 1;
pPar->fCreateMiter ^= 1;
break;
case 's':
fDecMuxes ^= 1;
pPar->fDecMuxes ^= 1;
break;
case 'v':
fVerbose ^= 1;
pPar->fVerbose ^= 1;
break;
case 'h':
goto usage;
......@@ -950,20 +973,29 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( 1, "Abc_CommandBlast(): There is no current design.\n" );
return 0;
}
if ( fMulti )
if ( pPar->fMulti )
{
vBoxIds = Wlc_NtkCollectMultipliers( pNtk );
if ( vBoxIds == NULL )
pPar->vBoxIds = Wlc_NtkCollectMultipliers( pNtk );
if ( pPar->vBoxIds == NULL )
Abc_Print( 1, "Warning: There is no multipliers in the design.\n" );
}
if ( iOutput >= 0 && iOutput + nOutputRange > Wlc_NtkPoNum(pNtk) )
else if ( pPar->nAdderLimit || pPar->nMultLimit )
{
Abc_Print( 1, "Abc_CommandBlast(): The output range [%d:%d] is incorrect.\n", iOutput, iOutput + nOutputRange - 1 );
int CountA, CountM;
pPar->vBoxIds = Wlc_NtkCollectAddMult( pNtk, pPar, &CountA, &CountM );
if ( pPar->vBoxIds == NULL )
Abc_Print( 1, "Warning: There is no adders and multipliers that will not be blasted.\n" );
else
Abc_Print( 1, "Warning: %d adders and %d multipliers will not be blasted.\n", CountA, CountM );
}
if ( pPar->iOutput >= 0 && pPar->iOutput + pPar->nOutputRange > Wlc_NtkPoNum(pNtk) )
{
Abc_Print( 1, "Abc_CommandBlast(): The output range [%d:%d] is incorrect.\n", pPar->iOutput, pPar->iOutput + pPar->nOutputRange - 1 );
return 0;
}
// transform
pNew = Wlc_NtkBitBlast( pNtk, vBoxIds, iOutput, nOutputRange, fGiaSimple, fAddOutputs, fBooth, 0, fCreateMiter, fDecMuxes );
Vec_IntFreeP( &vBoxIds );
pNew = Wlc_NtkBitBlast( pNtk, pPar );
Vec_IntFreeP( &pPar->vBoxIds );
if ( pNew == NULL )
{
Abc_Print( 1, "Abc_CommandBlast(): Bit-blasting has failed.\n" );
......@@ -972,17 +1004,19 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_FrameUpdateGia( pAbc, pNew );
return 0;
usage:
Abc_Print( -2, "usage: %%blast [-OR num] [-combdsvh]\n" );
Abc_Print( -2, "usage: %%blast [-ORAM num] [-combdsvh]\n" );
Abc_Print( -2, "\t performs bit-blasting of the word-level design\n" );
Abc_Print( -2, "\t-O num : zero-based index of the first word-level PO to bit-blast [default = %d]\n", iOutput );
Abc_Print( -2, "\t-R num : the total number of word-level POs to bit-blast [default = %d]\n", nOutputRange );
Abc_Print( -2, "\t-c : toggle using AIG w/o const propagation and strashing [default = %s]\n", fGiaSimple? "yes": "no" );
Abc_Print( -2, "\t-o : toggle using additional POs on the word-level boundaries [default = %s]\n", fAddOutputs? "yes": "no" );
Abc_Print( -2, "\t-m : toggle creating boxes for all multipliers in the design [default = %s]\n", fMulti? "yes": "no" );
Abc_Print( -2, "\t-b : toggle generating radix-4 Booth multipliers [default = %s]\n", fBooth? "yes": "no" );
Abc_Print( -2, "\t-d : toggle creating dual-output miter [default = %s]\n", fCreateMiter? "yes": "no" );
Abc_Print( -2, "\t-s : toggle creating decoded MUXes [default = %s]\n", fDecMuxes? "yes": "no" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-O num : zero-based index of the first word-level PO to bit-blast [default = %d]\n", pPar->iOutput );
Abc_Print( -2, "\t-R num : the total number of word-level POs to bit-blast [default = %d]\n", pPar->nOutputRange );
Abc_Print( -2, "\t-A num : blast adders smaller than this (0 = unused) [default = %d]\n", pPar->nAdderLimit );
Abc_Print( -2, "\t-M num : blast multipliers smaller than this (0 = unused) [default = %d]\n", pPar->nMultLimit );
Abc_Print( -2, "\t-c : toggle using AIG w/o const propagation and strashing [default = %s]\n", pPar->fGiaSimple? "yes": "no" );
Abc_Print( -2, "\t-o : toggle using additional POs on the word-level boundaries [default = %s]\n", pPar->fAddOutputs? "yes": "no" );
Abc_Print( -2, "\t-m : toggle creating boxes for all multipliers in the design [default = %s]\n", pPar->fMulti? "yes": "no" );
Abc_Print( -2, "\t-b : toggle generating radix-4 Booth multipliers [default = %s]\n", pPar->fBooth? "yes": "no" );
Abc_Print( -2, "\t-d : toggle creating dual-output miter [default = %s]\n", pPar->fCreateMiter? "yes": "no" );
Abc_Print( -2, "\t-s : toggle creating decoded MUXes [default = %s]\n", pPar->fDecMuxes? "yes": "no" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPar->fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
......
......@@ -210,7 +210,7 @@ Wlc_Ntk_t * Wlc_NtkGraftMulti( Wlc_Ntk_t * p, int fVerbose )
Gia_Obj_t * pObj;
Vec_Int_t * vObjsLHS = Wlc_NtkCollectObjs( p, 0, &nMultiLHS );
Vec_Int_t * vObjsRHS = Wlc_NtkCollectObjs( p, 1, &nMultiRHS );
Gia_Man_t * pGia = Wlc_NtkBitBlast( p, NULL, -1, 0, 0, 0, 0, 1, 0, 0 );
Gia_Man_t * pGia = Wlc_NtkBitBlast( p, NULL ); //, -1, 0, 0, 0, 0, 1, 0, 0 ); // <= no cleanup
Vec_Mem_t * vTtMem = Vec_MemAlloc( nWords, 10 );
Vec_MemHashAlloc( vTtMem, 10000 );
......@@ -540,7 +540,7 @@ int Sbc_ManWlcNodes( Wlc_Ntk_t * pNtk, Gia_Man_t * p, Vec_Int_t * vGia2Out, int
void Sbc_ManDetectMultTest( Wlc_Ntk_t * pNtk, int fVerbose )
{
extern Vec_Int_t * Sdb_StoComputeCutsDetect( Gia_Man_t * pGia );
Gia_Man_t * p = Wlc_NtkBitBlast( pNtk, NULL, -1, 0, 0, 0, 0, 1, 0, 0 );
Gia_Man_t * p = Wlc_NtkBitBlast( pNtk, NULL );//, -1, 0, 0, 0, 0, 1, 0, 0 ); // <= no cleanup
Vec_Int_t * vIns, * vGia2Out;
int iObjFound = -1;
// Gia_Obj_t * pObj; int i;
......
......@@ -1298,7 +1298,7 @@ void Io_ReadWordTest( char * pFileName )
return;
Wlc_WriteVer( pNtk, "test.v", 0, 0 );
pNew = Wlc_NtkBitBlast( pNtk, NULL, -1, 0, 0, 0, 0, 0, 0, 0 );
pNew = Wlc_NtkBitBlast( pNtk, NULL );
Gia_AigerWrite( pNew, "test.aig", 0, 0 );
Gia_ManStop( pNew );
......
......@@ -129,7 +129,7 @@ Vec_Ptr_t * Wlc_NtkSimulate( Wlc_Ntk_t * p, Vec_Int_t * vNodes, int nWords, int
{
Gia_Obj_t * pObj;
Vec_Ptr_t * vOne, * vRes;
Gia_Man_t * pGia = Wlc_NtkBitBlast( p, NULL, -1, 0, 0, 0, 0, 0, 0, 0 );
Gia_Man_t * pGia = Wlc_NtkBitBlast( p, NULL );
Wlc_Obj_t * pWlcObj;
int f, i, k, w, nBits, Counter = 0;
// allocate simulation info for one timeframe
......
......@@ -32,6 +32,38 @@ ABC_NAMESPACE_IMPL_START
/**Function*************************************************************
Synopsis [Collect adds and mults.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Wlc_NtkCollectAddMult( Wlc_Ntk_t * p, Wlc_BstPar_t * pPar, int * pCountA, int * pCountM )
{
Vec_Int_t * vBoxIds;
Wlc_Obj_t * pObj; int i;
*pCountA = *pCountM = 0;
if ( pPar->nAdderLimit == 0 && pPar->nMultLimit == 0 )
return NULL;
vBoxIds = Vec_IntAlloc( 100 );
Wlc_NtkForEachObj( p, pObj, i )
{
if ( pObj->Type == WLC_OBJ_ARI_ADD && pPar->nAdderLimit && Wlc_ObjRange(pObj) >= pPar->nAdderLimit )
Vec_IntPush( vBoxIds, i ), (*pCountA)++;
else if ( pObj->Type == WLC_OBJ_ARI_MULTI && pPar->nMultLimit && Wlc_ObjRange(pObj) >= pPar->nMultLimit )
Vec_IntPush( vBoxIds, i ), (*pCountM)++;
}
if ( Vec_IntSize( vBoxIds ) > 0 )
return vBoxIds;
Vec_IntFree( vBoxIds );
return NULL;
}
/**Function*************************************************************
Synopsis [Check if two objects have the same input/output signatures.]
Description []
......
......@@ -364,6 +364,7 @@ struct If_Box_t_
struct If_LibBox_t_
{
int nBoxes;
Vec_Ptr_t * vBoxes;
};
......@@ -600,6 +601,7 @@ extern float If_LibLutSlowestPinDelay( If_LibLut_t * p );
/*=== ifLibBox.c =============================================================*/
extern If_LibBox_t * If_LibBoxStart();
extern void If_LibBoxFree( If_LibBox_t * p );
extern int If_LibBoxNum( If_LibBox_t * p );
extern If_Box_t * If_LibBoxReadBox( If_LibBox_t * p, int Id );
extern If_Box_t * If_LibBoxFindBox( If_LibBox_t * p, char * pName );
extern void If_LibBoxAdd( If_LibBox_t * p, If_Box_t * pBox );
......@@ -608,6 +610,7 @@ extern If_LibBox_t * If_LibBoxRead2( char * pFileName );
extern void If_LibBoxPrint( FILE * pFile, If_LibBox_t * p );
extern void If_LibBoxWrite( char * pFileName, If_LibBox_t * p );
extern int If_LibBoxLoad( char * pFileName );
extern If_Box_t * If_BoxStart( char * pName, int Id, int nPis, int nPos, int fSeq, int fBlack, int fOuter );
/*=== ifMan.c =============================================================*/
extern If_Man_t * If_ManStart( If_Par_t * pPars );
extern void If_ManRestart( If_Man_t * p );
......
......@@ -139,6 +139,11 @@ void If_LibBoxAdd( If_LibBox_t * p, If_Box_t * pBox )
Vec_PtrFillExtra( p->vBoxes, 2 * pBox->Id + 10, NULL );
assert( Vec_PtrEntry( p->vBoxes, pBox->Id ) == NULL );
Vec_PtrWriteEntry( p->vBoxes, pBox->Id, pBox );
p->nBoxes++;
}
int If_LibBoxNum( If_LibBox_t * p )
{
return p->nBoxes;
}
/**Function*************************************************************
......
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