abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcDress2.c File Reference
#include "base/abc/abc.h"
#include "aig/aig/aig.h"
#include "proof/dch/dch.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Abc_ObjEquivId2ObjId (int EquivId)
 
int Abc_ObjEquivId2Polar (int EquivId)
 
int Abc_ObjEquivId2NtkId (int EquivId)
 
Aig_Man_tAbc_NtkToDar (Abc_Ntk_t *pNtk, int fExors, int fRegisters)
 DECLARATIONS ///. More...
 
void Dch_ComputeEquivalences (Aig_Man_t *pAig, Dch_Pars_t *pPars)
 
Aig_Man_tAig_ManCreateDualOutputMiter (Aig_Man_t *p1, Aig_Man_t *p2)
 FUNCTION DEFINITIONS ///. More...
 
void Abc_NtkDressMapSetPolarity (Abc_Ntk_t *pNtk)
 
Vec_Int_tAbc_NtkDressMapClasses (Aig_Man_t *pMiter, Abc_Ntk_t *pNtk)
 
Vec_Int_tAbc_ObjDressClass (Vec_Ptr_t *vRes, Vec_Int_t *vClass2Num, int Class)
 
int Abc_ObjDressMakeId (Abc_Ntk_t *pNtk, int ObjId, int iNtk)
 
Vec_Ptr_tAbc_NtkDressMapIds (Aig_Man_t *pMiter, Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2)
 
Vec_Ptr_tAbc_NtkDressComputeEquivs (Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int nConflictLimit, int fVerbose)
 
void Abc_NtkDressPrintEquivs (Vec_Ptr_t *vRes)
 
void Abc_NtkDressPrintStats (Vec_Ptr_t *vRes, int nNodes0, int nNodes1, abctime Time)
 
void Abc_NtkDress2 (Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int nConflictLimit, int fVerbose)
 

Function Documentation

void Abc_NtkDress2 ( Abc_Ntk_t pNtk1,
Abc_Ntk_t pNtk2,
int  nConflictLimit,
int  fVerbose 
)

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

Synopsis [Transfers names from pNtk1 to pNtk2.]

Description [Internally calls new procedure for mapping node IDs of both networks into the shared equivalence classes.]

SideEffects []

SeeAlso []

Definition at line 419 of file abcDress2.c.

420 {
421  Vec_Ptr_t * vRes;
422  abctime clk = Abc_Clock();
423  vRes = Abc_NtkDressComputeEquivs( pNtk1, pNtk2, nConflictLimit, fVerbose );
424 // Abc_NtkDressPrintEquivs( vRes );
425  Abc_NtkDressPrintStats( vRes, Abc_NtkNodeNum(pNtk1), Abc_NtkNodeNum(pNtk1), Abc_Clock() - clk );
426  Vec_VecFree( (Vec_Vec_t *)vRes );
427 }
void Abc_NtkDressPrintStats(Vec_Ptr_t *vRes, int nNodes0, int nNodes1, abctime Time)
Definition: abcDress2.c:361
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
ABC_INT64_T abctime
Definition: abc_global.h:278
Vec_Ptr_t * Abc_NtkDressComputeEquivs(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int nConflictLimit, int fVerbose)
Definition: abcDress2.c:290
Vec_Ptr_t* Abc_NtkDressComputeEquivs ( Abc_Ntk_t pNtk1,
Abc_Ntk_t pNtk2,
int  nConflictLimit,
int  fVerbose 
)

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

Synopsis [Computes equivalence classes of objects in pNtk1 and pNtk2.]

Description [Returns the array (Vec_Ptr_t) of integer arrays (Vec_Int_t). Each of the integer arrays contains entries of one equivalence class. Each entry contains the following information: the network number (0/1), the polarity (0/1) and the object ID in the the network (0 <= num < MaxId) where MaxId is the largest number of an ID of an object in that network.]

SideEffects []

SeeAlso []

Definition at line 290 of file abcDress2.c.

291 {
292  Dch_Pars_t Pars, * pPars = &Pars;
293  Abc_Ntk_t * pAig1, * pAig2;
294  Aig_Man_t * pMan1, * pMan2, * pMiter;
295  Vec_Ptr_t * vRes;
296  assert( !Abc_NtkIsStrash(pNtk1) );
297  assert( !Abc_NtkIsStrash(pNtk2) );
298  // convert network into AIG
299  pAig1 = Abc_NtkStrash( pNtk1, 1, 1, 0 );
300  pAig2 = Abc_NtkStrash( pNtk2, 1, 1, 0 );
301  pMan1 = Abc_NtkToDar( pAig1, 0, 0 );
302  pMan2 = Abc_NtkToDar( pAig2, 0, 0 );
303  // derive the miter
304  pMiter = Aig_ManCreateDualOutputMiter( pMan1, pMan2 );
305  // set up parameters for SAT sweeping
306  Dch_ManSetDefaultParams( pPars );
307  pPars->nBTLimit = nConflictLimit;
308  pPars->fVerbose = fVerbose;
309  // perform SAT sweeping
310  Dch_ComputeEquivalences( pMiter, pPars );
311  // now, pMiter is annotated with the equivl class info
312  // convert this info into the resulting array
313  vRes = Abc_NtkDressMapIds( pMiter, pNtk1, pNtk2 );
314  Aig_ManStop( pMiter );
315  Aig_ManStop( pMan1 );
316  Aig_ManStop( pMan2 );
317  Abc_NtkDelete( pAig1 );
318  Abc_NtkDelete( pAig2 );
319  return vRes;
320 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Dch_ManSetDefaultParams(Dch_Pars_t *p)
DECLARATIONS ///.
Definition: dchCore.c:45
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
typedefABC_NAMESPACE_HEADER_START struct Dch_Pars_t_ Dch_Pars_t
INCLUDES ///.
Definition: dch.h:43
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
Vec_Ptr_t * Abc_NtkDressMapIds(Aig_Man_t *pMiter, Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2)
Definition: abcDress2.c:225
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
DECLARATIONS ///.
Definition: abcDar.c:233
Aig_Man_t * Aig_ManCreateDualOutputMiter(Aig_Man_t *p1, Aig_Man_t *p2)
FUNCTION DEFINITIONS ///.
Definition: abcDress2.c:82
#define assert(ex)
Definition: util_old.h:213
void Dch_ComputeEquivalences(Aig_Man_t *pAig, Dch_Pars_t *pPars)
Definition: dchCore.c:134
Vec_Int_t* Abc_NtkDressMapClasses ( Aig_Man_t pMiter,
Abc_Ntk_t pNtk 
)

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

Synopsis [Create mapping of node IDs of pNtk into equiv classes of pMiter.]

Description []

SideEffects []

SeeAlso []

Definition at line 146 of file abcDress2.c.

147 {
148  Vec_Int_t * vId2Lit;
149  Abc_Obj_t * pObj, * pAnd;
150  Aig_Obj_t * pObjMan, * pObjMiter, * pObjRepr;
151  int i;
152  vId2Lit = Vec_IntAlloc( 0 );
153  Vec_IntFill( vId2Lit, Abc_NtkObjNumMax(pNtk), -1 );
154  Abc_NtkForEachNode( pNtk, pObj, i )
155  {
156  // get the pointer to the miter node corresponding to pObj
157  if ( (pAnd = Abc_ObjRegular(pObj->pCopy)) && Abc_ObjType(pAnd) != ABC_OBJ_NONE && // strashed node is present and legal
158  (pObjMan = Aig_Regular((Aig_Obj_t *)pAnd->pCopy)) && Aig_ObjType(pObjMan) != AIG_OBJ_NONE && // AIG node is present and legal
159  (pObjMiter = Aig_Regular((Aig_Obj_t *)pObjMan->pData)) && Aig_ObjType(pObjMiter) != AIG_OBJ_NONE ) // miter node is present and legal
160  {
161  // get the representative of the miter node
162  pObjRepr = Aig_ObjRepr( pMiter, pObjMiter );
163  pObjRepr = pObjRepr? pObjRepr : pObjMiter;
164  // map pObj (whose ID is i) into the repr node ID (i.e. equiv class)
165  Vec_IntWriteEntry( vId2Lit, i, Aig_ObjId(pObjRepr) );
166  }
167  }
168  return vId2Lit;
169 }
static Aig_Obj_t * Aig_ObjRepr(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:330
static Aig_Type_t Aig_ObjType(Aig_Obj_t *pObj)
Definition: aig.h:272
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
Abc_Obj_t * pCopy
Definition: abc.h:148
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static unsigned Abc_ObjType(Abc_Obj_t *pObj)
Definition: abc.h:328
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
Definition: aig.h:69
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
Vec_Ptr_t* Abc_NtkDressMapIds ( Aig_Man_t pMiter,
Abc_Ntk_t pNtk1,
Abc_Ntk_t pNtk2 
)

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

Synopsis [Computes equivalence classes of objects in pNtk1 and pNtk2.]

Description [Internal procedure.]

SideEffects []

SeeAlso []

Definition at line 225 of file abcDress2.c.

226 {
227  Vec_Ptr_t * vRes;
228  Vec_Int_t * vId2Lit1, * vId2Lit2, * vCounts0, * vCounts1, * vClassC, * vClass2Num;
229  int i, Class;
230  // start the classes
231  vRes = Vec_PtrAlloc( 1000 );
232  // set polarity of the nodes
235  // create mapping of node IDs of pNtk1/pNtk2 into the IDs of equiv classes of pMiter
236  vId2Lit1 = Abc_NtkDressMapClasses( pMiter, pNtk1 );
237  vId2Lit2 = Abc_NtkDressMapClasses( pMiter, pNtk2 );
238  // count the number of nodes in each equivalence class
239  vCounts0 = Vec_IntStart( Aig_ManObjNumMax(pMiter) );
240  Vec_IntForEachEntry( vId2Lit1, Class, i )
241  if ( Class >= 0 )
242  Vec_IntAddToEntry( vCounts0, Class, 1 );
243  vCounts1 = Vec_IntStart( Aig_ManObjNumMax(pMiter) );
244  Vec_IntForEachEntry( vId2Lit2, Class, i )
245  if ( Class >= 0 )
246  Vec_IntAddToEntry( vCounts1, Class, 1 );
247  // get the costant class
248  vClassC = Vec_IntAlloc( 100 );
249  Vec_IntForEachEntry( vId2Lit1, Class, i )
250  if ( Class == 0 )
251  Vec_IntPush( vClassC, Abc_ObjDressMakeId(pNtk1, i, 0) );
252  Vec_IntForEachEntry( vId2Lit2, Class, i )
253  if ( Class == 0 )
254  Vec_IntPush( vClassC, Abc_ObjDressMakeId(pNtk2, i, 1) );
255  Vec_PtrPush( vRes, vClassC );
256  // map repr node IDs into class numbers
257  vClass2Num = Vec_IntAlloc( 0 );
258  Vec_IntFill( vClass2Num, Aig_ManObjNumMax(pMiter), -1 );
259  // keep classes having at least one element from pNtk1 and one from pNtk2
260  Vec_IntForEachEntry( vId2Lit1, Class, i )
261  if ( Class > 0 && Vec_IntEntry(vCounts0, Class) && Vec_IntEntry(vCounts1, Class) )
262  Vec_IntPush( Abc_ObjDressClass(vRes, vClass2Num, Class), Abc_ObjDressMakeId(pNtk1, i, 0) );
263  Vec_IntForEachEntry( vId2Lit2, Class, i )
264  if ( Class > 0 && Vec_IntEntry(vCounts0, Class) && Vec_IntEntry(vCounts1, Class) )
265  Vec_IntPush( Abc_ObjDressClass(vRes, vClass2Num, Class), Abc_ObjDressMakeId(pNtk2, i, 1) );
266  // package them accordingly
267  Vec_IntFree( vClass2Num );
268  Vec_IntFree( vCounts0 );
269  Vec_IntFree( vCounts1 );
270  Vec_IntFree( vId2Lit1 );
271  Vec_IntFree( vId2Lit2 );
272  return vRes;
273 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
Vec_Int_t * Abc_ObjDressClass(Vec_Ptr_t *vRes, Vec_Int_t *vClass2Num, int Class)
Definition: abcDress2.c:182
Vec_Int_t * Abc_NtkDressMapClasses(Aig_Man_t *pMiter, Abc_Ntk_t *pNtk)
Definition: abcDress2.c:146
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
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
void Abc_NtkDressMapSetPolarity(Abc_Ntk_t *pNtk)
Definition: abcDress2.c:123
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int Abc_ObjDressMakeId(Abc_Ntk_t *pNtk, int ObjId, int iNtk)
Definition: abcDress2.c:209
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void Abc_NtkDressMapSetPolarity ( Abc_Ntk_t pNtk)

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

Synopsis [Sets polarity attribute of each object in the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 123 of file abcDress2.c.

124 {
125  Abc_Obj_t * pObj, * pAnd;
126  int i;
127  // each node refers to the the strash copy whose polarity is set
128  Abc_NtkForEachObj( pNtk, pObj, i )
129  {
130  if ( (pAnd = Abc_ObjRegular(pObj->pCopy)) && Abc_ObjType(pAnd) != ABC_OBJ_NONE ) // strashed object is present and legal
131  pObj->fPhase = pAnd->fPhase ^ Abc_ObjIsComplement(pObj->pCopy);
132  }
133 }
Abc_Obj_t * pCopy
Definition: abc.h:148
static unsigned Abc_ObjType(Abc_Obj_t *pObj)
Definition: abc.h:328
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
unsigned fPhase
Definition: abc.h:137
void Abc_NtkDressPrintEquivs ( Vec_Ptr_t vRes)

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

Synopsis [Prints information about node equivalences.]

Description []

SideEffects []

SeeAlso []

Definition at line 333 of file abcDress2.c.

334 {
335  Vec_Int_t * vClass;
336  int i, k, Entry;
337  Vec_PtrForEachEntry( Vec_Int_t *, vRes, vClass, i )
338  {
339  printf( "Class %5d : ", i );
340  printf( "Num =%5d ", Vec_IntSize(vClass) );
341  Vec_IntForEachEntry( vClass, Entry, k )
342  printf( "%5d%c%d ",
343  Abc_ObjEquivId2ObjId(Entry),
344  Abc_ObjEquivId2Polar(Entry)? '-':'+',
345  Abc_ObjEquivId2NtkId(Entry) );
346  printf( "\n" );
347  }
348 }
int Abc_ObjEquivId2NtkId(int EquivId)
Definition: abcDress2.c:58
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Abc_ObjEquivId2Polar(int EquivId)
Definition: abcDress2.c:57
ABC_NAMESPACE_IMPL_START int Abc_ObjEquivId2ObjId(int EquivId)
Definition: abcDress2.c:56
void Abc_NtkDressPrintStats ( Vec_Ptr_t vRes,
int  nNodes0,
int  nNodes1,
abctime  Time 
)

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

Synopsis [Prints information about node equivalences.]

Description []

SideEffects []

SeeAlso []

Definition at line 361 of file abcDress2.c.

362 {
363  Vec_Int_t * vClass;
364  int i, k, Entry;
365  int NegAll[2] = {0}, PosAll[2] = {0}, PairsAll = 0, PairsOne = 0;
366  int Pos[2], Neg[2];
367  // count the number of equivalences in each class
368  Vec_PtrForEachEntry( Vec_Int_t *, vRes, vClass, i )
369  {
370  Pos[0] = Pos[1] = 0;
371  Neg[0] = Neg[1] = 0;
372  Vec_IntForEachEntry( vClass, Entry, k )
373  {
374  if ( Abc_ObjEquivId2NtkId(Entry) )
375  {
376  if ( Abc_ObjEquivId2Polar(Entry) )
377  Neg[1]++; // negative polarity in network 1
378  else
379  Pos[1]++; // positive polarity in network 1
380  }
381  else
382  {
383  if ( Abc_ObjEquivId2Polar(Entry) )
384  Neg[0]++; // negative polarity in network 0
385  else
386  Pos[0]++; // positive polarity in network 0
387  }
388  }
389  PosAll[0] += Pos[0]; // total positive polarity in network 0
390  PosAll[1] += Pos[1]; // total positive polarity in network 1
391  NegAll[0] += Neg[0]; // total negative polarity in network 0
392  NegAll[1] += Neg[1]; // total negative polarity in network 1
393 
394  // assuming that the name can be transferred to only one node
395  PairsAll += Abc_MinInt(Neg[0] + Pos[0], Neg[1] + Pos[1]);
396  PairsOne += Abc_MinInt(Neg[0], Neg[1]) + Abc_MinInt(Pos[0], Pos[1]);
397  }
398  printf( "Total number of equiv classes = %7d.\n", Vec_PtrSize(vRes) );
399  printf( "Participating nodes from both networks = %7d.\n", NegAll[0]+PosAll[0]+NegAll[1]+PosAll[1] );
400  printf( "Participating nodes from the first network = %7d. (%7.2f %% of nodes)\n", NegAll[0]+PosAll[0], 100.0*(NegAll[0]+PosAll[0])/(nNodes0+1) );
401  printf( "Participating nodes from the second network = %7d. (%7.2f %% of nodes)\n", NegAll[1]+PosAll[1], 100.0*(NegAll[1]+PosAll[1])/(nNodes1+1) );
402  printf( "Node pairs (any polarity) = %7d. (%7.2f %% of names can be moved)\n", PairsAll, 100.0*PairsAll/(nNodes0+1) );
403  printf( "Node pairs (same polarity) = %7d. (%7.2f %% of names can be moved)\n", PairsOne, 100.0*PairsOne/(nNodes0+1) );
404  ABC_PRT( "Total runtime", Time );
405 }
int Abc_ObjEquivId2NtkId(int EquivId)
Definition: abcDress2.c:58
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
ush Pos
Definition: deflate.h:88
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
#define ABC_PRT(a, t)
Definition: abc_global.h:220
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Abc_ObjEquivId2Polar(int EquivId)
Definition: abcDress2.c:57
Aig_Man_t* Abc_NtkToDar ( Abc_Ntk_t pNtk,
int  fExors,
int  fRegisters 
)

DECLARATIONS ///.

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

Synopsis [Converts the network from the AIG manager into ABC.]

Description [Assumes that registers are ordered after PIs/POs.]

SideEffects []

SeeAlso []

Definition at line 233 of file abcDar.c.

234 {
235  Vec_Ptr_t * vNodes;
236  Aig_Man_t * pMan;
237  Aig_Obj_t * pObjNew;
238  Abc_Obj_t * pObj;
239  int i, nNodes, nDontCares;
240  // make sure the latches follow PIs/POs
241  if ( fRegisters )
242  {
243  assert( Abc_NtkBoxNum(pNtk) == Abc_NtkLatchNum(pNtk) );
244  Abc_NtkForEachCi( pNtk, pObj, i )
245  if ( i < Abc_NtkPiNum(pNtk) )
246  {
247  assert( Abc_ObjIsPi(pObj) );
248  if ( !Abc_ObjIsPi(pObj) )
249  Abc_Print( 1, "Abc_NtkToDar(): Temporary bug: The PI ordering is wrong!\n" );
250  }
251  else
252  assert( Abc_ObjIsBo(pObj) );
253  Abc_NtkForEachCo( pNtk, pObj, i )
254  if ( i < Abc_NtkPoNum(pNtk) )
255  {
256  assert( Abc_ObjIsPo(pObj) );
257  if ( !Abc_ObjIsPo(pObj) )
258  Abc_Print( 1, "Abc_NtkToDar(): Temporary bug: The PO ordering is wrong!\n" );
259  }
260  else
261  assert( Abc_ObjIsBi(pObj) );
262  // print warning about initial values
263  nDontCares = 0;
264  Abc_NtkForEachLatch( pNtk, pObj, i )
265  if ( Abc_LatchIsInitDc(pObj) )
266  {
267  Abc_LatchSetInit0(pObj);
268  nDontCares++;
269  }
270  if ( nDontCares )
271  {
272  Abc_Print( 1, "Warning: %d registers in this network have don't-care init values.\n", nDontCares );
273  Abc_Print( 1, "The don't-care are assumed to be 0. The result may not verify.\n" );
274  Abc_Print( 1, "Use command \"print_latch\" to see the init values of registers.\n" );
275  Abc_Print( 1, "Use command \"zero\" to convert or \"init\" to change the values.\n" );
276  }
277  }
278  // create the manager
279  pMan = Aig_ManStart( Abc_NtkNodeNum(pNtk) + 100 );
280  pMan->fCatchExor = fExors;
281  pMan->nConstrs = pNtk->nConstrs;
282  pMan->nBarBufs = pNtk->nBarBufs;
283  pMan->pName = Extra_UtilStrsav( pNtk->pName );
284  pMan->pSpec = Extra_UtilStrsav( pNtk->pSpec );
285  // transfer the pointers to the basic nodes
286  Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)Aig_ManConst1(pMan);
287  Abc_NtkForEachCi( pNtk, pObj, i )
288  {
289  pObj->pCopy = (Abc_Obj_t *)Aig_ObjCreateCi(pMan);
290  // initialize logic level of the CIs
291  ((Aig_Obj_t *)pObj->pCopy)->Level = pObj->Level;
292  }
293  // complement the 1-values registers
294  if ( fRegisters ) {
295  Abc_NtkForEachLatch( pNtk, pObj, i )
296  if ( Abc_LatchIsInit1(pObj) )
297  Abc_ObjFanout0(pObj)->pCopy = Abc_ObjNot(Abc_ObjFanout0(pObj)->pCopy);
298  }
299  // perform the conversion of the internal nodes (assumes DFS ordering)
300 // pMan->fAddStrash = 1;
301  vNodes = Abc_NtkDfs( pNtk, 0 );
302  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
303 // Abc_NtkForEachNode( pNtk, pObj, i )
304  {
305  pObj->pCopy = (Abc_Obj_t *)Aig_And( pMan, (Aig_Obj_t *)Abc_ObjChild0Copy(pObj), (Aig_Obj_t *)Abc_ObjChild1Copy(pObj) );
306 // Abc_Print( 1, "%d->%d ", pObj->Id, ((Aig_Obj_t *)pObj->pCopy)->Id );
307  }
308  Vec_PtrFree( vNodes );
309  pMan->fAddStrash = 0;
310  // create the POs
311  Abc_NtkForEachCo( pNtk, pObj, i )
312  Aig_ObjCreateCo( pMan, (Aig_Obj_t *)Abc_ObjChild0Copy(pObj) );
313  // complement the 1-valued registers
314  Aig_ManSetRegNum( pMan, Abc_NtkLatchNum(pNtk) );
315  if ( fRegisters )
316  Aig_ManForEachLiSeq( pMan, pObjNew, i )
318  pObjNew->pFanin0 = Aig_Not(pObjNew->pFanin0);
319  // remove dangling nodes
320  nNodes = (Abc_NtkGetChoiceNum(pNtk) == 0)? Aig_ManCleanup( pMan ) : 0;
321  if ( !fExors && nNodes )
322  Abc_Print( 1, "Abc_NtkToDar(): Unexpected %d dangling nodes when converting to AIG!\n", nNodes );
323 //Aig_ManDumpVerilog( pMan, "test.v" );
324  // save the number of registers
325  if ( fRegisters )
326  {
327  Aig_ManSetRegNum( pMan, Abc_NtkLatchNum(pNtk) );
328  pMan->vFlopNums = Vec_IntStartNatural( pMan->nRegs );
329 // pMan->vFlopNums = NULL;
330 // pMan->vOnehots = Abc_NtkConverLatchNamesIntoNumbers( pNtk );
331  if ( pNtk->vOnehots )
332  pMan->vOnehots = (Vec_Ptr_t *)Vec_VecDupInt( (Vec_Vec_t *)pNtk->vOnehots );
333  }
334  if ( !Aig_ManCheck( pMan ) )
335  {
336  Abc_Print( 1, "Abc_NtkToDar: AIG check has failed.\n" );
337  Aig_ManStop( pMan );
338  return NULL;
339  }
340  return pMan;
341 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL int Aig_ManCheck(Aig_Man_t *p)
FUNCTION DECLARATIONS ///.
Definition: aigCheck.c:45
unsigned Level
Definition: aig.h:82
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static int Abc_ObjIsBo(Abc_Obj_t *pObj)
Definition: abc.h:350
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
static int Abc_NtkBoxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:289
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
static Abc_Obj_t * Abc_ObjChild1Copy(Abc_Obj_t *pObj)
Definition: abc.h:387
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_ObjIsPi(Abc_Obj_t *pObj)
Definition: abc.h:347
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Definition: aig.h:247
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static Vec_Int_t * Vec_IntStartNatural(int nSize)
Definition: bblif.c:192
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
unsigned Level
Definition: abc.h:142
char * Extra_UtilStrsav(const char *s)
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static Abc_Obj_t * Abc_NtkCo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:318
static Vec_Vec_t * Vec_VecDupInt(Vec_Vec_t *p)
Definition: vecVec.h:395
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
static Abc_Obj_t * Abc_ObjChild0Copy(Abc_Obj_t *pObj)
Definition: abc.h:386
Abc_Obj_t * pCopy
Definition: abc.h:148
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
Definition: aigMan.c:438
static int Abc_LatchIsInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:424
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static int Abc_ObjIsBi(Abc_Obj_t *pObj)
Definition: abc.h:349
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
static int Abc_ObjIsPo(Abc_Obj_t *pObj)
Definition: abc.h:348
#define assert(ex)
Definition: util_old.h:213
#define Aig_ManForEachLiSeq(p, pObj, i)
Definition: aig.h:447
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
Definition: abc.h:324
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Abc_LatchSetInit0(Abc_Obj_t *pLatch)
Definition: abc.h:418
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
DECLARATIONS ///.
Definition: abcDar.c:233
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Vec_Int_t* Abc_ObjDressClass ( Vec_Ptr_t vRes,
Vec_Int_t vClass2Num,
int  Class 
)

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

Synopsis [Returns the vector of given equivalence class of objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 182 of file abcDress2.c.

183 {
184  int ClassNumber;
185  assert( Class > 0 );
186  ClassNumber = Vec_IntEntry( vClass2Num, Class );
187  assert( ClassNumber != 0 );
188  if ( ClassNumber > 0 )
189  return (Vec_Int_t *)Vec_PtrEntry( vRes, ClassNumber ); // previous class
190  // create new class
191  Vec_IntWriteEntry( vClass2Num, Class, Vec_PtrSize(vRes) );
192  Vec_PtrPush( vRes, Vec_IntAlloc(4) );
193  return (Vec_Int_t *)Vec_PtrEntryLast( vRes );
194 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define assert(ex)
Definition: util_old.h:213
int Abc_ObjDressMakeId ( Abc_Ntk_t pNtk,
int  ObjId,
int  iNtk 
)

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

Synopsis [Returns the ID of a node in an equivalence class.]

Description [The ID is composed of three parts: object ID, followed by one bit telling the phase of this node, followed by one bit telling the network to which this node belongs.]

SideEffects []

SeeAlso []

Definition at line 209 of file abcDress2.c.

210 {
211  return (ObjId << 2) | (Abc_NtkObj(pNtk,ObjId)->fPhase << 1) | iNtk;
212 }
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
unsigned fPhase
Definition: abc.h:137
int Abc_ObjEquivId2NtkId ( int  EquivId)

Definition at line 58 of file abcDress2.c.

58 { return EquivId & 1; }
int Abc_ObjEquivId2ObjId ( int  EquivId)

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

FileName [abcDressw.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Transfers names from one netlist to the other.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 56 of file abcDress2.c.

56 { return EquivId >> 2; }
int Abc_ObjEquivId2Polar ( int  EquivId)

Definition at line 57 of file abcDress2.c.

57 { return (EquivId >> 1) & 1; }
Aig_Man_t* Aig_ManCreateDualOutputMiter ( Aig_Man_t p1,
Aig_Man_t p2 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Creates the dual-output miter.]

Description []

SideEffects []

SeeAlso []

Definition at line 82 of file abcDress2.c.

83 {
84  Aig_Man_t * pNew;
85  Aig_Obj_t * pObj;
86  int i;
87  assert( Aig_ManCiNum(p1) == Aig_ManCiNum(p2) );
88  assert( Aig_ManCoNum(p1) == Aig_ManCoNum(p2) );
90  // add first AIG
91  Aig_ManConst1(p1)->pData = Aig_ManConst1(pNew);
92  Aig_ManForEachCi( p1, pObj, i )
93  pObj->pData = Aig_ObjCreateCi( pNew );
94  Aig_ManForEachNode( p1, pObj, i )
95  pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
96  // add second AIG
97  Aig_ManConst1(p2)->pData = Aig_ManConst1(pNew);
98  Aig_ManForEachCi( p2, pObj, i )
99  pObj->pData = Aig_ManCi( pNew, i );
100  Aig_ManForEachNode( p2, pObj, i )
101  pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
102  // add the outputs
103  for ( i = 0; i < Aig_ManCoNum(p1); i++ )
104  {
107  }
108  Aig_ManCleanup( pNew );
109  return pNew;
110 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void * pData
Definition: aig.h:87
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
for(p=first;p->value< newval;p=p->next)
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
Definition: aig.h:69
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
#define assert(ex)
Definition: util_old.h:213
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
void Dch_ComputeEquivalences ( Aig_Man_t pAig,
Dch_Pars_t pPars 
)

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

Synopsis [Performs computation of AIGs with choices.]

Description [Takes several AIGs and performs choicing.]

SideEffects []

SeeAlso []

Definition at line 134 of file dchCore.c.

135 {
136  Dch_Man_t * p;
137  abctime clk, clkTotal = Abc_Clock();
138  // reset random numbers
139  Aig_ManRandom(1);
140  // start the choicing manager
141  p = Dch_ManCreate( pAig, pPars );
142  // compute candidate equivalence classes
143 clk = Abc_Clock();
144  p->ppClasses = Dch_CreateCandEquivClasses( pAig, pPars->nWords, pPars->fVerbose );
145 p->timeSimInit = Abc_Clock() - clk;
146 // Dch_ClassesPrint( p->ppClasses, 0 );
147  p->nLits = Dch_ClassesLitNum( p->ppClasses );
148  // perform SAT sweeping
149  Dch_ManSweep( p );
150  // free memory ahead of time
151 p->timeTotal = Abc_Clock() - clkTotal;
152  Dch_ManStop( p );
153 }
int Dch_ClassesLitNum(Dch_Cla_t *p)
Definition: dchClass.c:206
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Dch_ManStop(Dch_Man_t *p)
Definition: dchMan.c:122
void Dch_ManSweep(Dch_Man_t *p)
Definition: dchSweep.c:106
unsigned Aig_ManRandom(int fReset)
Definition: aigUtil.c:1157
static abctime Abc_Clock()
Definition: abc_global.h:279
Dch_Cla_t * Dch_CreateCandEquivClasses(Aig_Man_t *pAig, int nWords, int fVerbose)
Definition: dchSim.c:264
int nLits
Definition: dchInt.h:82
Dch_Man_t * Dch_ManCreate(Aig_Man_t *pAig, Dch_Pars_t *pPars)
DECLARATIONS ///.
Definition: dchMan.c:45
Dch_Cla_t * ppClasses
Definition: dchInt.h:60
abctime timeTotal
Definition: dchInt.h:95
abctime timeSimInit
Definition: dchInt.h:87
ABC_INT64_T abctime
Definition: abc_global.h:278