src/base/abc/abcLib.c File Reference

#include "abc.h"
Include dependency graph for abcLib.c:

Go to the source code of this file.

Functions

Abc_Lib_tAbc_LibCreate (char *pName)
void Abc_LibFree (Abc_Lib_t *pLib, Abc_Ntk_t *pNtkSave)
Abc_Lib_tAbc_LibDupBlackboxes (Abc_Lib_t *pLib, Abc_Ntk_t *pNtkSave)
void Abc_LibPrint (Abc_Lib_t *pLib)
int Abc_LibAddModel (Abc_Lib_t *pLib, Abc_Ntk_t *pNtk)
Abc_Ntk_tAbc_LibFindModelByName (Abc_Lib_t *pLib, char *pName)
Abc_Ntk_tAbc_LibDeriveRoot (Abc_Lib_t *pLib)
int Abc_LibFindTopLevelModels (Abc_Lib_t *pLib)
int Abc_LibDeriveBlackBoxes (Abc_Ntk_t *pNtk, Abc_Lib_t *pLib)
void Abc_NodeStrashUsingNetwork_rec (Abc_Ntk_t *pNtkAig, Abc_Obj_t *pObj)
void Abc_NodeStrashUsingNetwork (Abc_Ntk_t *pNtkAig, Abc_Obj_t *pBox)
Abc_Ntk_tAbc_LibDeriveAig (Abc_Ntk_t *pNtk, Abc_Lib_t *pLib)

Function Documentation

int Abc_LibAddModel ( Abc_Lib_t pLib,
Abc_Ntk_t pNtk 
)

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

Synopsis [Create the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file abcLib.c.

00168 {
00169     if ( st_is_member( pLib->tModules, (char *)pNtk->pName ) )
00170         return 0;
00171     st_insert( pLib->tModules, (char *)pNtk->pName, (char *)pNtk );
00172     Vec_PtrPush( pLib->vModules, pNtk );
00173     pNtk->pDesign = pLib;
00174     return 1;
00175 }

Abc_Lib_t* Abc_LibCreate ( char *  pName  ) 

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

FileName [abcLib.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Functions to manipulate verilog libraries.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Create the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file abcLib.c.

00043 {
00044     Abc_Lib_t * p;
00045     p = ALLOC( Abc_Lib_t, 1 );
00046     memset( p, 0, sizeof(Abc_Lib_t) );
00047     p->pName    = Extra_UtilStrsav( pName );
00048     p->tModules = st_init_table( strcmp, st_strhash );
00049     p->vTops    = Vec_PtrAlloc( 100 );
00050     p->vModules = Vec_PtrAlloc( 100 );
00051     p->pManFunc = Hop_ManStart();
00052     p->pLibrary = NULL;
00053     return p;
00054 }

Abc_Ntk_t* Abc_LibDeriveAig ( Abc_Ntk_t pNtk,
Abc_Lib_t pLib 
)

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

Synopsis [Derive the AIG of the logic in the netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 398 of file abcLib.c.

00399 {
00400     ProgressBar * pProgress;
00401     Vec_Ptr_t * vNodes;
00402     Abc_Ntk_t * pNtkAig;
00403     Abc_Obj_t * pObj;
00404     int i, nBoxes;
00405     // explicitly derive black boxes
00406     assert( Abc_NtkIsNetlist(pNtk) );
00407     nBoxes = Abc_LibDeriveBlackBoxes( pNtk, pLib );
00408     if ( nBoxes )
00409         printf( "Detected and transformed %d black boxes.\n", nBoxes );
00410     // create the new network with black boxes in place
00411     pNtkAig = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
00412     // transer to the nets
00413     Abc_NtkForEachCi( pNtk, pObj, i )
00414         Abc_ObjFanout0(pObj)->pCopy = pObj->pCopy;
00415     // build the AIG for the remaining logic in the netlist
00416     vNodes = Abc_NtkDfs( pNtk, 0 );
00417     pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(vNodes) );
00418     Vec_PtrForEachEntry( vNodes, pObj, i )
00419     {
00420         Extra_ProgressBarUpdate( pProgress, i, NULL );
00421         if ( Abc_ObjIsNode(pObj) )
00422         {
00423             pObj->pCopy = Abc_NodeStrash( pNtkAig, pObj, 0 );
00424             Abc_ObjFanout0(pObj)->pCopy = pObj->pCopy;
00425             continue;
00426         }
00427         Abc_NodeStrashUsingNetwork( pNtkAig, pObj );
00428     }
00429     Extra_ProgressBarStop( pProgress );
00430     Vec_PtrFree( vNodes );
00431     // deallocate memory manager, which remembers the phase
00432     if ( pNtk->pData )
00433     {
00434         Extra_MmFlexStop( pNtk->pData );
00435         pNtk->pData = NULL;
00436     }
00437     // set the COs
00438 //    Abc_NtkFinalize( pNtk, pNtkAig );
00439     Abc_NtkForEachCo( pNtk, pObj, i )
00440         Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFanin0(pObj)->pCopy );
00441     Abc_AigCleanup( pNtkAig->pManFunc );
00442     // make sure that everything is okay
00443     if ( !Abc_NtkCheck( pNtkAig ) )
00444     {
00445         printf( "Abc_LibDeriveAig: The network check has failed.\n" );
00446         return 0;
00447     }
00448     return pNtkAig;
00449 }

int Abc_LibDeriveBlackBoxes ( Abc_Ntk_t pNtk,
Abc_Lib_t pLib 
)

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

Synopsis [Surround boxes without content (black boxes) with BIs/BOs.]

Description [Returns the number of black boxes converted.]

SideEffects []

SeeAlso []

Definition at line 278 of file abcLib.c.

00279 {
00280 /*
00281     Abc_Obj_t * pObj, * pFanin, * pFanout;
00282     int i, k;
00283     assert( Abc_NtkIsNetlist(pNtk) );
00284     // collect blackbox nodes
00285     assert( Vec_PtrSize(pNtk->vBoxes) == 0 );
00286     Vec_PtrClear( pNtk->vBoxes );
00287     Abc_NtkForEachBox( pNtk, pObj, i )
00288         if ( Abc_NtkNodeNum(pObj->pData) == 0 )
00289             Vec_PtrPush( pNtk->vBoxes, pObj );
00290     // return if there is no black boxes without content
00291     if ( Vec_PtrSize(pNtk->vBoxes) == 0 )
00292         return 0;
00293     // print the boxes
00294     printf( "Black boxes are: " );
00295     Abc_NtkForEachBox( pNtk, pObj, i )
00296         printf( " %s", ((Abc_Ntk_t *)pObj->pData)->pName );
00297     printf( "\n" );
00298     // iterate through the boxes and add BIs/BOs
00299     Abc_NtkForEachBox( pNtk, pObj, i )
00300     {
00301         // go through the fanin nets
00302         Abc_ObjForEachFanin( pObj, pFanin, k )
00303             Abc_ObjInsertBetween( pFanin, pObj, ABC_OBJ_BI );
00304         // go through the fanout nets
00305         Abc_ObjForEachFanout( pObj, pFanout, k )
00306         {
00307             Abc_ObjInsertBetween( pObj, pFanout, ABC_OBJ_BO );
00308             // if the name is not given assign name
00309             if ( pFanout->pData == NULL )
00310             {
00311                 pFanout->pData = Abc_ObjName( pFanout );
00312                 Nm_ManStoreIdName( pNtk->pManName, pFanout->Id, pFanout->pData, NULL );
00313             }
00314         }
00315     }
00316     return Vec_PtrSize(pNtk->vBoxes);
00317 */
00318     return 0;
00319 }

Abc_Ntk_t* Abc_LibDeriveRoot ( Abc_Lib_t pLib  ) 

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

Synopsis [Frees the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 208 of file abcLib.c.

00209 {
00210     Abc_Ntk_t * pNtk;
00211     if ( Vec_PtrSize(pLib->vModules) > 1 )
00212     {
00213         printf( "The design includes more than one module and is currently not used.\n" );
00214         return NULL;
00215     }
00216     pNtk = Vec_PtrEntry( pLib->vModules, 0 );  Vec_PtrClear( pLib->vModules );
00217     pNtk->pManFunc = pLib->pManFunc;           pLib->pManFunc = NULL;
00218     return pNtk;
00219 }

Abc_Lib_t* Abc_LibDupBlackboxes ( Abc_Lib_t pLib,
Abc_Ntk_t pNtkSave 
)

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

Synopsis [Frees the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 106 of file abcLib.c.

00107 {
00108     Abc_Lib_t * pLibNew;
00109     Abc_Ntk_t * pNtkTemp;
00110     int i;
00111     assert( Vec_PtrSize(pLib->vTops) > 0 );
00112     assert( Vec_PtrSize(pLib->vModules) > 1 );
00113     pLibNew = Abc_LibCreate( pLib->pName );
00114 //    pLibNew->pManFunc = pNtkSave->pManFunc;
00115     Vec_PtrPush( pLibNew->vTops, pNtkSave );
00116     Vec_PtrPush( pLibNew->vModules, pNtkSave );
00117     Vec_PtrForEachEntry( pLib->vModules, pNtkTemp, i )
00118         if ( Abc_NtkHasBlackbox( pNtkTemp ) )
00119             Vec_PtrPush( pLibNew->vModules, Abc_NtkDup(pNtkTemp) );
00120     return pLibNew;
00121 }

Abc_Ntk_t* Abc_LibFindModelByName ( Abc_Lib_t pLib,
char *  pName 
)

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

Synopsis [Create the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 188 of file abcLib.c.

00189 {
00190     Abc_Ntk_t * pNtk;
00191     if ( !st_is_member( pLib->tModules, (char *)pName ) )
00192         return NULL;
00193     st_lookup( pLib->tModules, (char *)pName, (char **)&pNtk );
00194     return pNtk;
00195 }

int Abc_LibFindTopLevelModels ( Abc_Lib_t pLib  ) 

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

Synopsis [Detects the top-level models.]

Description []

SideEffects []

SeeAlso []

Definition at line 232 of file abcLib.c.

00233 {
00234     Abc_Ntk_t * pNtk, * pNtkBox;
00235     Abc_Obj_t * pObj;
00236     int i, k;
00237     assert( Vec_PtrSize( pLib->vModules ) > 0 );
00238     // clear the models
00239     Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
00240         pNtk->fHieVisited = 0;
00241     // mark all the models reachable from other models
00242     Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
00243     {
00244         Abc_NtkForEachBox( pNtk, pObj, k )
00245         {
00246             if ( Abc_ObjIsLatch(pObj) )
00247                 continue;
00248             if ( pObj->pData == NULL )
00249                 continue;
00250             pNtkBox = pObj->pData;
00251             pNtkBox->fHieVisited = 1;
00252         }
00253     }
00254     // collect the models that are not marked
00255     Vec_PtrClear( pLib->vTops );
00256     Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
00257     {
00258         if ( pNtk->fHieVisited == 0 )
00259             Vec_PtrPush( pLib->vTops, pNtk );
00260         else
00261             pNtk->fHieVisited = 0;
00262     }
00263     return Vec_PtrSize( pLib->vTops );
00264 }

void Abc_LibFree ( Abc_Lib_t pLib,
Abc_Ntk_t pNtkSave 
)

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

Synopsis [Frees the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 67 of file abcLib.c.

00068 {
00069     Abc_Ntk_t * pNtk;
00070     int i;
00071     if ( pLib->pName )
00072         free( pLib->pName );
00073     if ( pLib->pManFunc )
00074         Hop_ManStop( pLib->pManFunc );
00075     if ( pLib->tModules )
00076         st_free_table( pLib->tModules );
00077     if ( pLib->vModules )
00078     {
00079         Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
00080         {
00081 //            pNtk->pManFunc = NULL;
00082             if ( pNtk == pNtkSave )
00083                 continue;
00084             pNtk->pManFunc = NULL;
00085             pNtk->pDesign = NULL;
00086             Abc_NtkDelete( pNtk );
00087         }
00088         Vec_PtrFree( pLib->vModules );
00089     }
00090     if ( pLib->vTops )
00091         Vec_PtrFree( pLib->vTops );
00092     free( pLib );
00093 }

void Abc_LibPrint ( Abc_Lib_t pLib  ) 

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

Synopsis [Prints the library.]

Description []

SideEffects []

SeeAlso []

Definition at line 135 of file abcLib.c.

00136 {
00137     Abc_Ntk_t * pNtk;
00138     Abc_Obj_t * pObj;
00139     int i, k;
00140     printf( "Models of design %s:\n", pLib->pName );
00141     Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
00142     {
00143         printf( "%2d : %20s   ", i+1, pNtk->pName );
00144         printf( "nd = %6d   lat = %6d   whitebox = %3d   blackbox = %3d\n", 
00145             Abc_NtkNodeNum(pNtk), Abc_NtkLatchNum(pNtk), 
00146             Abc_NtkWhiteboxNum(pNtk), Abc_NtkBlackboxNum(pNtk) );
00147         if ( Abc_NtkBlackboxNum(pNtk) == 0 )
00148             continue;
00149         Abc_NtkForEachWhitebox( pNtk, pObj, k )
00150             printf( "     %20s (whitebox)\n", Abc_NtkName(pObj->pData) );
00151         Abc_NtkForEachBlackbox( pNtk, pObj, k )
00152             printf( "     %20s (blackbox)\n", Abc_NtkName(pObj->pData) );
00153     }
00154 }

void Abc_NodeStrashUsingNetwork ( Abc_Ntk_t pNtkAig,
Abc_Obj_t pBox 
)

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

Synopsis [Derive the AIG of the logic in the netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 359 of file abcLib.c.

00360 { 
00361     Abc_Ntk_t * pNtkGate;
00362     Abc_Obj_t * pObj;
00363     unsigned * pPolarity;
00364     int i, fCompl;
00365     assert( Abc_ObjIsBox(pBox) );
00366     pNtkGate = pBox->pData;
00367     pPolarity = (unsigned *)pBox->pNext;
00368     assert( Abc_NtkIsNetlist(pNtkGate) );
00369     assert( Abc_NtkLatchNum(pNtkGate) == 0 );
00370     Abc_NtkCleanCopy( pNtkGate );
00371     // set the PI values
00372     Abc_NtkForEachPi( pNtkGate, pObj, i )
00373     {
00374         fCompl = (pPolarity && Abc_InfoHasBit(pPolarity, i));
00375         pObj->pCopy = Abc_ObjNotCond( Abc_ObjFanin(pBox,i)->pCopy, fCompl );
00376         Abc_ObjFanout0(pObj)->pCopy = pObj->pCopy;
00377     }
00378     // build recursively and set the PO values
00379     Abc_NtkForEachPo( pNtkGate, pObj, i )
00380     {
00381         Abc_NodeStrashUsingNetwork_rec( pNtkAig, Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)) );
00382         Abc_ObjFanout(pBox,i)->pCopy = Abc_ObjFanin0(pObj)->pCopy;
00383     }
00384 //printf( "processing %d\n", pBox->Id );
00385 }

void Abc_NodeStrashUsingNetwork_rec ( Abc_Ntk_t pNtkAig,
Abc_Obj_t pObj 
)

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

Synopsis [Derive the AIG of the logic in the netlist.]

Description []

SideEffects []

SeeAlso []

Definition at line 332 of file abcLib.c.

00333 {
00334     Abc_Obj_t * pFanin;
00335     int i;
00336     assert( !Abc_ObjIsNet(pObj) );
00337     if ( pObj->pCopy )
00338         return;
00339     // call for the fanins
00340     Abc_ObjForEachFanin( pObj, pFanin, i )
00341         Abc_NodeStrashUsingNetwork_rec( pNtkAig, Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)) );
00342     // compute for the node
00343     pObj->pCopy = Abc_NodeStrash( pNtkAig, pObj, 0 );
00344     // set for the fanout net
00345     Abc_ObjFanout0(pObj)->pCopy = pObj->pCopy;
00346 }


Generated on Tue Jan 5 12:18:31 2010 for abc70930 by  doxygen 1.6.1