abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dauGia.c File Reference
#include "dauInt.h"
#include "aig/gia/gia.h"
#include "misc/util/utilTruth.h"

Go to the source code of this file.

Macros

#define DAU_DSD_MAX_VAR   12
 

Functions

ABC_NAMESPACE_IMPL_START int Kit_TruthToGia (Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
 DECLARATIONS ///. More...
 
int Dau_DsdToGiaCompose_rec (Gia_Man_t *pGia, word Func, int *pFanins, int nVars)
 FUNCTION DEFINITIONS ///. More...
 
int Dau_DsdToGia2_rec (Gia_Man_t *pGia, char *pStr, char **p, int *pMatches, int *pLits, Vec_Int_t *vCover)
 
int Dau_DsdToGia2 (Gia_Man_t *pGia, char *p, int *pLits, Vec_Int_t *vCover)
 
void Dau_DsdAddToArray (Gia_Man_t *pGia, int *pFans, int nFans, int iFan)
 
int Dau_DsdBalance (Gia_Man_t *pGia, int *pFans, int nFans, int fAnd)
 
int Dau_DsdToGia_rec (Gia_Man_t *pGia, char *pStr, char **p, int *pMatches, int *pLits, Vec_Int_t *vCover)
 
int Dau_DsdToGia (Gia_Man_t *pGia, char *p, int *pLits, Vec_Int_t *vCover)
 
int Dsm_ManTruthToGia (void *p, word *pTruth, Vec_Int_t *vLeaves, Vec_Int_t *vCover)
 
void Dsm_ManReportStats ()
 
void * Dsm_ManDeriveGia (void *pGia, int fUseMuxes)
 

Variables

static int m_Calls = 0
 
static int m_NonDsd = 0
 
static int m_Non1Step = 0
 

Macro Definition Documentation

#define DAU_DSD_MAX_VAR   12

Definition at line 33 of file dauGia.c.

Function Documentation

void Dau_DsdAddToArray ( Gia_Man_t pGia,
int *  pFans,
int  nFans,
int  iFan 
)

Function*************************************************************

Synopsis [Derives GIA for the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 219 of file dauGia.c.

220 {
221  int i;
222  pFans[nFans] = iFan;
223  if ( nFans == 0 )
224  return;
225  for ( i = nFans; i > 0; i-- )
226  {
227  if ( Gia_ObjLevelId(pGia, Abc_Lit2Var(pFans[i])) <= Gia_ObjLevelId(pGia, Abc_Lit2Var(pFans[i-1])) )
228  return;
229  ABC_SWAP( int, pFans[i], pFans[i-1] );
230  }
231 }
static int Gia_ObjLevelId(Gia_Man_t *p, int Id)
Definition: gia.h:500
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int Dau_DsdBalance ( Gia_Man_t pGia,
int *  pFans,
int  nFans,
int  fAnd 
)

Definition at line 232 of file dauGia.c.

233 {
234  Gia_Obj_t * pObj;
235  int iFan0, iFan1, iFan;
236  if ( nFans == 1 )
237  return pFans[0];
238  assert( nFans > 1 );
239  iFan0 = pFans[--nFans];
240  iFan1 = pFans[--nFans];
241  if ( fAnd )
242  iFan = Gia_ManHashAnd( pGia, iFan0, iFan1 );
243  else if ( pGia->pMuxes )
244  iFan = Gia_ManHashXorReal( pGia, iFan0, iFan1 );
245  else
246  iFan = Gia_ManHashXor( pGia, iFan0, iFan1 );
247  pObj = Gia_ManObj(pGia, Abc_Lit2Var(iFan));
248  if ( Gia_ObjIsAnd(pObj) )
249  {
250  if ( fAnd )
251  Gia_ObjSetAndLevel( pGia, pObj );
252  else if ( pGia->pMuxes )
253  Gia_ObjSetXorLevel( pGia, pObj );
254  else
255  {
256  if ( Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) )
257  Gia_ObjSetAndLevel( pGia, Gia_ObjFanin0(pObj) );
258  if ( Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) )
259  Gia_ObjSetAndLevel( pGia, Gia_ObjFanin1(pObj) );
260  Gia_ObjSetAndLevel( pGia, pObj );
261  }
262  }
263  Dau_DsdAddToArray( pGia, pFans, nFans++, iFan );
264  return Dau_DsdBalance( pGia, pFans, nFans, fAnd );
265 }
void Dau_DsdAddToArray(Gia_Man_t *pGia, int *pFans, int nFans, int iFan)
Definition: dauGia.c:219
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:658
unsigned * pMuxes
Definition: gia.h:104
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
int Dau_DsdBalance(Gia_Man_t *pGia, int *pFans, int nFans, int fAnd)
Definition: dauGia.c:232
static void Gia_ObjSetAndLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:506
int Gia_ManHashXorReal(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:465
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static void Gia_ObjSetXorLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:507
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
int Dau_DsdToGia ( Gia_Man_t pGia,
char *  p,
int *  pLits,
Vec_Int_t vCover 
)

Definition at line 391 of file dauGia.c.

392 {
393  int Res;
394  if ( *p == '0' && *(p+1) == 0 )
395  Res = 0;
396  else if ( *p == '1' && *(p+1) == 0 )
397  Res = 1;
398  else
399  Res = Dau_DsdToGia_rec( pGia, p, &p, Dau_DsdComputeMatches(p), pLits, vCover );
400  assert( *++p == 0 );
401  return Res;
402 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int * Dau_DsdComputeMatches(char *p)
Definition: dauDsd.c:80
int Dau_DsdToGia_rec(Gia_Man_t *pGia, char *pStr, char **p, int *pMatches, int *pLits, Vec_Int_t *vCover)
Definition: dauGia.c:266
#define assert(ex)
Definition: util_old.h:213
int Dau_DsdToGia2 ( Gia_Man_t pGia,
char *  p,
int *  pLits,
Vec_Int_t vCover 
)

Definition at line 195 of file dauGia.c.

196 {
197  int Res;
198  if ( *p == '0' && *(p+1) == 0 )
199  Res = 0;
200  else if ( *p == '1' && *(p+1) == 0 )
201  Res = 1;
202  else
203  Res = Dau_DsdToGia2_rec( pGia, p, &p, Dau_DsdComputeMatches(p), pLits, vCover );
204  assert( *++p == 0 );
205  return Res;
206 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int * Dau_DsdComputeMatches(char *p)
Definition: dauDsd.c:80
int Dau_DsdToGia2_rec(Gia_Man_t *pGia, char *pStr, char **p, int *pMatches, int *pLits, Vec_Int_t *vCover)
Definition: dauGia.c:88
#define assert(ex)
Definition: util_old.h:213
int Dau_DsdToGia2_rec ( Gia_Man_t pGia,
char *  pStr,
char **  p,
int *  pMatches,
int *  pLits,
Vec_Int_t vCover 
)

Function*************************************************************

Synopsis [Derives GIA for the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file dauGia.c.

89 {
90  int fCompl = 0;
91  if ( **p == '!' )
92  (*p)++, fCompl = 1;
93  if ( **p >= 'a' && **p < 'a' + DAU_DSD_MAX_VAR ) // var
94  return Abc_LitNotCond( pLits[**p - 'a'], fCompl );
95  if ( **p == '(' ) // and/or
96  {
97  char * q = pStr + pMatches[ *p - pStr ];
98  int Res = 1, Lit;
99  assert( **p == '(' && *q == ')' );
100  for ( (*p)++; *p < q; (*p)++ )
101  {
102  Lit = Dau_DsdToGia2_rec( pGia, pStr, p, pMatches, pLits, vCover );
103  Res = Gia_ManHashAnd( pGia, Res, Lit );
104  }
105  assert( *p == q );
106  return Abc_LitNotCond( Res, fCompl );
107  }
108  if ( **p == '[' ) // xor
109  {
110  char * q = pStr + pMatches[ *p - pStr ];
111  int Res = 0, Lit;
112  assert( **p == '[' && *q == ']' );
113  for ( (*p)++; *p < q; (*p)++ )
114  {
115  Lit = Dau_DsdToGia2_rec( pGia, pStr, p, pMatches, pLits, vCover );
116  if ( pGia->pMuxes )
117  Res = Gia_ManHashXorReal( pGia, Res, Lit );
118  else
119  Res = Gia_ManHashXor( pGia, Res, Lit );
120  }
121  assert( *p == q );
122  return Abc_LitNotCond( Res, fCompl );
123  }
124  if ( **p == '<' ) // mux
125  {
126  int nVars = 0;
127  int Temp[3], * pTemp = Temp, Res;
128  int Fanins[DAU_DSD_MAX_VAR], * pLits2;
129  char * pOld = *p;
130  char * q = pStr + pMatches[ *p - pStr ];
131  // read fanins
132  if ( *(q+1) == '{' )
133  {
134  char * q2;
135  *p = q+1;
136  q2 = pStr + pMatches[ *p - pStr ];
137  assert( **p == '{' && *q2 == '}' );
138  for ( nVars = 0, (*p)++; *p < q2; (*p)++, nVars++ )
139  Fanins[nVars] = Dau_DsdToGia2_rec( pGia, pStr, p, pMatches, pLits, vCover );
140  assert( *p == q2 );
141  pLits2 = Fanins;
142  }
143  else
144  pLits2 = pLits;
145  // read MUX
146  *p = pOld;
147  q = pStr + pMatches[ *p - pStr ];
148  assert( **p == '<' && *q == '>' );
149  // verify internal variables
150  if ( nVars )
151  for ( ; pOld < q; pOld++ )
152  if ( *pOld >= 'a' && *pOld <= 'z' )
153  assert( *pOld - 'a' < nVars );
154  // derive MUX components
155  for ( (*p)++; *p < q; (*p)++ )
156  *pTemp++ = Dau_DsdToGia2_rec( pGia, pStr, p, pMatches, pLits2, vCover );
157  assert( pTemp == Temp + 3 );
158  assert( *p == q );
159  if ( *(q+1) == '{' ) // and/or
160  {
161  char * q = pStr + pMatches[ ++(*p) - pStr ];
162  assert( **p == '{' && *q == '}' );
163  *p = q;
164  }
165  if ( pGia->pMuxes )
166  Res = Gia_ManHashMuxReal( pGia, Temp[0], Temp[1], Temp[2] );
167  else
168  Res = Gia_ManHashMux( pGia, Temp[0], Temp[1], Temp[2] );
169  return Abc_LitNotCond( Res, fCompl );
170  }
171  if ( (**p >= 'A' && **p <= 'F') || (**p >= '0' && **p <= '9') )
172  {
173  Vec_Int_t vLeaves; char * q;
174  word pFunc[DAU_DSD_MAX_VAR > 6 ? (1 << (DAU_DSD_MAX_VAR-6)) : 1];
175  int Fanins[DAU_DSD_MAX_VAR], Res;
176  int i, nVars = Abc_TtReadHex( pFunc, *p );
177  *p += Abc_TtHexDigitNum( nVars );
178  q = pStr + pMatches[ *p - pStr ];
179  assert( **p == '{' && *q == '}' );
180  for ( i = 0, (*p)++; *p < q; (*p)++, i++ )
181  Fanins[i] = Dau_DsdToGia2_rec( pGia, pStr, p, pMatches, pLits, vCover );
182  assert( i == nVars );
183  assert( *p == q );
184 // Res = Dau_DsdToGia2Compose_rec( pGia, Func, Fanins, nVars );
185  vLeaves.nCap = nVars;
186  vLeaves.nSize = nVars;
187  vLeaves.pArray = Fanins;
188  Res = Kit_TruthToGia( pGia, (unsigned *)pFunc, nVars, vCover, &vLeaves, 1 );
189  m_Non1Step++;
190  return Abc_LitNotCond( Res, fCompl );
191  }
192  assert( 0 );
193  return 0;
194 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:658
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
unsigned * pMuxes
Definition: gia.h:104
#define DAU_DSD_MAX_VAR
Definition: dauGia.c:33
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int m_Non1Step
Definition: dauGia.c:37
static int Abc_TtReadHex(word *pTruth, char *pString)
Definition: utilTruth.h:838
static int Abc_TtHexDigitNum(int nVars)
Definition: utilTruth.h:171
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition: giaHash.c:677
int Gia_ManHashXorReal(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:465
int Dau_DsdToGia2_rec(Gia_Man_t *pGia, char *pStr, char **p, int *pMatches, int *pLits, Vec_Int_t *vCover)
Definition: dauGia.c:88
ABC_NAMESPACE_IMPL_START int Kit_TruthToGia(Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
DECLARATIONS ///.
Definition: kitHop.c:80
#define assert(ex)
Definition: util_old.h:213
int Gia_ManHashMuxReal(Gia_Man_t *p, int iLitC, int iLit1, int iLit0)
Definition: giaHash.c:517
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
int Dau_DsdToGia_rec ( Gia_Man_t pGia,
char *  pStr,
char **  p,
int *  pMatches,
int *  pLits,
Vec_Int_t vCover 
)

Definition at line 266 of file dauGia.c.

267 {
268  int fCompl = 0;
269  if ( **p == '!' )
270  (*p)++, fCompl = 1;
271  if ( **p >= 'a' && **p < 'a' + DAU_DSD_MAX_VAR ) // var
272  return Abc_LitNotCond( pLits[**p - 'a'], fCompl );
273  if ( **p == '(' ) // and/or
274  {
275  char * q = pStr + pMatches[ *p - pStr ];
276  int pFans[DAU_DSD_MAX_VAR], nFans = 0, Fan;
277  assert( **p == '(' && *q == ')' );
278  for ( (*p)++; *p < q; (*p)++ )
279  {
280  Fan = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover );
281  Dau_DsdAddToArray( pGia, pFans, nFans++, Fan );
282  }
283  Fan = Dau_DsdBalance( pGia, pFans, nFans, 1 );
284  assert( *p == q );
285  return Abc_LitNotCond( Fan, fCompl );
286  }
287  if ( **p == '[' ) // xor
288  {
289  char * q = pStr + pMatches[ *p - pStr ];
290  int pFans[DAU_DSD_MAX_VAR], nFans = 0, Fan;
291  assert( **p == '[' && *q == ']' );
292  for ( (*p)++; *p < q; (*p)++ )
293  {
294  Fan = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover );
295  Dau_DsdAddToArray( pGia, pFans, nFans++, Fan );
296  }
297  Fan = Dau_DsdBalance( pGia, pFans, nFans, 0 );
298  assert( *p == q );
299  return Abc_LitNotCond( Fan, fCompl );
300  }
301  if ( **p == '<' ) // mux
302  {
303  Gia_Obj_t * pObj;
304  int nVars = 0;
305  int Temp[3], * pTemp = Temp, Res;
306  int Fanins[DAU_DSD_MAX_VAR], * pLits2;
307  char * pOld = *p;
308  char * q = pStr + pMatches[ *p - pStr ];
309  // read fanins
310  if ( *(q+1) == '{' )
311  {
312  char * q2;
313  *p = q+1;
314  q2 = pStr + pMatches[ *p - pStr ];
315  assert( **p == '{' && *q2 == '}' );
316  for ( nVars = 0, (*p)++; *p < q2; (*p)++, nVars++ )
317  Fanins[nVars] = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover );
318  assert( *p == q2 );
319  pLits2 = Fanins;
320  }
321  else
322  pLits2 = pLits;
323  // read MUX
324  *p = pOld;
325  q = pStr + pMatches[ *p - pStr ];
326  assert( **p == '<' && *q == '>' );
327  // verify internal variables
328  if ( nVars )
329  for ( ; pOld < q; pOld++ )
330  if ( *pOld >= 'a' && *pOld <= 'z' )
331  assert( *pOld - 'a' < nVars );
332  // derive MUX components
333  for ( (*p)++; *p < q; (*p)++ )
334  *pTemp++ = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits2, vCover );
335  assert( pTemp == Temp + 3 );
336  assert( *p == q );
337  if ( *(q+1) == '{' ) // and/or
338  {
339  char * q = pStr + pMatches[ ++(*p) - pStr ];
340  assert( **p == '{' && *q == '}' );
341  *p = q;
342  }
343  if ( pGia->pMuxes )
344  Res = Gia_ManHashMuxReal( pGia, Temp[0], Temp[1], Temp[2] );
345  else
346  Res = Gia_ManHashMux( pGia, Temp[0], Temp[1], Temp[2] );
347  pObj = Gia_ManObj(pGia, Abc_Lit2Var(Res));
348  if ( Gia_ObjIsAnd(pObj) )
349  {
350  if ( pGia->pMuxes )
351  Gia_ObjSetMuxLevel( pGia, pObj );
352  else
353  {
354  if ( Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) )
355  Gia_ObjSetAndLevel( pGia, Gia_ObjFanin0(pObj) );
356  if ( Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) )
357  Gia_ObjSetAndLevel( pGia, Gia_ObjFanin1(pObj) );
358  Gia_ObjSetAndLevel( pGia, pObj );
359  }
360  }
361  return Abc_LitNotCond( Res, fCompl );
362  }
363  if ( (**p >= 'A' && **p <= 'F') || (**p >= '0' && **p <= '9') )
364  {
365  Vec_Int_t vLeaves; char * q;
366  word pFunc[DAU_DSD_MAX_VAR > 6 ? (1 << (DAU_DSD_MAX_VAR-6)) : 1];
367  int Fanins[DAU_DSD_MAX_VAR], Res, nObjOld;
368  int i, nVars = Abc_TtReadHex( pFunc, *p );
369  *p += Abc_TtHexDigitNum( nVars );
370  q = pStr + pMatches[ *p - pStr ];
371  assert( **p == '{' && *q == '}' );
372  for ( i = 0, (*p)++; *p < q; (*p)++, i++ )
373  Fanins[i] = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover );
374  assert( i == nVars );
375  assert( *p == q );
376  vLeaves.nCap = nVars;
377  vLeaves.nSize = nVars;
378  vLeaves.pArray = Fanins;
379  nObjOld = Gia_ManObjNum(pGia);
380  Res = Kit_TruthToGia( pGia, (unsigned *)pFunc, nVars, vCover, &vLeaves, 1 );
381 // assert( nVars <= 6 );
382 // Res = Dau_DsdToGiaCompose_rec( pGia, pFunc[0], Fanins, nVars );
383  for ( i = nObjOld; i < Gia_ManObjNum(pGia); i++ )
384  Gia_ObjSetGateLevel( pGia, Gia_ManObj(pGia, i) );
385  m_Non1Step++;
386  return Abc_LitNotCond( Res, fCompl );
387  }
388  assert( 0 );
389  return 0;
390 }
void Dau_DsdAddToArray(Gia_Man_t *pGia, int *pFans, int nFans, int iFan)
Definition: dauGia.c:219
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Gia_ObjSetGateLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:509
unsigned * pMuxes
Definition: gia.h:104
#define DAU_DSD_MAX_VAR
Definition: dauGia.c:33
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
static int m_Non1Step
Definition: dauGia.c:37
static int Abc_TtReadHex(word *pTruth, char *pString)
Definition: utilTruth.h:838
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static int Abc_TtHexDigitNum(int nVars)
Definition: utilTruth.h:171
int Dau_DsdBalance(Gia_Man_t *pGia, int *pFans, int nFans, int fAnd)
Definition: dauGia.c:232
static void Gia_ObjSetAndLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:506
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition: giaHash.c:677
int Dau_DsdToGia_rec(Gia_Man_t *pGia, char *pStr, char **p, int *pMatches, int *pLits, Vec_Int_t *vCover)
Definition: dauGia.c:266
ABC_NAMESPACE_IMPL_START int Kit_TruthToGia(Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
DECLARATIONS ///.
Definition: kitHop.c:80
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static void Gia_ObjSetMuxLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:508
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
int Gia_ManHashMuxReal(Gia_Man_t *p, int iLitC, int iLit1, int iLit0)
Definition: giaHash.c:517
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int Dau_DsdToGiaCompose_rec ( Gia_Man_t pGia,
word  Func,
int *  pFanins,
int  nVars 
)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Derives GIA for the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 54 of file dauGia.c.

55 {
56  int t0, t1;
57  if ( Func == 0 )
58  return 0;
59  if ( Func == ~(word)0 )
60  return 1;
61  assert( nVars > 0 );
62  if ( --nVars == 0 )
63  {
64  assert( Func == s_Truths6[0] || Func == s_Truths6Neg[0] );
65  return Abc_LitNotCond( pFanins[0], (int)(Func == s_Truths6Neg[0]) );
66  }
67  if ( !Abc_Tt6HasVar(Func, nVars) )
68  return Dau_DsdToGiaCompose_rec( pGia, Func, pFanins, nVars );
69  t0 = Dau_DsdToGiaCompose_rec( pGia, Abc_Tt6Cofactor0(Func, nVars), pFanins, nVars );
70  t1 = Dau_DsdToGiaCompose_rec( pGia, Abc_Tt6Cofactor1(Func, nVars), pFanins, nVars );
71  if ( pGia->pMuxes )
72  return Gia_ManHashMuxReal( pGia, pFanins[nVars], t1, t0 );
73  else
74  return Gia_ManHashMux( pGia, pFanins[nVars], t1, t0 );
75 }
int Dau_DsdToGiaCompose_rec(Gia_Man_t *pGia, word Func, int *pFanins, int nVars)
FUNCTION DEFINITIONS ///.
Definition: dauGia.c:54
static int Abc_Tt6HasVar(word t, int iVar)
Definition: utilTruth.h:949
unsigned * pMuxes
Definition: gia.h:104
static word Abc_Tt6Cofactor0(word t, int iVar)
Definition: utilTruth.h:370
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static word Abc_Tt6Cofactor1(word t, int iVar)
Definition: utilTruth.h:375
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition: giaHash.c:677
static word s_Truths6Neg[6]
Definition: utilTruth.h:47
static word s_Truths6[6]
#define assert(ex)
Definition: util_old.h:213
int Gia_ManHashMuxReal(Gia_Man_t *p, int iLitC, int iLit1, int iLit0)
Definition: giaHash.c:517
void* Dsm_ManDeriveGia ( void *  pGia,
int  fUseMuxes 
)

Function*************************************************************

Synopsis [Performs structural hashing on the LUT functions.]

Description []

SideEffects []

SeeAlso []

Definition at line 471 of file dauGia.c.

472 {
473  Gia_Man_t * p = (Gia_Man_t *)pGia;
474  Gia_Man_t * pNew, * pTemp;
475  Vec_Int_t * vCover, * vLeaves;
476  Gia_Obj_t * pObj;
477  int k, i, iLut, iVar;
478  word * pTruth;
479  assert( Gia_ManHasMapping(p) );
480  // create new manager
481  pNew = Gia_ManStart( 6*Gia_ManObjNum(p)/5 + 100 );
482  pNew->pName = Abc_UtilStrsav( p->pName );
483  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
484  pNew->vLevels = Vec_IntStart( 6*Gia_ManObjNum(p)/5 + 100 );
485  if ( fUseMuxes )
486  pNew->pMuxes = ABC_CALLOC( unsigned, pNew->nObjsAlloc );
487  // map primary inputs
488  Gia_ManFillValue(p);
489  Gia_ManConst0(p)->Value = 0;
490  Gia_ManForEachCi( p, pObj, i )
491  pObj->Value = Gia_ManAppendCi(pNew);
492  // iterate through nodes used in the mapping
493  vLeaves = Vec_IntAlloc( 16 );
494  vCover = Vec_IntAlloc( 1 << 16 );
495  Gia_ManHashStart( pNew );
497  Gia_ManForEachAnd( p, pObj, iLut )
498  {
499  if ( Gia_ObjIsBuf(pObj) )
500  {
501  pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
502  continue;
503  }
504  if ( !Gia_ObjIsLut(p, iLut) )
505  continue;
506  // collect leaves
507  Vec_IntClear( vLeaves );
508  Gia_LutForEachFanin( p, iLut, iVar, k )
509  Vec_IntPush( vLeaves, iVar );
510  pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ManObj(p, iLut), vLeaves );
511  // collect incoming literals
512  Vec_IntClear( vLeaves );
513  Gia_LutForEachFanin( p, iLut, iVar, k )
514  Vec_IntPush( vLeaves, Gia_ManObj(p, iVar)->Value );
515  Gia_ManObj(p, iLut)->Value = Dsm_ManTruthToGia( pNew, pTruth, vLeaves, vCover );
516  }
518  Gia_ManForEachCo( p, pObj, i )
519  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
520  Gia_ManHashStop( pNew );
521  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
522  Vec_IntFree( vLeaves );
523  Vec_IntFree( vCover );
524 /*
525  Gia_ManForEachAnd( pNew, pObj, i )
526  {
527  int iLev = Gia_ObjLevelId(pNew, i);
528  int iLev0 = Gia_ObjLevelId(pNew, Gia_ObjFaninId0(pObj, i));
529  int iLev1 = Gia_ObjLevelId(pNew, Gia_ObjFaninId1(pObj, i));
530  assert( iLev == 1 + Abc_MaxInt(iLev0, iLev1) );
531  }
532 */
533  // perform cleanup
534  pNew = Gia_ManCleanup( pTemp = pNew );
535  Gia_ManStop( pTemp );
536  return pNew;
537 }
int nObjsAlloc
Definition: gia.h:102
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
void Gia_ObjComputeTruthTableStart(Gia_Man_t *p, int nVarsMax)
Definition: giaTruth.c:282
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
word * Gia_ObjComputeTruthTableCut(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition: giaTruth.c:351
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
void Gia_ObjComputeTruthTableStop(Gia_Man_t *p)
Definition: giaTruth.c:293
unsigned * pMuxes
Definition: gia.h:104
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Definition: gia.h:427
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
int Dsm_ManTruthToGia(void *p, word *pTruth, Vec_Int_t *vLeaves, Vec_Int_t *vCover)
Definition: dauGia.c:415
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ManAppendBuf(Gia_Man_t *p, int iLit)
Definition: gia.h:694
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
void Gia_ManHashStart(Gia_Man_t *p)
Definition: giaHash.c:117
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
int Gia_ManLutSizeMax(Gia_Man_t *p)
Definition: giaIf.c:125
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
static int Gia_ManHasMapping(Gia_Man_t *p)
Definition: gia.h:951
Definition: gia.h:95
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
Vec_Int_t * vLevels
Definition: gia.h:115
static int Gia_ObjIsLut(Gia_Man_t *p, int Id)
Definition: gia.h:952
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
void Dsm_ManReportStats ( )

Function*************************************************************

Synopsis [Convert TT to GIA via DSD.]

Description []

SideEffects []

SeeAlso []

Definition at line 454 of file dauGia.c.

455 {
456  printf( "Calls = %d. NonDSD = %d. Non1Step = %d.\n", m_Calls, m_NonDsd, m_Non1Step );
457  m_Calls = m_NonDsd = m_Non1Step = 0;
458 }
static int m_Non1Step
Definition: dauGia.c:37
static int m_NonDsd
Definition: dauGia.c:36
static int m_Calls
Definition: dauGia.c:35
int Dsm_ManTruthToGia ( void *  p,
word pTruth,
Vec_Int_t vLeaves,
Vec_Int_t vCover 
)

Function*************************************************************

Synopsis [Convert TT to GIA via DSD.]

Description []

SideEffects []

SeeAlso []

Definition at line 415 of file dauGia.c.

416 {
417  int fUseMuxes = 0;
418  int fDelayBalance = 1;
419  Gia_Man_t * pGia = (Gia_Man_t *)p;
420  int nSizeNonDec;
421  char pDsd[1000];
422  m_Calls++;
423  assert( Vec_IntSize(vLeaves) <= DAU_DSD_MAX_VAR );
424  // collect delay information
425  if ( fDelayBalance && fUseMuxes )
426  {
427  int i, iLit, pVarLevels[DAU_DSD_MAX_VAR];
428  Vec_IntForEachEntry( vLeaves, iLit, i )
429  pVarLevels[i] = Gia_ObjLevelId( pGia, Abc_Lit2Var(iLit) );
430  nSizeNonDec = Dau_DsdDecomposeLevel( pTruth, Vec_IntSize(vLeaves), fUseMuxes, 1, pDsd, pVarLevels );
431  }
432  else
433  nSizeNonDec = Dau_DsdDecompose( pTruth, Vec_IntSize(vLeaves), fUseMuxes, 1, pDsd );
434  if ( nSizeNonDec )
435  m_NonDsd++;
436 // printf( "%s\n", pDsd );
437  if ( fDelayBalance )
438  return Dau_DsdToGia( pGia, pDsd, Vec_IntArray(vLeaves), vCover );
439  else
440  return Dau_DsdToGia2( pGia, pDsd, Vec_IntArray(vLeaves), vCover );
441 }
static int Gia_ObjLevelId(Gia_Man_t *p, int Id)
Definition: gia.h:500
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define DAU_DSD_MAX_VAR
Definition: dauGia.c:33
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
Definition: dauDsd.c:1912
int Dau_DsdDecomposeLevel(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes, int *pVarLevels)
Definition: dauDsd.c:1936
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static int m_NonDsd
Definition: dauGia.c:36
int Dau_DsdToGia(Gia_Man_t *pGia, char *p, int *pLits, Vec_Int_t *vCover)
Definition: dauGia.c:391
int Dau_DsdToGia2(Gia_Man_t *pGia, char *p, int *pLits, Vec_Int_t *vCover)
Definition: dauGia.c:195
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: gia.h:95
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static int m_Calls
Definition: dauGia.c:35
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
ABC_NAMESPACE_IMPL_START int Kit_TruthToGia ( Gia_Man_t pMan,
unsigned *  pTruth,
int  nVars,
Vec_Int_t vMemory,
Vec_Int_t vLeaves,
int  fHash 
)

DECLARATIONS ///.

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

]

CFile****************************************************************

FileName [giaMap.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Manipulation of mapping associated with the AIG.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
giaMap.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 80 of file kitHop.c.

81 {
82  int iLit;
83  Kit_Graph_t * pGraph;
84  // transform truth table into the decomposition tree
85  if ( vMemory == NULL )
86  {
87  vMemory = Vec_IntAlloc( 0 );
88  pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
89  Vec_IntFree( vMemory );
90  }
91  else
92  pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
93  if ( pGraph == NULL )
94  {
95  printf( "Kit_TruthToGia(): Converting truth table to AIG has failed for function:\n" );
96  Kit_DsdPrintFromTruth( pTruth, nVars ); printf( "\n" );
97  }
98  // derive the AIG for the decomposition tree
99  iLit = Kit_GraphToGia( pMan, pGraph, vLeaves, fHash );
100  Kit_GraphFree( pGraph );
101  return iLit;
102 }
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition: kitGraph.c:131
int Kit_GraphToGia(Gia_Man_t *pMan, Kit_Graph_t *pGraph, Vec_Int_t *vLeaves, int fHash)
Definition: kitHop.c:70
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Kit_Graph_t * Kit_TruthToGraph(unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
Definition: kitGraph.c:355

Variable Documentation

int m_Calls = 0
static

Definition at line 35 of file dauGia.c.

int m_Non1Step = 0
static

Definition at line 37 of file dauGia.c.

int m_NonDsd = 0
static

Definition at line 36 of file dauGia.c.