Commit caa2227b by Alan Mishchenko

Changes to LUT mappers.

parent 15a1c4b9
...@@ -2201,7 +2201,7 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -2201,7 +2201,7 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
extern void Kit_DsdTest( unsigned * pTruth, int nVars ); extern void Kit_DsdTest( unsigned * pTruth, int nVars );
extern void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVerbose ); extern void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVerbose );
extern void Dau_DecTrySets( word * p, int nVars ); extern void Dau_DecTrySets( word * p, int nVars, int fVerbose );
// set defaults // set defaults
nCofLevel = 1; nCofLevel = 1;
...@@ -2274,7 +2274,7 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -2274,7 +2274,7 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
// Extra_PrintBinary( stdout, pTruth, 1 << Abc_ObjFaninNum(pObj) ); // Extra_PrintBinary( stdout, pTruth, 1 << Abc_ObjFaninNum(pObj) );
// Abc_Print( -1, "\n" ); // Abc_Print( -1, "\n" );
if ( fPrintDec )//&&Abc_ObjFaninNum(pObj) <= 6 ) if ( fPrintDec )//&&Abc_ObjFaninNum(pObj) <= 6 )
Dau_DecTrySets( (word *)pTruth, Abc_ObjFaninNum(pObj) ); Dau_DecTrySets( (word *)pTruth, Abc_ObjFaninNum(pObj), 1 );
if ( fProfile ) if ( fProfile )
Kit_TruthPrintProfile( pTruth, Abc_ObjFaninNum(pObj) ); Kit_TruthPrintProfile( pTruth, Abc_ObjFaninNum(pObj) );
else if ( fCofactor ) else if ( fCofactor )
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "bool/dec/dec.h" #include "bool/dec/dec.h"
#include "bool/kit/kit.h" #include "bool/kit/kit.h"
#include "opt/dau/dau.h" #include "opt/dau/dau.h"
#include "misc/util/utilTruth.h"
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
...@@ -564,11 +565,13 @@ void Abc_TruthDecPerform( Abc_TtStore_t * p, int DecType, int fVerbose ) ...@@ -564,11 +565,13 @@ void Abc_TruthDecPerform( Abc_TtStore_t * p, int DecType, int fVerbose )
{ {
for ( i = 0; i < p->nFuncs; i++ ) for ( i = 0; i < p->nFuncs; i++ )
{ {
extern void Dau_DecTrySets( word * pInit, int nVars ); extern void Dau_DecTrySets( word * pInit, int nVars, int fVerbose );
int nSuppSize = Abc_TtSupportSize( p->pFuncs[i], p->nVars );
if ( fVerbose ) if ( fVerbose )
printf( "%7d : ", i ); printf( "%7d : ", i );
Dau_DecTrySets( p->pFuncs[i], p->nVars ); Dau_DecTrySets( p->pFuncs[i], nSuppSize, fVerbose );
printf( "\n" ); if ( fVerbose )
printf( "\n" );
} }
} }
else assert( 0 ); else assert( 0 );
......
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
#include "misc/mem/mem.h" #include "misc/mem/mem.h"
#include "misc/tim/tim.h" #include "misc/tim/tim.h"
#include "misc/util/utilNam.h" #include "misc/util/utilNam.h"
#include "opt/dau/dau.h"
#include "misc/vec/vecMem.h" #include "misc/vec/vecMem.h"
#include "misc/util/utilTruth.h" #include "misc/util/utilTruth.h"
#include "opt/dau/dau.h"
ABC_NAMESPACE_HEADER_START ABC_NAMESPACE_HEADER_START
...@@ -153,8 +153,8 @@ struct If_Par_t_ ...@@ -153,8 +153,8 @@ struct If_Par_t_
float * pTimesArr; // arrival times float * pTimesArr; // arrival times
float * pTimesReq; // required times float * pTimesReq; // required times
int (* pFuncCost) (If_Man_t *, If_Cut_t *); // procedure to compute the user's cost of a cut int (* pFuncCost) (If_Man_t *, If_Cut_t *); // procedure to compute the user's cost of a cut
int (* pFuncUser) (If_Man_t *, If_Obj_t *, If_Cut_t *); // procedure called for each cut when cut computation is finished int (* pFuncUser) (If_Man_t *, If_Obj_t *, If_Cut_t *); // procedure called for each cut when cut computation is finished
int (* pFuncCell) (If_Man_t *, unsigned *, int, int, char *); // procedure called for cut functions int (* pFuncCell) (If_Man_t *, unsigned *, int, int, char *); // procedure called for cut functions
void * pReoMan; // reordering manager void * pReoMan; // reordering manager
}; };
...@@ -233,6 +233,7 @@ struct If_Man_t_ ...@@ -233,6 +233,7 @@ struct If_Man_t_
int nCuts5, nCuts5a; int nCuts5, nCuts5a;
If_DsdMan_t * pIfDsdMan; If_DsdMan_t * pIfDsdMan;
Vec_Mem_t * vTtMem; // truth table memory and hash table Vec_Mem_t * vTtMem; // truth table memory and hash table
Vec_Int_t * vDsds; // mapping of truth table into DSD
int nBestCutSmall[2]; int nBestCutSmall[2];
// timing manager // timing manager
...@@ -518,7 +519,8 @@ extern If_DsdMan_t * If_DsdManAlloc( int nLutSize ); ...@@ -518,7 +519,8 @@ extern If_DsdMan_t * If_DsdManAlloc( int nLutSize );
extern void If_DsdManDump( If_DsdMan_t * p ); extern void If_DsdManDump( If_DsdMan_t * p );
extern void If_DsdManPrint( If_DsdMan_t * p, char * pFileName, int fVerbose ); extern void If_DsdManPrint( If_DsdMan_t * p, char * pFileName, int fVerbose );
extern void If_DsdManFree( If_DsdMan_t * p ); extern void If_DsdManFree( If_DsdMan_t * p );
extern int If_DsdManCompute( If_DsdMan_t * p, word * pTruth, int nLeaves, unsigned char * pPerm ); extern int If_DsdManCompute( If_DsdMan_t * p, word * pTruth, int nLeaves, unsigned char * pPerm, char * pLutStruct );
extern int If_DsdManCheckDec( If_DsdMan_t * pIfMan, int iDsd );
/*=== ifLib.c =============================================================*/ /*=== ifLib.c =============================================================*/
extern If_LibLut_t * If_LibLutRead( char * FileName ); extern If_LibLut_t * If_LibLutRead( char * FileName );
extern If_LibLut_t * If_LibLutDup( If_LibLut_t * p ); extern If_LibLut_t * If_LibLutDup( If_LibLut_t * p );
......
...@@ -84,7 +84,12 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) ...@@ -84,7 +84,12 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
p->puTemp[3] = p->puTemp[2] + p->nTruth6Words*2; p->puTemp[3] = p->puTemp[2] + p->nTruth6Words*2;
p->puTempW = p->pPars->fTruth? ABC_ALLOC( word, p->nTruth6Words ) : NULL; p->puTempW = p->pPars->fTruth? ABC_ALLOC( word, p->nTruth6Words ) : NULL;
if ( pPars->fUseDsd ) if ( pPars->fUseDsd )
{
p->pIfDsdMan = If_DsdManAlloc( pPars->nLutSize ); p->pIfDsdMan = If_DsdManAlloc( pPars->nLutSize );
p->vDsds = Vec_IntAlloc( 1000 );
Vec_IntPush( p->vDsds, 0 );
Vec_IntPush( p->vDsds, 2 );
}
// create the constant node // create the constant node
p->pConst1 = If_ManSetupObj( p ); p->pConst1 = If_ManSetupObj( p );
p->pConst1->Type = IF_CONST1; p->pConst1->Type = IF_CONST1;
...@@ -165,9 +170,10 @@ void If_ManStop( If_Man_t * p ) ...@@ -165,9 +170,10 @@ void If_ManStop( If_Man_t * p )
Vec_WrdFreeP( &p->vAnds ); Vec_WrdFreeP( &p->vAnds );
Vec_WrdFreeP( &p->vAndGate ); Vec_WrdFreeP( &p->vAndGate );
Vec_WrdFreeP( &p->vOrGate ); Vec_WrdFreeP( &p->vOrGate );
if ( p->vObjsRev ) Vec_PtrFree( p->vObjsRev ); Vec_PtrFreeP( &p->vObjsRev );
if ( p->vLatchOrder ) Vec_PtrFree( p->vLatchOrder ); Vec_PtrFreeP( &p->vLatchOrder );
if ( p->vLags ) Vec_IntFree( p->vLags ); Vec_IntFreeP( &p->vLags );
Vec_IntFreeP( &p->vDsds );
Vec_MemHashFree( p->vTtMem ); Vec_MemHashFree( p->vTtMem );
Vec_MemFreeP( &p->vTtMem ); Vec_MemFreeP( &p->vTtMem );
Mem_FixedStop( p->pMemObj, 0 ); Mem_FixedStop( p->pMemObj, 0 );
......
...@@ -217,6 +217,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -217,6 +217,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
// abctime clk = Abc_Clock(); // abctime clk = Abc_Clock();
If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 ); If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 );
// p->timeTruth += Abc_Clock() - clk; // p->timeTruth += Abc_Clock() - clk;
// run user functions
pCut->fUseless = 0; pCut->fUseless = 0;
if ( p->pPars->pFuncCell ) if ( p->pPars->pFuncCell )
{ {
...@@ -250,9 +251,26 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -250,9 +251,26 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
p->nCuts5a++; p->nCuts5a++;
} }
} }
if ( p->pPars->fUseDsd )
{
int truthId = Abc_Lit2Var(pCut->iCutFunc);
if ( Vec_IntSize(p->vDsds) <= truthId || Vec_IntEntry(p->vDsds, truthId) == -1 )
{
pCut->iCutDsd = If_DsdManCompute( p->pIfDsdMan, If_CutTruthW(p, pCut), pCut->nLeaves, (unsigned char *)pCut->pPerm, p->pPars->pLutStruct );
while ( Vec_IntSize(p->vDsds) <= truthId )
Vec_IntPush( p->vDsds, -1 );
Vec_IntWriteEntry( p->vDsds, truthId, Abc_LitNotCond(pCut->iCutDsd, Abc_LitIsCompl(pCut->iCutFunc)) );
}
else
pCut->iCutDsd = Abc_LitNotCond( Vec_IntEntry(p->vDsds, truthId), Abc_LitIsCompl(pCut->iCutFunc) );
if ( p->pPars->pLutStruct )
{
int Value = If_DsdManCheckDec( p->pIfDsdMan, pCut->iCutDsd );
if ( Value != (int)pCut->fUseless )
printf( "Difference\n" );
}
}
} }
if ( p->pPars->fUseDsd && Abc_Lit2Var(pCut->iCutFunc) == Vec_MemEntryNum(p->vTtMem)-1 )
pCut->iCutDsd = If_DsdManCompute( p->pIfDsdMan, If_CutTruthW(p, pCut), pCut->nLeaves, (unsigned char *)pCut->pPerm );
// compute the application-specific cost and depth // compute the application-specific cost and depth
pCut->fUser = (p->pPars->pFuncCost != NULL); pCut->fUser = (p->pPars->pFuncCost != NULL);
......
...@@ -97,6 +97,11 @@ extern void * Dsm_ManDeriveGia( void * p, int fUseMuxes ); ...@@ -97,6 +97,11 @@ extern void * Dsm_ManDeriveGia( void * p, int fUseMuxes );
extern void Dau_DsdRemoveBraces( char * pDsd, int * pMatches ); extern void Dau_DsdRemoveBraces( char * pDsd, int * pMatches );
extern char * Dau_DsdMerge( char * pDsd0i, int * pPerm0, char * pDsd1i, int * pPerm1, int fCompl0, int fCompl1, int nVars ); extern char * Dau_DsdMerge( char * pDsd0i, int * pPerm0, char * pDsd1i, int * pPerm1, int fCompl0, int fCompl1, int nVars );
/*=== dauNonDsd.c ==========================================================*/
extern Vec_Int_t * Dau_DecFindSets( word * pInit, int nVars );
extern void Dau_DecPrintSets( Vec_Int_t * vSets, int nVars );
extern void Dau_DecPrintSet( unsigned set, int nVars, int fNewLine );
/*=== dauTree.c ==========================================================*/ /*=== dauTree.c ==========================================================*/
extern Dss_Man_t * Dss_ManAlloc( int nVars, int nNonDecLimit ); extern Dss_Man_t * Dss_ManAlloc( int nVars, int nNonDecLimit );
extern void Dss_ManFree( Dss_Man_t * p ); extern void Dss_ManFree( Dss_Man_t * p );
......
...@@ -459,7 +459,7 @@ void Dau_DecMoveFreeToLSB( word * p, int nVars, int * V2P, int * P2V, int maskB, ...@@ -459,7 +459,7 @@ void Dau_DecMoveFreeToLSB( word * p, int nVars, int * V2P, int * P2V, int maskB,
Abc_TtMoveVar( p, nVars, V2P, P2V, v, c++ ); Abc_TtMoveVar( p, nVars, V2P, P2V, v, c++ );
assert( c == nVars - sizeB ); assert( c == nVars - sizeB );
} }
Vec_Int_t * Dau_DecFindSets( word * p, int nVars ) Vec_Int_t * Dau_DecFindSets( word * pInit, int nVars )
{ {
Vec_Int_t * vSets = Vec_IntAlloc( 32 ); Vec_Int_t * vSets = Vec_IntAlloc( 32 );
int V2P[16], P2V[16], pVarsB[16]; int V2P[16], P2V[16], pVarsB[16];
...@@ -467,6 +467,8 @@ Vec_Int_t * Dau_DecFindSets( word * p, int nVars ) ...@@ -467,6 +467,8 @@ Vec_Int_t * Dau_DecFindSets( word * p, int nVars )
int c, v, sizeB, sizeS, maskB, maskS; int c, v, sizeB, sizeS, maskB, maskS;
int * pSched[16] = {NULL}; int * pSched[16] = {NULL};
unsigned setMixed; unsigned setMixed;
word p[1<<10];
memcpy( p, pInit, sizeof(word) * Abc_TtWordNum(nVars) );
for ( v = 0; v < nVars; v++ ) for ( v = 0; v < nVars; v++ )
assert( Abc_TtHasVar( p, nVars, v ) ); assert( Abc_TtHasVar( p, nVars, v ) );
for ( v = 2; v < nVars; v++ ) for ( v = 2; v < nVars; v++ )
...@@ -703,7 +705,7 @@ int Dau_DecVerify( word * pInit, int nVars, char * pDsdC, char * pDsdD ) ...@@ -703,7 +705,7 @@ int Dau_DecVerify( word * pInit, int nVars, char * pDsdC, char * pDsdD )
printf( "\n" ); printf( "\n" );
return 1; return 1;
} }
int Dau_DecPerform( word * p, int nVars, unsigned uSet ) int Dau_DecPerform6( word * p, int nVars, unsigned uSet )
{ {
word tComp = 0, tDec = 0, tDec0, tComp0, tComp1, FuncC, FuncD; word tComp = 0, tDec = 0, tDec0, tComp0, tComp1, FuncC, FuncD;
char pDsdC[1000], pDsdD[1000]; char pDsdC[1000], pDsdD[1000];
...@@ -760,7 +762,7 @@ int Dau_DecPerform( word * p, int nVars, unsigned uSet ) ...@@ -760,7 +762,7 @@ int Dau_DecPerform( word * p, int nVars, unsigned uSet )
return 1; return 1;
} }
int Dau_DecPerform2( word * pInit, int nVars, unsigned uSet ) int Dau_DecPerform( word * pInit, int nVars, unsigned uSet )
{ {
word p[1<<10], pDec[1<<10], pComp[1<<10]; // at most 2^10 words word p[1<<10], pDec[1<<10], pComp[1<<10]; // at most 2^10 words
char pDsdC[5000], pDsdD[5000]; // at most 2^12 hex digits char pDsdC[5000], pDsdD[5000]; // at most 2^12 hex digits
...@@ -820,15 +822,18 @@ int Dau_DecPerform2( word * pInit, int nVars, unsigned uSet ) ...@@ -820,15 +822,18 @@ int Dau_DecPerform2( word * pInit, int nVars, unsigned uSet )
Dau_DecVerify( pInit, nVars, pDsdC, pDsdD ); Dau_DecVerify( pInit, nVars, pDsdC, pDsdD );
return 1; return 1;
} }
void Dau_DecTrySets( word * pInit, int nVars ) void Dau_DecTrySets( word * pInit, int nVars, int fVerbose )
{ {
word p[1<<10];
Vec_Int_t * vSets; Vec_Int_t * vSets;
int i, Entry; int i, Entry;
assert( nVars <= 16 ); assert( nVars <= 16 );
memcpy( p, pInit, sizeof(word) * Abc_TtWordNum(nVars) ); vSets = Dau_DecFindSets( pInit, nVars );
vSets = Dau_DecFindSets( p, nVars ); if ( !fVerbose )
Dau_DsdPrintFromTruth( p, nVars ); {
Vec_IntFree( vSets );
return;
}
Dau_DsdPrintFromTruth( pInit, nVars );
printf( "This %d-variable function has %d decomposable variable sets:\n", nVars, Vec_IntSize(vSets) ); printf( "This %d-variable function has %d decomposable variable sets:\n", nVars, Vec_IntSize(vSets) );
Vec_IntForEachEntry( vSets, Entry, i ) Vec_IntForEachEntry( vSets, Entry, i )
{ {
...@@ -837,12 +842,12 @@ void Dau_DecTrySets( word * pInit, int nVars ) ...@@ -837,12 +842,12 @@ void Dau_DecTrySets( word * pInit, int nVars )
if ( nVars > 6 ) if ( nVars > 6 )
{ {
Dau_DecPrintSet( uSet, nVars, 0 ); Dau_DecPrintSet( uSet, nVars, 0 );
Dau_DecPerform2( pInit, nVars, uSet ); Dau_DecPerform( pInit, nVars, uSet );
} }
else else
{ {
Dau_DecPrintSet( uSet, nVars, 1 ); Dau_DecPrintSet( uSet, nVars, 1 );
Dau_DecPerform( pInit, nVars, uSet ); Dau_DecPerform6( pInit, nVars, uSet );
} }
} }
Vec_IntFree( vSets ); Vec_IntFree( vSets );
...@@ -860,7 +865,7 @@ void Dau_DecFindSetsTest3() ...@@ -860,7 +865,7 @@ void Dau_DecFindSetsTest3()
// char * pStr = "Abcd"; // char * pStr = "Abcd";
// char * pStr = "ab"; // char * pStr = "ab";
unsigned uSet = Dau_DecReadSet( pStr ); unsigned uSet = Dau_DecReadSet( pStr );
Dau_DecPerform( &t, nVars, uSet ); Dau_DecPerform6( &t, nVars, uSet );
} }
void Dau_DecFindSetsTest() void Dau_DecFindSetsTest()
...@@ -879,7 +884,7 @@ void Dau_DecFindSetsTest() ...@@ -879,7 +884,7 @@ void Dau_DecFindSetsTest()
// word t = ABC_CONST(0x2B0228022B022802); // 5-var non-dec0x0F7700000F770000 // word t = ABC_CONST(0x2B0228022B022802); // 5-var non-dec0x0F7700000F770000
// word t = ABC_CONST(0x0F7700000F770000); // (!<(ab)cd>e) // word t = ABC_CONST(0x0F7700000F770000); // (!<(ab)cd>e)
// word t = ABC_CONST(0x7F00000000000000); // (!(abc)def) // word t = ABC_CONST(0x7F00000000000000); // (!(abc)def)
Dau_DecTrySets( &t, nVars ); Dau_DecTrySets( &t, nVars, 1 );
} }
......
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