@@ -34,6 +34,65 @@ ABC_NAMESPACE_IMPL_START
3434/// FUNCTION DEFINITIONS ///
3535////////////////////////////////////////////////////////////////////////
3636
37+ /**Function*************************************************************
38+
39+ Synopsis []
40+
41+ Description []
42+
43+ SideEffects []
44+
45+ SeeAlso []
46+
47+ ***********************************************************************/
48+ int Gia_ManGenSymFun_rec ( Gia_Man_t * p , word Str , int nChars , Vec_Ptr_t * vStrs , Vec_Wec_t * vLits , Vec_Int_t * vIns )
49+ {
50+ if ( Str == 0 ) return 0 ;
51+ if ( Str == Abc_Tt6Mask (nChars ) ) return 1 ;
52+ assert ( nChars > 1 );
53+ Vec_Wrd_t * vStore = (Vec_Wrd_t * )Vec_PtrEntry (vStrs , nChars - 1 );
54+ Vec_Int_t * vValue = Vec_WecEntry (vLits , nChars - 1 );
55+ int Index ;
56+ if ( (Index = Vec_WrdFind (vStore , Str )) >= 0 )
57+ return Vec_IntEntry (vValue , Index );
58+ word Str0 = Str & ~Abc_Tt6MaskI (nChars - 1 );
59+ word Str1 = Str >> 1 ;
60+ int Lit0 = Gia_ManGenSymFun_rec ( p , Str0 , nChars - 1 , vStrs , vLits , vIns );
61+ int Lit1 = Gia_ManGenSymFun_rec ( p , Str1 , nChars - 1 , vStrs , vLits , vIns );
62+ int Lit = Gia_ManAppendMux2 ( p , Vec_IntEntry (vIns , nChars - 2 ), Lit1 , Lit0 );
63+ Vec_WrdPush ( vStore , Str );
64+ Vec_WrdPush ( vStore , ~Str & Abc_Tt6Mask (nChars ) );
65+ Vec_IntPush ( vValue , Lit );
66+ Vec_IntPush ( vValue , Abc_LitNot (Lit ) );
67+ return Lit ;
68+ }
69+ Gia_Man_t * Gia_ManGenSymFun ( Vec_Wrd_t * vFuns , int nChars , int fVerbose )
70+ {
71+ assert ( nChars <= 64 );
72+ word Str ; int i ;
73+ Vec_Ptr_t * vStrs = Vec_PtrAlloc (nChars );
74+ for ( i = 0 ; i < nChars ; i ++ )
75+ Vec_PtrPush ( vStrs , Vec_WrdAlloc (0 ) );
76+ Vec_Wec_t * vLits = Vec_WecStart (nChars );
77+ Vec_Int_t * vOuts = Vec_IntAlloc (Vec_WrdSize (vFuns ));
78+ Gia_Man_t * pNew = Gia_ManStart ( 10000 );
79+ pNew -> pName = Abc_UtilStrsav ( "sym" );
80+ Vec_Int_t * vIns = Vec_IntAlloc (nChars - 1 );
81+ for ( i = 0 ; i < nChars - 1 ; i ++ )
82+ Vec_IntPush (vIns , Gia_ManAppendCi (pNew ));
83+ Vec_WrdForEachEntry ( vFuns , Str , i )
84+ Vec_IntPush ( vOuts , Gia_ManGenSymFun_rec (pNew , Str , nChars , vStrs , vLits , vIns ) );
85+ Vec_WrdForEachEntry ( vFuns , Str , i )
86+ Gia_ManAppendCo (pNew , Vec_IntEntry (vOuts ,i ) );
87+ for ( i = 0 ; i < nChars ; i ++ )
88+ Vec_WrdFree ( (Vec_Wrd_t * )Vec_PtrEntry (vStrs , i ) );
89+ Vec_PtrFree (vStrs );
90+ Vec_WecFree (vLits );
91+ Vec_IntFree (vOuts );
92+ Vec_IntFree (vIns );
93+ return pNew ;
94+ }
95+
3796/**Function*************************************************************
3897
3998 Synopsis []
@@ -101,15 +160,15 @@ char * Gia_LutCasPerm( int nVars, int nLuts, int LutSize )
101160 Gia_LutCasSort ( pRes + i * LutSize , 1 , LutSize - 1 );
102161 return pRes ;
103162}
104- int Gia_ManLutCasGen_rec ( Gia_Man_t * pNew , Vec_Int_t * vCtrls , int iCtrl , Vec_Int_t * vDatas , int Shift )
163+ int Gia_ManGenLutCas_rec ( Gia_Man_t * pNew , Vec_Int_t * vCtrls , int iCtrl , Vec_Int_t * vDatas , int Shift )
105164{
106165 if ( iCtrl -- == 0 )
107166 return Vec_IntEntry ( vDatas , Shift );
108- int iLit0 = Gia_ManLutCasGen_rec ( pNew , vCtrls , iCtrl , vDatas , Shift );
109- int iLit1 = Gia_ManLutCasGen_rec ( pNew , vCtrls , iCtrl , vDatas , Shift + (1 <<iCtrl ));
167+ int iLit0 = Gia_ManGenLutCas_rec ( pNew , vCtrls , iCtrl , vDatas , Shift );
168+ int iLit1 = Gia_ManGenLutCas_rec ( pNew , vCtrls , iCtrl , vDatas , Shift + (1 <<iCtrl ));
110169 return Gia_ManAppendMux ( pNew , Vec_IntEntry (vCtrls , iCtrl ), iLit1 , iLit0 );
111170}
112- Gia_Man_t * Gia_ManLutCasGen ( Gia_Man_t * p , char * pPermStr , int nVars , int nLuts , int LutSize , int Seed , int fVerbose )
171+ Gia_Man_t * Gia_ManGenLutCas ( Gia_Man_t * p , char * pPermStr , int nVars , int nLuts , int LutSize , int Seed , int fVerbose )
113172{
114173 if ( Seed )
115174 srand (Seed );
@@ -139,7 +198,7 @@ Gia_Man_t * Gia_ManLutCasGen( Gia_Man_t * p, char * pPermStr, int nVars, int nLu
139198 pCur ++ ;
140199 for ( int k = 1 ; k < LutSize ; k ++ )
141200 Vec_IntWriteEntry ( vLits , k , Vec_IntEntry (vCtrls , (int )(* pCur ++ - 'a' )) );
142- Vec_IntWriteEntry ( vLits , 0 , Gia_ManLutCasGen_rec (pNew , vLits , LutSize , vDatas , i * (1 << LutSize )) );
201+ Vec_IntWriteEntry ( vLits , 0 , Gia_ManGenLutCas_rec (pNew , vLits , LutSize , vDatas , i * (1 << LutSize )) );
143202 }
144203 // if the AIG is given, create a miter
145204 int iLit = Vec_IntEntry (vLits , 0 );
@@ -166,15 +225,15 @@ Gia_Man_t * Gia_ManLutCasGen( Gia_Man_t * p, char * pPermStr, int nVars, int nLu
166225}
167226
168227/*
169- int Gia_ManLutCasGenSolve ( int nVars, int nLuts, int LutSize, char * pTtStr, int fVerbose )
228+ int Gia_ManGenLutCasSolve ( int nVars, int nLuts, int LutSize, char * pTtStr, int fVerbose )
170229{
171230 extern Gia_Man_t * Gia_QbfQuantifyAll( Gia_Man_t * p, int nPars, int fAndAll, int fOrAll );
172231 assert( strlen(pTtStr) <= 1024 );
173232 word pTruth[64] = {0};
174233 int i, Id, nVars = Abc_TtReadHex( pTruth, pTtStr );
175234 assert( nVars <= 12 );
176235 int nParams = nLuts * (1 << LutSize);
177- Gia_Man_t * pCas = Gia_ManLutCasGen ( NULL, NULL, nVars, nLuts, LutSize, 0, fVerbose );
236+ Gia_Man_t * pCas = Gia_ManGenLutCas ( NULL, NULL, nVars, nLuts, LutSize, 0, fVerbose );
178237 Gia_Man_t * pCofs = Gia_QbfQuantifyAll( pCas, nParams, 0, 0 );
179238 Gia_ManFree( pCas );
180239 Cnf_Dat_t * pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( pCofs, 8, 0, 0, 0, 0 );
0 commit comments