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

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Abc_NtkAddPoBuffers (Abc_Ntk_t *pNtk)
 DECLARATIONS ///. More...
 
static Abc_Ntk_tAbc_NtkLogicToNetlist (Abc_Ntk_t *pNtk)
 
static Abc_Ntk_tAbc_NtkAigToLogicSop (Abc_Ntk_t *pNtk)
 
static Abc_Ntk_tAbc_NtkAigToLogicSopBench (Abc_Ntk_t *pNtk)
 
Abc_Ntk_tAbc_NtkToLogic (Abc_Ntk_t *pNtk)
 FUNCTION DEFINITIONS ///. More...
 
Abc_Ntk_tAbc_NtkToNetlist (Abc_Ntk_t *pNtk)
 
Abc_Ntk_tAbc_NtkToNetlistBench (Abc_Ntk_t *pNtk)
 
Abc_Ntk_tAbc_NtkAigToLogicSopNand (Abc_Ntk_t *pNtk)
 

Function Documentation

void Abc_NtkAddPoBuffers ( Abc_Ntk_t pNtk)
static

DECLARATIONS ///.

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

FileName [abcNetlist.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Transforms netlist into a logic network and vice versa.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Adds buffers for each PO.]

Description []

SideEffects []

SeeAlso []

Definition at line 485 of file abcNetlist.c.

486 {
487  Abc_Obj_t * pObj, * pFanin, * pFaninNew;
488  int i;
489  assert( Abc_NtkIsStrash(pNtk) );
490  Abc_NtkForEachPo( pNtk, pObj, i )
491  {
492  pFanin = Abc_ObjChild0(pObj);
493  pFaninNew = Abc_NtkCreateNode(pNtk);
494  Abc_ObjAddFanin( pFaninNew, pFanin );
495  Abc_ObjPatchFanin( pObj, pFanin, pFaninNew );
496  }
497 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
static Abc_Obj_t * Abc_ObjChild0(Abc_Obj_t *pObj)
Definition: abc.h:383
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition: abcFanio.c:172
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
Abc_Ntk_t * Abc_NtkAigToLogicSop ( Abc_Ntk_t pNtk)
static

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

Synopsis [Converts the AIG into the logic network with SOPs.]

Description [Correctly handles the case of choice nodes.]

SideEffects []

SeeAlso []

Definition at line 243 of file abcNetlist.c.

244 {
245  extern int Abc_NtkLogicMakeSimpleCos2( Abc_Ntk_t * pNtk, int fDuplicate );
246 
247  Abc_Ntk_t * pNtkNew;
248  Abc_Obj_t * pObj, * pFanin, * pNodeNew;
249  Vec_Int_t * vInts;
250  int i, k, fChoices = 0;
251  assert( Abc_NtkIsStrash(pNtk) );
252  // start the network
253  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
254  // if the constant node is used, duplicate it
255  pObj = Abc_AigConst1(pNtk);
256  if ( Abc_ObjFanoutNum(pObj) > 0 )
257  pObj->pCopy = Abc_NtkCreateNodeConst1(pNtkNew);
258  // duplicate the nodes and create node functions
259  Abc_NtkForEachNode( pNtk, pObj, i )
260  {
261  Abc_NtkDupObj(pNtkNew, pObj, 0);
262  pObj->pCopy->pData = Abc_SopCreateAnd2( (Mem_Flex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
263  }
264  // create the choice nodes
265  Abc_NtkForEachNode( pNtk, pObj, i )
266  {
267  if ( !Abc_AigNodeIsChoice(pObj) )
268  continue;
269  // create an OR gate
270  pNodeNew = Abc_NtkCreateNode(pNtkNew);
271  // add fanins
272  vInts = Vec_IntAlloc( 10 );
273  for ( pFanin = pObj; pFanin; pFanin = (Abc_Obj_t *)pFanin->pData )
274  {
275  Vec_IntPush( vInts, (int)(pObj->fPhase != pFanin->fPhase) );
276  Abc_ObjAddFanin( pNodeNew, pFanin->pCopy );
277  }
278  // create the logic function
279  pNodeNew->pData = Abc_SopCreateOrMultiCube( (Mem_Flex_t *)pNtkNew->pManFunc, Vec_IntSize(vInts), Vec_IntArray(vInts) );
280  // set the new node
281  pObj->pCopy->pCopy = pNodeNew;
282  Vec_IntFree( vInts );
283  fChoices = 1;
284  }
285  // connect the internal nodes
286  Abc_NtkForEachNode( pNtk, pObj, i )
287  Abc_ObjForEachFanin( pObj, pFanin, k )
288  if ( pFanin->pCopy->pCopy )
289  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy->pCopy );
290  else
291  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
292  // connect the COs
293 // Abc_NtkFinalize( pNtk, pNtkNew );
294  Abc_NtkForEachCo( pNtk, pObj, i )
295  {
296  pFanin = Abc_ObjFanin0(pObj);
297  if ( pFanin->pCopy->pCopy )
298  pNodeNew = Abc_ObjNotCond(pFanin->pCopy->pCopy, Abc_ObjFaninC0(pObj));
299  else
300  pNodeNew = Abc_ObjNotCond(pFanin->pCopy, Abc_ObjFaninC0(pObj));
301  Abc_ObjAddFanin( pObj->pCopy, pNodeNew );
302  }
303 
304  // fix the problem with complemented and duplicated CO edges
305  if ( fChoices )
306  Abc_NtkLogicMakeSimpleCos2( pNtkNew, 0 );
307  else
308  Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
309  // duplicate the EXDC Ntk
310  if ( pNtk->pExdc )
311  {
312  if ( Abc_NtkIsStrash(pNtk->pExdc) )
313  pNtkNew->pExdc = Abc_NtkAigToLogicSop( pNtk->pExdc );
314  else
315  pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
316  }
317  if ( !Abc_NtkCheck( pNtkNew ) )
318  fprintf( stdout, "Abc_NtkAigToLogicSop(): Network check has failed.\n" );
319  return pNtkNew;
320 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
int Abc_NtkLogicMakeSimpleCos2(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:954
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
Abc_Ntk_t * pExdc
Definition: abc.h:201
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
ABC_DLL char * Abc_SopCreateAnd2(Mem_Flex_t *pMan, int fCompl0, int fCompl1)
Definition: abcSop.c:139
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
void * pManFunc
Definition: abc.h:191
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
static Abc_Ntk_t * Abc_NtkAigToLogicSop(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:243
Abc_Obj_t * pCopy
Definition: abc.h:148
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
static int Abc_AigNodeIsChoice(Abc_Obj_t *pNode)
Definition: abc.h:398
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
ABC_DLL char * Abc_SopCreateOrMultiCube(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:228
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
unsigned fPhase
Definition: abc.h:137
Abc_Ntk_t * Abc_NtkAigToLogicSopBench ( Abc_Ntk_t pNtk)
static

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

Synopsis [Converts the AIG into the logic network with SOPs for bench writing.]

Description [This procedure does not copy the choices.]

SideEffects []

SeeAlso []

Definition at line 333 of file abcNetlist.c.

334 {
335  Abc_Ntk_t * pNtkNew;
336  Abc_Obj_t * pObj, * pFanin;
337  Vec_Ptr_t * vNodes;
338  int i, k;
339  assert( Abc_NtkIsStrash(pNtk) );
340  if ( Abc_NtkGetChoiceNum(pNtk) )
341  printf( "Warning: Choice nodes are skipped.\n" );
342  // start the network
343  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
344  // collect the nodes to be used (marks all nodes with current TravId)
345  vNodes = Abc_NtkDfs( pNtk, 0 );
346  // create inverters for the constant node
347  pObj = Abc_AigConst1(pNtk);
348  if ( Abc_ObjFanoutNum(pObj) > 0 )
349  pObj->pCopy = Abc_NtkCreateNodeConst1(pNtkNew);
351  pObj->pCopy->pCopy = Abc_NtkCreateNodeInv( pNtkNew, pObj->pCopy );
352  // create inverters for the CIs
353  Abc_NtkForEachCi( pNtk, pObj, i )
355  pObj->pCopy->pCopy = Abc_NtkCreateNodeInv( pNtkNew, pObj->pCopy );
356  // duplicate the nodes, create node functions, and inverters
357  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
358  {
359  Abc_NtkDupObj( pNtkNew, pObj, 0 );
360  pObj->pCopy->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, 2, NULL );
362  pObj->pCopy->pCopy = Abc_NtkCreateNodeInv( pNtkNew, pObj->pCopy );
363  }
364  // connect the objects
365  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
366  Abc_ObjForEachFanin( pObj, pFanin, k )
367  {
368  if ( Abc_ObjFaninC( pObj, k ) )
369  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy->pCopy );
370  else
371  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
372  }
373  Vec_PtrFree( vNodes );
374  // connect the COs
375  Abc_NtkForEachCo( pNtk, pObj, i )
376  {
377  pFanin = Abc_ObjFanin0(pObj);
378  if ( Abc_ObjFaninC0( pObj ) )
379  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy->pCopy );
380  else
381  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
382  }
383  // fix the problem with complemented and duplicated CO edges
384  Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
385  // duplicate the EXDC Ntk
386  if ( pNtk->pExdc )
387  printf( "Warning: The EXDc network is skipped.\n" );
388  if ( !Abc_NtkCheck( pNtkNew ) )
389  fprintf( stdout, "Abc_NtkAigToLogicSopBench(): Network check has failed.\n" );
390  return pNtkNew;
391 }
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
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
Abc_Ntk_t * pExdc
Definition: abc.h:201
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
ABC_DLL char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:162
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
if(last==0)
Definition: sparse_int.h:34
ABC_DLL int Abc_AigNodeHasComplFanoutEdgeTrav(Abc_Obj_t *pNode)
Definition: abcAig.c:1251
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
static int Abc_ObjFaninC(Abc_Obj_t *pObj, int i)
Definition: abc.h:379
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_Ntk_t* Abc_NtkAigToLogicSopNand ( Abc_Ntk_t pNtk)

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

Synopsis [Converts the AIG into the logic network with SOPs for bench writing.]

Description [This procedure does not copy the choices.]

SideEffects []

SeeAlso []

Definition at line 404 of file abcNetlist.c.

405 {
406  Abc_Ntk_t * pNtkNew;
407  Abc_Obj_t * pObj, * pFanin;
408  Vec_Ptr_t * vNodes;
409  int i, k;
410  assert( Abc_NtkIsStrash(pNtk) );
411  if ( Abc_NtkGetChoiceNum(pNtk) )
412  printf( "Warning: Choice nodes are skipped.\n" );
413  // convert complemented edges
414  Abc_NtkForEachObj( pNtk, pObj, i )
415  Abc_ObjForEachFanin( pObj, pFanin, k )
416  if ( Abc_ObjIsNode(pFanin) )
417  Abc_ObjXorFaninC( pObj, k );
418  // start the network
419  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
420  // collect the nodes to be used (marks all nodes with current TravId)
421  vNodes = Abc_NtkDfs( pNtk, 0 );
422  // create inverters for the constant node
423  pObj = Abc_AigConst1(pNtk);
424  if ( Abc_ObjFanoutNum(pObj) > 0 )
425  pObj->pCopy = Abc_NtkCreateNodeConst1(pNtkNew);
427  pObj->pCopy->pCopy = Abc_NtkCreateNodeInv( pNtkNew, pObj->pCopy );
428  // create inverters for the CIs
429  Abc_NtkForEachCi( pNtk, pObj, i )
431  pObj->pCopy->pCopy = Abc_NtkCreateNodeInv( pNtkNew, pObj->pCopy );
432  // duplicate the nodes, create node functions, and inverters
433  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
434  {
435  Abc_NtkDupObj( pNtkNew, pObj, 0 );
436  pObj->pCopy->pData = Abc_SopCreateNand( (Mem_Flex_t *)pNtkNew->pManFunc, 2 );
438  pObj->pCopy->pCopy = Abc_NtkCreateNodeInv( pNtkNew, pObj->pCopy );
439  }
440  // connect the objects
441  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
442  Abc_ObjForEachFanin( pObj, pFanin, k )
443  {
444  if ( Abc_ObjFaninC( pObj, k ) )
445  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy->pCopy );
446  else
447  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
448  }
449  Vec_PtrFree( vNodes );
450  // connect the COs
451  Abc_NtkForEachCo( pNtk, pObj, i )
452  {
453  pFanin = Abc_ObjFanin0(pObj);
454  if ( Abc_ObjFaninC0( pObj ) )
455  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy->pCopy );
456  else
457  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
458  }
459  // fix the problem with complemented and duplicated CO edges
460  Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
461  // convert complemented edges
462  Abc_NtkForEachObj( pNtk, pObj, i )
463  Abc_ObjForEachFanin( pObj, pFanin, k )
464  if ( Abc_ObjIsNode(pFanin) )
465  Abc_ObjXorFaninC( pObj, k );
466  // duplicate the EXDC Ntk
467  if ( pNtk->pExdc )
468  printf( "Warning: The EXDc network is skipped.\n" );
469  if ( !Abc_NtkCheck( pNtkNew ) )
470  fprintf( stdout, "Abc_NtkAigToLogicSopBench(): Network check has failed.\n" );
471  return pNtkNew;
472 }
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
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
ABC_DLL char * Abc_SopCreateNand(Mem_Flex_t *pMan, int nVars)
Definition: abcSop.c:184
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
static void check(int expr)
Definition: satSolver.c:46
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
if(last==0)
Definition: sparse_int.h:34
static Abc_Ntk_t * Abc_NtkAigToLogicSopBench(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:333
ABC_DLL int Abc_AigNodeHasComplFanoutEdgeTrav(Abc_Obj_t *pNode)
Definition: abcAig.c:1251
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
static int Abc_ObjFaninC(Abc_Obj_t *pObj, int i)
Definition: abc.h:379
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static void Abc_ObjXorFaninC(Abc_Obj_t *pObj, int i)
Definition: abc.h:381
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Abc_Ntk_t * Abc_NtkLogicToNetlist ( Abc_Ntk_t pNtk)
static

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

Synopsis [Transform the logic network into a netlist.]

Description [The logic network given to this procedure should have exactly the same structure as the resulting netlist. The COs can only point to CIs if they have identical names. Otherwise, they should have a node between them, even if this node is inverter or buffer.]

SideEffects []

SeeAlso []

Definition at line 147 of file abcNetlist.c.

148 {
149  Abc_Ntk_t * pNtkNew;
150  Abc_Obj_t * pObj, * pNet, * pDriver, * pFanin;
151  int i, k;
152 
153  assert( Abc_NtkIsLogic(pNtk) );
154 
155  // remove dangling nodes
156  Abc_NtkCleanup( pNtk, 0 );
157 
158  // make sure the CO names are unique
162 
163 // assert( Abc_NtkLogicHasSimpleCos(pNtk) );
164  if ( !Abc_NtkLogicHasSimpleCos(pNtk) )
165  {
166  if ( !Abc_FrameReadFlag("silentmode") )
167  printf( "Abc_NtkLogicToNetlist() warning: The network is converted to have simple COs.\n" );
168  Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
169  }
170 
171  // start the netlist by creating PI/PO/Latch objects
172  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_NETLIST, pNtk->ntkFunc );
173  // create the CI nets and remember them in the new CI nodes
174  Abc_NtkForEachCi( pNtk, pObj, i )
175  {
176  pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) );
177  Abc_ObjAddFanin( pNet, pObj->pCopy );
178  pObj->pCopy->pCopy = pNet;
179  }
180  // duplicate all nodes
181  Abc_NtkForEachNode( pNtk, pObj, i )
182  Abc_NtkDupObj(pNtkNew, pObj, 0);
183  // first add the nets to the CO drivers
184  Abc_NtkForEachCo( pNtk, pObj, i )
185  {
186  pDriver = Abc_ObjFanin0(pObj);
187  if ( Abc_ObjIsCi(pDriver) )
188  {
189  assert( !strcmp( Abc_ObjName(pDriver), Abc_ObjName(pObj) ) );
190  Abc_ObjAddFanin( pObj->pCopy, pDriver->pCopy->pCopy );
191  continue;
192  }
193  assert( Abc_ObjIsNode(pDriver) );
194  // if the CO driver has no net, create it
195  if ( pDriver->pCopy->pCopy == NULL )
196  {
197  // create the CO net and connect it to CO
198  pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) );
199  Abc_ObjAddFanin( pObj->pCopy, pNet );
200  // connect the CO net to the new driver and remember it in the new driver
201  Abc_ObjAddFanin( pNet, pDriver->pCopy );
202  pDriver->pCopy->pCopy = pNet;
203  }
204  else
205  {
206  assert( !strcmp( Abc_ObjName(pDriver->pCopy->pCopy), Abc_ObjName(pObj) ) );
207  Abc_ObjAddFanin( pObj->pCopy, pDriver->pCopy->pCopy );
208  }
209  }
210  // create the missing nets
211  Abc_NtkForEachNode( pNtk, pObj, i )
212  {
213  if ( pObj->pCopy->pCopy ) // the net of the new object is already created
214  continue;
215  // create the new net
216  pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) ); // here we create ridiculous names net line "n48", where 48 is the ID of the node
217  Abc_ObjAddFanin( pNet, pObj->pCopy );
218  pObj->pCopy->pCopy = pNet;
219  }
220  // connect nodes to the fanins nets
221  Abc_NtkForEachNode( pNtk, pObj, i )
222  Abc_ObjForEachFanin( pObj, pFanin, k )
223  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy->pCopy );
224  // duplicate EXDC
225  if ( pNtk->pExdc )
226  pNtkNew->pExdc = Abc_NtkToNetlist( pNtk->pExdc );
227  if ( !Abc_NtkCheck( pNtkNew ) )
228  fprintf( stdout, "Abc_NtkLogicToNetlist(): Network check has failed.\n" );
229  return pNtkNew;
230 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
ABC_DLL int Abc_NtkLogicHasSimpleCos(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:909
static Abc_Ntk_t * Abc_NtkLogicToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:147
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL int Abc_NtkCheckUniqueCioNames(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:919
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL int Abc_NtkCleanup(Abc_Ntk_t *pNtk, int fVerbose)
Definition: abcSweep.c:476
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:97
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
int strcmp()
static void check(int expr)
Definition: satSolver.c:46
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_DLL int Abc_NtkCheckUniqueCoNames(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:885
if(last==0)
Definition: sparse_int.h:34
ABC_DLL int Abc_NtkCheckUniqueCiNames(Abc_Ntk_t *pNtk)
Definition: abcCheck.c:854
ABC_DLL Abc_Obj_t * Abc_NtkFindOrCreateNet(Abc_Ntk_t *pNtk, char *pName)
Definition: abcObj.c:579
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
Abc_NtkFunc_t ntkFunc
Definition: abc.h:157
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define assert(ex)
Definition: util_old.h:213
ABC_DLL char * Abc_FrameReadFlag(char *pFlag)
Definition: mainFrame.c:64
Abc_Ntk_t* Abc_NtkToLogic ( Abc_Ntk_t pNtk)

FUNCTION DEFINITIONS ///.

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

Synopsis [Transform the netlist into a logic network.]

Description []

SideEffects []

SeeAlso []

Definition at line 52 of file abcNetlist.c.

53 {
54  Abc_Ntk_t * pNtkNew;
55  Abc_Obj_t * pObj, * pFanin;
56  int i, k;
57  // consider the case of the AIG
58  if ( Abc_NtkIsStrash(pNtk) )
59  return Abc_NtkAigToLogicSop( pNtk );
60  assert( Abc_NtkIsNetlist(pNtk) );
61  // consider simple case when there is hierarchy
62 // assert( pNtk->pDesign == NULL );
63  assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
64  assert( Abc_NtkBlackboxNum(pNtk) == 0 );
65  // start the network
66  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, pNtk->ntkFunc );
67  // duplicate the nodes
68  Abc_NtkForEachNode( pNtk, pObj, i )
69  Abc_NtkDupObj(pNtkNew, pObj, 0);
70  // reconnect the internal nodes in the new network
71  Abc_NtkForEachNode( pNtk, pObj, i )
72  Abc_ObjForEachFanin( pObj, pFanin, k )
73  Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFanin0(pFanin)->pCopy );
74  // collect the CO nodes
75  Abc_NtkFinalize( pNtk, pNtkNew );
76  // fix the problem with CO pointing directly to CIs
77  Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
78  // duplicate EXDC
79  if ( pNtk->pExdc )
80  pNtkNew->pExdc = Abc_NtkToLogic( pNtk->pExdc );
81  if ( !Abc_NtkCheck( pNtkNew ) )
82  fprintf( stdout, "Abc_NtkToLogic(): Network check has failed.\n" );
83  return pNtkNew;
84 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
Abc_Ntk_t * Abc_NtkToLogic(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcNetlist.c:52
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static int Abc_NtkWhiteboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:295
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
static void check(int expr)
Definition: satSolver.c:46
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
static Abc_Ntk_t * Abc_NtkAigToLogicSop(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:243
if(last==0)
Definition: sparse_int.h:34
ABC_DLL void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition: abcNtk.c:302
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
Abc_NtkFunc_t ntkFunc
Definition: abc.h:157
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define assert(ex)
Definition: util_old.h:213
static int Abc_NtkBlackboxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:296
Abc_Ntk_t* Abc_NtkToNetlist ( Abc_Ntk_t pNtk)

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

Synopsis [Transform the logic network into a netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file abcNetlist.c.

98 {
99  Abc_Ntk_t * pNtkNew, * pNtkTemp;
100  assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) );
101  if ( Abc_NtkIsStrash(pNtk) )
102  {
103  pNtkTemp = Abc_NtkAigToLogicSop(pNtk);
104  pNtkNew = Abc_NtkLogicToNetlist( pNtkTemp );
105  Abc_NtkDelete( pNtkTemp );
106  return pNtkNew;
107  }
108  return Abc_NtkLogicToNetlist( pNtk );
109 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static Abc_Ntk_t * Abc_NtkLogicToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:147
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static Abc_Ntk_t * Abc_NtkAigToLogicSop(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:243
#define assert(ex)
Definition: util_old.h:213
Abc_Ntk_t* Abc_NtkToNetlistBench ( Abc_Ntk_t pNtk)

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

Synopsis [Converts the AIG into the netlist.]

Description [This procedure does not copy the choices.]

SideEffects []

SeeAlso []

Definition at line 122 of file abcNetlist.c.

123 {
124  Abc_Ntk_t * pNtkNew, * pNtkTemp;
125  assert( Abc_NtkIsStrash(pNtk) );
126  pNtkTemp = Abc_NtkAigToLogicSopBench( pNtk );
127  pNtkNew = Abc_NtkLogicToNetlist( pNtkTemp );
128  Abc_NtkDelete( pNtkTemp );
129  return pNtkNew;
130 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static Abc_Ntk_t * Abc_NtkLogicToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:147
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static Abc_Ntk_t * Abc_NtkAigToLogicSopBench(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:333
#define assert(ex)
Definition: util_old.h:213