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

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START
stmm_table
Abc_NtkDressDeriveMapping (Abc_Ntk_t *pNtk)
 DECLARATIONS ///. More...
 
static void Abc_NtkDressTransferNames (Abc_Ntk_t *pNtk, stmm_table *tMapping, int fVerbose)
 
Abc_Ntk_tAbc_NtkIvyFraig (Abc_Ntk_t *pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fVerbose)
 
void Abc_NtkDress (Abc_Ntk_t *pNtkLogic, char *pFileName, int fVerbose)
 FUNCTION DEFINITIONS ///. More...
 

Function Documentation

void Abc_NtkDress ( Abc_Ntk_t pNtkLogic,
char *  pFileName,
int  fVerbose 
)

FUNCTION DEFINITIONS ///.

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file abcDress.c.

52 {
53  Abc_Ntk_t * pNtkOrig, * pNtkLogicOrig;
54  Abc_Ntk_t * pMiter, * pMiterFraig;
55  stmm_table * tMapping;
56 
57  assert( Abc_NtkIsLogic(pNtkLogic) );
58 
59  // get the original netlist
60  pNtkOrig = Io_ReadNetlist( pFileName, Io_ReadFileType(pFileName), 1 );
61  if ( pNtkOrig == NULL )
62  return;
63  assert( Abc_NtkIsNetlist(pNtkOrig) );
64 
65  Abc_NtkCleanCopy(pNtkLogic);
66  Abc_NtkCleanCopy(pNtkOrig);
67 
68  // convert it into the logic network
69  pNtkLogicOrig = Abc_NtkToLogic( pNtkOrig );
70  // check that the networks have the same PIs/POs/latches
71  if ( !Abc_NtkCompareSignals( pNtkLogic, pNtkLogicOrig, 1, 1 ) )
72  {
73  Abc_NtkDelete( pNtkOrig );
74  Abc_NtkDelete( pNtkLogicOrig );
75  return;
76  }
77 
78  // convert the current logic network into an AIG
79  pMiter = Abc_NtkStrash( pNtkLogic, 1, 0, 0 );
80 
81  // convert it into the AIG and make the netlist point to the AIG
82  Abc_NtkAppend( pMiter, pNtkLogicOrig, 1 );
83  Abc_NtkTransferCopy( pNtkOrig );
84  Abc_NtkDelete( pNtkLogicOrig );
85 
86 if ( fVerbose )
87 {
88 printf( "After mitering:\n" );
89 printf( "Logic: Nodes = %5d. Copy = %5d. \n", Abc_NtkNodeNum(pNtkLogic), Abc_NtkCountCopy(pNtkLogic) );
90 printf( "Orig: Nodes = %5d. Copy = %5d. \n", Abc_NtkNodeNum(pNtkOrig), Abc_NtkCountCopy(pNtkOrig) );
91 }
92 
93  // fraig the miter (miter nodes point to the fraiged miter)
94  pMiterFraig = Abc_NtkIvyFraig( pMiter, 100, 1, 0, 1, 0 );
95  // make netlists point to the fraiged miter
96  Abc_NtkTransferCopy( pNtkLogic );
97  Abc_NtkTransferCopy( pNtkOrig );
98  Abc_NtkDelete( pMiter );
99 
100 if ( fVerbose )
101 {
102 printf( "After fraiging:\n" );
103 printf( "Logic: Nodes = %5d. Copy = %5d. \n", Abc_NtkNodeNum(pNtkLogic), Abc_NtkCountCopy(pNtkLogic) );
104 printf( "Orig: Nodes = %5d. Copy = %5d. \n", Abc_NtkNodeNum(pNtkOrig), Abc_NtkCountCopy(pNtkOrig) );
105 }
106 
107  // derive mapping from the fraiged nodes into their prototype nodes in the original netlist
108  tMapping = Abc_NtkDressDeriveMapping( pNtkOrig );
109 
110  // transfer the names to the new netlist
111  Abc_NtkDressTransferNames( pNtkLogic, tMapping, fVerbose );
112 
113  // clean up
114  stmm_free_table( tMapping );
115  Abc_NtkDelete( pMiterFraig );
116  Abc_NtkDelete( pNtkOrig );
117 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
ABC_DLL int Abc_NtkCountCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:572
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
Abc_Ntk_t * Io_ReadNetlist(char *pFileName, Io_FileType_t FileType, int fCheck)
Definition: ioUtil.c:98
ABC_DLL int Abc_NtkCompareSignals(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fOnlyPis, int fComb)
Definition: abcCheck.c:741
static void Abc_NtkDressTransferNames(Abc_Ntk_t *pNtk, stmm_table *tMapping, int fVerbose)
Definition: abcDress.c:163
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL Abc_Ntk_t * Abc_NtkToLogic(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcNetlist.c:52
Io_FileType_t Io_ReadFileType(char *pFileName)
DECLARATIONS ///.
Definition: ioUtil.c:46
Abc_Ntk_t * Abc_NtkIvyFraig(Abc_Ntk_t *pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fVerbose)
Definition: abcIvy.c:456
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
void stmm_free_table(stmm_table *table)
Definition: stmm.c:79
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
#define assert(ex)
Definition: util_old.h:213
ABC_DLL void Abc_NtkTransferCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:1922
static ABC_NAMESPACE_IMPL_START stmm_table * Abc_NtkDressDeriveMapping(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: abcDress.c:130
ABC_DLL int Abc_NtkAppend(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int fAddPos)
Definition: abcStrash.c:320
stmm_table * Abc_NtkDressDeriveMapping ( Abc_Ntk_t pNtk)
static

DECLARATIONS ///.

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

FileName [abcDress.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:
abcDress.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

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

Synopsis [Returns the mapping from the fraig nodes point into the nodes of the netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 130 of file abcDress.c.

131 {
132  stmm_table * tResult;
133  Abc_Obj_t * pNode, * pNodeMap, * pNodeFraig;
134  int i;
135  assert( Abc_NtkIsNetlist(pNtk) );
137  Abc_NtkForEachNode( pNtk, pNode, i )
138  {
139  // get the fraiged node
140  pNodeFraig = Abc_ObjRegular(pNode->pCopy);
141  // if this node is already mapped, skip
142  if ( stmm_is_member( tResult, (char *)pNodeFraig ) )
143  continue;
144  // get the mapping of this node
145  pNodeMap = Abc_ObjNotCond( pNode, Abc_ObjIsComplement(pNode->pCopy) );
146  // add the mapping
147  stmm_insert( tResult, (char *)pNodeFraig, (char *)pNodeMap );
148  }
149  return tResult;
150 }
stmm_table * stmm_init_table(stmm_compare_func_type compare, stmm_hash_func_type hash)
Definition: stmm.c:69
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
int stmm_insert(stmm_table *table, char *key, char *value)
Definition: stmm.c:200
#define stmm_is_member(table, key)
Definition: stmm.h:75
Abc_Obj_t * pCopy
Definition: abc.h:148
int stmm_ptrhash(const char *x, int size)
Definition: stmm.c:533
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int stmm_ptrcmp(const char *x, const char *y)
Definition: stmm.c:545
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
void Abc_NtkDressTransferNames ( Abc_Ntk_t pNtk,
stmm_table tMapping,
int  fVerbose 
)
static

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

Synopsis [Attaches the names of to the new netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file abcDress.c.

164 {
165  Abc_Obj_t * pNet, * pNode, * pNodeMap, * pNodeFraig;
166  char * pName;
167  int i, Counter = 0, CounterInv = 0, CounterInit = stmm_count(tMapping);
168  assert( Abc_NtkIsLogic(pNtk) );
169  Abc_NtkForEachNode( pNtk, pNode, i )
170  {
171  // if the node already has a name, quit
172  pName = Nm_ManFindNameById( pNtk->pManName, pNode->Id );
173  if ( pName != NULL )
174  continue;
175  // get the fraiged node
176  pNodeFraig = Abc_ObjRegular(pNode->pCopy);
177  // find the matching node of the original netlist
178  if ( !stmm_lookup( tMapping, (char *)pNodeFraig, (char **)&pNodeMap ) )
179  continue;
180  // find the true match
181  pNodeMap = Abc_ObjNotCond( pNodeMap, Abc_ObjIsComplement(pNode->pCopy) );
182  // get the name
183  pNet = Abc_ObjFanout0(Abc_ObjRegular(pNodeMap));
184  pName = Nm_ManFindNameById( pNet->pNtk->pManName, pNet->Id );
185  assert( pName != NULL );
186  // set the name
187  if ( Abc_ObjIsComplement(pNodeMap) )
188  {
189  Abc_ObjAssignName( pNode, pName, "_inv" );
190  CounterInv++;
191  }
192  else
193  {
194  Abc_ObjAssignName( pNode, pName, NULL );
195  Counter++;
196  }
197  // remove the name
198  stmm_delete( tMapping, (char **)&pNodeFraig, (char **)&pNodeMap );
199  }
200  if ( fVerbose )
201  {
202  printf( "Total number of names collected = %5d.\n", CounterInit );
203  printf( "Total number of names assigned = %5d. (Dir = %5d. Compl = %5d.)\n",
204  Counter + CounterInv, Counter, CounterInv );
205  }
206 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
Nm_Man_t * pManName
Definition: abc.h:160
#define stmm_count(table)
Definition: stmm.h:76
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
Abc_Obj_t * pCopy
Definition: abc.h:148
int stmm_lookup(stmm_table *table, char *key, char **value)
Definition: stmm.c:134
char * Nm_ManFindNameById(Nm_Man_t *p, int ObjId)
Definition: nmApi.c:199
static int Counter
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
Abc_Ntk_t * pNtk
Definition: abc.h:130
int Id
Definition: abc.h:132
int stmm_delete(stmm_table *table, char **keyp, char **value)
Definition: stmm.c:430
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
Abc_Ntk_t* Abc_NtkIvyFraig ( Abc_Ntk_t pNtk,
int  nConfLimit,
int  fDoSparse,
int  fProve,
int  fTransfer,
int  fVerbose 
)

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

Synopsis [Gives the current ABC network to AIG manager for processing.]

Description []

SideEffects []

SeeAlso []

Definition at line 456 of file abcIvy.c.

457 {
458  Ivy_FraigParams_t Params, * pParams = &Params;
459  Abc_Ntk_t * pNtkAig;
460  Ivy_Man_t * pMan, * pTemp;
461  pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
462  if ( pMan == NULL )
463  return NULL;
464  Ivy_FraigParamsDefault( pParams );
465  pParams->nBTLimitNode = nConfLimit;
466  pParams->fVerbose = fVerbose;
467  pParams->fProve = fProve;
468  pParams->fDoSparse = fDoSparse;
469  pMan = Ivy_FraigPerform( pTemp = pMan, pParams );
470  // transfer the pointers
471  if ( fTransfer == 1 )
472  {
473  Vec_Ptr_t * vCopies;
474  vCopies = Abc_NtkSaveCopy( pNtk );
475  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
476  Abc_NtkLoadCopy( pNtk, vCopies );
477  Vec_PtrFree( vCopies );
478  Abc_NtkTransferPointers( pNtk, pNtkAig );
479  }
480  else
481  pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
482  Ivy_ManStop( pTemp );
483  Ivy_ManStop( pMan );
484  return pNtkAig;
485 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Ivy_FraigParamsDefault(Ivy_FraigParams_t *pParams)
FUNCTION DEFINITIONS ///.
Definition: ivyFraig.c:225
int nBTLimitNode
Definition: ivy.h:143
void Ivy_ManStop(Ivy_Man_t *p)
Definition: ivyMan.c:238
typedefABC_NAMESPACE_HEADER_START struct Ivy_Man_t_ Ivy_Man_t
INCLUDES ///.
Definition: ivy.h:46
void Abc_NtkTransferPointers(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkAig)
Definition: abcIvy.c:419
Ivy_Man_t * Abc_NtkIvyBefore(Abc_Ntk_t *pNtk, int fSeq, int fUseDc)
FUNCTION DEFINITIONS ///.
Definition: abcIvy.c:84
ABC_DLL Vec_Ptr_t * Abc_NtkSaveCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:595
Ivy_Man_t * Ivy_FraigPerform(Ivy_Man_t *pManAig, Ivy_FraigParams_t *pParams)
Definition: ivyFraig.c:451
ABC_DLL void Abc_NtkLoadCopy(Abc_Ntk_t *pNtk, Vec_Ptr_t *vCopies)
Definition: abcUtil.c:617
Abc_Ntk_t * Abc_NtkIvyAfter(Abc_Ntk_t *pNtk, Ivy_Man_t *pMan, int fSeq, int fHaig)
Definition: abcIvy.c:137
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223