From f8f37d261bfb513a804078bba396f7b040024ff7 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 15 Jul 2013 15:22:05 -0700 Subject: New technology mapper. --- src/base/abci/abc.c | 16 ++++++++++++++-- src/base/abci/abcMfs.c | 4 +++- src/map/mpm/mpm.h | 2 +- src/map/mpm/mpmCore.c | 2 ++ src/map/mpm/mpmDsd.c | 14 ++++---------- src/map/mpm/mpmInt.h | 12 ++++++------ src/map/mpm/mpmLib.c | 2 +- src/map/mpm/mpmTruth.c | 2 +- 8 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index d942e41b..73e96054 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.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, "KDtmzrcuvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "KCDtmzrcuvwh" ) ) != EOF ) { switch ( c ) { @@ -29542,6 +29542,17 @@ int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv ) assert( pPars->pLib == NULL ); pPars->pLib = Mpm_LibLutSetSimple( nLutSize ); break; + case 'C': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" ); + goto usage; + } + pPars->nNumCuts = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nNumCuts < 0 ) + goto usage; + break; case 'D': if ( globalUtilOptind >= argc ) { @@ -29605,9 +29616,10 @@ usage: sprintf(Buffer, "best possible" ); else sprintf(Buffer, "%d", pPars->DelayTarget ); - Abc_Print( -2, "usage: &if2 [-KD num] [-tmzrcuvwh]\n" ); + Abc_Print( -2, "usage: &if2 [-KCD num] [-tmzrcuvwh]\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-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nNumCuts ); 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" ); diff --git a/src/base/abci/abcMfs.c b/src/base/abci/abcMfs.c index dfd950dc..aa2a702e 100644 --- a/src/base/abci/abcMfs.c +++ b/src/base/abci/abcMfs.c @@ -232,7 +232,9 @@ int Abc_NtkPerformMfs( Abc_Ntk_t * pNtk, Sfm_Par_t * pPars ) nNodes = Sfm_NtkPerform( p, pPars ); // call the fast extract procedure if ( nNodes == 0 ) - Abc_Print( 1, "The network is not changed by \"mfs\".\n" ); + { +// Abc_Print( 1, "The network is not changed by \"mfs\".\n" ); + } else { Abc_NtkInsertMfs( pNtk, p ); diff --git a/src/map/mpm/mpm.h b/src/map/mpm/mpm.h index 70f8b4c8..9a5f3dbb 100644 --- a/src/map/mpm/mpm.h +++ b/src/map/mpm/mpm.h @@ -37,7 +37,7 @@ ABC_NAMESPACE_HEADER_START /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// -#define MPM_VAR_MAX 32 +#define MPM_VAR_MAX 12 //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// diff --git a/src/map/mpm/mpmCore.c b/src/map/mpm/mpmCore.c index 99badbe2..7e7ab615 100644 --- a/src/map/mpm/mpmCore.c +++ b/src/map/mpm/mpmCore.c @@ -90,6 +90,8 @@ Gia_Man_t * Mpm_ManMappingTest( Gia_Man_t * pGia, Mpm_Par_t * pPars ) { Mig_Man_t * p; Gia_Man_t * pNew; + assert( pPars->pLib->LutMax <= MPM_VAR_MAX ); + assert( pPars->nNumCuts <= MPM_CUT_MAX ); if ( pPars->fUseGates ) { pGia = Gia_ManDupMuxes( pGia ); diff --git a/src/map/mpm/mpmDsd.c b/src/map/mpm/mpmDsd.c index e26b5e18..2cb021ce 100644 --- a/src/map/mpm/mpmDsd.c +++ b/src/map/mpm/mpmDsd.c @@ -737,7 +737,7 @@ void Mpm_ManPrecomputePerms( Mpm_Man_t * p ) // 0(1:1) 1(2:1) 2(4:2) 3(10:6) 4(33:23) 5(131:98) 6(595:464) int nClasses[7] = { 1, 2, 4, 10, 33, 131, 595 }; int nPerms = Extra_Factorial( nVars ); - int nSwaps = (1 << nVars); +// int nSwaps = (1 << nVars); int * pComp, * pPerm; int i, k, x, One, OneCopy, Num; Vec_Int_t * vVars; @@ -886,7 +886,6 @@ int Mpm_CutComputeDsd6( Mpm_Man_t * p, Mpm_Cut_t * pCut, Mpm_Cut_t * pCut0, Mpm_ int fVerbose = 0; int i, Config, iClass, Entry, fCompl = 0; int pLeavesNew[6] = { -1, -1, -1, -1, -1, -1 }; - char * pPerm6; word t = 0; if ( pCutC == NULL ) { @@ -894,7 +893,6 @@ int Mpm_CutComputeDsd6( Mpm_Man_t * p, Mpm_Cut_t * pCut, Mpm_Cut_t * pCut0, Mpm_ int iClass0 = Abc_Lit2Var(pCut0->iFunc); int iClass1 = Abc_Lit2Var(pCut1->iFunc); word Truth0 = p->pDsd6[iClass0].uTruth; - word Truth1 = p->pDsd6[iClass1].uTruth; int Perm1 = Vec_IntEntry( p->vMap2Perm, p->uPermMask[1] ); word Truth1p = Vec_WrdEntry( p->vPerm6, iClass1 * 720 + Perm1 ); if ( p->uComplMask[1] ) @@ -915,7 +913,6 @@ if ( fVerbose ) { Mpm_ManPrintPerm( p->uPermMask[1] ); printf( "\n" ); Kit_DsdPrintFromTruth( (unsigned *)&Truth0, 6 ); printf( "\n" ); -Kit_DsdPrintFromTruth( (unsigned *)&Truth1, 6 ); printf( "\n" ); Kit_DsdPrintFromTruth( (unsigned *)&Truth1p, 6 ); printf( "\n" ); Kit_DsdPrintFromTruth( (unsigned *)&t, 6 ); printf( "\n" ); } @@ -927,8 +924,6 @@ Kit_DsdPrintFromTruth( (unsigned *)&t, 6 ); printf( "\n" ); int iClass1 = Abc_Lit2Var(pCut1->iFunc); int iClassC = Abc_Lit2Var(pCutC->iFunc); word Truth0 = p->pDsd6[iClass0].uTruth; - word Truth1 = p->pDsd6[iClass1].uTruth; - word TruthC = p->pDsd6[iClassC].uTruth; int Perm1 = Vec_IntEntry( p->vMap2Perm, p->uPermMask[1] ); int PermC = Vec_IntEntry( p->vMap2Perm, p->uPermMask[2] ); word Truth1p = Vec_WrdEntry( p->vPerm6, iClass1 * 720 + Perm1 ); @@ -968,7 +963,6 @@ Kit_DsdPrintFromTruth( (unsigned *)&t, 6 ); printf( "\n" ); pCut->iFunc = Abc_Var2Lit( iClass, fCompl ); Config &= 0xFFFF; assert( (Config >> 6) < 720 ); - pPerm6 = p->Perm6[Config >> 6]; if ( fVerbose ) { @@ -978,10 +972,10 @@ Mpm_CutPrint( pCut ); } for ( i = 0; i < (int)pCut->nLeaves; i++ ) - pLeavesNew[pPerm6[i]] = Abc_LitNotCond( pCut->pLeaves[i], (Config >> i) & 1 ); + pLeavesNew[(int)p->Perm6[Config >> 6]] = Abc_LitNotCond( pCut->pLeaves[i], (Config >> i) & 1 ); pCut->nLeaves = p->pDsd6[iClass].nVars; - for ( i = 0; i < (int)pCut->nLeaves; i++ ) - assert( pLeavesNew[i] != -1 ); +// for ( i = 0; i < (int)pCut->nLeaves; i++ ) +// assert( pLeavesNew[i] != -1 ); for ( i = 0; i < (int)pCut->nLeaves; i++ ) pCut->pLeaves[i] = pLeavesNew[i]; p->nCountDsd[iClass]++; diff --git a/src/map/mpm/mpmInt.h b/src/map/mpm/mpmInt.h index 32854b72..9ee4603a 100644 --- a/src/map/mpm/mpmInt.h +++ b/src/map/mpm/mpmInt.h @@ -46,7 +46,7 @@ ABC_NAMESPACE_HEADER_START /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// -#define MPM_CUT_MAX 64 +#define MPM_CUT_MAX 32 #define MPM_UNIT_TIME 1 #define MPM_UNIT_AREA 20 @@ -77,7 +77,7 @@ struct Mpm_Uni_t_ word uSign; // cut signature int Cost; // user cost Mpm_Cut_t pCut; // new cut - int Data[MPM_VAR_MAX]; // padding + int Data[MPM_VAR_MAX-1]; // padding }; typedef struct Mpm_Dsd_t_ Mpm_Dsd_t; @@ -127,10 +127,10 @@ struct Mpm_Man_t_ Vec_Mem_t * vTtMem; // truth table memory and hash table int funcCst0; // constant 0 int funcVar0; // variable 0 - word Truth0[1024]; - word Truth1[1024]; - word TruthC[1024]; - word Truth[1024]; + word Truth0[(1 << ((MPM_VAR_MAX)-6))]; + word Truth1[(1 << ((MPM_VAR_MAX)-6))]; + word TruthC[(1 << ((MPM_VAR_MAX)-6))]; + word Truth[(1 << ((MPM_VAR_MAX)-6))]; // DSD Mpm_Dsd_t * pDsd6; // NPN class information Hsh_IntMan_t * pHash; // maps DSD functions into NPN classes diff --git a/src/map/mpm/mpmLib.c b/src/map/mpm/mpmLib.c index 14330323..e49eec07 100644 --- a/src/map/mpm/mpmLib.c +++ b/src/map/mpm/mpmLib.c @@ -46,7 +46,7 @@ Mpm_LibLut_t * Mpm_LibLutSetSimple( int nLutSize ) { Mpm_LibLut_t * pLib; int i, k; - assert( nLutSize < MPM_VAR_MAX ); + assert( nLutSize <= MPM_VAR_MAX ); pLib = ABC_CALLOC( Mpm_LibLut_t, 1 ); pLib->LutMax = nLutSize; for ( i = 1; i <= pLib->LutMax; i++ ) diff --git a/src/map/mpm/mpmTruth.c b/src/map/mpm/mpmTruth.c index 0d917f7e..79f24cca 100644 --- a/src/map/mpm/mpmTruth.c +++ b/src/map/mpm/mpmTruth.c @@ -138,8 +138,8 @@ static inline int Mpm_CutTruthMinimize7( Mpm_Man_t * p, Mpm_Cut_t * pCut ) } } assert( k == nSuppSize ); + assert( nSuppSize == Abc_TtSupportSize(p->Truth, Mpm_CutLeafNum(pCut)) ); pCut->nLeaves = nSuppSize; - assert( nSuppSize == Abc_TtSupportSize(p->Truth, 6) ); // save the result pCut->iFunc = Abc_Var2Lit( Vec_MemHashInsert(p->vTtMem, p->Truth), Abc_LitIsCompl(pCut->iFunc) ); return 1; -- cgit v1.2.3