summaryrefslogtreecommitdiffstats
path: root/src/opt
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2013-09-27 13:30:36 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2013-09-27 13:30:36 -0700
commit940cf7f98b6de040cb984b1d9ee356a232647648 (patch)
treeb367cf1ce286b9dfa8b5dd3a4f22f54b9f1e7d58 /src/opt
parentdebbf4d807f96211c0e900d32eceaec98ed81c5b (diff)
downloadabc-940cf7f98b6de040cb984b1d9ee356a232647648.tar.gz
abc-940cf7f98b6de040cb984b1d9ee356a232647648.tar.bz2
abc-940cf7f98b6de040cb984b1d9ee356a232647648.zip
Generation of plain AIG after mapping.
Diffstat (limited to 'src/opt')
-rw-r--r--src/opt/dau/dau.h3
-rw-r--r--src/opt/dau/dauDsd.c2
-rw-r--r--src/opt/dau/dauGia.c225
-rw-r--r--src/opt/dau/module.make1
4 files changed, 230 insertions, 1 deletions
diff --git a/src/opt/dau/dau.h b/src/opt/dau/dau.h
index 0f332b26..0ee50007 100644
--- a/src/opt/dau/dau.h
+++ b/src/opt/dau/dau.h
@@ -87,6 +87,9 @@ extern int Dau_DsdCountAnds( char * pDsd );
extern void Dau_DsdTruthCompose_rec( word * pFunc, word pFanins[DAU_MAX_VAR][DAU_MAX_WORD], word * pRes, int nVars, int nWordsR );
extern int Dau_DsdCheck1Step( word * pTruth, int nVarsInit );
+/*=== dauGia.c ==========================================================*/
+extern int Dsm_ManDeriveGia( void * p, word uTruth, Vec_Int_t * vLeaves, Vec_Int_t * vCover );
+
/*=== dauMerge.c ==========================================================*/
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 );
diff --git a/src/opt/dau/dauDsd.c b/src/opt/dau/dauDsd.c
index 2aeeb958..05cfc485 100644
--- a/src/opt/dau/dauDsd.c
+++ b/src/opt/dau/dauDsd.c
@@ -1021,7 +1021,7 @@ static inline int Dau_DsdWritePrime( Dau_Dsd_t * p, word * pTruth, int * pVars,
int nNonDecSize;
// compose the result
Dau_DsdWriteString( p, "<" );
- Dau_DsdWriteVar( p, pVars[vBest], 0 );
+ Dau_DsdWriteVar( p, vBest, 0 );
// split decomposition
Abc_TtCofactor1p( pCofTemp, pTruth, nWords, vBest );
nNonDecSize = Dau_DsdDecompose( pCofTemp, nVars, 0, p->fWriteTruth, pRes );
diff --git a/src/opt/dau/dauGia.c b/src/opt/dau/dauGia.c
new file mode 100644
index 00000000..4ced55e6
--- /dev/null
+++ b/src/opt/dau/dauGia.c
@@ -0,0 +1,225 @@
+/**CFile****************************************************************
+
+ FileName [dauGia.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [DAG-aware unmapping.]
+
+ Synopsis [Coverting DSD into GIA.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: dauGia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "dauInt.h"
+#include "aig/gia/gia.h"
+#include "misc/util/utilTruth.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Derives GIA for the truth table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dau_DsdToGiaCompose_rec( Gia_Man_t * pGia, word Func, int * pFanins, int nVars )
+{
+ int t0, t1;
+ if ( Func == 0 )
+ return 0;
+ if ( Func == ~(word)0 )
+ return 1;
+ assert( nVars > 0 );
+ if ( --nVars == 0 )
+ {
+ assert( Func == s_Truths6[0] || Func == s_Truths6Neg[0] );
+ return Abc_LitNotCond( pFanins[0], (int)(Func == s_Truths6Neg[0]) );
+ }
+ if ( !Abc_Tt6HasVar(Func, nVars) )
+ return Dau_DsdToGiaCompose_rec( pGia, Func, pFanins, nVars );
+ t0 = Dau_DsdToGiaCompose_rec( pGia, Abc_Tt6Cofactor0(Func, nVars), pFanins, nVars );
+ t1 = Dau_DsdToGiaCompose_rec( pGia, Abc_Tt6Cofactor1(Func, nVars), pFanins, nVars );
+ return Gia_ManHashMux( pGia, pFanins[nVars], t1, t0 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives GIA for the DSD formula.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dau_DsdToGia_rec( Gia_Man_t * pGia, char * pStr, char ** p, int * pMatches, int * pLits, Vec_Int_t * vCover )
+{
+ int fCompl = 0;
+ if ( **p == '!' )
+ (*p)++, fCompl = 1;
+ if ( **p >= 'a' && **p <= 'f' ) // var
+ {
+ assert( **p - 'a' >= 0 && **p - 'a' < 6 );
+ return Abc_LitNotCond( pLits[**p - 'a'], fCompl );
+ }
+ if ( **p == '(' ) // and/or
+ {
+ char * q = pStr + pMatches[ *p - pStr ];
+ int Res = 1, Lit;
+ assert( **p == '(' && *q == ')' );
+ for ( (*p)++; *p < q; (*p)++ )
+ {
+ Lit = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover );
+ Res = Gia_ManHashAnd( pGia, Res, Lit );
+ }
+ assert( *p == q );
+ return Abc_LitNotCond( Res, fCompl );
+ }
+ if ( **p == '[' ) // xor
+ {
+ char * q = pStr + pMatches[ *p - pStr ];
+ int Res = 0, Lit;
+ assert( **p == '[' && *q == ']' );
+ for ( (*p)++; *p < q; (*p)++ )
+ {
+ Lit = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover );
+ Res = Gia_ManHashXor( pGia, Res, Lit );
+ }
+ assert( *p == q );
+ return Abc_LitNotCond( Res, fCompl );
+ }
+ if ( **p == '<' ) // mux
+ {
+ int nVars = 0;
+ int Temp[3], * pTemp = Temp, Res;
+ int Fanins[6], * pLits2;
+ char * pOld = *p;
+ char * q = pStr + pMatches[ *p - pStr ];
+ // read fanins
+ if ( *(q+1) == '{' )
+ {
+ char * q2;
+ *p = q+1;
+ q2 = pStr + pMatches[ *p - pStr ];
+ assert( **p == '{' && *q2 == '}' );
+ for ( nVars = 0, (*p)++; *p < q2; (*p)++, nVars++ )
+ Fanins[nVars] = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover );
+ assert( *p == q2 );
+ pLits2 = Fanins;
+ }
+ else
+ pLits2 = pLits;
+ // read MUX
+ *p = pOld;
+ q = pStr + pMatches[ *p - pStr ];
+ assert( **p == '<' && *q == '>' );
+ // verify internal variables
+ if ( nVars )
+ for ( ; pOld < q; pOld++ )
+ if ( *pOld >= 'a' && *pOld <= 'z' )
+ assert( *pOld - 'a' < nVars );
+ // derive MUX components
+ for ( (*p)++; *p < q; (*p)++ )
+ *pTemp++ = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits2, vCover );
+ assert( pTemp == Temp + 3 );
+ assert( *p == q );
+ if ( *(q+1) == '{' ) // and/or
+ {
+ char * q = pStr + pMatches[ ++(*p) - pStr ];
+ assert( **p == '{' && *q == '}' );
+ *p = q;
+ }
+ Res = Gia_ManHashMux( pGia, Temp[0], Temp[1], Temp[2] );
+ return Abc_LitNotCond( Res, fCompl );
+ }
+ if ( (**p >= 'A' && **p <= 'F') || (**p >= '0' && **p <= '9') )
+ {
+ word Func;
+ int Fanins[6], Res;
+ Vec_Int_t vLeaves;
+ char * q;
+ int i, nVars = Abc_TtReadHex( &Func, *p );
+ *p += Abc_TtHexDigitNum( nVars );
+ q = pStr + pMatches[ *p - pStr ];
+ assert( **p == '{' && *q == '}' );
+ for ( i = 0, (*p)++; *p < q; (*p)++, i++ )
+ Fanins[i] = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover );
+ assert( i == nVars );
+ assert( *p == q );
+// Res = Dau_DsdToGiaCompose_rec( pGia, Func, Fanins, nVars );
+ vLeaves.nCap = nVars;
+ vLeaves.nSize = nVars;
+ vLeaves.pArray = Fanins;
+ Res = Kit_TruthToGia( pGia, (unsigned *)&Func, nVars, vCover, &vLeaves, 1 );
+ return Abc_LitNotCond( Res, fCompl );
+ }
+ assert( 0 );
+ return 0;
+}
+int Dau_DsdToGia( Gia_Man_t * pGia, char * p, int * pLits, Vec_Int_t * vCover )
+{
+ int Res;
+ if ( *p == '0' && *(p+1) == 0 )
+ Res = 0;
+ else if ( *p == '1' && *(p+1) == 0 )
+ Res = 1;
+ else
+ Res = Dau_DsdToGia_rec( pGia, p, &p, Dau_DsdComputeMatches(p), pLits, vCover );
+ assert( *++p == 0 );
+ return Res;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Convert TT to GIA via DSD.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dsm_ManDeriveGia( void * p, word uTruth, Vec_Int_t * vLeaves, Vec_Int_t * vCover )
+{
+ Gia_Man_t * pGia = (Gia_Man_t *)p;
+ char pDsd[1000];
+ int nSizeNonDec;
+// static int Counter = 0; Counter++;
+ nSizeNonDec = Dau_DsdDecompose( &uTruth, Vec_IntSize(vLeaves), 1, 1, pDsd );
+// printf( "%s\n", pDsd );
+ return Dau_DsdToGia( pGia, pDsd, Vec_IntArray(vLeaves), vCover );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/dau/module.make b/src/opt/dau/module.make
index 5a3df1d5..f339810b 100644
--- a/src/opt/dau/module.make
+++ b/src/opt/dau/module.make
@@ -3,5 +3,6 @@ SRC += src/opt/dau/dauCanon.c \
src/opt/dau/dauDivs.c \
src/opt/dau/dauDsd.c \
src/opt/dau/dauEnum.c \
+ src/opt/dau/dauGia.c \
src/opt/dau/dauMerge.c \
src/opt/dau/dauTree.c