Commit fba33fbb by Alan Mishchenko

New technology mapper.

parent 2ee26b00
...@@ -15,7 +15,7 @@ MODULES := \ ...@@ -15,7 +15,7 @@ MODULES := \
src/bdd/cudd src/bdd/dsd src/bdd/epd src/bdd/mtr src/bdd/parse \ src/bdd/cudd src/bdd/dsd src/bdd/epd src/bdd/mtr src/bdd/parse \
src/bdd/reo src/bdd/cas \ src/bdd/reo src/bdd/cas \
src/map/mapper src/map/mio src/map/super src/map/if \ src/map/mapper src/map/mio src/map/super src/map/if \
src/map/amap src/map/cov src/map/scl \ src/map/amap src/map/cov src/map/scl src/map/mpm \
src/misc/extra src/misc/mvc src/misc/st src/misc/util src/misc/nm \ src/misc/extra src/misc/mvc src/misc/st src/misc/util src/misc/nm \
src/misc/vec src/misc/hash src/misc/tim src/misc/bzlib src/misc/zlib \ src/misc/vec src/misc/hash src/misc/tim src/misc/bzlib src/misc/zlib \
src/misc/mem src/misc/bar src/misc/bbl \ src/misc/mem src/misc/bar src/misc/bbl \
......
...@@ -2295,10 +2295,6 @@ SOURCE=.\src\map\if\ifDec16.c ...@@ -2295,10 +2295,6 @@ SOURCE=.\src\map\if\ifDec16.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\map\if\ifDsd.c
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifLibBox.c SOURCE=.\src\map\if\ifLibBox.c
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -2486,6 +2482,58 @@ SOURCE=.\src\map\scl\sclUpsize.c ...@@ -2486,6 +2482,58 @@ SOURCE=.\src\map\scl\sclUpsize.c
SOURCE=.\src\map\scl\sclUtil.c SOURCE=.\src\map\scl\sclUtil.c
# End Source File # End Source File
# End Group # End Group
# Begin Group "mpm"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\map\mpm\mpm.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpm.h
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpmAbc.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpmCore.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpmInt.h
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpmLib.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpmMap.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpmMig.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpmMig.h
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpmPre.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpmTruth.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mpm\mpmUtil.c
# End Source File
# End Group
# End Group # End Group
# Begin Group "misc" # Begin Group "misc"
...@@ -3667,10 +3715,6 @@ SOURCE=.\src\aig\gia\giaSwitch.c ...@@ -3667,10 +3715,6 @@ SOURCE=.\src\aig\gia\giaSwitch.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\aig\gia\giaTest.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaTim.c SOURCE=.\src\aig\gia\giaTim.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -44,7 +44,6 @@ SRC += src/aig/gia/giaAig.c \ ...@@ -44,7 +44,6 @@ SRC += src/aig/gia/giaAig.c \
src/aig/gia/giaSweep.c \ src/aig/gia/giaSweep.c \
src/aig/gia/giaSweeper.c \ src/aig/gia/giaSweeper.c \
src/aig/gia/giaSwitch.c \ src/aig/gia/giaSwitch.c \
src/aig/gia/giaTest.c \
src/aig/gia/giaTim.c \ src/aig/gia/giaTim.c \
src/aig/gia/giaTruth.c \ src/aig/gia/giaTruth.c \
src/aig/gia/giaTsim.c \ src/aig/gia/giaTsim.c \
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "proof/ssc/ssc.h" #include "proof/ssc/ssc.h"
#include "opt/sfm/sfm.h" #include "opt/sfm/sfm.h"
#include "bool/rpo/rpo.h" #include "bool/rpo/rpo.h"
#include "map/mpm/mpm.h"
#ifndef _WIN32 #ifndef _WIN32
#include <unistd.h> #include <unistd.h>
...@@ -371,6 +372,7 @@ static int Abc_CommandAbc9Sweep ( Abc_Frame_t * pAbc, int argc, cha ...@@ -371,6 +372,7 @@ static int Abc_CommandAbc9Sweep ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAbc9Force ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Force ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Embed ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Embed ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9If ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9If ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9If2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Trace ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Trace ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Speedup ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Speedup ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Era ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Era ( Abc_Frame_t * pAbc, int argc, char ** argv );
...@@ -921,6 +923,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) ...@@ -921,6 +923,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "ABC9", "&force", Abc_CommandAbc9Force, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&force", Abc_CommandAbc9Force, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&embed", Abc_CommandAbc9Embed, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&embed", Abc_CommandAbc9Embed, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&if", Abc_CommandAbc9If, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&if", Abc_CommandAbc9If, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&if2", Abc_CommandAbc9If2, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&trace", Abc_CommandAbc9Trace, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&trace", Abc_CommandAbc9Trace, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&speedup", Abc_CommandAbc9Speedup, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&speedup", Abc_CommandAbc9Speedup, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&era", Abc_CommandAbc9Era, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&era", Abc_CommandAbc9Era, 0 );
...@@ -10114,7 +10117,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -10114,7 +10117,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage; goto usage;
} }
} }
/*
if ( pNtk == NULL ) if ( pNtk == NULL )
{ {
Abc_Print( -1, "Empty network.\n" ); Abc_Print( -1, "Empty network.\n" );
...@@ -10126,7 +10129,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -10126,7 +10129,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "This command works only for logic networks.\n" ); Abc_Print( -1, "This command works only for logic networks.\n" );
return 1; return 1;
} }
*/
/* /*
if ( Abc_NtkLatchNum(pNtk) == 0 ) if ( Abc_NtkLatchNum(pNtk) == 0 )
{ {
...@@ -10163,8 +10166,12 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -10163,8 +10166,12 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1; return 1;
} }
*/ */
if ( pNtk ) // if ( pNtk )
Abc_NtkMakeLegit( pNtk ); // Abc_NtkMakeLegit( pNtk );
{
extern void Ifd_ManDsdTest();
Ifd_ManDsdTest();
}
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: test [-CKDN] [-aovwh] <file_name>\n" ); Abc_Print( -2, "usage: test [-CKDN] [-aovwh] <file_name>\n" );
...@@ -29444,7 +29451,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -29444,7 +29451,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
pNew = Gia_ManPerformMapping( pAbc->pGia, pPars, 1 ); pNew = Gia_ManPerformMapping( pAbc->pGia, pPars, 1 );
if ( pNew == NULL ) if ( pNew == NULL )
{ {
Abc_Print( -1, "Abc_CommandAbc9If(): Mapping of the AIG has failed.\n" ); Abc_Print( -1, "Abc_CommandAbc9If(): Mapping of GIA has failed.\n" );
return 1; return 1;
} }
Abc_FrameUpdateGia( pAbc, pNew ); Abc_FrameUpdateGia( pAbc, pNew );
...@@ -29505,6 +29512,74 @@ usage: ...@@ -29505,6 +29512,74 @@ usage:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern Gia_Man_t * Mpm_ManMappingTest( Gia_Man_t * p, Mpm_Par_t * pPars );
char Buffer[200];
Gia_Man_t * pNew;
Mpm_Par_t Pars, * pPars = &Pars;
int c;
// set defaults
Mpm_ManSetParsDefault( pPars );
// pPars->pLutLib = (If_LibLut_t *)pAbc->pLibLut;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Dvh" ) ) != EOF )
{
switch ( c )
{
case 'D':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->DelayTarget = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->DelayTarget <= 0.0 )
goto usage;
break;
case 'v':
pPars->fVerbose ^= 1;
break;
case 'h':
default:
goto usage;
}
}
// perform mapping
pNew = Mpm_ManMappingTest( pAbc->pGia, pPars );
if ( pNew == NULL )
{
Abc_Print( -1, "Abc_CommandAbc9If2(): Mapping of GIA has failed.\n" );
return 1;
}
Abc_FrameUpdateGia( pAbc, pNew );
return 0;
usage:
if ( pPars->DelayTarget == -1 )
sprintf(Buffer, "best possible" );
else
sprintf(Buffer, "%.2f", pPars->DelayTarget );
Abc_Print( -2, "usage: &if2 [-D num] [-vh]\n" );
Abc_Print( -2, "\t performs technology mapping of the network\n" );
Abc_Print( -2, "\t-D num : sets the delay constraint for the mapping [default = %s]\n", Buffer );
Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : prints the command usage\n");
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandAbc9Trace( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandAbc9Trace( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
...@@ -30654,11 +30729,13 @@ int Abc_CommandAbc9ReachY( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -30654,11 +30729,13 @@ int Abc_CommandAbc9ReachY( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9ReachN(): The current AIG has no latches.\n" ); Abc_Print( -1, "Abc_CommandAbc9ReachN(): The current AIG has no latches.\n" );
return 0; return 0;
} }
/*
if ( Gia_ManObjNum(pAbc->pGia) >= (1<<16) ) if ( Gia_ManObjNum(pAbc->pGia) >= (1<<16) )
{ {
Abc_Print( -1, "Abc_CommandAbc9ReachN(): Currently cannot handle AIGs with more than %d objects.\n", (1<<16) ); Abc_Print( -1, "Abc_CommandAbc9ReachN(): Currently cannot handle AIGs with more than %d objects.\n", (1<<16) );
return 0; return 0;
} }
*/
pMan = Gia_ManToAigSimple( pAbc->pGia ); pMan = Gia_ManToAigSimple( pAbc->pGia );
pAbc->Status = Llb_Nonlin4CoreReach( pMan, pPars ); pAbc->Status = Llb_Nonlin4CoreReach( pMan, pPars );
pAbc->nFrames = pPars->iFrame; pAbc->nFrames = pPars->iFrame;
...@@ -32589,7 +32666,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -32589,7 +32666,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
// extern Gia_Man_t * Bmc_CexDepthTest( Gia_Man_t * p, Abc_Cex_t * pCex, int nFrames, int fVerbose ); // extern Gia_Man_t * Bmc_CexDepthTest( Gia_Man_t * p, Abc_Cex_t * pCex, int nFrames, int fVerbose );
// extern Gia_Man_t * Bmc_CexTarget( Gia_Man_t * p, int nFrames ); // extern Gia_Man_t * Bmc_CexTarget( Gia_Man_t * p, int nFrames );
// extern void Gia_ManMuxProfiling( Gia_Man_t * p ); // extern void Gia_ManMuxProfiling( Gia_Man_t * p );
extern Gia_Man_t * Mig_ManTest( Gia_Man_t * pGia ); // extern Gia_Man_t * Mig_ManTest( Gia_Man_t * pGia );
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Fsvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "Fsvh" ) ) != EOF )
...@@ -32659,8 +32736,8 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -32659,8 +32736,8 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
// pTemp = Bmc_CexTarget( pAbc->pGia, nFrames ); // pTemp = Bmc_CexTarget( pAbc->pGia, nFrames );
// Abc_FrameUpdateGia( pAbc, pTemp ); // Abc_FrameUpdateGia( pAbc, pTemp );
// Gia_ManMuxProfiling( pAbc->pGia ); // Gia_ManMuxProfiling( pAbc->pGia );
pTemp = Mig_ManTest( pAbc->pGia ); // pTemp = Mig_ManTest( pAbc->pGia );
Abc_FrameUpdateGia( pAbc, pTemp ); // Abc_FrameUpdateGia( pAbc, pTemp );
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: &test [-F num] [-svh]\n" ); Abc_Print( -2, "usage: &test [-F num] [-svh]\n" );
SRC += src/map/mpm/mpmAbc.c \
src/map/mpm/mpmCore.c \
src/map/mpm/mpmDsd.c \
src/map/mpm/mpmLib.c \
src/map/mpm/mpmMap.c \
src/map/mpm/mpmMig.c \
src/map/mpm/mpmPre.c \
src/map/mpm/mpmTruth.c \
src/map/mpm/mpmUtil.c
/**CFile****************************************************************
FileName [mpm.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Configurable technology mapper.]
Synopsis []
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 1, 2013.]
Revision [$Id: mpm.c,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
***********************************************************************/
#include "mpmInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Mpm_ManTest()
{
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
/**CFile****************************************************************
FileName [mpm.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Configurable technology mapper.]
Synopsis [External declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 1, 2013.]
Revision [$Id: mpm.h,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef ABC__map__mpm__h
#define ABC__map__mpm__h
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
#define MPM_VAR_MAX 32
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
typedef struct Mpm_LibLut_t_ Mpm_LibLut_t;
struct Mpm_LibLut_t_
{
char * pName; // the name of the LUT library
int LutMax; // the maximum LUT size
int fVarPinDelays; // set to 1 if variable pin delays are specified
int pLutAreas[MPM_VAR_MAX+1]; // the areas of LUTs
int pLutDelays[MPM_VAR_MAX+1][MPM_VAR_MAX+1]; // the delays of LUTs
};
typedef struct Mpm_Par_t_ Mpm_Par_t;
struct Mpm_Par_t_
{
int DelayTarget;
int fVerbose;
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== mpmCore.c ===========================================================*/
extern void Mpm_ManSetParsDefault( Mpm_Par_t * p );
ABC_NAMESPACE_HEADER_END
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [mpmAbc.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Configurable technology mapper.]
Synopsis [Interface with ABC data structures.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 1, 2013.]
Revision [$Id: mpmAbc.c,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
***********************************************************************/
#include "aig/gia/gia.h"
#include "mpmInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Mig_ObjFanin0Copy( Gia_Obj_t * pObj ) { return Abc_LitNotCond( Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj) ); }
static inline int Mig_ObjFanin1Copy( Gia_Obj_t * pObj ) { return Abc_LitNotCond( Gia_ObjFanin1(pObj)->Value, Gia_ObjFaninC1(pObj) ); }
Mig_Man_t * Mig_ManCreate( void * pGia )
{
Gia_Man_t * p = (Gia_Man_t *)pGia;
Mig_Man_t * pNew;
Gia_Obj_t * pObj;
int i;
// create the new manager
pNew = Mig_ManStart();
pNew->pName = Abc_UtilStrsav( p->pName );
Gia_ManConst0(p)->Value = 0;
// create objects
Gia_ManForEachObj1( p, pObj, i )
{
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 );
else if ( Gia_ObjIsCo(pObj) )
pObj->Value = Mig_ManAppendCo( pNew, Mig_ObjFanin0Copy(pObj) );
else assert( 0 );
}
Mig_ManSetRegNum( pNew, Gia_ManRegNum(p) );
return pNew;
}
/**Function*************************************************************
Synopsis [Recursively derives the local AIG for the cut.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline unsigned Mpm_CutDataInt( Mpm_Cut_t * pCut ) { return pCut->hNext; }
static inline void Mpm_CutSetDataInt( Mpm_Cut_t * pCut, unsigned Data ) { pCut->hNext = Data; }
int Mpm_ManNodeIfToGia_rec( Gia_Man_t * pNew, Mpm_Man_t * pMan, Mig_Obj_t * pObj, Vec_Ptr_t * vVisited, int fHash )
{
Mig_Obj_t * pTemp;
Mpm_Cut_t * pCut;
int iFunc, iFunc0, iFunc1;
// get the best cut
pCut = Mpm_ObjCutBestP( pMan, pObj );
// if the cut is visited, return the result
if ( Mpm_CutDataInt(pCut) )
return Mpm_CutDataInt(pCut);
// mark the node as visited
Vec_PtrPush( vVisited, pCut );
// insert the worst case
Mpm_CutSetDataInt( pCut, ~0 );
// skip in case of primary input
if ( Mig_ObjIsCi(pObj) )
return Mpm_CutDataInt(pCut);
// compute the functions of the children
for ( pTemp = pObj; pTemp; pTemp = Mig_ObjSibl(pTemp) )
{
iFunc0 = Mpm_ManNodeIfToGia_rec( pNew, pMan, Mig_ObjFanin0(pTemp), vVisited, fHash );
if ( iFunc0 == ~0 )
continue;
iFunc1 = Mpm_ManNodeIfToGia_rec( pNew, pMan, Mig_ObjFanin1(pTemp), vVisited, fHash );
if ( iFunc1 == ~0 )
continue;
// both branches are solved
if ( fHash )
iFunc = Gia_ManHashAnd( pNew, Abc_LitNotCond(iFunc0, Mig_ObjFaninC0(pTemp)), Abc_LitNotCond(iFunc1, Mig_ObjFaninC1(pTemp)) );
else
iFunc = Gia_ManAppendAnd( pNew, Abc_LitNotCond(iFunc0, Mig_ObjFaninC0(pTemp)), Abc_LitNotCond(iFunc1, Mig_ObjFaninC1(pTemp)) );
if ( Mig_ObjPhase(pTemp) != Mig_ObjPhase(pObj) )
iFunc = Abc_LitNot(iFunc);
Mpm_CutSetDataInt( pCut, iFunc );
break;
}
return Mpm_CutDataInt(pCut);
}
int Mpm_ManNodeIfToGia( Gia_Man_t * pNew, Mpm_Man_t * pMan, Mig_Obj_t * pObj, Vec_Int_t * vLeaves, int fHash )
{
Mpm_Cut_t * pCut;
Mig_Obj_t * pFanin;
int i, iRes;
// get the best cut
pCut = Mpm_ObjCutBestP( pMan, pObj );
assert( pCut->nLeaves > 1 );
// set the leaf variables
Mpm_CutForEachLeaf( pMan->pMig, pCut, pFanin, i )
Mpm_CutSetDataInt( Mpm_ObjCutBestP(pMan, pFanin), Vec_IntEntry(vLeaves, i) );
// recursively compute the function while collecting visited cuts
Vec_PtrClear( pMan->vTemp );
iRes = Mpm_ManNodeIfToGia_rec( pNew, pMan, pObj, pMan->vTemp, fHash );
if ( iRes == ~0 )
{
Abc_Print( -1, "Mpm_ManNodeIfToGia(): Computing local AIG has failed.\n" );
return ~0;
}
// clean the cuts
Mpm_CutForEachLeaf( pMan->pMig, pCut, pFanin, i )
Mpm_CutSetDataInt( Mpm_ObjCutBestP(pMan, pFanin), 0 );
Vec_PtrForEachEntry( Mpm_Cut_t *, pMan->vTemp, pCut, i )
Mpm_CutSetDataInt( pCut, 0 );
return iRes;
}
void * Mpm_ManFromIfLogic( Mpm_Man_t * pMan )
{
Gia_Man_t * pNew;
Mpm_Cut_t * pCutBest;
Mig_Obj_t * pObj, * pFanin;
Vec_Int_t * vMapping, * vMapping2, * vPacking = NULL;
Vec_Int_t * vLeaves, * vLeaves2, * vCover;
int i, k, Entry, iLitNew;
// assert( !pMan->pPars->fDeriveLuts || pMan->pPars->fTruth );
// start mapping and packing
vMapping = Vec_IntStart( Mig_ManObjNum(pMan->pMig) );
vMapping2 = Vec_IntStart( 1 );
if ( 0 ) // pMan->pPars->fDeriveLuts && pMan->pPars->pLutStruct )
{
vPacking = Vec_IntAlloc( 1000 );
Vec_IntPush( vPacking, 0 );
}
// create new manager
pNew = Gia_ManStart( Mig_ManObjNum(pMan->pMig) );
// iterate through nodes used in the mapping
vCover = Vec_IntAlloc( 1 << 16 );
vLeaves = Vec_IntAlloc( 16 );
vLeaves2 = Vec_IntAlloc( 16 );
Mig_ManCleanCopy( pMan->pMig );
Mig_ManForEachObj( pMan->pMig, pObj )
{
if ( !Mpm_ObjMapRef(pMan, pObj) && !Mig_ObjIsTerm(pObj) )
continue;
if ( Mig_ObjIsNode(pObj) )
{
// collect leaves of the best cut
Vec_IntClear( vLeaves );
pCutBest = Mpm_ObjCutBestP( pMan, pObj );
Mpm_CutForEachLeaf( pMan->pMig, pCutBest, pFanin, k )
Vec_IntPush( vLeaves, Mig_ObjCopy(pFanin) );
// perform one of the two types of mapping: with and without structures
iLitNew = Mpm_ManNodeIfToGia( pNew, pMan, pObj, vLeaves, 0 );
// write mapping
Vec_IntSetEntry( vMapping, Abc_Lit2Var(iLitNew), Vec_IntSize(vMapping2) );
Vec_IntPush( vMapping2, Vec_IntSize(vLeaves) );
Vec_IntForEachEntry( vLeaves, Entry, k )
assert( Abc_Lit2Var(Entry) < Abc_Lit2Var(iLitNew) );
Vec_IntForEachEntry( vLeaves, Entry, k )
Vec_IntPush( vMapping2, Abc_Lit2Var(Entry) );
Vec_IntPush( vMapping2, Abc_Lit2Var(iLitNew) );
}
else if ( Mig_ObjIsCi(pObj) )
iLitNew = Gia_ManAppendCi(pNew);
else if ( Mig_ObjIsCo(pObj) )
iLitNew = Gia_ManAppendCo( pNew, Abc_LitNotCond(Mig_ObjCopy(Mig_ObjFanin0(pObj)), Mig_ObjFaninC0(pObj)) );
else if ( Mig_ObjIsConst0(pObj) )
{
iLitNew = 0;
// create const LUT
Vec_IntWriteEntry( vMapping, 0, Vec_IntSize(vMapping2) );
Vec_IntPush( vMapping2, 0 );
Vec_IntPush( vMapping2, 0 );
}
else assert( 0 );
Mig_ObjSetCopy( pObj, iLitNew );
}
Vec_IntFree( vCover );
Vec_IntFree( vLeaves );
Vec_IntFree( vLeaves2 );
// printf( "Mapping array size: IfMan = %d. Gia = %d. Increase = %.2f\n",
// Mig_ManObjNum(pMan), Gia_ManObjNum(pNew), 1.0 * Gia_ManObjNum(pNew) / Mig_ManObjNum(pMan) );
// finish mapping
if ( Vec_IntSize(vMapping) > Gia_ManObjNum(pNew) )
Vec_IntShrink( vMapping, Gia_ManObjNum(pNew) );
else
Vec_IntFillExtra( vMapping, Gia_ManObjNum(pNew), 0 );
assert( Vec_IntSize(vMapping) == Gia_ManObjNum(pNew) );
Vec_IntForEachEntry( vMapping, Entry, i )
if ( Entry > 0 )
Vec_IntAddToEntry( vMapping, i, Gia_ManObjNum(pNew) );
Vec_IntAppend( vMapping, vMapping2 );
Vec_IntFree( vMapping2 );
// attach mapping and packing
assert( pNew->vMapping == NULL );
assert( pNew->vPacking == NULL );
pNew->vMapping = vMapping;
pNew->vPacking = vPacking;
// verify that COs have mapping
{
Gia_Obj_t * pObj;
Gia_ManForEachCo( pNew, pObj, i )
assert( !Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) || Gia_ObjIsLut(pNew, Gia_ObjFaninId0p(pNew, pObj)) );
}
return pNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
/*
void Mig_ManTest2( Gia_Man_t * pGia )
{
extern int Gia_ManSuppSizeTest( Gia_Man_t * p );
Mig_Man_t * p;
Gia_ManSuppSizeTest( pGia );
p = Mig_ManCreate( pGia );
Mig_ManSuppSizeTest( p );
Mig_ManStop( p );
}
*/
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
/**CFile****************************************************************
FileName [mpmCore.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Configurable technology mapper.]
Synopsis [Core procedures.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 1, 2013.]
Revision [$Id: mpmCore.c,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
***********************************************************************/
#include "aig/gia/gia.h"
#include "mpmInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Mpm_ManSetParsDefault( Mpm_Par_t * p )
{
memset( p, 0, sizeof(Mpm_Par_t) );
p->DelayTarget = -1; // delay target
p->fVerbose = 0; // verbose output
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t * Mpm_ManPerformTest( Mig_Man_t * pMig )
{
Gia_Man_t * pNew;
Mpm_LibLut_t * pLib;
Mpm_Man_t * p;
pLib = Mpm_LibLutSetSimple( 6 );
p = Mpm_ManStart( pMig, pLib, 8 );
Mpm_ManPrintStatsInit( p );
Mpm_ManPrepare( p );
Mpm_ManPerform( p );
Mpm_ManPrintStats( p );
pNew = (Gia_Man_t *)Mpm_ManFromIfLogic( p );
Mpm_ManStop( p );
Mpm_LibLutFree( pLib );
return pNew;
}
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 );
pNew = Mpm_ManPerformTest( p );
Mig_ManStop( p );
return pNew;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
/**CFile****************************************************************
FileName [mpmDsd.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Configurable technology mapper.]
Synopsis [DSD manipulation.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 1, 2013.]
Revision [$Id: mpmDsd.c,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
***********************************************************************/
#include "mpmInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
/**CFile****************************************************************
FileName [mpmLib.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Configurable technology mapper.]
Synopsis [DSD manipulation for 6-input functions.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 1, 2013.]
Revision [$Id: mpmLib.c,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
***********************************************************************/
#include "mpmInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Mpm_LibLut_t * Mpm_LibLutSetSimple( int nLutSize )
{
Mpm_LibLut_t * pLib;
int i, k;
assert( nLutSize < MPM_VAR_MAX );
pLib = ABC_CALLOC( Mpm_LibLut_t, 1 );
pLib->LutMax = nLutSize;
for ( i = 1; i <= pLib->LutMax; i++ )
{
pLib->pLutAreas[i] = MPM_UNIT_AREA;
for ( k = 0; k < i; k++ )
pLib->pLutDelays[i][k] = MPM_UNIT_TIME;
}
return pLib;
}
void Mpm_LibLutFree( Mpm_LibLut_t * pLib )
{
if ( pLib == NULL )
return;
ABC_FREE( pLib->pName );
ABC_FREE( pLib );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
/**CFile****************************************************************
FileName [mpmMig.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Configurable technology mapper.]
Synopsis [Subject graph data structure.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 1, 2013.]
Revision [$Id: mpmMig.c,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
***********************************************************************/
#include "mpmInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Mig_Man_t * Mig_ManStart()
{
Mig_Man_t * p;
assert( sizeof(Mig_Obj_t) >= 16 );
assert( (1 << MIG_BASE) == MIG_MASK + 1 );
p = ABC_CALLOC( Mig_Man_t, 1 );
Vec_IntGrow( &p->vCis, 1024 );
Vec_IntGrow( &p->vCos, 1024 );
Mig_ManAppendObj( p ); // const0
return p;
}
void Mig_ManStop( Mig_Man_t * p )
{
if ( 0 )
printf( "Subject graph uses %d pages of %d objects with %d entries. Total memory = %.2f MB.\n",
Vec_PtrSize(&p->vPages), MIG_MASK + 1, p->nObjs,
1.0 * Vec_PtrSize(&p->vPages) * (MIG_MASK + 1) * 16 / (1 << 20) );
// attributes
ABC_FREE( p->vTravIds.pArray );
ABC_FREE( p->vCopies.pArray );
ABC_FREE( p->vLevels.pArray );
ABC_FREE( p->vRefs.pArray );
ABC_FREE( p->vSibls.pArray );
// pages
Vec_PtrForEachEntry( Mig_Obj_t *, &p->vPages, p->pPage, p->iPage )
--p->pPage, ABC_FREE( p->pPage );
// objects
ABC_FREE( p->vPages.pArray );
ABC_FREE( p->vCis.pArray );
ABC_FREE( p->vCos.pArray );
ABC_FREE( p->pName );
ABC_FREE( p );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Mig_ManSetRefs( Mig_Man_t * p, int fSkipCos )
{
Mig_Obj_t * pObj;
int i, iFanin;
// increment references
Vec_IntFill( &p->vRefs, Mig_ManObjNum(p), 0 );
Mig_ManForEachNode( p, pObj )
Mig_ObjForEachFaninId( pObj, iFanin, i )
Vec_IntAddToEntry( &p->vRefs, iFanin, 1 );
if ( !fSkipCos )
{
// and CO references
Mig_ManForEachCo( p, pObj, i )
Vec_IntAddToEntry( &p->vRefs, Mig_ObjFaninId(pObj, 0), 1 );
// check that internal nodes have fanins
Mig_ManForEachNode( p, pObj )
assert( Vec_IntEntry(&p->vRefs, Mig_ObjId(pObj)) > 0 );
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Mig_ManSuppSize_rec( Mig_Obj_t * pObj )
{
if ( pObj == NULL )
return 0;
if ( Mig_ObjIsTravIdCurrent(pObj) )
return 0;
Mig_ObjSetTravIdCurrent(pObj);
if ( Mig_ObjIsCi(pObj) )
return 1;
assert( Mig_ObjIsNode(pObj) );
return Mig_ManSuppSize_rec( Mig_ObjFanin0(pObj) ) +
Mig_ManSuppSize_rec( Mig_ObjFanin1(pObj) ) +
Mig_ManSuppSize_rec( Mig_ObjFanin2(pObj) );
}
int Mig_ManSuppSize2_rec( Mig_Man_t * p, int iObj )
{
Mig_Obj_t * pObj;
if ( iObj == MIG_NONE )
return 0;
if ( Mig_ObjIsTravIdCurrentId(p, iObj) )
return 0;
Mig_ObjSetTravIdCurrentId(p, iObj);
pObj = Mig_ManObj( p, iObj );
if ( Mig_ObjIsCi(pObj) )
return 1;
assert( Mig_ObjIsNode(pObj) );
return Mig_ManSuppSize2_rec( p, Mig_ObjFaninId0(pObj) ) +
Mig_ManSuppSize2_rec( p, Mig_ObjFaninId1(pObj) ) +
Mig_ManSuppSize2_rec( p, Mig_ObjFaninId2(pObj) );
}
int Mig_ManSuppSizeOne( Mig_Obj_t * pObj )
{
Mig_ObjIncrementTravId( pObj );
// return Mig_ManSuppSize_rec( pObj );
return Mig_ManSuppSize2_rec( Mig_ObjMan(pObj), Mig_ObjId(pObj) );
}
int Mig_ManSuppSizeTest( Mig_Man_t * p )
{
Mig_Obj_t * pObj;
int Counter = 0;
abctime clk = Abc_Clock();
Mig_ManForEachObj( p, pObj )
if ( Mig_ObjIsNode(pObj) )
Counter += (Mig_ManSuppSizeOne(pObj) <= 16);
printf( "Nodes with small support %d (out of %d)\n", Counter, Mig_ManNodeNum(p) );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
return Counter;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
/**CFile**************************************************************** /**CFile****************************************************************
FileName [ifDsd.c] FileName [mpmPre.c]
SystemName [ABC: Logic synthesis and verification system.] SystemName [ABC: Logic synthesis and verification system.]
PackageName [FPGA mapping based on priority cuts.] PackageName [Configurable technology mapper.]
Synopsis [Sequential mapping.] Synopsis [DSD-related precomputations.]
Author [Alan Mishchenko] Author [Alan Mishchenko]
Affiliation [UC Berkeley] Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - November 21, 2006.] Date [Ver. 1.0. Started - June 1, 2013.]
Revision [$Id: ifDsd.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $] Revision [$Id: mpmPre.c,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
***********************************************************************/ ***********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "if.h" #include "misc/vec/vec.h"
#include "misc/vec/vecHsh.h" #include "misc/vec/vecHsh.h"
#include "misc/extra/extra.h" #include "misc/extra/extra.h"
......
/**CFile****************************************************************
FileName [mpmTruth.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Configurable technology mapper.]
Synopsis [Truth table manipulation.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 1, 2013.]
Revision [$Id: mpmTruth.c,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
***********************************************************************/
#include "mpmInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
/**CFile****************************************************************
FileName [mpmUtil.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Configurable technology mapper.]
Synopsis [Various utilities.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 1, 2013.]
Revision [$Id: mpmUtil.c,v 1.00 2013/06/01 00:00:00 alanmi Exp $]
***********************************************************************/
#include "mpmInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_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