From 1116313d28d4e7665459bb90cca210bc86c7ffe5 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 11 Nov 2012 14:38:24 -0800 Subject: Improved DSD. --- abclib.dsp | 4 ++ src/opt/dau/dau.h | 2 +- src/opt/dau/dauDivs.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++ src/opt/dau/dauDsd.c | 16 ++++--- src/opt/dau/module.make | 1 + 5 files changed, 126 insertions(+), 8 deletions(-) create mode 100644 src/opt/dau/dauDivs.c diff --git a/abclib.dsp b/abclib.dsp index c971cb63..976ce9a9 100644 --- a/abclib.dsp +++ b/abclib.dsp @@ -1987,6 +1987,10 @@ SOURCE=.\src\opt\dau\dauCore.c # End Source File # Begin Source File +SOURCE=.\src\opt\dau\dauDivs.c +# End Source File +# Begin Source File + SOURCE=.\src\opt\dau\dauDsd.c # End Source File # Begin Source File diff --git a/src/opt/dau/dau.h b/src/opt/dau/dau.h index 51475f27..755af85c 100644 --- a/src/opt/dau/dau.h +++ b/src/opt/dau/dau.h @@ -39,7 +39,7 @@ ABC_NAMESPACE_HEADER_START -#define DAU_MAX_VAR 16 // should be 6 or more +#define DAU_MAX_VAR 12 // should be 6 or more #define DAU_MAX_STR 256 #define DAU_MAX_WORD (1<<(DAU_MAX_VAR-6)) diff --git a/src/opt/dau/dauDivs.c b/src/opt/dau/dauDivs.c new file mode 100644 index 00000000..424a11df --- /dev/null +++ b/src/opt/dau/dauDivs.c @@ -0,0 +1,111 @@ +/**CFile**************************************************************** + + FileName [dauDivs.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [DAG-aware unmapping.] + + Synopsis [Divisor computation.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: dauDivs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "dauInt.h" +#include "dau.h" +#include "misc/util/utilTruth.h" + +ABC_NAMESPACE_IMPL_START + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Int_t * Dau_DsdDivisors( word * pTruth, int nVars ) +{ + word Copy[DAU_MAX_WORD]; + int nWords = Abc_TtWordNum(nVars); + int nDigits = Abc_TtHexDigitNum(nVars); + int i, j, k, Digit, Counter[5]; + + printf( " " ); + printf( " !a *!b" ); + printf( " !a * b" ); + printf( " a *!b" ); + printf( " a * b" ); + printf( " a + b" ); + printf( "\n" ); + + for ( i = 0; i < nVars; i++ ) + for ( j = i+1; j < nVars; j++ ) + { + Abc_TtCopy( Copy, pTruth, nWords, 0 ); + Abc_TtSwapVars( Copy, nVars, 0, i ); + Abc_TtSwapVars( Copy, nVars, 1, j ); + for ( k = 0; k < 5; k++ ) + Counter[k] = 0; + for ( k = 0; k < nDigits; k++ ) + { + Digit = Abc_TtGetHex( Copy, k ); + if ( Digit == 1 || Digit == 14 ) + Counter[0]++; + else if ( Digit == 2 || Digit == 13 ) + Counter[1]++; + else if ( Digit == 4 || Digit == 11 ) + Counter[2]++; + else if ( Digit == 8 || Digit == 7 ) + Counter[3]++; + else if ( Digit == 6 || Digit == 9 ) + Counter[4]++; + } + printf( "%c %c ", 'a'+i, 'a'+j ); + for ( k = 0; k < 5; k++ ) + printf( "%7d", Counter[k] ); + printf( "\n" ); + } + return NULL; +} +void Dau_DsdTest() +{ +// char * pDsd = "!(!(abc)!(def))"; +// char * pDsd = "[(abc)(def)]"; + char * pDsd = "<d(ef)>"; + word t = Dau_Dsd6ToTruth( pDsd ); +// word t = 0xCA88CA88CA88CA88; +// word t = 0x9ef7a8d9c7193a0f; + int nVars = Abc_TtSupportSize( &t, 6 ); + return; +// word t = 0xCACACACACACACACA; + Dau_DsdDivisors( &t, nVars ); +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + +ABC_NAMESPACE_IMPL_END + diff --git a/src/opt/dau/dauDsd.c b/src/opt/dau/dauDsd.c index a3d377d0..72c0278d 100644 --- a/src/opt/dau/dauDsd.c +++ b/src/opt/dau/dauDsd.c @@ -1942,7 +1942,7 @@ void Dau_DsdTest888() i = 0; } -void Dau_DsdTest() +void Dau_DsdTest555() { int nVars = 10; int nWords = Abc_TtWordNum(nVars); @@ -1953,8 +1953,8 @@ void Dau_DsdTest() char pRes[DAU_MAX_STR]; int nSizeNonDec; int i, Counter = 0; - clock_t clk = clock(); - return; + clock_t clk = clock(), clkDec = 0, clk2; +// return; while ( fgets( pBuffer, DAU_MAX_STR, pFile ) != NULL ) { @@ -1967,14 +1967,15 @@ void Dau_DsdTest() continue; Counter++; - for ( i = 0; i < 10; i++ ) + for ( i = 0; i < 1; i++ ) { - Dau_DsdPermute( pBuffer ); - +// Dau_DsdPermute( pBuffer ); pTruth = Dau_DsdToTruth( pBuffer[0] == '*' ? pBuffer + 1 : pBuffer, nVars ); Abc_TtCopy( Tru[0], pTruth, nWords, 0 ); Abc_TtCopy( Tru[1], pTruth, nWords, 0 ); + clk2 = clock(); nSizeNonDec = Dau_DsdDecompose( Tru[1], nVars, 0, pRes ); + clkDec += clock() - clk2; Dau_DsdNormalize( pRes ); // pStr2 = Dau_DsdPerform( t ); nSizeNonDec = 0; assert( nSizeNonDec == 0 ); @@ -1990,7 +1991,8 @@ void Dau_DsdTest() } } printf( "Finished trying %d decompositions. ", Counter ); - Abc_PrintTime( 1, "Time", clock() - clk ); + Abc_PrintTime( 1, "Time", clkDec ); + Abc_PrintTime( 1, "Total", clock() - clk ); Abc_PrintTime( 1, "Time1", s_Times[0] ); Abc_PrintTime( 1, "Time2", s_Times[1] ); diff --git a/src/opt/dau/module.make b/src/opt/dau/module.make index ad32445c..eedd9a9f 100644 --- a/src/opt/dau/module.make +++ b/src/opt/dau/module.make @@ -1,6 +1,7 @@ SRC += src/opt/dau/dau.c \ src/opt/dau/dauCanon.c \ src/opt/dau/dauCore.c \ + src/opt/dau/dauDivs.c \ src/opt/dau/dauDsd.c \ src/opt/dau/dauEnum.c \ src/opt/dau/dauMerge.c -- cgit v1.2.3