Commit 118e40b8 by Alan Mishchenko

New technology mapper.

parent 16734052
......@@ -1043,6 +1043,9 @@ extern int Gia_MmStepReadMemUsage( Gia_MmStep_t * p );
/*=== giaMini.c ===========================================================*/
extern Gia_Man_t * Gia_ManReadMiniAig( char * pFileName );
extern void Gia_ManWriteMiniAig( Gia_Man_t * pGia, char * pFileName );
/*=== giaMuxes.c ===========================================================*/
extern Gia_Man_t * Gia_ManDupMuxes( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManDupNoMuxes( Gia_Man_t * p );
/*=== giaPat.c ===========================================================*/
extern void Gia_SatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pRoot, Vec_Int_t * vCex, Vec_Int_t * vVisit );
/*=== giaRetime.c ===========================================================*/
......
......@@ -29522,7 +29522,7 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults
Mpm_ManSetParsDefault( pPars );
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "KDmzvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "KDtmzvh" ) ) != EOF )
{
switch ( c )
{
......@@ -29553,6 +29553,9 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->DelayTarget <= 0.0 )
goto usage;
break;
case 't':
pPars->fUseGates ^= 1;
break;
case 'm':
pPars->fCutMin ^= 1;
break;
......@@ -29587,10 +29590,11 @@ usage:
sprintf(Buffer, "best possible" );
else
sprintf(Buffer, "%d", pPars->DelayTarget );
Abc_Print( -2, "usage: &if2 [-KD num] [-mzvh]\n" );
Abc_Print( -2, "usage: &if2 [-KD num] [-tmzvh]\n" );
Abc_Print( -2, "\t performs technology mapping of the network\n" );
Abc_Print( -2, "\t-K num : sets the LUT size for the mapping [default = %d]\n", nLutSize );
Abc_Print( -2, "\t-D num : sets the delay constraint for the mapping [default = %s]\n", Buffer );
Abc_Print( -2, "\t-t : enables using AND/XOR/MUX nodes instead of simple AIG [default = %s]\n", pPars->fUseGates? "yes": "no" );
Abc_Print( -2, "\t-m : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
Abc_Print( -2, "\t-z : toggles deriving LUTs when mapping into LUT structures [default = %s]\n", pPars->fDeriveLuts? "yes": "no" );
Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
......@@ -59,6 +59,7 @@ struct Mpm_Par_t_
Mpm_LibLut_t * pLib;
int nNumCuts;
int DelayTarget;
int fUseGates;
int fUseTruth;
int fUseDsd;
int fCutMin;
......
......@@ -59,7 +59,11 @@ Mig_Man_t * Mig_ManCreate( void * pGia )
// create objects
Gia_ManForEachObj1( p, pObj, i )
{
if ( Gia_ObjIsAnd(pObj) )
if ( Gia_ObjIsMux(p, i) )
pObj->Value = Mig_ManAppendMux( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj), Gia_ObjFanin2Copy(p, pObj) );
else if ( Gia_ObjIsXor(pObj) )
pObj->Value = Mig_ManAppendXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
else if ( Gia_ObjIsAnd(pObj) )
pObj->Value = Mig_ManAppendAnd( pNew, Mig_ObjFanin0Copy(pObj), Mig_ObjFanin1Copy(pObj) );
else if ( Gia_ObjIsCi(pObj) )
pObj->Value = Mig_ManAppendCi( pNew );
......@@ -88,7 +92,8 @@ int Mpm_ManNodeIfToGia_rec( Gia_Man_t * pNew, Mpm_Man_t * pMan, Mig_Obj_t * pObj
{
Mig_Obj_t * pTemp;
Mpm_Cut_t * pCut;
int iFunc, iFunc0, iFunc1;
int iFunc, iFunc0, iFunc1, iFunc2 = 0;
assert( fHash == 0 );
// get the best cut
pCut = Mpm_ObjCutBestP( pMan, pObj );
// if the cut is visited, return the result
......@@ -110,11 +115,34 @@ int Mpm_ManNodeIfToGia_rec( Gia_Man_t * pNew, Mpm_Man_t * pMan, Mig_Obj_t * pObj
iFunc1 = Mpm_ManNodeIfToGia_rec( pNew, pMan, Mig_ObjFanin1(pTemp), vVisited, fHash );
if ( iFunc1 == ~0 )
continue;
if ( Mig_ObjIsNode3(pTemp) )
{
iFunc2 = Mpm_ManNodeIfToGia_rec( pNew, pMan, Mig_ObjFanin2(pTemp), vVisited, fHash );
if ( iFunc2 == ~0 )
continue;
iFunc2 = Abc_LitNotCond(iFunc2, Mig_ObjFaninC2(pTemp));
}
iFunc0 = Abc_LitNotCond(iFunc0, Mig_ObjFaninC0(pTemp));
iFunc1 = Abc_LitNotCond(iFunc1, Mig_ObjFaninC1(pTemp));
// both branches are solved
if ( fHash )
iFunc = Gia_ManHashAnd( pNew, Abc_LitNotCond(iFunc0, Mig_ObjFaninC0(pTemp)), Abc_LitNotCond(iFunc1, Mig_ObjFaninC1(pTemp)) );
{
if ( Mig_ObjIsMux(pTemp) )
iFunc = Gia_ManHashMux( pNew, iFunc2, iFunc1, iFunc0 );
else if ( Mig_ObjIsXor(pTemp) )
iFunc = Gia_ManHashXor( pNew, iFunc0, iFunc1 );
else
iFunc = Gia_ManHashAnd( pNew, iFunc0, iFunc1 );
}
else
iFunc = Gia_ManAppendAnd( pNew, Abc_LitNotCond(iFunc0, Mig_ObjFaninC0(pTemp)), Abc_LitNotCond(iFunc1, Mig_ObjFaninC1(pTemp)) );
{
if ( Mig_ObjIsMux(pTemp) )
iFunc = Gia_ManAppendMux( pNew, iFunc2, iFunc1, iFunc0 );
else if ( Mig_ObjIsXor(pTemp) )
iFunc = Gia_ManAppendXor( pNew, iFunc0, iFunc1 );
else
iFunc = Gia_ManAppendAnd( pNew, iFunc0, iFunc1 );
}
if ( Mig_ObjPhase(pTemp) != Mig_ObjPhase(pObj) )
iFunc = Abc_LitNot(iFunc);
Mpm_CutSetDataInt( pCut, iFunc );
......
......@@ -84,7 +84,14 @@ Gia_Man_t * Mpm_ManMappingTest( Gia_Man_t * pGia, Mpm_Par_t * pPars )
{
Mig_Man_t * p;
Gia_Man_t * pNew;
p = Mig_ManCreate( pGia );
if ( pPars->fUseGates )
{
pGia = Gia_ManDupMuxes( pGia );
p = Mig_ManCreate( pGia );
Gia_ManStop( pGia );
}
else
p = Mig_ManCreate( pGia );
pNew = Mpm_ManPerformTest( p, pPars );
Mig_ManStop( p );
return pNew;
......
......@@ -145,9 +145,10 @@ void Mpm_ManStop( Mpm_Man_t * p )
***********************************************************************/
void Mpm_ManPrintStatsInit( Mpm_Man_t * p )
{
printf( "K = %d. C = %d. Cands = %d. Choices = %d. CutMin = %d. Truth = %d.\n",
printf( "K = %d. C = %d. Cands = %d. XOR = %d. MUX = %d. Choices = %d. CutMin = %d. Truth = %d.\n",
p->nLutSize, p->nNumCuts,
Mig_ManCiNum(p->pMig) + Mig_ManNodeNum(p->pMig), 0,
Mig_ManCiNum(p->pMig) + Mig_ManNodeNum(p->pMig),
Mig_ManXorNum(p->pMig), Mig_ManMuxNum(p->pMig), 0,
p->pPars->fCutMin, p->pPars->fUseTruth );
}
void Mpm_ManPrintStats( Mpm_Man_t * p )
......
......@@ -540,7 +540,6 @@ static inline int Mpm_ObjDeriveCut( Mpm_Man_t * p, Mpm_Cut_t ** pCuts, Mpm_Cut_t
pCut->iFunc = 0; pCut->iFunc = ~pCut->iFunc;
pCut->fUseless = 0;
pCut->fCompl = 0;
// assert( pCut->nLeaves > 0 );
p->nCutsMerged++;
if ( p->pPars->fUseTruth )
Vec_IntSelectSort( pCut->pLeaves, pCut->nLeaves );
......
......@@ -76,6 +76,38 @@ void Mig_ManStop( Mig_Man_t * p )
ABC_FREE( p );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Mig_ManTypeNum( Mig_Man_t * p, int Type )
{
Mig_Obj_t * pObj;
int Counter = 0;
Mig_ManForEachNode( p, pObj )
Counter += (Mig_ObjNodeType(pObj) == Type);
return Counter;
}
int Mig_ManAndNum( Mig_Man_t * p )
{
return Mig_ManTypeNum(p, 1);
}
int Mig_ManXorNum( Mig_Man_t * p )
{
return Mig_ManTypeNum(p, 2);
}
int Mig_ManMuxNum( Mig_Man_t * p )
{
return Mig_ManTypeNum(p, 3);
}
/**Function*************************************************************
......
......@@ -342,7 +342,9 @@ static inline int Mig_ManAppendMaj( Mig_Man_t * p, int iLit0, int iLit1, int iLi
extern Mig_Man_t * Mig_ManStart();
extern void Mig_ManStop( Mig_Man_t * p );
extern void Mig_ManSetRefs( Mig_Man_t * p, int fSkipCos );
extern int Mig_ManAndNum( Mig_Man_t * p );
extern int Mig_ManXorNum( Mig_Man_t * p );
extern int Mig_ManMuxNum( Mig_Man_t * p );
ABC_NAMESPACE_HEADER_END
......
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