abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaFx.c File Reference
#include "gia.h"
#include "bool/kit/kit.h"
#include "misc/vec/vecWec.h"
#include "bool/dec/dec.h"
#include "opt/dau/dau.h"
#include "misc/util/utilTruth.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Gia_ManGraphToAig (Gia_Man_t *p, Dec_Graph_t *pGraph)
 DECLARATIONS ///. More...
 
int Gia_ManSopToAig (Gia_Man_t *p, char *pSop, Vec_Int_t *vLeaves)
 
int Gia_ManFactorNode (Gia_Man_t *p, char *pSop, Vec_Int_t *vLeaves)
 
Vec_Wrd_tGia_ManComputeTruths (Gia_Man_t *p, int nCutSize, int nLutNum, int fReverse)
 
int Gia_ManAssignNumbers (Gia_Man_t *p)
 
Vec_Wec_tGia_ManFxRetrieve (Gia_Man_t *p, Vec_Str_t **pvCompl, int fReverse)
 
void Gia_ManFxTopoOrder_rec (Vec_Wec_t *vCubes, Vec_Int_t *vFirst, Vec_Int_t *vCount, Vec_Int_t *vVisit, Vec_Int_t *vOrder, int iObj)
 
Vec_Int_tGia_ManFxTopoOrder (Vec_Wec_t *vCubes, int nInputs, int nStart, Vec_Int_t **pvFirst, Vec_Int_t **pvCount)
 
Gia_Man_tGia_ManFxInsert (Gia_Man_t *p, Vec_Wec_t *vCubes, Vec_Str_t *vCompls)
 
Gia_Man_tGia_ManPerformFx (Gia_Man_t *p, int nNewNodesMax, int LitCountMax, int fReverse, int fVerbose, int fVeryVerbose)
 

Function Documentation

int Gia_ManAssignNumbers ( Gia_Man_t p)

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

Synopsis [Extracts information about the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 175 of file giaFx.c.

176 {
177  Gia_Obj_t * pObj;
178  int i, Counter = 0;
179  Gia_ManFillValue( p );
180  Gia_ManForEachCi( p, pObj, i )
181  pObj->Value = Counter++;
182  Gia_ManForEachLut( p, i )
183  Gia_ManObj(p, i)->Value = Counter++;
184  return Counter;
185 }
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static int Counter
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
Vec_Wrd_t* Gia_ManComputeTruths ( Gia_Man_t p,
int  nCutSize,
int  nLutNum,
int  fReverse 
)

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

Synopsis [Computing truth tables for the mapped network.]

Description []

SideEffects []

SeeAlso []

Definition at line 135 of file giaFx.c.

136 {
137  Vec_Wrd_t * vTruths;
138  Vec_Int_t vLeaves;
139  word * pTruth;
140  int i, k, nWords;
141  nWords = Abc_Truth6WordNum( nCutSize );
142  vTruths = Vec_WrdAlloc( nWords * nLutNum );
143  Gia_ObjComputeTruthTableStart( p, nCutSize );
144  Gia_ManForEachLut( p, i )
145  {
146  // collect and sort fanins
147  vLeaves.nCap = vLeaves.nSize = Gia_ObjLutSize( p, i );
148  vLeaves.pArray = Gia_ObjLutFanins( p, i );
149  assert( Vec_IntCheckUniqueSmall(&vLeaves) );
150  Vec_IntSelectSort( Vec_IntArray(&vLeaves), Vec_IntSize(&vLeaves) );
151  if ( !fReverse )
152  Vec_IntReverseOrder( &vLeaves );
153  // compute truth table
154  pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ManObj(p, i), &vLeaves );
155  for ( k = 0; k < nWords; k++ )
156  Vec_WrdPush( vTruths, pTruth[k] );
157 // Kit_DsdPrintFromTruth( (unsigned *)pTruth, 6 ); printf( "\n" );
158  }
160  assert( Vec_WrdCap(vTruths) == 16 || Vec_WrdSize(vTruths) == Vec_WrdCap(vTruths) );
161  return vTruths;
162 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static int Vec_IntCheckUniqueSmall(Vec_Int_t *p)
Definition: vecInt.h:1336
void Gia_ObjComputeTruthTableStart(Gia_Man_t *p, int nVarsMax)
Definition: giaTruth.c:282
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 Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:618
static int Vec_WrdCap(Vec_Wrd_t *p)
Definition: vecWrd.h:352
void Gia_ObjComputeTruthTableStop(Gia_Man_t *p)
Definition: giaTruth.c:293
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
int nWords
Definition: abcNpn.c:127
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static void Vec_IntReverseOrder(Vec_Int_t *p)
Definition: vecInt.h:1042
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static void Vec_IntSelectSort(int *pArray, int nSize)
Definition: vecInt.h:1740
static int Gia_ObjLutSize(Gia_Man_t *p, int Id)
Definition: gia.h:953
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int * Gia_ObjLutFanins(Gia_Man_t *p, int Id)
Definition: gia.h:954
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWrd.h:80
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
int Gia_ManFactorNode ( Gia_Man_t p,
char *  pSop,
Vec_Int_t vLeaves 
)

Definition at line 99 of file giaFx.c.

100 {
101  if ( Kit_PlaGetVarNum(pSop) == 0 )
102  return Abc_LitNotCond( 1, Kit_PlaIsConst0(pSop) );
103  assert( Kit_PlaGetVarNum(pSop) == Vec_IntSize(vLeaves) );
104  if ( Kit_PlaGetVarNum(pSop) > 2 && Kit_PlaGetCubeNum(pSop) > 1 )
105  {
106  Dec_Graph_t * pFForm;
107  Dec_Node_t * pFFNode;
108  int i, Lit;
109  pFForm = Dec_Factor( pSop );
110  // assign fanins
111  Dec_GraphForEachLeaf( pFForm, pFFNode, i )
112  {
113  assert( Vec_IntEntry(vLeaves, i) >= 0 );
114  pFFNode->iFunc = Vec_IntEntry(vLeaves, i);
115  }
116  // perform strashing
117  Lit = Gia_ManGraphToAig( p, pFForm );
118  Dec_GraphFree( pFForm );
119  return Lit;
120  }
121  return Gia_ManSopToAig( p, pSop, vLeaves );
122 }
int Kit_PlaIsConst0(char *pSop)
DECLARATIONS ///.
Definition: kitPla.c:46
Dec_Graph_t * Dec_Factor(char *pSop)
FUNCTION DECLARATIONS ///.
Definition: decFactor.c:55
int Kit_PlaGetCubeNum(char *pSop)
Definition: kitPla.c:138
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
ABC_NAMESPACE_IMPL_START int Gia_ManGraphToAig(Gia_Man_t *p, Dec_Graph_t *pGraph)
DECLARATIONS ///.
Definition: giaFx.c:50
int Gia_ManSopToAig(Gia_Man_t *p, char *pSop, Vec_Int_t *vLeaves)
Definition: giaFx.c:70
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int iFunc
Definition: dec.h:55
#define Dec_GraphForEachLeaf(pGraph, pLeaf, i)
ITERATORS ///.
Definition: dec.h:98
static void Dec_GraphFree(Dec_Graph_t *pGraph)
Definition: dec.h:307
#define assert(ex)
Definition: util_old.h:213
int Kit_PlaGetVarNum(char *pSop)
Definition: kitPla.c:118
Gia_Man_t* Gia_ManFxInsert ( Gia_Man_t p,
Vec_Wec_t vCubes,
Vec_Str_t vCompls 
)

Definition at line 310 of file giaFx.c.

311 {
312  Gia_Man_t * pNew, * pTemp;
313  Gia_Obj_t * pObj; Vec_Str_t * vSop;
314  Vec_Int_t * vOrder, * vFirst, * vCount, * vFanins, * vCover;
315  Vec_Int_t * vCopies, * vCube, * vMap;
316  int k, c, v, Lit, Var, iItem;
317 // abctime clk = Abc_Clock();
318  // prepare the cubes
319  vOrder = Gia_ManFxTopoOrder( vCubes, Gia_ManCiNum(p), Vec_StrSize(vCompls), &vFirst, &vCount );
320  if ( vOrder == NULL )
321  return Gia_ManDup( p );
322  assert( Vec_IntSize(vOrder) > Vec_StrSize(vCompls) );
323  // create new manager
324  pNew = Gia_ManStart( Gia_ManObjNum(p) );
325  pNew->pName = Abc_UtilStrsav( p->pName );
326  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
327  Gia_ManHashStart( pNew );
328  // create primary inputs
329  vMap = Vec_IntStartFull( Vec_IntSize(vOrder) );
330  vCopies = Vec_IntAlloc( Vec_IntSize(vOrder) );
331  Gia_ManForEachCi( p, pObj, k )
332  Vec_IntPush( vCopies, Gia_ManAppendCi(pNew) );
333  Vec_IntFillExtra( vCopies, Vec_IntSize(vOrder), -1 );
334  // add AIG nodes in the topological order
335  vSop = Vec_StrAlloc( 1000 );
336  vCover = Vec_IntAlloc( 1 << 16 );
337  vFanins = Vec_IntAlloc( 100 );
338  Vec_IntForEachEntryStart( vOrder, iItem, k, Gia_ManCiNum(p) )
339  {
340  int iFirst = Vec_IntEntry( vFirst, iItem );
341  int nCubes = Vec_IntEntry( vCount, iItem );
342  // collect fanins
343  Vec_IntClear( vFanins );
344  for ( c = 0; c < nCubes; c++ )
345  {
346  vCube = Vec_WecEntry( vCubes, iFirst + c );
347  Vec_IntForEachEntryStart( vCube, Lit, v, 1 )
348  if ( Vec_IntEntry(vMap, Abc_Lit2Var(Lit)) == -1 )
349  {
350  Vec_IntWriteEntry( vMap, Abc_Lit2Var(Lit), Vec_IntSize(vFanins) );
351  Vec_IntPush( vFanins, Abc_Lit2Var(Lit) );
352  }
353  }
354  if ( Vec_IntSize(vFanins) > 6 )
355  {
356  // create SOP
357  Vec_StrClear( vSop );
358  for ( c = 0; c < nCubes; c++ )
359  {
360  for ( v = 0; v < Vec_IntSize(vFanins); v++ )
361  Vec_StrPush( vSop, '-' );
362  vCube = Vec_WecEntry( vCubes, iFirst + c );
363  Vec_IntForEachEntryStart( vCube, Lit, v, 1 )
364  {
365  Lit = Abc_Lit2LitV( Vec_IntArray(vMap), Lit );
366  assert( Lit >= 0 && Abc_Lit2Var(Lit) < Vec_IntSize(vFanins) );
367  Vec_StrWriteEntry( vSop, Vec_StrSize(vSop) - Vec_IntSize(vFanins) + Abc_Lit2Var(Lit), (char)(Abc_LitIsCompl(Lit)? '0' : '1') );
368  }
369  Vec_StrPush( vSop, ' ' );
370  Vec_StrPush( vSop, '1' );
371  Vec_StrPush( vSop, '\n' );
372  }
373  Vec_StrPush( vSop, '\0' );
374  // collect fanins
375  Vec_IntForEachEntry( vFanins, Var, v )
376  {
377  Vec_IntWriteEntry( vMap, Var, -1 );
378  Vec_IntWriteEntry( vFanins, v, Vec_IntEntry(vCopies, Var) );
379  }
380  // derive new AIG
381  Lit = Gia_ManFactorNode( pNew, Vec_StrArray(vSop), vFanins );
382  }
383  else
384  {
385  word uTruth = 0, uCube;
386  for ( c = 0; c < nCubes; c++ )
387  {
388  uCube = ~(word)0;
389  vCube = Vec_WecEntry( vCubes, iFirst + c );
390  Vec_IntForEachEntryStart( vCube, Lit, v, 1 )
391  {
392  Lit = Abc_Lit2LitV( Vec_IntArray(vMap), Lit );
393  assert( Lit >= 0 && Abc_Lit2Var(Lit) < Vec_IntSize(vFanins) );
394  uCube &= Abc_LitIsCompl(Lit) ? ~s_Truths6[Abc_Lit2Var(Lit)] : s_Truths6[Abc_Lit2Var(Lit)];
395  }
396  uTruth |= uCube;
397  }
398  // complement constant
399  if ( uTruth == 0 )
400  uTruth = ~uTruth;
401  // collect fanins
402  Vec_IntForEachEntry( vFanins, Var, v )
403  {
404  Vec_IntWriteEntry( vMap, Var, -1 );
405  Vec_IntWriteEntry( vFanins, v, Vec_IntEntry(vCopies, Var) );
406  }
407  // create truth table
408  Lit = Dsm_ManTruthToGia( pNew, &uTruth, vFanins, vCover );
409  }
410  // complement if the original SOP was complemented
411  Lit = Abc_LitNotCond( Lit, (iItem < Vec_StrSize(vCompls)) && (Vec_StrEntry(vCompls, iItem) > 0) );
412  // remeber this literal
413  assert( Vec_IntEntry(vCopies, iItem) == -1 );
414  Vec_IntWriteEntry( vCopies, iItem, Lit );
415  }
416  Gia_ManHashStop( pNew );
417  // create primary outputs
418  Gia_ManForEachCo( p, pObj, k )
419  {
420  Lit = Gia_ObjFaninId0p(p, pObj) ? Vec_IntEntry(vCopies, Gia_ObjFanin0(pObj)->Value) : 0;
421  Gia_ManAppendCo( pNew, Abc_LitNotCond( Lit, Gia_ObjFaninC0(pObj) ) );
422  }
423  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
424  // cleanup
425  Vec_IntFree( vOrder );
426  Vec_IntFree( vFirst );
427  Vec_IntFree( vCount );
428  Vec_IntFree( vFanins );
429  Vec_IntFree( vCopies );
430  Vec_IntFree( vMap );
431  Vec_StrFree( vSop );
432  Vec_IntFree( vCover );
433  // remove dangling nodes
434  pNew = Gia_ManCleanup( pTemp = pNew );
435  Gia_ManStop( pTemp );
436 // Abc_PrintTime( 1, "Setdn time", Abc_Clock() - clk );
437  return pNew;
438 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static int Abc_Lit2LitV(int *pMap, int Lit)
Definition: abc_global.h:269
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition: giaDup.c:552
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:376
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static void Vec_StrClear(Vec_Str_t *p)
Definition: vecStr.h:519
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
int Dsm_ManTruthToGia(void *p, word *pTruth, Vec_Int_t *vLeaves, Vec_Int_t *vCover)
Definition: dauGia.c:415
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
static Vec_Int_t * Vec_IntStartFull(int nSize)
Definition: vecInt.h:119
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
if(last==0)
Definition: sparse_int.h:34
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
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
int Gia_ManFactorNode(Gia_Man_t *p, char *pSop, Vec_Int_t *vLeaves)
Definition: giaFx.c:99
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
static word s_Truths6[6]
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t * Gia_ManFxTopoOrder(Vec_Wec_t *vCubes, int nInputs, int nStart, Vec_Int_t **pvFirst, Vec_Int_t **pvCount)
Definition: giaFx.c:270
Definition: gia.h:95
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int Var
Definition: SolverTypes.h:42
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
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 Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
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
Vec_Wec_t* Gia_ManFxRetrieve ( Gia_Man_t p,
Vec_Str_t **  pvCompl,
int  fReverse 
)

Definition at line 186 of file giaFx.c.

187 {
188  Vec_Wec_t * vCubes;
189  Vec_Wrd_t * vTruths;
190  Vec_Int_t * vCube, * vCover;
191  int nItems, nCutSize, nWords;
192  int i, c, v, Lit, Cube, Counter = 0;
193 // abctime clk = Abc_Clock();
194  nItems = Gia_ManAssignNumbers( p );
195  // compute truth tables
196  nCutSize = Gia_ManLutSizeMax( p );
197  nWords = Abc_Truth6WordNum( nCutSize );
198  vTruths = Gia_ManComputeTruths( p, nCutSize, nItems - Gia_ManCiNum(p), fReverse );
199  vCover = Vec_IntAlloc( 1 << 16 );
200  // collect cubes
201  vCubes = Vec_WecAlloc( 1000 );
202  *pvCompl = Vec_StrStart( nItems );
203  Gia_ManForEachLut( p, i )
204  {
205  Gia_Obj_t * pObj = Gia_ManObj( p, i );
206  int nVars = Gia_ObjLutSize( p, i );
207  int * pVars = Gia_ObjLutFanins( p, i );
208  word * pTruth = Vec_WrdEntryP( vTruths, Counter++ * nWords );
209  int Status = Kit_TruthIsop( (unsigned *)pTruth, nVars, vCover, 1 );
210  if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover,0) == 0) )
211  {
212  Vec_StrWriteEntry( *pvCompl, pObj->Value, (char)(Vec_IntSize(vCover) == 0) );
213  vCube = Vec_WecPushLevel( vCubes );
214  Vec_IntPush( vCube, pObj->Value );
215  continue;
216  }
217  Vec_StrWriteEntry( *pvCompl, pObj->Value, (char)Status );
218  Vec_IntForEachEntry( vCover, Cube, c )
219  {
220  vCube = Vec_WecPushLevel( vCubes );
221  Vec_IntPush( vCube, pObj->Value );
222  for ( v = 0; v < nVars; v++ )
223  {
224  Lit = 3 & (Cube >> (v << 1));
225  if ( Lit == 1 )
226  Vec_IntPush( vCube, Abc_Var2Lit(Gia_ManObj(p, pVars[v])->Value, 1) );
227  else if ( Lit == 2 )
228  Vec_IntPush( vCube, Abc_Var2Lit(Gia_ManObj(p, pVars[v])->Value, 0) );
229  else if ( Lit != 0 )
230  assert( 0 );
231  }
232  Vec_IntSelectSort( Vec_IntArray(vCube) + 1, Vec_IntSize(vCube) - 1 );
233  }
234  }
235  assert( Counter * nWords == Vec_WrdSize(vTruths) );
236  Vec_WrdFree( vTruths );
237  Vec_IntFree( vCover );
238 // Abc_PrintTime( 1, "Setup time", Abc_Clock() - clk );
239  return vCubes;
240 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static Vec_Wec_t * Vec_WecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWec.h:87
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition: vecWec.h:42
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
Vec_Wrd_t * Gia_ManComputeTruths(Gia_Man_t *p, int nCutSize, int nLutNum, int fReverse)
Definition: giaFx.c:135
int nWords
Definition: abcNpn.c:127
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
#define Gia_ManForEachLut(p, i)
Definition: gia.h:968
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
static void Vec_IntSelectSort(int *pArray, int nSize)
Definition: vecInt.h:1740
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjLutSize(Gia_Man_t *p, int Id)
Definition: gia.h:953
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
static Vec_Str_t * Vec_StrStart(int nSize)
Definition: vecStr.h:95
static int * Gia_ObjLutFanins(Gia_Man_t *p, int Id)
Definition: gia.h:954
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Counter
int Gia_ManLutSizeMax(Gia_Man_t *p)
Definition: giaIf.c:125
int Gia_ManAssignNumbers(Gia_Man_t *p)
Definition: giaFx.c:175
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
static word * Vec_WrdEntryP(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:401
Vec_Int_t* Gia_ManFxTopoOrder ( Vec_Wec_t vCubes,
int  nInputs,
int  nStart,
Vec_Int_t **  pvFirst,
Vec_Int_t **  pvCount 
)

Definition at line 270 of file giaFx.c.

271 {
272  Vec_Int_t * vOrder, * vFirst, * vCount, * vVisit, * vCube;
273  int i, iFanin, nNodeMax = -1;
274  // find the largest index
275  Vec_WecForEachLevel( vCubes, vCube, i )
276  nNodeMax = Abc_MaxInt( nNodeMax, Vec_IntEntry(vCube, 0) );
277  nNodeMax++;
278  // quit if there is no new nodes
279  if ( nNodeMax == nStart )
280  {
281  printf( "The network is unchanged by fast extract.\n" );
282  return NULL;
283  }
284  // find first cube and how many cubes
285  vFirst = Vec_IntStart( nNodeMax );
286  vCount = Vec_IntStart( nNodeMax );
287  Vec_WecForEachLevel( vCubes, vCube, i )
288  {
289  iFanin = Vec_IntEntry( vCube, 0 );
290  assert( iFanin >= nInputs );
291  if ( Vec_IntEntry(vCount, iFanin) == 0 )
292  Vec_IntWriteEntry( vFirst, iFanin, i );
293  Vec_IntAddToEntry( vCount, iFanin, 1 );
294  }
295  // put all of them in a topo order
296  vOrder = Vec_IntStart( nInputs );
297  vVisit = Vec_IntStart( nNodeMax );
298  for ( i = 0; i < nInputs; i++ )
299  Vec_IntWriteEntry( vVisit, i, 1 );
300  for ( i = nInputs; i < nNodeMax; i++ )
301  if ( !Vec_IntEntry( vVisit, i ) )
302  Gia_ManFxTopoOrder_rec( vCubes, vFirst, vCount, vVisit, vOrder, i );
303  assert( Vec_IntSize(vOrder) == nNodeMax );
304  Vec_IntFree( vVisit );
305  // return topological order of new nodes
306  *pvFirst = vFirst;
307  *pvCount = vCount;
308  return vOrder;
309 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
void Gia_ManFxTopoOrder_rec(Vec_Wec_t *vCubes, Vec_Int_t *vFirst, Vec_Int_t *vCount, Vec_Int_t *vVisit, Vec_Int_t *vOrder, int iObj)
Definition: giaFx.c:253
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition: vecWec.h:55
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
if(last==0)
Definition: sparse_int.h:34
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
void Gia_ManFxTopoOrder_rec ( Vec_Wec_t vCubes,
Vec_Int_t vFirst,
Vec_Int_t vCount,
Vec_Int_t vVisit,
Vec_Int_t vOrder,
int  iObj 
)

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

Synopsis [Generates GIA after factoring the resulting SOPs.]

Description []

SideEffects []

SeeAlso []

Definition at line 253 of file giaFx.c.

254 {
255  int c, v, Lit;
256  int iFirst = Vec_IntEntry( vFirst, iObj );
257  int nCubes = Vec_IntEntry( vCount, iObj );
258  assert( !Vec_IntEntry( vVisit, iObj ) );
259  Vec_IntWriteEntry( vVisit, iObj, 1 );
260  for ( c = 0; c < nCubes; c++ )
261  {
262  Vec_Int_t * vCube = Vec_WecEntry( vCubes, iFirst + c );
263  assert( Vec_IntEntry(vCube, 0) == iObj );
264  Vec_IntForEachEntryStart( vCube, Lit, v, 1 )
265  if ( !Vec_IntEntry( vVisit, Abc_Lit2Var(Lit) ) )
266  Gia_ManFxTopoOrder_rec( vCubes, vFirst, vCount, vVisit, vOrder, Abc_Lit2Var(Lit) );
267  }
268  Vec_IntPush( vOrder, iObj );
269 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
void Gia_ManFxTopoOrder_rec(Vec_Wec_t *vCubes, Vec_Int_t *vFirst, Vec_Int_t *vCount, Vec_Int_t *vVisit, Vec_Int_t *vOrder, int iObj)
Definition: giaFx.c:253
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
ABC_NAMESPACE_IMPL_START int Gia_ManGraphToAig ( Gia_Man_t p,
Dec_Graph_t pGraph 
)

DECLARATIONS ///.

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

FileName [giaFx.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Interface to fast_extract package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
giaFx.c,v 1.00 2013/09/29 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Create GIA for SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file giaFx.c.

51 {
52  Dec_Node_t * pNode = NULL; // Suppress "might be used uninitialized"
53  int i, iAnd0, iAnd1;
54  // check for constant function
55  if ( Dec_GraphIsConst(pGraph) )
56  return Abc_LitNotCond( 1, Dec_GraphIsComplement(pGraph) );
57  // check for a literal
58  if ( Dec_GraphIsVar(pGraph) )
59  return Abc_LitNotCond( Dec_GraphVar(pGraph)->iFunc, Dec_GraphIsComplement(pGraph) );
60  // build the AIG nodes corresponding to the AND gates of the graph
61  Dec_GraphForEachNode( pGraph, pNode, i )
62  {
63  iAnd0 = Abc_LitNotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->iFunc, pNode->eEdge0.fCompl );
64  iAnd1 = Abc_LitNotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->iFunc, pNode->eEdge1.fCompl );
65  pNode->iFunc = Gia_ManHashAnd( p, iAnd0, iAnd1 );
66  }
67  // complement the result if necessary
68  return Abc_LitNotCond( pNode->iFunc, Dec_GraphIsComplement(pGraph) );
69 }
static int Dec_GraphIsConst(Dec_Graph_t *pGraph)
Definition: dec.h:324
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int Dec_GraphIsComplement(Dec_Graph_t *pGraph)
Definition: dec.h:372
static Dec_Node_t * Dec_GraphVar(Dec_Graph_t *pGraph)
Definition: dec.h:517
Dec_Edge_t eEdge0
Definition: dec.h:52
#define Dec_GraphForEachNode(pGraph, pAnd, i)
Definition: dec.h:101
int iFunc
Definition: dec.h:55
static int Dec_GraphIsVar(Dec_Graph_t *pGraph)
Definition: dec.h:485
static Dec_Node_t * Dec_GraphNode(Dec_Graph_t *pGraph, int i)
Definition: dec.h:437
Dec_Edge_t eEdge1
Definition: dec.h:53
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
Gia_Man_t* Gia_ManPerformFx ( Gia_Man_t p,
int  nNewNodesMax,
int  LitCountMax,
int  fReverse,
int  fVerbose,
int  fVeryVerbose 
)

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

Synopsis [Performs classical fast_extract on logic functions.]

Description []

SideEffects [Sorts the fanins of each cut in the increasing order.]

SeeAlso []

Definition at line 451 of file giaFx.c.

452 {
453  extern int Fx_FastExtract( Vec_Wec_t * vCubes, int ObjIdMax, int nNewNodesMax, int LitCountMax, int fVerbose, int fVeryVerbose );
454  Gia_Man_t * pNew = NULL;
455  Vec_Wec_t * vCubes;
456  Vec_Str_t * vCompl;
457 // abctime clk;
458  assert( Gia_ManHasMapping(p) );
459  // collect information
460  vCubes = Gia_ManFxRetrieve( p, &vCompl, fReverse );
461  // call the fast extract procedure
462 // clk = Abc_Clock();
463  Fx_FastExtract( vCubes, Vec_StrSize(vCompl), nNewNodesMax, LitCountMax, fVerbose, fVeryVerbose );
464 // Abc_PrintTime( 1, "Fx runtime", Abc_Clock() - clk );
465  // insert information
466  pNew = Gia_ManFxInsert( p, vCubes, vCompl );
467  Gia_ManTransferTiming( pNew, p );
468  // cleanup
469  Vec_WecFree( vCubes );
470  Vec_StrFree( vCompl );
471  return pNew;
472 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition: vecWec.h:42
static void Vec_WecFree(Vec_Wec_t *p)
Definition: vecWec.h:345
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
void Gia_ManTransferTiming(Gia_Man_t *p, Gia_Man_t *pGia)
Definition: giaIf.c:1912
Gia_Man_t * Gia_ManFxInsert(Gia_Man_t *p, Vec_Wec_t *vCubes, Vec_Str_t *vCompls)
Definition: giaFx.c:310
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
static int Gia_ManHasMapping(Gia_Man_t *p)
Definition: gia.h:951
int Fx_FastExtract(Vec_Wec_t *vCubes, int ObjIdMax, int nNewNodesMax, int LitCountMax, int fVerbose, int fVeryVerbose)
Definition: abcFx.c:1168
Definition: gia.h:95
Vec_Wec_t * Gia_ManFxRetrieve(Gia_Man_t *p, Vec_Str_t **pvCompl, int fReverse)
Definition: giaFx.c:186
#define assert(ex)
Definition: util_old.h:213
int Gia_ManSopToAig ( Gia_Man_t p,
char *  pSop,
Vec_Int_t vLeaves 
)

Definition at line 70 of file giaFx.c.

71 {
72  int i, iAnd, iSum, Value, nFanins;
73  char * pCube;
74  // get the number of variables
75  nFanins = Kit_PlaGetVarNum(pSop);
76  // go through the cubes of the node's SOP
77  iSum = 0;
78  Kit_PlaForEachCube( pSop, nFanins, pCube )
79  {
80  // create the AND of literals
81  iAnd = 1;
82  Kit_PlaCubeForEachVar( pCube, Value, i )
83  {
84  assert( Vec_IntEntry(vLeaves, i) >= 0 );
85  if ( Value == '1' )
86  iAnd = Gia_ManHashAnd( p, iAnd, Vec_IntEntry(vLeaves, i) );
87  else if ( Value == '0' )
88  iAnd = Gia_ManHashAnd( p, iAnd, Abc_LitNot(Vec_IntEntry(vLeaves, i)) );
89  else assert( Value == '-' );
90  }
91  // add to the sum of cubes
92  iSum = Gia_ManHashOr( p, iSum, iAnd );
93  }
94  // decide whether to complement the result
95  if ( Kit_PlaIsComplement(pSop) )
96  iSum = Abc_LitNot(iSum);
97  return iSum;
98 }
#define Kit_PlaCubeForEachVar(pCube, Value, i)
Definition: kit.h:164
int Kit_PlaIsComplement(char *pSop)
Definition: kitPla.c:160
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Kit_PlaForEachCube(pSop, nFanins, pCube)
Definition: kit.h:162
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
#define assert(ex)
Definition: util_old.h:213
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:611
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
int Kit_PlaGetVarNum(char *pSop)
Definition: kitPla.c:118