summaryrefslogtreecommitdiffstats
path: root/src/base/abc
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2006-04-12 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2006-04-12 08:01:00 -0700
commitc1710767b298a8acae16421a660a0874255636a5 (patch)
tree308ec887b66bcd608a1d7f448d45c27b3b2e93fb /src/base/abc
parent3f4fc5e4507f7fb9df431fc116529b4c209ab97c (diff)
downloadabc-c1710767b298a8acae16421a660a0874255636a5.tar.gz
abc-c1710767b298a8acae16421a660a0874255636a5.tar.bz2
abc-c1710767b298a8acae16421a660a0874255636a5.zip
Version abc60412
Diffstat (limited to 'src/base/abc')
-rw-r--r--src/base/abc/abc.h21
-rw-r--r--src/base/abc/abcCheck.c85
-rw-r--r--src/base/abc/abcDfs.c8
-rw-r--r--src/base/abc/abcNetlist.c158
-rw-r--r--src/base/abc/abcNtk.c23
-rw-r--r--src/base/abc/abcObj.c23
-rw-r--r--src/base/abc/abcUtil.c20
7 files changed, 328 insertions, 10 deletions
diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h
index e0f0df99..32365b81 100644
--- a/src/base/abc/abc.h
+++ b/src/base/abc/abc.h
@@ -52,7 +52,8 @@ typedef enum {
ABC_NTK_LOGIC, // 2: network with PIs/POs, latches, and nodes
ABC_NTK_STRASH, // 3: structurally hashed AIG (two input AND gates with c-attributes on edges)
ABC_NTK_SEQ, // 4: sequential AIG (two input AND gates with c- and latch-attributes on edges)
- ABC_NTK_OTHER // 5: unused
+ ABC_NTK_BLACKBOX, // 5: black box about which nothing is known
+ ABC_NTK_OTHER // 6: unused
} Abc_NtkType_t;
// network functionality
@@ -62,7 +63,8 @@ typedef enum {
ABC_FUNC_BDD, // 2: binary decision diagrams
ABC_FUNC_AIG, // 3: and-inverter graphs
ABC_FUNC_MAP, // 4: standard cell library
- ABC_FUNC_OTHER // 5: unused
+ ABC_FUNC_BLACKBOX, // 5: black box about which nothing is known
+ ABC_FUNC_OTHER // 6: unused
} Abc_NtkFunc_t;
// Supported type/functionality combinations:
@@ -168,6 +170,7 @@ struct Abc_Ntk_t_
int nObjs; // the number of live objs
int nNets; // the number of live nets
int nNodes; // the number of live nodes
+ int nBoxes; // the number of live nodes
int nLatches; // the number of live latches
int nPis; // the number of primary inputs
int nPos; // the number of primary outputs
@@ -198,6 +201,11 @@ struct Abc_Ntk_t_
// the backup network and the step number
Abc_Ntk_t * pNetBackup; // the pointer to the previous backup network
int iStep; // the generation number for the given network
+ // hierarchical design
+ stmm_table * tName2Model; // the table hashing names into network pointers (or NULL if no hierarchy)
+ Vec_Int_t * pBlackBoxes; // stores pairs (PI num, PO num) for each model, including the base model (or NULL if no hierarchy)
+ short fHieVisited; // flag to mark the visited network
+ short fHiePath; // flag to mark the network on the path
// memory management
Extra_MmFlex_t * pMmNames; // memory manager for net names
Extra_MmFixed_t* pMmObj; // memory manager for objects
@@ -223,11 +231,13 @@ static inline bool Abc_NtkIsNetlist( Abc_Ntk_t * pNtk ) { return pN
static inline bool Abc_NtkIsLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkType == ABC_NTK_LOGIC; }
static inline bool Abc_NtkIsStrash( Abc_Ntk_t * pNtk ) { return pNtk->ntkType == ABC_NTK_STRASH; }
static inline bool Abc_NtkIsSeq( Abc_Ntk_t * pNtk ) { return pNtk->ntkType == ABC_NTK_SEQ; }
+static inline bool Abc_NtkIsBlackbox( Abc_Ntk_t * pNtk ) { return pNtk->ntkType == ABC_NTK_BLACKBOX;}
static inline bool Abc_NtkHasSop( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_SOP; }
static inline bool Abc_NtkHasBdd( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BDD; }
static inline bool Abc_NtkHasAig( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_AIG; }
static inline bool Abc_NtkHasMapping( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_MAP; }
+static inline bool Abc_NtkHasBlackbox( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BLACKBOX; }
static inline bool Abc_NtkIsSopNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_SOP && pNtk->ntkType == ABC_NTK_NETLIST; }
static inline bool Abc_NtkIsMappedNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_MAP && pNtk->ntkType == ABC_NTK_NETLIST; }
@@ -294,6 +304,7 @@ static inline Abc_Obj_t * Abc_ObjNotCond( Abc_Obj_t * p, int c ) { return (A
// checking the object type
static inline bool Abc_ObjIsNode( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_NODE; }
+static inline bool Abc_ObjIsBox( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_BOX; }
static inline bool Abc_ObjIsNet( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_NET; }
static inline bool Abc_ObjIsLatch( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_LATCH; }
static inline bool Abc_ObjIsPi( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PI; }
@@ -376,6 +387,9 @@ static inline int Abc_LatchInit( Abc_Obj_t * pLatch ) { assert(Ab
#define Abc_NtkForEachNode( pNtk, pNode, i ) \
for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ ) \
if ( (pNode) == NULL || !Abc_ObjIsNode(pNode) ) {} else
+#define Abc_NtkForEachBox( pNtk, pNode, i ) \
+ for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ ) \
+ if ( (pNode) == NULL || !Abc_ObjIsBox(pNode) ) {} else
#define Abc_AigForEachAnd( pNtk, pNode, i ) \
for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ ) \
if ( (pNode) == NULL || !Abc_NodeIsAigAnd(pNode) ) {} else
@@ -510,6 +524,7 @@ extern Abc_Obj_t * Abc_NtkFindCo( Abc_Ntk_t * pNtk, char * pName );
extern Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName );
extern Abc_Obj_t * Abc_NtkFindOrCreateNet( Abc_Ntk_t * pNtk, char * pName );
extern Abc_Obj_t * Abc_NtkCreateNode( Abc_Ntk_t * pNtk );
+extern Abc_Obj_t * Abc_NtkCreateBox( Abc_Ntk_t * pNtk );
extern Abc_Obj_t * Abc_NtkCreatePi( Abc_Ntk_t * pNtk );
extern Abc_Obj_t * Abc_NtkCreatePo( Abc_Ntk_t * pNtk );
extern Abc_Obj_t * Abc_NtkCreateLatch( Abc_Ntk_t * pNtk );
@@ -651,6 +666,7 @@ extern char * Abc_SopFromTruthHex( char * pTruth );
extern Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes, bool fCleanup );
extern Abc_Obj_t * Abc_NodeStrash( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode );
extern int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 );
+extern Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels );
/*=== abcSweep.c ==========================================================*/
extern int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose );
extern int Abc_NtkCleanup( Abc_Ntk_t * pNtk, int fVerbose );
@@ -698,6 +714,7 @@ extern int Abc_NtkGetBddNodeNum( Abc_Ntk_t * pNtk );
extern int Abc_NtkGetClauseNum( Abc_Ntk_t * pNtk );
extern double Abc_NtkGetMappedArea( Abc_Ntk_t * pNtk );
extern int Abc_NtkGetExorNum( Abc_Ntk_t * pNtk );
+extern int Abc_NtkGetMuxNum( Abc_Ntk_t * pNtk );
extern int Abc_NtkGetChoiceNum( Abc_Ntk_t * pNtk );
extern int Abc_NtkGetFaninMax( Abc_Ntk_t * pNtk );
extern void Abc_NtkCleanCopy( Abc_Ntk_t * pNtk );
diff --git a/src/base/abc/abcCheck.c b/src/base/abc/abcCheck.c
index 080164bd..5c152409 100644
--- a/src/base/abc/abcCheck.c
+++ b/src/base/abc/abcCheck.c
@@ -38,6 +38,8 @@ static bool Abc_NtkComparePis( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
static bool Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
static bool Abc_NtkCompareLatches( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
+static int Abc_NtkIsAcyclicHierarchy( Abc_Ntk_t * pNtk );
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -90,12 +92,12 @@ bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk )
Abc_Obj_t * pObj, * pNet, * pNode;
int i;
- if ( !Abc_NtkIsNetlist(pNtk) && !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsSeq(pNtk) )
+ if ( !Abc_NtkIsNetlist(pNtk) && !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsSeq(pNtk) && !Abc_NtkIsBlackbox(pNtk) )
{
fprintf( stdout, "NetworkCheck: Unknown network type.\n" );
return 0;
}
- if ( !Abc_NtkHasSop(pNtk) && !Abc_NtkHasBdd(pNtk) && !Abc_NtkHasAig(pNtk) && !Abc_NtkHasMapping(pNtk) )
+ if ( !Abc_NtkHasSop(pNtk) && !Abc_NtkHasBdd(pNtk) && !Abc_NtkHasAig(pNtk) && !Abc_NtkHasMapping(pNtk) && !Abc_NtkHasBlackbox(pNtk) )
{
fprintf( stdout, "NetworkCheck: Unknown functionality type.\n" );
return 0;
@@ -187,6 +189,27 @@ bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk )
// }
return Abc_NtkCheck( pNtk->pExdc );
}
+
+ // check the hierarchy
+ if ( Abc_NtkIsNetlist(pNtk) && pNtk->tName2Model )
+ {
+ stmm_generator * gen;
+ Abc_Ntk_t * pNtkTemp;
+ char * pName;
+ // check other networks
+ stmm_foreach_item( pNtk->tName2Model, gen, &pName, (char **)&pNtkTemp )
+ {
+ pNtkTemp->fHiePath = pNtkTemp->fHieVisited = 0;
+ if ( !Abc_NtkCheck( pNtkTemp ) )
+ return 0;
+ }
+ // check acyclic dependency of the models
+ if ( !Abc_NtkIsAcyclicHierarchy( pNtk ) )
+ {
+ fprintf( stdout, "NetworkCheck: Network hierarchical dependences contains a cycle.\n" );
+ return 0;
+ }
+ }
return 1;
}
@@ -711,6 +734,64 @@ bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
return 1;
}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 0 if the network hierachy contains a cycle.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkIsAcyclicHierarchy_rec( Abc_Ntk_t * pNtk )
+{
+ Abc_Ntk_t * pNtkNext;
+ Abc_Obj_t * pObj;
+ int i;
+ // return if visited
+ if ( pNtk->fHieVisited )
+ return 1;
+ pNtk->fHieVisited = 1;
+ // return if black box
+ if ( Abc_NtkIsBlackbox(pNtk) )
+ return 1;
+ assert( Abc_NtkIsNetlist(pNtk) );
+ // go through all the children networks
+ Abc_NtkForEachBox( pNtk, pObj, i )
+ {
+ pNtkNext = pObj->pData;
+ assert( pNtkNext != NULL );
+ if ( pNtkNext->fHiePath )
+ return 0;
+ pNtk->fHiePath = 1;
+ if ( !Abc_NtkIsAcyclicHierarchy_rec( pNtkNext ) )
+ return 0;
+ pNtk->fHiePath = 0;
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 0 if the network hierachy contains a cycle.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkIsAcyclicHierarchy( Abc_Ntk_t * pNtk )
+{
+ assert( Abc_NtkIsNetlist(pNtk) && pNtk->tName2Model );
+ pNtk->fHiePath = 1;
+ return Abc_NtkIsAcyclicHierarchy_rec( pNtk );
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/base/abc/abcDfs.c b/src/base/abc/abcDfs.c
index 9701c0e2..bd707c25 100644
--- a/src/base/abc/abcDfs.c
+++ b/src/base/abc/abcDfs.c
@@ -129,7 +129,7 @@ void Abc_NtkDfs_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes )
// skip the CI
if ( Abc_ObjIsCi(pNode) )
return;
- assert( Abc_ObjIsNode( pNode ) );
+ assert( Abc_ObjIsNode( pNode ) || Abc_ObjIsBox( pNode ) );
// visit the transitive fanin of the node
Abc_ObjForEachFanin( pNode, pFanin, i )
Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(pFanin), vNodes );
@@ -581,15 +581,15 @@ bool Abc_NtkIsAcyclic_rec( Abc_Obj_t * pNode )
assert( !Abc_ObjIsNet(pNode) );
if ( Abc_ObjIsCi(pNode) )
return 1;
- assert( Abc_ObjIsNode( pNode ) );
+ assert( Abc_ObjIsNode( pNode ) || Abc_ObjIsBox( pNode ) );
// make sure the node is not visited
assert( !Abc_NodeIsTravIdPrevious(pNode) );
// check if the node is part of the combinational loop
if ( Abc_NodeIsTravIdCurrent(pNode) )
{
- fprintf( stdout, "Network \"%s\" contains combinational loop!\n", pNtk->pName );
+ fprintf( stdout, "Network \"%s\" contains combinational loop!\n", Abc_NtkName(pNtk) );
fprintf( stdout, "Node \"%s\" is encountered twice on the following path:\n", Abc_ObjName(pNode) );
- fprintf( stdout, " %s", Abc_ObjName(pNode) );
+ fprintf( stdout, " %s", Abc_ObjIsNode(pNode)? Abc_ObjName(pNode) : Abc_NtkName(pNode->pData) );
return 0;
}
// mark this node as a node on the current path
diff --git a/src/base/abc/abcNetlist.c b/src/base/abc/abcNetlist.c
index 737d63c2..75f3ed33 100644
--- a/src/base/abc/abcNetlist.c
+++ b/src/base/abc/abcNetlist.c
@@ -24,7 +24,9 @@
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-
+
+static Abc_Ntk_t * Abc_NtkNetlistToLogicHie( Abc_Ntk_t * pNtk );
+static void Abc_NtkNetlistToLogicHie_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtkOld, int * pCounter );
static void Abc_NtkAddPoBuffers( Abc_Ntk_t * pNtk );
////////////////////////////////////////////////////////////////////////
@@ -48,6 +50,9 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk )
Abc_Obj_t * pObj, * pFanin;
int i, k;
assert( Abc_NtkIsNetlist(pNtk) );
+ // consider simple case when there is hierarchy
+ if ( pNtk->tName2Model )
+ return Abc_NtkNetlistToLogicHie( pNtk );
// start the network
if ( !Abc_NtkHasMapping(pNtk) )
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
@@ -74,6 +79,157 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk )
/**Function*************************************************************
+ Synopsis [Transform the netlist into a logic network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Ntk_t * Abc_NtkNetlistToLogicHie( Abc_Ntk_t * pNtk )
+{
+ Abc_Ntk_t * pNtkNew;
+ Abc_Obj_t * pObj;
+ int i, Counter = 0;
+ assert( Abc_NtkIsNetlist(pNtk) );
+ // start the network
+// pNtkNew = Abc_NtkAlloc( Type, Func );
+ if ( !Abc_NtkHasMapping(pNtk) )
+ pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP );
+ else
+ pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_MAP );
+ // duplicate the name and the spec
+ pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
+ pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
+ // clean the node copy fields
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ pObj->pCopy = NULL;
+ // map the constant nodes
+ if ( Abc_NtkConst1(pNtk) )
+ Abc_NtkConst1(pNtk)->pCopy = Abc_NtkConst1(pNtkNew);
+ // clone PIs/POs and make old nets point to new terminals; create PI/PO names
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ {
+ Abc_ObjFanout0(pObj)->pCopy = Abc_NtkDupObj(pNtkNew, pObj);
+ Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(pObj) );
+ }
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ {
+ Abc_NtkDupObj(pNtkNew, pObj);
+ Abc_NtkLogicStoreName( pObj->pCopy, Abc_ObjName(pObj) );
+ }
+ // recursively flatten hierarchy, create internal logic, add new PI/PO names if there are black boxes
+ Abc_NtkNetlistToLogicHie_rec( pNtkNew, pNtk, &Counter );
+ if ( Counter )
+ printf( "Warning: The total of %d block boxes are transformed into PI/PO pairs.\n", Counter );
+ // add latches
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ {
+ Abc_ObjFanout0(pObj)->pCopy = Abc_NtkDupObj(pNtkNew, pObj);
+ Vec_PtrPush( pNtkNew->vCis, pObj->pCopy );
+ Vec_PtrPush( pNtkNew->vCos, pObj->pCopy );
+ Abc_NtkLogicStoreName( Abc_NtkLatch(pNtkNew,i), Abc_ObjName(pObj) );
+ }
+ // collect the CO nodes
+ Abc_NtkForEachCo( pNtk, pObj, i )
+ Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFanin0(pObj)->pCopy );
+ // copy the timing information
+ Abc_ManTimeDup( pNtk, pNtkNew );
+ // fix the problem with CO pointing directly to CIs
+ Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
+ // duplicate EXDC
+ if ( pNtk->pExdc )
+ pNtkNew->pExdc = Abc_NtkNetlistToLogic( pNtk->pExdc );
+ if ( !Abc_NtkCheck( pNtkNew ) )
+ fprintf( stdout, "Abc_NtkNetlistToLogic(): Network check has failed.\n" );
+ return pNtkNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Transform the netlist into a logic network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkNetlistToLogicHie_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtkOld, int * pCounter )
+{
+ char Prefix[1000];
+ Vec_Ptr_t * vNodes;
+ Abc_Ntk_t * pNtkModel;
+ Abc_Obj_t * pNode, * pObj, * pFanin;
+ int i, k;
+ // collect nodes and boxes in topological order
+ vNodes = Abc_NtkDfs( pNtkOld, 0 );
+ // create logic for nodes and boxes
+ Vec_PtrForEachEntry( vNodes, pNode, i )
+ {
+ if ( Abc_ObjFaninNum(pNode) == 0 )
+ continue;
+ if ( Abc_ObjIsNode(pNode) )
+ {
+ // duplicate the node and save it in the fanout net
+ Abc_NtkDupObj( pNtkNew, pNode );
+ Abc_ObjForEachFanin( pNode, pFanin, k )
+ Abc_ObjAddFanin( pNode->pCopy, pFanin->pCopy );
+ Abc_ObjFanout0(pNode)->pCopy = pNode->pCopy;
+ continue;
+ }
+ assert( Abc_ObjIsBox(pNode) );
+ pNtkModel = pNode->pData;
+ // consider the case of the black box
+ if ( Abc_NtkIsBlackbox(pNtkModel) )
+ {
+ if ( pNtkNew->pBlackBoxes == NULL )
+ {
+ pNtkNew->pBlackBoxes = Vec_IntAlloc( 10 );
+ Vec_IntPush( pNtkNew->pBlackBoxes, (Abc_NtkPiNum(pNtkNew) << 16) | Abc_NtkPoNum(pNtkNew) );
+ }
+ sprintf( Prefix, "%s_%d_", Abc_NtkName(pNtkModel), *pCounter );
+ // create new PIs from the POs of the box
+ Abc_NtkForEachPo( pNtkModel, pObj, k )
+ {
+ pObj->pCopy = Abc_NtkCreatePi( pNtkNew );
+ Abc_ObjFanout(pNode, k)->pCopy = pObj->pCopy;
+ Abc_NtkLogicStoreNamePlus( pObj->pCopy, Prefix, Abc_ObjName(pObj) );
+ }
+ // create new POs from the PIs of the box
+ Abc_NtkForEachPi( pNtkModel, pObj, k )
+ {
+ pObj->pCopy = Abc_NtkCreatePo( pNtkNew );
+ Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFanin(pNode, k)->pCopy );
+ Abc_NtkLogicStoreNamePlus( pObj->pCopy, Prefix, Abc_ObjName(pObj) );
+ }
+ (*pCounter)++;
+ Vec_IntPush( pNtkNew->pBlackBoxes, (Abc_NtkPiNum(pNtkNew) << 16) | Abc_NtkPoNum(pNtkNew) );
+ }
+ else
+ {
+ // map the constant nodes
+ if ( Abc_NtkConst1(pNtkModel) )
+ Abc_NtkConst1(pNtkModel)->pCopy = Abc_NtkConst1(pNtkNew);
+ // transfer the nodes to the box inputs
+ Abc_NtkForEachPi( pNtkModel, pObj, k )
+ Abc_ObjFanout0(pObj)->pCopy = Abc_ObjFanin(pNode, k)->pCopy;
+ // construct recursively
+ Abc_NtkNetlistToLogicHie_rec( pNtkNew, pNtkModel, pCounter );
+ // transfer the results back
+ Abc_NtkForEachPo( pNtkModel, pObj, k )
+ Abc_ObjFanout(pNode, k)->pCopy = Abc_ObjFanin0(pObj)->pCopy;
+ }
+ }
+ Vec_PtrFree( vNodes );
+}
+
+
+/**Function*************************************************************
+
Synopsis [Transform the logic network into a netlist.]
Description []
diff --git a/src/base/abc/abcNtk.c b/src/base/abc/abcNtk.c
index 60ad2412..0640d661 100644
--- a/src/base/abc/abcNtk.c
+++ b/src/base/abc/abcNtk.c
@@ -320,8 +320,17 @@ Abc_Ntk_t * Abc_NtkStartRead( char * pName )
***********************************************************************/
void Abc_NtkFinalizeRead( Abc_Ntk_t * pNtk )
{
- Abc_Obj_t * pLatch;
+ Abc_Obj_t * pLatch, * pBox, * pObj;
int i;
+ if ( pNtk->ntkType == ABC_NTK_BLACKBOX )
+ {
+ pBox = Abc_NtkCreateBox(pNtk);
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ Abc_ObjAddFanin( pBox, Abc_ObjFanout0(pObj) );
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ Abc_ObjAddFanin( Abc_ObjFanin0(pObj), pBox );
+ return;
+ }
assert( Abc_NtkIsNetlist(pNtk) );
// fix the net drivers
Abc_NtkFixNonDrivenNets( pNtk );
@@ -788,6 +797,18 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
}
else if ( !Abc_NtkHasMapping(pNtk) )
assert( 0 );
+ // free the hierarchy
+ if ( Abc_NtkIsNetlist(pNtk) && pNtk->tName2Model )
+ {
+ stmm_generator * gen;
+ Abc_Ntk_t * pNtkTemp;
+ char * pName;
+ stmm_foreach_item( pNtk->tName2Model, gen, &pName, (char **)&pNtkTemp )
+ Abc_NtkDelete( pNtkTemp );
+ stmm_free_table( pNtk->tName2Model );
+ if ( pNtk->pBlackBoxes )
+ Vec_IntFree( pNtk->pBlackBoxes );
+ }
free( pNtk );
}
diff --git a/src/base/abc/abcObj.c b/src/base/abc/abcObj.c
index 0ffe3298..68518ef0 100644
--- a/src/base/abc/abcObj.c
+++ b/src/base/abc/abcObj.c
@@ -128,6 +128,10 @@ void Abc_ObjAdd( Abc_Obj_t * pObj )
Vec_PtrPush( pNtk->vCos, pObj );
pNtk->nPos++;
}
+ else if ( Abc_ObjIsBox(pObj) )
+ {
+ pNtk->nBoxes++;
+ }
else
{
assert( 0 );
@@ -415,6 +419,25 @@ Abc_Obj_t * Abc_NtkCreateNode( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
+Abc_Obj_t * Abc_NtkCreateBox( Abc_Ntk_t * pNtk )
+{
+ Abc_Obj_t * pObj;
+ pObj = Abc_ObjAlloc( pNtk, ABC_OBJ_BOX );
+ Abc_ObjAdd( pObj );
+ return pObj;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Create the new node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
Abc_Obj_t * Abc_NtkCreatePi( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj;
diff --git a/src/base/abc/abcUtil.c b/src/base/abc/abcUtil.c
index 122cf589..8449c91d 100644
--- a/src/base/abc/abcUtil.c
+++ b/src/base/abc/abcUtil.c
@@ -249,6 +249,26 @@ int Abc_NtkGetExorNum( Abc_Ntk_t * pNtk )
/**Function*************************************************************
+ Synopsis [Counts the number of exors.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkGetMuxNum( Abc_Ntk_t * pNtk )
+{
+ Abc_Obj_t * pNode;
+ int i, Counter = 0;
+ Abc_NtkForEachNode( pNtk, pNode, i )
+ Counter += Abc_NodeIsMuxType(pNode);
+ return Counter;
+}
+
+/**Function*************************************************************
+
Synopsis [Returns 1 if it is an AIG with choice nodes.]
Description []