Commit fb51057e by Alan Mishchenko

Version abc70219

parent 50e0d1de
...@@ -57,6 +57,7 @@ alias rv read_verilog ...@@ -57,6 +57,7 @@ alias rv read_verilog
alias rvl read_verlib alias rvl read_verlib
alias rsup read_super mcnc5_old.super alias rsup read_super mcnc5_old.super
alias rlib read_library alias rlib read_library
alias rlibc read_library cadence.genlib
alias rw rewrite alias rw rewrite
alias rwz rewrite -z alias rwz rewrite -z
alias rf refactor alias rf refactor
...@@ -118,10 +119,10 @@ alias fflitmin "compress2rs; ren; sop; ps -f" ...@@ -118,10 +119,10 @@ alias fflitmin "compress2rs; ren; sop; ps -f"
alias t0 "r res.blif; aig; mfs" alias t0 "r res.blif; aig; mfs"
alias t "r res2.blif; aig; mfs" alias t "r res2.blif; aig; mfs"
alias tt "rh a/quip_opt/nut_001_opt.blif" alias tt "r a/quip_opt/nut_001_opt.blif"
alias ttb "wh a/quip_opt/nut_001_opt.blif 1.blif" alias ttb "wh a/quip_opt/nut_001_opt.blif 1.blif"
alias ttv "wh a/quip_opt/nut_001_opt.blif 1.v" alias ttv "wh a/quip_opt/nut_001_opt.blif 1.v"
alias reach "st; ps; compress2; ps; qrel; ps; qreach -v; ps" alias reach "st; ps; compress2; ps; qrel; ps; compress2; ps; qreach -v; ps"
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "abctestlib"=.\abctestlib.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
...@@ -222,6 +222,7 @@ struct Abc_Lib_t_ ...@@ -222,6 +222,7 @@ struct Abc_Lib_t_
Vec_Ptr_t * vModules; // the array of modules Vec_Ptr_t * vModules; // the array of modules
st_table * tModules; // the table hashing module names into their networks st_table * tModules; // the table hashing module names into their networks
Abc_Lib_t * pLibrary; // the library used to map this design Abc_Lib_t * pLibrary; // the library used to map this design
void * pGenlib; // the genlib library used to map this design
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -468,11 +469,11 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At ...@@ -468,11 +469,11 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At
for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_NtkBox(pNtk, i)), 1); i++ ) \ for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_NtkBox(pNtk, i)), 1); i++ ) \
if ( !Abc_ObjIsLatch(pObj) ) {} else if ( !Abc_ObjIsLatch(pObj) ) {} else
#define Abc_NtkForEachLatchInput( pNtk, pObj, i ) \ #define Abc_NtkForEachLatchInput( pNtk, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_ObjFanin0(Abc_NtkBox(pNtk, i))), 1); i++ ) \ for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)); i++ ) \
if ( !Abc_ObjIsLatch(Abc_NtkBox(pNtk, i)) ) {} else if ( !(Abc_ObjIsLatch(Abc_NtkBox(pNtk, i)) && (((pObj) = Abc_ObjFanin0(Abc_NtkBox(pNtk, i))), 1)) ) {} else
#define Abc_NtkForEachLatchOutput( pNtk, pObj, i ) \ #define Abc_NtkForEachLatchOutput( pNtk, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_ObjFanout0(Abc_NtkBox(pNtk, i))), 1); i++ ) \ for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)); i++ ) \
if ( !Abc_ObjIsLatch(Abc_NtkBox(pNtk, i)) ) {} else if ( !(Abc_ObjIsLatch(Abc_NtkBox(pNtk, i)) && (((pObj) = Abc_ObjFanout0(Abc_NtkBox(pNtk, i))), 1)) ) {} else
#define Abc_NtkForEachWhitebox( pNtk, pObj, i ) \ #define Abc_NtkForEachWhitebox( pNtk, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_NtkBox(pNtk, i)), 1); i++ ) \ for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_NtkBox(pNtk, i)), 1); i++ ) \
if ( !Abc_ObjIsWhitebox(pObj) ) {} else if ( !Abc_ObjIsWhitebox(pObj) ) {} else
...@@ -596,9 +597,9 @@ extern void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk ); ...@@ -596,9 +597,9 @@ extern void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk );
extern int Abc_NtkSopToAig( Abc_Ntk_t * pNtk ); extern int Abc_NtkSopToAig( Abc_Ntk_t * pNtk );
extern int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk ); extern int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk );
extern int Abc_NtkMapToSop( Abc_Ntk_t * pNtk ); extern int Abc_NtkMapToSop( Abc_Ntk_t * pNtk );
extern int Abc_NtkLogicToSop( Abc_Ntk_t * pNtk, int fDirect ); extern int Abc_NtkToSop( Abc_Ntk_t * pNtk, int fDirect );
extern int Abc_NtkLogicToBdd( Abc_Ntk_t * pNtk ); extern int Abc_NtkToBdd( Abc_Ntk_t * pNtk );
extern int Abc_NtkLogicToAig( Abc_Ntk_t * pNtk ); extern int Abc_NtkToAig( Abc_Ntk_t * pNtk );
/*=== abcHie.c ==========================================================*/ /*=== abcHie.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy( Abc_Ntk_t * pNtk ); extern Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy( Abc_Ntk_t * pNtk );
extern Abc_Ntk_t * Abc_NtkConvertBlackboxes( Abc_Ntk_t * pNtk ); extern Abc_Ntk_t * Abc_NtkConvertBlackboxes( Abc_Ntk_t * pNtk );
...@@ -680,12 +681,9 @@ extern void Abc_NtkAddDummyAssertNames( Abc_Ntk_t * pNtk ); ...@@ -680,12 +681,9 @@ extern void Abc_NtkAddDummyAssertNames( Abc_Ntk_t * pNtk );
extern void Abc_NtkAddDummyBoxNames( Abc_Ntk_t * pNtk ); extern void Abc_NtkAddDummyBoxNames( Abc_Ntk_t * pNtk );
extern void Abc_NtkShortNames( Abc_Ntk_t * pNtk ); extern void Abc_NtkShortNames( Abc_Ntk_t * pNtk );
/*=== abcNetlist.c ==========================================================*/ /*=== abcNetlist.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk ); extern Abc_Ntk_t * Abc_NtkToLogic( Abc_Ntk_t * pNtk );
extern Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk, int fDirect ); extern Abc_Ntk_t * Abc_NtkToNetlist( Abc_Ntk_t * pNtk, int fDirect );
extern Abc_Ntk_t * Abc_NtkLogicToNetlistBench( Abc_Ntk_t * pNtk ); extern Abc_Ntk_t * Abc_NtkToNetlistBench( Abc_Ntk_t * pNtk );
extern Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk );
extern Abc_Ntk_t * Abc_NtkAigToLogicSop( Abc_Ntk_t * pNtk );
extern Abc_Ntk_t * Abc_NtkAigToLogicSopBench( Abc_Ntk_t * pNtk );
/*=== abcNtbdd.c ==========================================================*/ /*=== abcNtbdd.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkDeriveFromBdd( DdManager * dd, DdNode * bFunc, char * pNamePo, Vec_Ptr_t * vNamesPi ); extern Abc_Ntk_t * Abc_NtkDeriveFromBdd( DdManager * dd, DdNode * bFunc, char * pNamePo, Vec_Ptr_t * vNamesPi );
extern Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk ); extern Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk );
......
...@@ -53,7 +53,7 @@ int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk ) ...@@ -53,7 +53,7 @@ int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk )
DdManager * dd; DdManager * dd;
int nFaninsMax, i; int nFaninsMax, i;
assert( Abc_NtkIsSopLogic(pNtk) ); assert( Abc_NtkHasSop(pNtk) );
// start the functionality manager // start the functionality manager
nFaninsMax = Abc_NtkGetFaninMax( pNtk ); nFaninsMax = Abc_NtkGetFaninMax( pNtk );
...@@ -159,7 +159,7 @@ void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk ) ...@@ -159,7 +159,7 @@ void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk )
Abc_Obj_t * pNode; Abc_Obj_t * pNode;
int nFaninsMax, fFound, i; int nFaninsMax, fFound, i;
assert( Abc_NtkIsSopLogic(pNtk) ); assert( Abc_NtkHasSop(pNtk) );
// check if there are nodes with complemented SOPs // check if there are nodes with complemented SOPs
fFound = 0; fFound = 0;
...@@ -221,7 +221,7 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fDirect ) ...@@ -221,7 +221,7 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fDirect )
else else
fMode = -1; fMode = -1;
assert( Abc_NtkIsBddLogic(pNtk) ); assert( Abc_NtkHasBdd(pNtk) );
if ( dd->size > 0 ) if ( dd->size > 0 )
Cudd_zddVarsFromBddVars( dd, 2 ); Cudd_zddVarsFromBddVars( dd, 2 );
// create the new manager // create the new manager
...@@ -481,7 +481,7 @@ int Abc_ConvertZddToSop( DdManager * dd, DdNode * zCover, char * pSop, int nFani ...@@ -481,7 +481,7 @@ int Abc_ConvertZddToSop( DdManager * dd, DdNode * zCover, char * pSop, int nFani
***********************************************************************/ ***********************************************************************/
void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Extra_MmFlex_t * pMmMan, Vec_Str_t * vCube, int fAllPrimes, char ** ppSop0, char ** ppSop1 ) void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Extra_MmFlex_t * pMmMan, Vec_Str_t * vCube, int fAllPrimes, char ** ppSop0, char ** ppSop1 )
{ {
assert( Abc_NtkIsBddLogic(pNode->pNtk) ); assert( Abc_NtkHasBdd(pNode->pNtk) );
*ppSop0 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 0 ); *ppSop0 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 0 );
*ppSop1 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 1 ); *ppSop1 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 1 );
} }
...@@ -554,7 +554,7 @@ int Abc_NtkSopToAig( Abc_Ntk_t * pNtk ) ...@@ -554,7 +554,7 @@ int Abc_NtkSopToAig( Abc_Ntk_t * pNtk )
Hop_Man_t * pMan; Hop_Man_t * pMan;
int i; int i;
assert( Abc_NtkIsSopLogic(pNtk) || Abc_NtkIsSopNetlist(pNtk) ); assert( Abc_NtkHasSop(pNtk) );
// start the functionality manager // start the functionality manager
pMan = Hop_ManStart(); pMan = Hop_ManStart();
...@@ -664,7 +664,7 @@ int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk ) ...@@ -664,7 +664,7 @@ int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk )
DdManager * dd; DdManager * dd;
int nFaninsMax, i; int nFaninsMax, i;
assert( Abc_NtkIsAigLogic(pNtk) ); assert( Abc_NtkHasAig(pNtk) );
// start the functionality manager // start the functionality manager
nFaninsMax = Abc_NtkGetFaninMax( pNtk ); nFaninsMax = Abc_NtkGetFaninMax( pNtk );
...@@ -863,7 +863,7 @@ int Abc_NtkMapToSop( Abc_Ntk_t * pNtk ) ...@@ -863,7 +863,7 @@ int Abc_NtkMapToSop( Abc_Ntk_t * pNtk )
char * pSop; char * pSop;
int i; int i;
assert( Abc_NtkIsMappedLogic(pNtk) ); assert( Abc_NtkHasMapping(pNtk) );
// update the functionality manager // update the functionality manager
assert( pNtk->pManFunc == Abc_FrameReadLibGen() ); assert( pNtk->pManFunc == Abc_FrameReadLibGen() );
pNtk->pManFunc = Extra_MmFlexStart(); pNtk->pManFunc = Extra_MmFlexStart();
...@@ -889,10 +889,10 @@ int Abc_NtkMapToSop( Abc_Ntk_t * pNtk ) ...@@ -889,10 +889,10 @@ int Abc_NtkMapToSop( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Abc_NtkLogicToSop( Abc_Ntk_t * pNtk, int fDirect ) int Abc_NtkToSop( Abc_Ntk_t * pNtk, int fDirect )
{ {
assert( Abc_NtkIsLogic(pNtk) ); assert( !Abc_NtkIsStrash(pNtk) );
if ( Abc_NtkIsSopLogic(pNtk) ) if ( Abc_NtkHasSop(pNtk) )
{ {
if ( !fDirect ) if ( !fDirect )
return 1; return 1;
...@@ -900,11 +900,11 @@ int Abc_NtkLogicToSop( Abc_Ntk_t * pNtk, int fDirect ) ...@@ -900,11 +900,11 @@ int Abc_NtkLogicToSop( Abc_Ntk_t * pNtk, int fDirect )
return 0; return 0;
return Abc_NtkBddToSop(pNtk, fDirect); return Abc_NtkBddToSop(pNtk, fDirect);
} }
if ( Abc_NtkIsMappedLogic(pNtk) ) if ( Abc_NtkHasMapping(pNtk) )
return Abc_NtkMapToSop(pNtk); return Abc_NtkMapToSop(pNtk);
if ( Abc_NtkIsBddLogic(pNtk) ) if ( Abc_NtkHasBdd(pNtk) )
return Abc_NtkBddToSop(pNtk, fDirect); return Abc_NtkBddToSop(pNtk, fDirect);
if ( Abc_NtkIsAigLogic(pNtk) ) if ( Abc_NtkHasAig(pNtk) )
{ {
if ( !Abc_NtkAigToBdd(pNtk) ) if ( !Abc_NtkAigToBdd(pNtk) )
return 0; return 0;
...@@ -925,19 +925,19 @@ int Abc_NtkLogicToSop( Abc_Ntk_t * pNtk, int fDirect ) ...@@ -925,19 +925,19 @@ int Abc_NtkLogicToSop( Abc_Ntk_t * pNtk, int fDirect )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Abc_NtkLogicToBdd( Abc_Ntk_t * pNtk ) int Abc_NtkToBdd( Abc_Ntk_t * pNtk )
{ {
assert( Abc_NtkIsLogic(pNtk) ); assert( !Abc_NtkIsStrash(pNtk) );
if ( Abc_NtkIsBddLogic(pNtk) ) if ( Abc_NtkHasBdd(pNtk) )
return 1; return 1;
if ( Abc_NtkIsMappedLogic(pNtk) ) if ( Abc_NtkHasMapping(pNtk) )
{ {
Abc_NtkMapToSop(pNtk); Abc_NtkMapToSop(pNtk);
return Abc_NtkSopToBdd(pNtk); return Abc_NtkSopToBdd(pNtk);
} }
if ( Abc_NtkIsSopLogic(pNtk) ) if ( Abc_NtkHasSop(pNtk) )
return Abc_NtkSopToBdd(pNtk); return Abc_NtkSopToBdd(pNtk);
if ( Abc_NtkIsAigLogic(pNtk) ) if ( Abc_NtkHasAig(pNtk) )
return Abc_NtkAigToBdd(pNtk); return Abc_NtkAigToBdd(pNtk);
assert( 0 ); assert( 0 );
return 0; return 0;
...@@ -954,23 +954,23 @@ int Abc_NtkLogicToBdd( Abc_Ntk_t * pNtk ) ...@@ -954,23 +954,23 @@ int Abc_NtkLogicToBdd( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Abc_NtkLogicToAig( Abc_Ntk_t * pNtk ) int Abc_NtkToAig( Abc_Ntk_t * pNtk )
{ {
assert( Abc_NtkIsLogic(pNtk) ); assert( !Abc_NtkIsStrash(pNtk) );
if ( Abc_NtkIsAigLogic(pNtk) ) if ( Abc_NtkHasAig(pNtk) )
return 1; return 1;
if ( Abc_NtkIsMappedLogic(pNtk) ) if ( Abc_NtkHasMapping(pNtk) )
{ {
Abc_NtkMapToSop(pNtk); Abc_NtkMapToSop(pNtk);
return Abc_NtkSopToAig(pNtk); return Abc_NtkSopToAig(pNtk);
} }
if ( Abc_NtkIsBddLogic(pNtk) ) if ( Abc_NtkHasBdd(pNtk) )
{ {
if ( !Abc_NtkBddToSop(pNtk,0) ) if ( !Abc_NtkBddToSop(pNtk,0) )
return 0; return 0;
return Abc_NtkSopToAig(pNtk); return Abc_NtkSopToAig(pNtk);
} }
if ( Abc_NtkIsSopLogic(pNtk) ) if ( Abc_NtkHasSop(pNtk) )
return Abc_NtkSopToAig(pNtk); return Abc_NtkSopToAig(pNtk);
assert( 0 ); assert( 0 );
return 0; return 0;
......
...@@ -195,7 +195,7 @@ Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy( Abc_Ntk_t * pNtk ) ...@@ -195,7 +195,7 @@ Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy( Abc_Ntk_t * pNtk )
// recursively flatten hierarchy, create internal logic, add new PI/PO names if there are black boxes // recursively flatten hierarchy, create internal logic, add new PI/PO names if there are black boxes
Counter = -1; Counter = -1;
Abc_NtkFlattenLogicHierarchy_rec( pNtkNew, pNtk, &Counter ); Abc_NtkFlattenLogicHierarchy_rec( pNtkNew, pNtk, &Counter );
printf( "Hierarchy reader flattened %d logic instances. Preserved %d black boxes.\n", printf( "Hierarchy reader flattened %d instances of logic boxes and left %d black boxes.\n",
Counter, Abc_NtkBlackboxNum(pNtkNew) ); Counter, Abc_NtkBlackboxNum(pNtkNew) );
// pass the design // pass the design
...@@ -249,44 +249,29 @@ Abc_Ntk_t * Abc_NtkConvertBlackboxes( Abc_Ntk_t * pNtk ) ...@@ -249,44 +249,29 @@ Abc_Ntk_t * Abc_NtkConvertBlackboxes( Abc_Ntk_t * pNtk )
// clean the node copy fields // clean the node copy fields
Abc_NtkCleanCopy( pNtk ); Abc_NtkCleanCopy( pNtk );
// create PIs/POs for the box inputs/outputs
// mark the nodes that should not be connected // mark the nodes that should not be connected
Abc_NtkIncrementTravId( pNtk ); Abc_NtkIncrementTravId( pNtk );
Abc_NtkForEachBlackbox( pNtk, pObj, i ) Abc_NtkForEachBlackbox( pNtk, pObj, i )
{
Abc_NodeSetTravIdCurrent( pObj ); Abc_NodeSetTravIdCurrent( pObj );
Abc_NtkForEachCi( pNtk, pTerm, i )
Abc_NodeSetTravIdCurrent( pTerm );
Abc_NtkForEachCo( pNtk, pTerm, i )
Abc_NodeSetTravIdCurrent( pTerm );
// unmark PIs and LIs/LOs
Abc_NtkForEachPi( pNtk, pTerm, i )
Abc_NodeSetTravIdPrevious( pTerm );
Abc_NtkForEachLatchInput( pNtk, pTerm, i )
Abc_NodeSetTravIdPrevious( pTerm );
Abc_NtkForEachLatchOutput( pNtk, pTerm, i )
Abc_NodeSetTravIdPrevious( pTerm );
// copy the box outputs
Abc_NtkForEachBlackbox( pNtk, pObj, i )
Abc_ObjForEachFanout( pObj, pTerm, k ) Abc_ObjForEachFanout( pObj, pTerm, k )
{
pNet = Abc_ObjFanout0(pTerm);
if ( pNet->pCopy )
{
printf( "Error in Abc_NtkConvertBlackboxes(): Output %s of a black box has a non-unique name.\n", Abc_ObjName(pNet->pCopy) );
Abc_NtkDelete( pNtkNew );
return NULL;
}
pNet->pCopy = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pNet) );
pTerm->pCopy = Abc_NtkCreatePi( pNtkNew ); pTerm->pCopy = Abc_NtkCreatePi( pNtkNew );
Abc_NodeSetTravIdCurrent( pTerm );
}
}
Abc_NtkForEachBlackbox( pNtk, pObj, i )
{
Abc_ObjForEachFanin( pObj, pTerm, k )
{
pNet = Abc_ObjFanin0(pTerm);
if ( pNet->pCopy && !Abc_ObjIsCi(Abc_ObjFanin0(pNet)) )
{
Abc_NodeSetTravIdCurrent( pTerm );
continue;
}
pNet->pCopy = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pNet) );
pTerm->pCopy = Abc_NtkCreatePo( pNtkNew );
}
}
// duplicate other objects // duplicate other objects
Abc_NtkForEachObj( pNtk, pObj, i ) Abc_NtkForEachObj( pNtk, pObj, i )
if ( !Abc_NodeIsTravIdCurrent(pObj) && pObj->pCopy == NULL ) if ( !Abc_NodeIsTravIdCurrent(pObj) )
Abc_NtkDupObj( pNtkNew, pObj, Abc_ObjIsNet(pObj) ); Abc_NtkDupObj( pNtkNew, pObj, Abc_ObjIsNet(pObj) );
// connect all objects // connect all objects
...@@ -295,6 +280,23 @@ Abc_Ntk_t * Abc_NtkConvertBlackboxes( Abc_Ntk_t * pNtk ) ...@@ -295,6 +280,23 @@ Abc_Ntk_t * Abc_NtkConvertBlackboxes( Abc_Ntk_t * pNtk )
Abc_ObjForEachFanin( pObj, pFanin, k ) Abc_ObjForEachFanin( pObj, pFanin, k )
Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy ); Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
// create unique PO for each net feeding into blackboxes or POs
Abc_NtkIncrementTravId( pNtk );
Abc_NtkForEachCo( pNtk, pTerm, i )
{
// skip latch inputs
assert( Abc_ObjFanoutNum(pTerm) <= 1 );
if ( Abc_ObjFanoutNum(pTerm) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pTerm)) )
continue;
// check if the net is visited
pNet = Abc_ObjFanin0(pTerm);
if ( Abc_NodeIsTravIdCurrent(pNet) )
continue;
// create PO
Abc_NodeSetTravIdCurrent( pNet );
Abc_ObjAddFanin( Abc_NtkCreatePo(pNtkNew), pNet->pCopy );
}
// check integrity // check integrity
if ( !Abc_NtkCheck( pNtkNew ) ) if ( !Abc_NtkCheck( pNtkNew ) )
{ {
...@@ -337,18 +339,11 @@ Abc_Ntk_t * Abc_NtkInsertNewLogic( Abc_Ntk_t * pNtkH, Abc_Ntk_t * pNtkL ) ...@@ -337,18 +339,11 @@ Abc_Ntk_t * Abc_NtkInsertNewLogic( Abc_Ntk_t * pNtkH, Abc_Ntk_t * pNtkL )
assert( Abc_NtkWhiteboxNum(pNtkL) == 0 ); assert( Abc_NtkWhiteboxNum(pNtkL) == 0 );
assert( Abc_NtkBlackboxNum(pNtkL) == 0 ); assert( Abc_NtkBlackboxNum(pNtkL) == 0 );
if ( Abc_NtkIsSopNetlist(pNtkH) && Abc_NtkIsAigNetlist(pNtkL) )
Abc_NtkSopToAig( pNtkH );
if ( Abc_NtkIsAigNetlist(pNtkH) && Abc_NtkIsSopNetlist(pNtkL) )
Abc_NtkSopToAig( pNtkL );
assert( pNtkH->ntkFunc == pNtkL->ntkFunc );
// prepare the logic network for copying // prepare the logic network for copying
Abc_NtkCleanCopy( pNtkL ); Abc_NtkCleanCopy( pNtkL );
// start the network // start the network
pNtkNew = Abc_NtkAlloc( pNtkH->ntkType, pNtkH->ntkFunc, 1 ); pNtkNew = Abc_NtkAlloc( pNtkL->ntkType, pNtkL->ntkFunc, 1 );
// duplicate the name and the spec // duplicate the name and the spec
pNtkNew->pName = Extra_UtilStrsav( pNtkH->pName ); pNtkNew->pName = Extra_UtilStrsav( pNtkH->pName );
pNtkNew->pSpec = Extra_UtilStrsav( pNtkH->pSpec ); pNtkNew->pSpec = Extra_UtilStrsav( pNtkH->pSpec );
......
...@@ -82,6 +82,7 @@ void Abc_LibFree( Abc_Lib_t * pLib, Abc_Ntk_t * pNtkSave ) ...@@ -82,6 +82,7 @@ void Abc_LibFree( Abc_Lib_t * pLib, Abc_Ntk_t * pNtkSave )
if ( pNtk == pNtkSave ) if ( pNtk == pNtkSave )
continue; continue;
pNtk->pManFunc = NULL; pNtk->pManFunc = NULL;
pNtk->pDesign = NULL;
Abc_NtkDelete( pNtk ); Abc_NtkDelete( pNtk );
} }
Vec_PtrFree( pLib->vModules ); Vec_PtrFree( pLib->vModules );
...@@ -166,6 +167,7 @@ int Abc_LibAddModel( Abc_Lib_t * pLib, Abc_Ntk_t * pNtk ) ...@@ -166,6 +167,7 @@ int Abc_LibAddModel( Abc_Lib_t * pLib, Abc_Ntk_t * pNtk )
return 0; return 0;
st_insert( pLib->tModules, (char *)pNtk->pName, (char *)pNtk ); st_insert( pLib->tModules, (char *)pNtk->pName, (char *)pNtk );
Vec_PtrPush( pLib->vModules, pNtk ); Vec_PtrPush( pLib->vModules, pNtk );
pNtk->pDesign = pLib;
return 1; return 1;
} }
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static void Abc_NtkAddPoBuffers( Abc_Ntk_t * pNtk ); static void Abc_NtkAddPoBuffers( Abc_Ntk_t * pNtk );
static Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk );
static Abc_Ntk_t * Abc_NtkAigToLogicSop( Abc_Ntk_t * pNtk );
static Abc_Ntk_t * Abc_NtkAigToLogicSopBench( Abc_Ntk_t * pNtk );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
...@@ -42,22 +45,21 @@ static void Abc_NtkAddPoBuffers( Abc_Ntk_t * pNtk ); ...@@ -42,22 +45,21 @@ static void Abc_NtkAddPoBuffers( Abc_Ntk_t * pNtk );
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk ) Abc_Ntk_t * Abc_NtkToLogic( Abc_Ntk_t * pNtk )
{ {
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pObj, * pFanin; Abc_Obj_t * pObj, * pFanin;
int i, k; int i, k;
// consider the case of the AIG
if ( Abc_NtkIsStrash(pNtk) )
return Abc_NtkAigToLogicSop( pNtk );
assert( Abc_NtkIsNetlist(pNtk) ); assert( Abc_NtkIsNetlist(pNtk) );
// consider simple case when there is hierarchy // consider simple case when there is hierarchy
assert( pNtk->pDesign == NULL ); assert( pNtk->pDesign == NULL );
// assert( pNtk->tName2Model == NULL ); assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
// if ( pNtk->tName2Model ) assert( Abc_NtkBlackboxNum(pNtk) == 0 );
// return Abc_NtkNetlistToLogicHie( pNtk );
// start the network // start the network
if ( Abc_NtkHasMapping(pNtk) ) pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, pNtk->ntkFunc );
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_MAP );
else
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, pNtk->ntkFunc );
// duplicate the nodes // duplicate the nodes
Abc_NtkForEachNode( pNtk, pObj, i ) Abc_NtkForEachNode( pNtk, pObj, i )
Abc_NtkDupObj(pNtkNew, pObj, 0); Abc_NtkDupObj(pNtkNew, pObj, 0);
...@@ -71,9 +73,9 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk ) ...@@ -71,9 +73,9 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk )
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 ); Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
// duplicate EXDC // duplicate EXDC
if ( pNtk->pExdc ) if ( pNtk->pExdc )
pNtkNew->pExdc = Abc_NtkNetlistToLogic( pNtk->pExdc ); pNtkNew->pExdc = Abc_NtkToLogic( pNtk->pExdc );
if ( !Abc_NtkCheck( pNtkNew ) ) if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkNetlistToLogic(): Network check has failed.\n" ); fprintf( stdout, "Abc_NtkToLogic(): Network check has failed.\n" );
return pNtkNew; return pNtkNew;
} }
...@@ -88,36 +90,18 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk ) ...@@ -88,36 +90,18 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk, int fDirect ) Abc_Ntk_t * Abc_NtkToNetlist( Abc_Ntk_t * pNtk, int fDirect )
{ {
Abc_Ntk_t * pNtkNew, * pNtkTemp; Abc_Ntk_t * pNtkNew, * pNtkTemp;
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) ); assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsStrash(pNtk) );
if ( Abc_NtkIsStrash(pNtk) ) if ( Abc_NtkIsStrash(pNtk) )
{ {
pNtkTemp = Abc_NtkAigToLogicSop(pNtk); pNtkTemp = Abc_NtkAigToLogicSop(pNtk);
pNtkNew = Abc_NtkLogicSopToNetlist( pNtkTemp ); pNtkNew = Abc_NtkLogicToNetlist( pNtkTemp );
Abc_NtkDelete( pNtkTemp ); Abc_NtkDelete( pNtkTemp );
return pNtkNew;
} }
else if ( Abc_NtkIsBddLogic(pNtk) ) return Abc_NtkLogicToNetlist( pNtk );
{
if ( !Abc_NtkBddToSop(pNtk, fDirect) )
return NULL;
pNtkNew = Abc_NtkLogicSopToNetlist( pNtk );
Abc_NtkSopToBdd(pNtk);
}
else if ( Abc_NtkIsAigLogic(pNtk) )
{
if ( !Abc_NtkAigToBdd(pNtk) )
return NULL;
if ( !Abc_NtkBddToSop(pNtk, fDirect) )
return NULL;
pNtkNew = Abc_NtkLogicSopToNetlist( pNtk );
Abc_NtkSopToAig(pNtk);
}
else if ( Abc_NtkIsSopLogic(pNtk) || Abc_NtkIsMappedLogic(pNtk) )
pNtkNew = Abc_NtkLogicSopToNetlist( pNtk );
else assert( 0 );
return pNtkNew;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -131,12 +115,12 @@ Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk, int fDirect ) ...@@ -131,12 +115,12 @@ Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk, int fDirect )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkLogicToNetlistBench( Abc_Ntk_t * pNtk ) Abc_Ntk_t * Abc_NtkToNetlistBench( Abc_Ntk_t * pNtk )
{ {
Abc_Ntk_t * pNtkNew, * pNtkTemp; Abc_Ntk_t * pNtkNew, * pNtkTemp;
assert( Abc_NtkIsStrash(pNtk) ); assert( Abc_NtkIsStrash(pNtk) );
pNtkTemp = Abc_NtkAigToLogicSopBench( pNtk ); pNtkTemp = Abc_NtkAigToLogicSopBench( pNtk );
pNtkNew = Abc_NtkLogicSopToNetlist( pNtkTemp ); pNtkNew = Abc_NtkLogicToNetlist( pNtkTemp );
Abc_NtkDelete( pNtkTemp ); Abc_NtkDelete( pNtkTemp );
return pNtkNew; return pNtkNew;
} }
...@@ -156,32 +140,24 @@ Abc_Ntk_t * Abc_NtkLogicToNetlistBench( Abc_Ntk_t * pNtk ) ...@@ -156,32 +140,24 @@ Abc_Ntk_t * Abc_NtkLogicToNetlistBench( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk ) Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk )
{ {
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pObj, * pNet, * pDriver, * pFanin; Abc_Obj_t * pObj, * pNet, * pDriver, * pFanin;
int i, k; int i, k;
assert( Abc_NtkIsLogic(pNtk) );
// remove dangling nodes // remove dangling nodes
Abc_NtkCleanup( pNtk, 0 ); Abc_NtkCleanup( pNtk, 0 );
assert( Abc_NtkIsLogic(pNtk) );
// assert( Abc_NtkLogicHasSimpleCos(pNtk) ); // assert( Abc_NtkLogicHasSimpleCos(pNtk) );
if ( !Abc_NtkLogicHasSimpleCos(pNtk) ) if ( !Abc_NtkLogicHasSimpleCos(pNtk) )
{ {
printf( "Abc_NtkLogicSopToNetlist() warning: The network is converted to have simple COs.\n" ); printf( "Abc_NtkLogicToNetlist() warning: The network is converted to have simple COs.\n" );
Abc_NtkLogicMakeSimpleCos( pNtk, 0 ); Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
} }
if ( Abc_NtkIsBddLogic(pNtk) )
{
if ( !Abc_NtkBddToSop(pNtk,0) )
return NULL;
}
// Abc_NtkForEachCo(pNtk, pObj, i)
// Abc_ObjPrint( stdout, Abc_ObjFanin0(pObj) );
// start the netlist by creating PI/PO/Latch objects // start the netlist by creating PI/PO/Latch objects
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_NETLIST, pNtk->ntkFunc ); pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_NETLIST, pNtk->ntkFunc );
// create the CI nets and remember them in the new CI nodes // create the CI nets and remember them in the new CI nodes
...@@ -227,7 +203,7 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk ) ...@@ -227,7 +203,7 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk )
if ( pObj->pCopy->pCopy ) // the net of the new object is already created if ( pObj->pCopy->pCopy ) // the net of the new object is already created
continue; continue;
// create the new net // create the new net
pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) ); pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) ); // here we create ridiculous names net line "n48", where 48 is the ID of the node
Abc_ObjAddFanin( pNet, pObj->pCopy ); Abc_ObjAddFanin( pNet, pObj->pCopy );
pObj->pCopy->pCopy = pNet; pObj->pCopy->pCopy = pNet;
} }
...@@ -237,9 +213,9 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk ) ...@@ -237,9 +213,9 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk )
Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy->pCopy ); Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy->pCopy );
// duplicate EXDC // duplicate EXDC
if ( pNtk->pExdc ) if ( pNtk->pExdc )
pNtkNew->pExdc = Abc_NtkLogicToNetlist( pNtk->pExdc, 0 ); pNtkNew->pExdc = Abc_NtkToNetlist( pNtk->pExdc, 0 );
if ( !Abc_NtkCheck( pNtkNew ) ) if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkLogicSopToNetlist(): Network check has failed.\n" ); fprintf( stdout, "Abc_NtkLogicToNetlist(): Network check has failed.\n" );
return pNtkNew; return pNtkNew;
} }
......
...@@ -242,9 +242,9 @@ Abc_Ntk_t * Abc_NtkStartRead( char * pName ) ...@@ -242,9 +242,9 @@ Abc_Ntk_t * Abc_NtkStartRead( char * pName )
***********************************************************************/ ***********************************************************************/
void Abc_NtkFinalizeRead( Abc_Ntk_t * pNtk ) void Abc_NtkFinalizeRead( Abc_Ntk_t * pNtk )
{ {
Abc_Obj_t * pBox, * pObj, * pTerm; Abc_Obj_t * pBox, * pObj, * pTerm, * pNet;
int i; int i;
if ( Abc_NtkHasBlackbox(pNtk) ) if ( Abc_NtkHasBlackbox(pNtk) && Abc_NtkBoxNum(pNtk) == 0 )
{ {
pBox = Abc_NtkCreateBlackbox(pNtk); pBox = Abc_NtkCreateBlackbox(pNtk);
Abc_NtkForEachPi( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
...@@ -262,8 +262,23 @@ void Abc_NtkFinalizeRead( Abc_Ntk_t * pNtk ) ...@@ -262,8 +262,23 @@ void Abc_NtkFinalizeRead( Abc_Ntk_t * pNtk )
return; return;
} }
assert( Abc_NtkIsNetlist(pNtk) ); assert( Abc_NtkIsNetlist(pNtk) );
// check if constant 0 net is used
pNet = Abc_NtkFindOrCreateNet( pNtk, "1\'b0" );
if ( Abc_ObjFanoutNum(pNet) == 0 )
Abc_NtkDeleteObj(pNet);
else if ( Abc_ObjFaninNum(pNet) == 0 )
Abc_ObjAddFanin( pNet, Abc_NtkCreateNodeConst0(pNtk) );
// check if constant 1 net is used
pNet = Abc_NtkFindOrCreateNet( pNtk, "1\'b1" );
if ( Abc_ObjFanoutNum(pNet) == 0 )
Abc_NtkDeleteObj(pNet);
else if ( Abc_ObjFaninNum(pNet) == 0 )
Abc_ObjAddFanin( pNet, Abc_NtkCreateNodeConst1(pNtk) );
// fix the net drivers // fix the net drivers
Abc_NtkFixNonDrivenNets( pNtk ); Abc_NtkFixNonDrivenNets( pNtk );
// reorder the CI/COs to PI/POs first // reorder the CI/COs to PI/POs first
Abc_NtkOrderCisCos( pNtk ); Abc_NtkOrderCisCos( pNtk );
} }
......
...@@ -164,7 +164,7 @@ void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames, int fSeq, int fUseReverse ) ...@@ -164,7 +164,7 @@ void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames, int fSeq, int fUseReverse )
} }
// convert to logic SOP // convert to logic SOP
if ( Abc_NtkIsLogic(pNtk) ) if ( Abc_NtkIsLogic(pNtk) )
Abc_NtkLogicToSop( pNtk, 0 ); Abc_NtkToSop( pNtk, 0 );
// create the file name // create the file name
Abc_ShowGetFileName( pNtk->pName, FileNameDot ); Abc_ShowGetFileName( pNtk->pName, FileNameDot );
// check that the file can be opened // check that the file can be opened
......
...@@ -1404,6 +1404,8 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk ) ...@@ -1404,6 +1404,8 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk )
// rehash the AIG // rehash the AIG
Abc_AigRehash( pNtk->pManFunc ); Abc_AigRehash( pNtk->pManFunc );
// update the name manager!!!
} }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -3395,7 +3395,7 @@ int Abc_CommandLogic( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3395,7 +3395,7 @@ int Abc_CommandLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
// get the new network // get the new network
pNtkRes = Abc_NtkAigToLogicSop( pNtk ); pNtkRes = Abc_NtkToLogic( pNtk );
if ( pNtkRes == NULL ) if ( pNtkRes == NULL )
{ {
fprintf( pErr, "Converting to a logic network has failed.\n" ); fprintf( pErr, "Converting to a logic network has failed.\n" );
...@@ -3984,7 +3984,7 @@ int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3984,7 +3984,7 @@ int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( pErr, "Converting to SOP is possible only for logic networks.\n" ); fprintf( pErr, "Converting to SOP is possible only for logic networks.\n" );
return 1; return 1;
} }
if ( !Abc_NtkLogicToSop(pNtk, fDirect) ) if ( !Abc_NtkToSop(pNtk, fDirect) )
{ {
fprintf( pErr, "Converting to SOP has failed.\n" ); fprintf( pErr, "Converting to SOP has failed.\n" );
return 1; return 1;
...@@ -4047,7 +4047,7 @@ int Abc_CommandBdd( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -4047,7 +4047,7 @@ int Abc_CommandBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( pOut, "The logic network is already in the BDD form.\n" ); fprintf( pOut, "The logic network is already in the BDD form.\n" );
return 0; return 0;
} }
if ( !Abc_NtkLogicToBdd(pNtk) ) if ( !Abc_NtkToBdd(pNtk) )
{ {
fprintf( pErr, "Converting to BDD has failed.\n" ); fprintf( pErr, "Converting to BDD has failed.\n" );
return 1; return 1;
...@@ -4109,7 +4109,7 @@ int Abc_CommandAig( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -4109,7 +4109,7 @@ int Abc_CommandAig( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( pOut, "The logic network is already in the AIG form.\n" ); fprintf( pOut, "The logic network is already in the AIG form.\n" );
return 0; return 0;
} }
if ( !Abc_NtkLogicToAig(pNtk) ) if ( !Abc_NtkToAig(pNtk) )
{ {
fprintf( pErr, "Converting to AIG has failed.\n" ); fprintf( pErr, "Converting to AIG has failed.\n" );
return 1; return 1;
...@@ -7719,7 +7719,7 @@ int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -7719,7 +7719,7 @@ int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
// convert the network into the SOP network // convert the network into the SOP network
pNtkRes = Abc_NtkAigToLogicSop( pNtk ); pNtkRes = Abc_NtkToLogic( pNtk );
// get the new network // get the new network
if ( !Abc_NtkSuperChoiceLut( pNtkRes, nLutSize, nCutSizeMax, fVerbose ) ) if ( !Abc_NtkSuperChoiceLut( pNtkRes, nLutSize, nCutSizeMax, fVerbose ) )
...@@ -8716,7 +8716,7 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -8716,7 +8716,7 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
} }
// convert the network into an SOP network // convert the network into an SOP network
pNtkRes = Abc_NtkAigToLogicSop( pNtk ); pNtkRes = Abc_NtkToLogic( pNtk );
// perform the retiming // perform the retiming
Abc_NtkRetime( pNtkRes, Mode, fForward, fBackward, fVerbose ); Abc_NtkRetime( pNtkRes, Mode, fForward, fBackward, fVerbose );
// replace the current network // replace the current network
...@@ -8725,7 +8725,7 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -8725,7 +8725,7 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
// get the network in the SOP form // get the network in the SOP form
if ( !Abc_NtkLogicToSop(pNtk, 0) ) if ( !Abc_NtkToSop(pNtk, 0) )
{ {
printf( "Converting to SOPs has failed.\n" ); printf( "Converting to SOPs has failed.\n" );
return 0; return 0;
...@@ -9712,7 +9712,7 @@ int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -9712,7 +9712,7 @@ int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv )
else else
{ {
assert( Abc_NtkIsLogic(pNtk) ); assert( Abc_NtkIsLogic(pNtk) );
Abc_NtkLogicToBdd( pNtk ); Abc_NtkToBdd( pNtk );
RetValue = Abc_NtkMiterSat( pNtk, (sint64)nConfLimit, (sint64)nInsLimit, fVerbose, NULL, NULL ); RetValue = Abc_NtkMiterSat( pNtk, (sint64)nConfLimit, (sint64)nInsLimit, fVerbose, NULL, NULL );
} }
......
...@@ -196,7 +196,7 @@ Abc_Ntk_t * Abc_NtkAutoDebugModify( Abc_Ntk_t * pNtkInit, int Step, int fConst1 ...@@ -196,7 +196,7 @@ Abc_Ntk_t * Abc_NtkAutoDebugModify( Abc_Ntk_t * pNtkInit, int Step, int fConst1
Abc_NtkSweep( pNtk, 0 ); Abc_NtkSweep( pNtk, 0 );
Abc_NtkCleanupSeq( pNtk, 0, 0, 0 ); Abc_NtkCleanupSeq( pNtk, 0, 0, 0 );
Abc_NtkLogicToSop( pNtk, 0 ); Abc_NtkToSop( pNtk, 0 );
Abc_NtkCycleInitStateSop( pNtk, 50, 0 ); Abc_NtkCycleInitStateSop( pNtk, 50, 0 );
return pNtk; return pNtk;
} }
......
...@@ -63,7 +63,7 @@ void Abc_NtkDress( Abc_Ntk_t * pNtkLogic, char * pFileName, int fVerbose ) ...@@ -63,7 +63,7 @@ void Abc_NtkDress( Abc_Ntk_t * pNtkLogic, char * pFileName, int fVerbose )
Abc_NtkCleanCopy(pNtkOrig); Abc_NtkCleanCopy(pNtkOrig);
// convert it into the logic network // convert it into the logic network
pNtkLogicOrig = Abc_NtkNetlistToLogic( pNtkOrig ); pNtkLogicOrig = Abc_NtkToLogic( pNtkOrig );
// check that the networks have the same PIs/POs/latches // check that the networks have the same PIs/POs/latches
if ( !Abc_NtkCompareSignals( pNtkLogic, pNtkLogicOrig, 1, 1 ) ) if ( !Abc_NtkCompareSignals( pNtkLogic, pNtkLogicOrig, 1, 1 ) )
{ {
......
...@@ -61,7 +61,7 @@ bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p ) ...@@ -61,7 +61,7 @@ bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
// Abc_NtkBddToSop(pNtk); // Abc_NtkBddToSop(pNtk);
} }
// get the network in the SOP form // get the network in the SOP form
if ( !Abc_NtkLogicToSop(pNtk, 0) ) if ( !Abc_NtkToSop(pNtk, 0) )
{ {
printf( "Abc_NtkFastExtract(): Converting to SOPs has failed.\n" ); printf( "Abc_NtkFastExtract(): Converting to SOPs has failed.\n" );
return 0; return 0;
......
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan ); static Abc_Ntk_t * Abc_NtkFromIvy( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan );
static Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig ); static Abc_Ntk_t * Abc_NtkFromIvySeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig );
static Ivy_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtkOld ); static Ivy_Man_t * Abc_NtkToIvy( Abc_Ntk_t * pNtkOld );
static void Abc_NtkStrashPerformAig( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan ); static void Abc_NtkStrashPerformAig( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan );
static Ivy_Obj_t * Abc_NodeStrashAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode ); static Ivy_Obj_t * Abc_NodeStrashAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode );
...@@ -93,7 +93,7 @@ Ivy_Man_t * Abc_NtkIvyBefore( Abc_Ntk_t * pNtk, int fSeq, int fUseDc ) ...@@ -93,7 +93,7 @@ Ivy_Man_t * Abc_NtkIvyBefore( Abc_Ntk_t * pNtk, int fSeq, int fUseDc )
if ( Abc_NtkGetChoiceNum( pNtk ) ) if ( Abc_NtkGetChoiceNum( pNtk ) )
printf( "Warning: The choice nodes in the initial AIG are removed by strashing.\n" ); printf( "Warning: The choice nodes in the initial AIG are removed by strashing.\n" );
// convert to the AIG manager // convert to the AIG manager
pMan = Abc_NtkToAig( pNtk ); pMan = Abc_NtkToIvy( pNtk );
if ( !Ivy_ManCheck( pMan ) ) if ( !Ivy_ManCheck( pMan ) )
{ {
printf( "AIG check has failed.\n" ); printf( "AIG check has failed.\n" );
...@@ -130,9 +130,9 @@ Abc_Ntk_t * Abc_NtkIvyAfter( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan, int fSeq, int f ...@@ -130,9 +130,9 @@ Abc_Ntk_t * Abc_NtkIvyAfter( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan, int fSeq, int f
int nNodes, fCleanup = 1; int nNodes, fCleanup = 1;
// convert from the AIG manager // convert from the AIG manager
if ( fSeq ) if ( fSeq )
pNtkAig = Abc_NtkFromAigSeq( pNtk, pMan, fHaig ); pNtkAig = Abc_NtkFromIvySeq( pNtk, pMan, fHaig );
else else
pNtkAig = Abc_NtkFromAig( pNtk, pMan ); pNtkAig = Abc_NtkFromIvy( pNtk, pMan );
// report the cleanup results // report the cleanup results
if ( !fHaig && fCleanup && (nNodes = Abc_AigCleanup(pNtkAig->pManFunc)) ) if ( !fHaig && fCleanup && (nNodes = Abc_AigCleanup(pNtkAig->pManFunc)) )
printf( "Warning: AIG cleanup removed %d nodes (this is not a bug).\n", nNodes ); printf( "Warning: AIG cleanup removed %d nodes (this is not a bug).\n", nNodes );
...@@ -608,7 +608,7 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk ) ...@@ -608,7 +608,7 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk )
printf( "Warning: The choice nodes in the initial AIG are removed by strashing.\n" ); printf( "Warning: The choice nodes in the initial AIG are removed by strashing.\n" );
// convert to the AIG manager // convert to the AIG manager
pMan = Abc_NtkToAig( pNtk ); pMan = Abc_NtkToIvy( pNtk );
if ( !Ivy_ManCheck( pMan ) ) if ( !Ivy_ManCheck( pMan ) )
{ {
Vec_IntFree( vInit ); Vec_IntFree( vInit );
...@@ -654,8 +654,8 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk ) ...@@ -654,8 +654,8 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk )
/* /*
// convert from the AIG manager // convert from the AIG manager
pNtkAig = Abc_NtkFromAig( pNtk, pMan ); pNtkAig = Abc_NtkFromIvy( pNtk, pMan );
// pNtkAig = Abc_NtkFromAigSeq( pNtk, pMan ); // pNtkAig = Abc_NtkFromIvySeq( pNtk, pMan );
Ivy_ManStop( pMan ); Ivy_ManStop( pMan );
// report the cleanup results // report the cleanup results
...@@ -691,7 +691,7 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk ) ...@@ -691,7 +691,7 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan ) Abc_Ntk_t * Abc_NtkFromIvy( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan )
{ {
Vec_Int_t * vNodes; Vec_Int_t * vNodes;
Abc_Ntk_t * pNtk; Abc_Ntk_t * pNtk;
...@@ -732,7 +732,7 @@ Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan ) ...@@ -732,7 +732,7 @@ Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan )
} }
Vec_IntFree( vNodes ); Vec_IntFree( vNodes );
if ( !Abc_NtkCheck( pNtk ) ) if ( !Abc_NtkCheck( pNtk ) )
fprintf( stdout, "Abc_NtkFromAig(): Network check has failed.\n" ); fprintf( stdout, "Abc_NtkFromIvy(): Network check has failed.\n" );
return pNtk; return pNtk;
} }
...@@ -747,7 +747,7 @@ Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan ) ...@@ -747,7 +747,7 @@ Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig ) Abc_Ntk_t * Abc_NtkFromIvySeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig )
{ {
Vec_Int_t * vNodes, * vLatches; Vec_Int_t * vNodes, * vLatches;
Abc_Ntk_t * pNtk; Abc_Ntk_t * pNtk;
...@@ -830,7 +830,7 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig ...@@ -830,7 +830,7 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig
Vec_IntFree( vLatches ); Vec_IntFree( vLatches );
Vec_IntFree( vNodes ); Vec_IntFree( vNodes );
if ( !Abc_NtkCheck( pNtk ) ) if ( !Abc_NtkCheck( pNtk ) )
fprintf( stdout, "Abc_NtkFromAigSeq(): Network check has failed.\n" ); fprintf( stdout, "Abc_NtkFromIvySeq(): Network check has failed.\n" );
return pNtk; return pNtk;
} }
...@@ -845,7 +845,7 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig ...@@ -845,7 +845,7 @@ Abc_Ntk_t * Abc_NtkFromAigSeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Ivy_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtkOld ) Ivy_Man_t * Abc_NtkToIvy( Abc_Ntk_t * pNtkOld )
{ {
Ivy_Man_t * pMan; Ivy_Man_t * pMan;
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static Hop_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtk ); static Hop_Man_t * Abc_NtkToMini( Abc_Ntk_t * pNtk );
static Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtkOld, Hop_Man_t * pMan ); static Abc_Ntk_t * Abc_NtkFromMini( Abc_Ntk_t * pNtkOld, Hop_Man_t * pMan );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
...@@ -48,7 +48,7 @@ Abc_Ntk_t * Abc_NtkMiniBalance( Abc_Ntk_t * pNtk ) ...@@ -48,7 +48,7 @@ Abc_Ntk_t * Abc_NtkMiniBalance( Abc_Ntk_t * pNtk )
Hop_Man_t * pMan, * pTemp; Hop_Man_t * pMan, * pTemp;
assert( Abc_NtkIsStrash(pNtk) ); assert( Abc_NtkIsStrash(pNtk) );
// convert to the AIG manager // convert to the AIG manager
pMan = Abc_NtkToAig( pNtk ); pMan = Abc_NtkToMini( pNtk );
if ( pMan == NULL ) if ( pMan == NULL )
return NULL; return NULL;
if ( !Hop_ManCheck( pMan ) ) if ( !Hop_ManCheck( pMan ) )
...@@ -64,7 +64,7 @@ Abc_Ntk_t * Abc_NtkMiniBalance( Abc_Ntk_t * pNtk ) ...@@ -64,7 +64,7 @@ Abc_Ntk_t * Abc_NtkMiniBalance( Abc_Ntk_t * pNtk )
Hop_ManStop( pTemp ); Hop_ManStop( pTemp );
Hop_ManPrintStats( pMan ); Hop_ManPrintStats( pMan );
// convert from the AIG manager // convert from the AIG manager
pNtkAig = Abc_NtkFromAig( pNtk, pMan ); pNtkAig = Abc_NtkFromMini( pNtk, pMan );
if ( pNtkAig == NULL ) if ( pNtkAig == NULL )
return NULL; return NULL;
Hop_ManStop( pMan ); Hop_ManStop( pMan );
...@@ -89,7 +89,7 @@ Abc_Ntk_t * Abc_NtkMiniBalance( Abc_Ntk_t * pNtk ) ...@@ -89,7 +89,7 @@ Abc_Ntk_t * Abc_NtkMiniBalance( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Hop_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtk ) Hop_Man_t * Abc_NtkToMini( Abc_Ntk_t * pNtk )
{ {
Hop_Man_t * pMan; Hop_Man_t * pMan;
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
...@@ -121,7 +121,7 @@ Hop_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtk ) ...@@ -121,7 +121,7 @@ Hop_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtk, Hop_Man_t * pMan ) Abc_Ntk_t * Abc_NtkFromMini( Abc_Ntk_t * pNtk, Hop_Man_t * pMan )
{ {
Vec_Ptr_t * vNodes; Vec_Ptr_t * vNodes;
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
...@@ -142,7 +142,7 @@ Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtk, Hop_Man_t * pMan ) ...@@ -142,7 +142,7 @@ Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtk, Hop_Man_t * pMan )
Hop_ManForEachPo( pMan, pObj, i ) Hop_ManForEachPo( pMan, pObj, i )
Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), (Abc_Obj_t *)Hop_ObjChild0Copy(pObj) ); Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), (Abc_Obj_t *)Hop_ObjChild0Copy(pObj) );
if ( !Abc_NtkCheck( pNtkNew ) ) if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkFromAig(): Network check has failed.\n" ); fprintf( stdout, "Abc_NtkFromMini(): Network check has failed.\n" );
return pNtkNew; return pNtkNew;
} }
......
...@@ -30,6 +30,39 @@ ...@@ -30,6 +30,39 @@
/**Function************************************************************* /**Function*************************************************************
Synopsis [Performs fast synthesis.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkSynthesize( Abc_Ntk_t ** ppNtk, int fMoreEffort )
{
Abc_Ntk_t * pNtk, * pNtkTemp;
pNtk = *ppNtk;
Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
Abc_NtkRefactor( pNtk, 10, 16, 0, 0, 0, 0 );
pNtk = Abc_NtkBalance( pNtkTemp = pNtk, 0, 0, 0 );
Abc_NtkDelete( pNtkTemp );
if ( fMoreEffort )
{
Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 );
Abc_NtkRefactor( pNtk, 10, 16, 0, 0, 0, 0 );
pNtk = Abc_NtkBalance( pNtkTemp = pNtk, 0, 0, 0 );
Abc_NtkDelete( pNtkTemp );
}
*ppNtk = pNtk;
}
/**Function*************************************************************
Synopsis [Existentially quantifies one variable.] Synopsis [Existentially quantifies one variable.]
Description [] Description []
...@@ -113,6 +146,7 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose ) ...@@ -113,6 +146,7 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose )
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pObj, * pMiter; Abc_Obj_t * pObj, * pMiter;
int i, nLatches; int i, nLatches;
int fSynthesis = 1;
assert( Abc_NtkIsStrash(pNtk) ); assert( Abc_NtkIsStrash(pNtk) );
assert( Abc_NtkLatchNum(pNtk) ); assert( Abc_NtkLatchNum(pNtk) );
...@@ -136,7 +170,10 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose ) ...@@ -136,7 +170,10 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose )
// create PI variables // create PI variables
Abc_NtkForEachPi( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj, 1 ); Abc_NtkDupObj( pNtkNew, pObj, 1 );
// create the PO
Abc_NtkCreatePo( pNtkNew );
// restrash the nodes (assuming a topological order of the old network) // restrash the nodes (assuming a topological order of the old network)
Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
Abc_NtkForEachNode( pNtk, pObj, i ) Abc_NtkForEachNode( pNtk, pObj, i )
pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) ); pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// create the function of the primary output // create the function of the primary output
...@@ -150,7 +187,7 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose ) ...@@ -150,7 +187,7 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose )
pMiter = Abc_AigMiter( pNtkNew->pManFunc, vPairs ); pMiter = Abc_AigMiter( pNtkNew->pManFunc, vPairs );
Vec_PtrFree( vPairs ); Vec_PtrFree( vPairs );
// add the primary output // add the primary output
Abc_ObjAddFanin( Abc_NtkCreatePo(pNtkNew), Abc_ObjNot(pMiter) ); Abc_ObjAddFanin( Abc_NtkPo(pNtkNew,0), Abc_ObjNot(pMiter) );
Abc_ObjAssignName( Abc_NtkPo(pNtkNew,0), "rel", NULL ); Abc_ObjAssignName( Abc_NtkPo(pNtkNew,0), "rel", NULL );
// quantify inputs // quantify inputs
...@@ -158,7 +195,20 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose ) ...@@ -158,7 +195,20 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose )
{ {
assert( Abc_NtkPiNum(pNtkNew) == Abc_NtkPiNum(pNtk) + 2*nLatches ); assert( Abc_NtkPiNum(pNtkNew) == Abc_NtkPiNum(pNtk) + 2*nLatches );
for ( i = Abc_NtkPiNum(pNtkNew) - 1; i >= 2*nLatches; i-- ) for ( i = Abc_NtkPiNum(pNtkNew) - 1; i >= 2*nLatches; i-- )
// for ( i = 2*nLatches; i < Abc_NtkPiNum(pNtkNew); i++ )
{
Abc_NtkQuantify( pNtkNew, i, fVerbose ); Abc_NtkQuantify( pNtkNew, i, fVerbose );
// if ( fSynthesis && (i % 3 == 2) )
if ( fSynthesis )
{
Abc_NtkCleanData( pNtkNew );
Abc_AigCleanup( pNtkNew->pManFunc );
Abc_NtkSynthesize( &pNtkNew, 1 );
}
// printf( "Var = %3d. Nodes = %6d. ", Abc_NtkPiNum(pNtkNew) - 1 - i, Abc_NtkNodeNum(pNtkNew) );
// printf( "Var = %3d. Nodes = %6d. ", i - 2*nLatches, Abc_NtkNodeNum(pNtkNew) );
}
// printf( "\n" );
Abc_NtkCleanData( pNtkNew ); Abc_NtkCleanData( pNtkNew );
Abc_AigCleanup( pNtkNew->pManFunc ); Abc_AigCleanup( pNtkNew->pManFunc );
for ( i = Abc_NtkPiNum(pNtkNew) - 1; i >= 2*nLatches; i-- ) for ( i = Abc_NtkPiNum(pNtkNew) - 1; i >= 2*nLatches; i-- )
...@@ -169,7 +219,7 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose ) ...@@ -169,7 +219,7 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose )
} }
} }
// make sure that everything is okay // check consistency of the network
if ( !Abc_NtkCheck( pNtkNew ) ) if ( !Abc_NtkCheck( pNtkNew ) )
{ {
printf( "Abc_NtkTransRel: The network check has failed.\n" ); printf( "Abc_NtkTransRel: The network check has failed.\n" );
...@@ -263,6 +313,7 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose ) ...@@ -263,6 +313,7 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose )
int clk, i, v, nVars, nNodesOld, nNodesNew, nNodesPrev; int clk, i, v, nVars, nNodesOld, nNodesNew, nNodesPrev;
int fFixedPoint = 0; int fFixedPoint = 0;
int fSynthesis = 1; int fSynthesis = 1;
int fMoreEffort = 1;
assert( Abc_NtkIsStrash(pNtkRel) ); assert( Abc_NtkIsStrash(pNtkRel) );
assert( Abc_NtkLatchNum(pNtkRel) == 0 ); assert( Abc_NtkLatchNum(pNtkRel) == 0 );
...@@ -273,8 +324,8 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose ) ...@@ -273,8 +324,8 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose )
pNtkReached = Abc_NtkDup( pNtkFront ); pNtkReached = Abc_NtkDup( pNtkFront );
//Abc_NtkShow( pNtkReached, 0, 0, 0 ); //Abc_NtkShow( pNtkReached, 0, 0, 0 );
if ( fVerbose ) // if ( fVerbose )
printf( "Transition relation = %6d.\n", Abc_NtkNodeNum(pNtkRel) ); // printf( "Transition relation = %6d.\n", Abc_NtkNodeNum(pNtkRel) );
// perform iterations of reachability analysis // perform iterations of reachability analysis
nNodesPrev = Abc_NtkNodeNum(pNtkFront); nNodesPrev = Abc_NtkNodeNum(pNtkFront);
...@@ -293,25 +344,13 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose ) ...@@ -293,25 +344,13 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose )
{ {
Abc_NtkCleanData( pNtkNext ); Abc_NtkCleanData( pNtkNext );
Abc_AigCleanup( pNtkNext->pManFunc ); Abc_AigCleanup( pNtkNext->pManFunc );
Abc_NtkSynthesize( &pNtkNext, fMoreEffort );
Abc_NtkRewrite( pNtkNext, 0, 0, 0, 0, 0 );
pNtkNext = Abc_NtkBalance( pNtkTemp = pNtkNext, 0, 0, 0 );
Abc_NtkDelete( pNtkTemp );
} }
} }
Abc_NtkCleanData( pNtkNext ); Abc_NtkCleanData( pNtkNext );
Abc_AigCleanup( pNtkNext->pManFunc ); Abc_AigCleanup( pNtkNext->pManFunc );
if ( fSynthesis ) if ( fSynthesis )
{ Abc_NtkSynthesize( &pNtkNext, 1 );
Abc_NtkRewrite( pNtkNext, 0, 0, 0, 0, 0 );
pNtkNext = Abc_NtkBalance( pNtkTemp = pNtkNext, 0, 0, 0 );
Abc_NtkDelete( pNtkTemp );
Abc_NtkRewrite( pNtkNext, 0, 0, 0, 0, 0 );
Abc_NtkRefactor( pNtkReached, 10, 16, 0, 0, 0, 0 );
pNtkNext = Abc_NtkBalance( pNtkTemp = pNtkNext, 0, 0, 0 );
Abc_NtkDelete( pNtkTemp );
}
// map the next states into the current states // map the next states into the current states
pNtkNext = Abc_NtkSwapVariables( pNtkTemp = pNtkNext ); pNtkNext = Abc_NtkSwapVariables( pNtkTemp = pNtkNext );
Abc_NtkDelete( pNtkTemp ); Abc_NtkDelete( pNtkTemp );
...@@ -333,20 +372,15 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose ) ...@@ -333,20 +372,15 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose )
nNodesOld = Abc_NtkNodeNum(pNtkFront); nNodesOld = Abc_NtkNodeNum(pNtkFront);
if ( fSynthesis ) if ( fSynthesis )
{ {
Abc_NtkRewrite( pNtkFront, 0, 0, 0, 0, 0 ); Abc_NtkSynthesize( &pNtkFront, fMoreEffort );
pNtkFront = Abc_NtkBalance( pNtkTemp = pNtkFront, 0, 0, 0 ); Abc_NtkSynthesize( &pNtkReached, fMoreEffort );
Abc_NtkDelete( pNtkTemp );
Abc_NtkRewrite( pNtkReached, 0, 0, 0, 0, 0 );
pNtkReached = Abc_NtkBalance( pNtkTemp = pNtkReached, 0, 0, 0 );
Abc_NtkDelete( pNtkTemp );
} }
nNodesNew = Abc_NtkNodeNum(pNtkFront); nNodesNew = Abc_NtkNodeNum(pNtkFront);
// print statistics // print statistics
if ( fVerbose ) if ( fVerbose )
{ {
printf( "I = %3d : Reached = %6d Front = %6d FrontM = %6d %6.2f %% ", printf( "I = %3d : Reach = %6d Fr = %6d FrM = %6d %7.2f %% ",
i + 1, Abc_NtkNodeNum(pNtkReached), nNodesOld, nNodesNew, 100.0*(nNodesNew-nNodesPrev)/nNodesNew ); i + 1, Abc_NtkNodeNum(pNtkReached), nNodesOld, nNodesNew, 100.0*(nNodesNew-nNodesPrev)/nNodesPrev );
PRT( "T", clock() - clk ); PRT( "T", clock() - clk );
} }
nNodesPrev = Abc_NtkNodeNum(pNtkFront); nNodesPrev = Abc_NtkNodeNum(pNtkFront);
...@@ -354,13 +388,6 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose ) ...@@ -354,13 +388,6 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose )
if ( !fFixedPoint ) if ( !fFixedPoint )
fprintf( stdout, "Reachability analysis stopped after %d iterations.\n", nIters ); fprintf( stdout, "Reachability analysis stopped after %d iterations.\n", nIters );
// report the stats
if ( fVerbose )
{
// nMints = 1;
// fprintf( stdout, "The estimated number of minterms in the reachable state set = %d. (%6.2f %%)\n", nMints, 100.0*nMints/(1<<Abc_NtkLatchNum(pNtk)) );
}
// complement the output to represent the set of unreachable states // complement the output to represent the set of unreachable states
Abc_ObjXorFaninC( Abc_NtkPo(pNtkReached,0), 0 ); Abc_ObjXorFaninC( Abc_NtkPo(pNtkReached,0), 0 );
...@@ -372,7 +399,7 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose ) ...@@ -372,7 +399,7 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose )
Abc_NtkDeleteObj( pObj ); Abc_NtkDeleteObj( pObj );
} }
// make sure that everything is okay // check consistency of the network
if ( !Abc_NtkCheck( pNtkReached ) ) if ( !Abc_NtkCheck( pNtkReached ) )
{ {
printf( "Abc_NtkReachability: The network check has failed.\n" ); printf( "Abc_NtkReachability: The network check has failed.\n" );
......
...@@ -105,7 +105,7 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes, bool fCleanup ) ...@@ -105,7 +105,7 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes, bool fCleanup )
if ( Abc_NtkIsStrash(pNtk) ) if ( Abc_NtkIsStrash(pNtk) )
return Abc_NtkRestrash( pNtk, fCleanup ); return Abc_NtkRestrash( pNtk, fCleanup );
// convert the node representation in the logic network to the AIG form // convert the node representation in the logic network to the AIG form
if ( !Abc_NtkLogicToAig(pNtk) ) if ( !Abc_NtkToAig(pNtk) )
{ {
printf( "Converting to AIGs has failed.\n" ); printf( "Converting to AIGs has failed.\n" );
return NULL; return NULL;
...@@ -156,7 +156,7 @@ int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fAddPos ) ...@@ -156,7 +156,7 @@ int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fAddPos )
// the first network should be an AIG // the first network should be an AIG
assert( Abc_NtkIsStrash(pNtk1) ); assert( Abc_NtkIsStrash(pNtk1) );
assert( Abc_NtkIsLogic(pNtk2) || Abc_NtkIsStrash(pNtk2) ); assert( Abc_NtkIsLogic(pNtk2) || Abc_NtkIsStrash(pNtk2) );
if ( Abc_NtkIsLogic(pNtk2) && !Abc_NtkLogicToAig(pNtk2) ) if ( Abc_NtkIsLogic(pNtk2) && !Abc_NtkToAig(pNtk2) )
{ {
printf( "Converting to AIGs has failed.\n" ); printf( "Converting to AIGs has failed.\n" );
return 0; return 0;
......
...@@ -536,7 +536,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose ) ...@@ -536,7 +536,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose )
int i, nNodesOld; int i, nNodesOld;
assert( Abc_NtkIsLogic(pNtk) ); assert( Abc_NtkIsLogic(pNtk) );
// convert network to BDD representation // convert network to BDD representation
if ( !Abc_NtkLogicToBdd(pNtk) ) if ( !Abc_NtkToBdd(pNtk) )
{ {
fprintf( stdout, "Converting to BDD has failed.\n" ); fprintf( stdout, "Converting to BDD has failed.\n" );
return 1; return 1;
......
...@@ -1265,7 +1265,7 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -1265,7 +1265,7 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
} }
// write out the current network // write out the current network
pNetlist = Abc_NtkLogicToNetlist(pNtk,0); pNetlist = Abc_NtkToNetlist(pNtk,0);
if ( pNetlist == NULL ) if ( pNetlist == NULL )
{ {
fprintf( pErr, "Cannot produce the intermediate network.\n" ); fprintf( pErr, "Cannot produce the intermediate network.\n" );
...@@ -1406,7 +1406,7 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -1406,7 +1406,7 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
} }
// write out the current network // write out the current network
pNetlist = Abc_NtkLogicToNetlist(pNtk,0); pNetlist = Abc_NtkToNetlist(pNtk,0);
if ( pNetlist == NULL ) if ( pNetlist == NULL )
{ {
fprintf( pErr, "Cannot produce the intermediate network.\n" ); fprintf( pErr, "Cannot produce the intermediate network.\n" );
...@@ -1552,7 +1552,7 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -1552,7 +1552,7 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
} }
// write out the current network // write out the current network
pNetlist = Abc_NtkLogicToNetlist(pNtk,0); pNetlist = Abc_NtkToNetlist(pNtk,0);
if ( pNetlist == NULL ) if ( pNetlist == NULL )
{ {
fprintf( pErr, "Cannot produce the intermediate network.\n" ); fprintf( pErr, "Cannot produce the intermediate network.\n" );
......
...@@ -55,7 +55,7 @@ static int IoCommandWritePla ( Abc_Frame_t * pAbc, int argc, char **argv ); ...@@ -55,7 +55,7 @@ static int IoCommandWritePla ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteVerLib ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandWriteVerLib ( Abc_Frame_t * pAbc, int argc, char **argv );
extern Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, int fUseMemMan ); extern int glo_fMapped;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
...@@ -139,11 +139,15 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -139,11 +139,15 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
int c; int c;
fCheck = 1; fCheck = 1;
glo_fMapped = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "mch" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
case 'm':
glo_fMapped ^= 1;
break;
case 'c': case 'c':
fCheck ^= 1; fCheck ^= 1;
break; break;
...@@ -166,10 +170,11 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -166,10 +170,11 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
fprintf( pAbc->Err, "usage: read [-ch] <file>\n" ); fprintf( pAbc->Err, "usage: read [-mch] <file>\n" );
fprintf( pAbc->Err, "\t replaces the current network by the network read from <file>\n" ); fprintf( pAbc->Err, "\t replaces the current network by the network read from <file>\n" );
fprintf( pAbc->Err, "\t by calling the parser that matches the extension of <file>\n" ); fprintf( pAbc->Err, "\t by calling the parser that matches the extension of <file>\n" );
fprintf( pAbc->Err, "\t (to read a hierarchical design, use \"read_hie\")\n" ); fprintf( pAbc->Err, "\t (to read a hierarchical design, use \"read_hie\")\n" );
fprintf( pAbc->Err, "\t-m : toggle reading mapped Verilog [default = %s]\n", glo_fMapped? "yes":"no" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" ); fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" ); fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" ); fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
...@@ -332,7 +337,13 @@ int IoCommandReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -332,7 +337,13 @@ int IoCommandReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtk = Io_ReadBlifAsAig( pFileName, fCheck ); pNtk = Io_ReadBlifAsAig( pFileName, fCheck );
else else
// pNtk = Io_Read( pFileName, IO_FILE_BLIF, fCheck ); // pNtk = Io_Read( pFileName, IO_FILE_BLIF, fCheck );
{
Abc_Ntk_t * pTemp;
pNtk = Io_ReadBlif( pFileName, fCheck ); pNtk = Io_ReadBlif( pFileName, fCheck );
pNtk = Abc_NtkToLogic( pTemp = pNtk );
Abc_NtkDelete( pTemp );
}
if ( pNtk == NULL ) if ( pNtk == NULL )
return 1; return 1;
// replace the current network // replace the current network
...@@ -657,11 +668,15 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -657,11 +668,15 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
fCheck = 1; fCheck = 1;
glo_fMapped = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "mch" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
case 'm':
glo_fMapped ^= 1;
break;
case 'c': case 'c':
fCheck ^= 1; fCheck ^= 1;
break; break;
...@@ -684,8 +699,9 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -684,8 +699,9 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
fprintf( pAbc->Err, "usage: read_verilog [-ch] <file>\n" ); fprintf( pAbc->Err, "usage: read_verilog [-mch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in Verilog (IWLS 2005 subset)\n" ); fprintf( pAbc->Err, "\t read the network in Verilog (IWLS 2002/2005 subset)\n" );
fprintf( pAbc->Err, "\t-m : toggle reading mapped Verilog [default = %s]\n", glo_fMapped? "yes":"no" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" ); fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" ); fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" ); fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
...@@ -712,6 +728,7 @@ int IoCommandReadVer( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -712,6 +728,7 @@ int IoCommandReadVer( Abc_Frame_t * pAbc, int argc, char ** argv )
int fCheck; int fCheck;
int c; int c;
extern Abc_Ntk_t * Abc_LibDeriveAig( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib ); extern Abc_Ntk_t * Abc_LibDeriveAig( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib );
extern Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, int fUseMemMan );
fCheck = 1; fCheck = 1;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
...@@ -921,11 +938,15 @@ int IoCommandWriteHie( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -921,11 +938,15 @@ int IoCommandWriteHie( Abc_Frame_t * pAbc, int argc, char **argv )
char * pBaseName, * pFileName; char * pBaseName, * pFileName;
int c; int c;
glo_fMapped = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "mh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
case 'm':
glo_fMapped ^= 1;
break;
case 'h': case 'h':
goto usage; goto usage;
default: default:
...@@ -946,6 +967,7 @@ usage: ...@@ -946,6 +967,7 @@ usage:
fprintf( pAbc->Err, "usage: write_hie [-h] <orig> <file>\n" ); fprintf( pAbc->Err, "usage: write_hie [-h] <orig> <file>\n" );
fprintf( pAbc->Err, "\t writes the current network into <file> by calling\n" ); fprintf( pAbc->Err, "\t writes the current network into <file> by calling\n" );
fprintf( pAbc->Err, "\t the hierarchical writer that matches the extension of <file>\n" ); fprintf( pAbc->Err, "\t the hierarchical writer that matches the extension of <file>\n" );
fprintf( pAbc->Err, "\t-m : toggle reading mapped Verilog for <orig> [default = %s]\n", glo_fMapped? "yes":"no" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" ); fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\torig : the name of the original file with the hierarchical design\n" ); fprintf( pAbc->Err, "\torig : the name of the original file with the hierarchical design\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" ); fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
......
...@@ -150,7 +150,7 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p ) ...@@ -150,7 +150,7 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
Abc_ObjSetData( pNode, Abc_SopRegister( pNtk->pManFunc, " 0\n" ) ); Abc_ObjSetData( pNode, Abc_SopRegister( pNtk->pManFunc, " 0\n" ) );
else else
{ {
printf( "Cannot determine gate type \"%s\" in line %d.\n", pType, Extra_FileReaderGetLineNumber(p, 0) ); printf( "Io_ReadBenchNetwork(): Cannot determine gate type \"%s\" in line %d.\n", pType, Extra_FileReaderGetLineNumber(p, 0) );
Vec_StrFree( vString ); Vec_StrFree( vString );
Abc_NtkDelete( pNtk ); Abc_NtkDelete( pNtk );
return NULL; return NULL;
......
...@@ -98,6 +98,7 @@ static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine ); ...@@ -98,6 +98,7 @@ static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineMv( Io_MvMod_t * p, char * pLine ); static int Io_MvParseLineMv( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineNamesMv( Io_MvMod_t * p, char * pLine, int fReset ); static int Io_MvParseLineNamesMv( Io_MvMod_t * p, char * pLine, int fReset );
static int Io_MvParseLineNamesBlif( Io_MvMod_t * p, char * pLine ); static int Io_MvParseLineNamesBlif( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineGateBlif( Io_MvMod_t * p, Vec_Ptr_t * vTokens );
static int Io_MvCharIsSpace( char s ) { return s == ' ' || s == '\t' || s == '\r' || s == '\n'; } static int Io_MvCharIsSpace( char s ) { return s == ' ' || s == '\t' || s == '\r' || s == '\n'; }
static int Io_MvCharIsMvSymb( char s ) { return s == '(' || s == ')' || s == '{' || s == '}' || s == '-' || s == ',' || s == '!'; } static int Io_MvCharIsMvSymb( char s ) { return s == '(' || s == ')' || s == '{' || s == '}' || s == '-' || s == ',' || s == '!'; }
...@@ -568,7 +569,7 @@ static void Io_MvReadPreparse( Io_MvMan_t * p ) ...@@ -568,7 +569,7 @@ static void Io_MvReadPreparse( Io_MvMan_t * p )
// parse directives // parse directives
if ( *(pCur-1) != '.' ) if ( *(pCur-1) != '.' )
continue; continue;
if ( !strncmp(pCur, "names", 5) || !strncmp(pCur, "table", 5) ) if ( !strncmp(pCur, "names", 5) || !strncmp(pCur, "table", 5) || !strncmp(pCur, "gate", 4) )
Vec_PtrPush( p->pLatest->vNames, pCur ); Vec_PtrPush( p->pLatest->vNames, pCur );
else if ( p->fBlifMv && (!strncmp(pCur, "def ", 4) || !strncmp(pCur, "default ", 8)) ) else if ( p->fBlifMv && (!strncmp(pCur, "def ", 4) || !strncmp(pCur, "default ", 8)) )
continue; continue;
...@@ -1464,6 +1465,10 @@ static int Io_MvParseLineNamesBlif( Io_MvMod_t * p, char * pLine ) ...@@ -1464,6 +1465,10 @@ static int Io_MvParseLineNamesBlif( Io_MvMod_t * p, char * pLine )
char * pName; char * pName;
assert( !p->pMan->fBlifMv ); assert( !p->pMan->fBlifMv );
Io_MvSplitIntoTokens( vTokens, pLine, '\0' ); Io_MvSplitIntoTokens( vTokens, pLine, '\0' );
// parse the mapped node
if ( !strcmp(Vec_PtrEntry(vTokens,0), "gate") )
return Io_MvParseLineGateBlif( p, vTokens );
// parse the regular name line
assert( !strcmp(Vec_PtrEntry(vTokens,0), "names") ); assert( !strcmp(Vec_PtrEntry(vTokens,0), "names") );
pName = Vec_PtrEntryLast( vTokens ); pName = Vec_PtrEntryLast( vTokens );
pNet = Abc_NtkFindOrCreateNet( p->pNtk, pName ); pNet = Abc_NtkFindOrCreateNet( p->pNtk, pName );
...@@ -1483,6 +1488,104 @@ static int Io_MvParseLineNamesBlif( Io_MvMod_t * p, char * pLine ) ...@@ -1483,6 +1488,104 @@ static int Io_MvParseLineNamesBlif( Io_MvMod_t * p, char * pLine )
} }
#include "mio.h"
#include "main.h"
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static char * Io_ReadBlifCleanName( char * pName )
{
int i, Length;
Length = strlen(pName);
for ( i = 0; i < Length; i++ )
if ( pName[i] == '=' )
return pName + i + 1;
return NULL;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static int Io_MvParseLineGateBlif( Io_MvMod_t * p, Vec_Ptr_t * vTokens )
{
Mio_Library_t * pGenlib;
Mio_Gate_t * pGate;
Abc_Obj_t * pNode;
char ** ppNames, * pName;
int i, nNames;
pName = vTokens->pArray[0];
// check that the library is available
pGenlib = Abc_FrameReadLibGen();
if ( pGenlib == NULL )
{
sprintf( p->pMan->sError, "Line %d: The current library is not available.", Io_MvGetLine(p->pMan, pName) );
return 0;
}
// create a new node and add it to the network
if ( vTokens->nSize < 2 )
{
sprintf( p->pMan->sError, "Line %d: The .gate line has less than two tokens.", Io_MvGetLine(p->pMan, pName) );
return 0;
}
// get the gate
pGate = Mio_LibraryReadGateByName( pGenlib, vTokens->pArray[1] );
if ( pGate == NULL )
{
sprintf( p->pMan->sError, "Line %d: Cannot find gate \"%s\" in the library.", Io_MvGetLine(p->pMan, pName), vTokens->pArray[1] );
return 0;
}
// if this is the first line with gate, update the network type
if ( Abc_NtkNodeNum(p->pNtk) == 0 )
{
assert( p->pNtk->ntkFunc == ABC_FUNC_SOP );
p->pNtk->ntkFunc = ABC_FUNC_MAP;
Extra_MmFlexStop( p->pNtk->pManFunc );
p->pNtk->pManFunc = pGenlib;
}
// remove the formal parameter names
for ( i = 2; i < vTokens->nSize; i++ )
{
vTokens->pArray[i] = Io_ReadBlifCleanName( vTokens->pArray[i] );
if ( vTokens->pArray[i] == NULL )
{
sprintf( p->pMan->sError, "Line %d: Invalid gate input assignment.", Io_MvGetLine(p->pMan, pName) );
return 0;
}
}
// create the node
ppNames = (char **)vTokens->pArray + 2;
nNames = vTokens->nSize - 3;
pNode = Io_ReadCreateNode( p->pNtk, ppNames[nNames], ppNames, nNames );
// set the pointer to the functionality of the node
Abc_ObjSetData( pNode, pGate );
return 1;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -45,13 +45,12 @@ Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck ) ...@@ -45,13 +45,12 @@ Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck )
{ {
Abc_Ntk_t * pNtk; Abc_Ntk_t * pNtk;
Abc_Lib_t * pDesign; Abc_Lib_t * pDesign;
int i;
// parse the verilog file // parse the verilog file
pDesign = Ver_ParseFile( pFileName, NULL, 1, fCheck ); pDesign = Ver_ParseFile( pFileName, NULL, fCheck, 1 );
if ( pDesign == NULL ) if ( pDesign == NULL )
return NULL; return NULL;
/*
// extract the master network // extract the master network
pNtk = Vec_PtrEntryLast( pDesign->vModules ); pNtk = Vec_PtrEntryLast( pDesign->vModules );
pNtk->pDesign = pDesign; pNtk->pDesign = pDesign;
...@@ -75,6 +74,28 @@ Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck ) ...@@ -75,6 +74,28 @@ Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck )
// check that there is no cyclic dependency // check that there is no cyclic dependency
Abc_NtkIsAcyclicHierarchy( pNtk ); Abc_NtkIsAcyclicHierarchy( pNtk );
} }
*/
// extract the master network
pNtk = Vec_PtrEntry( pDesign->vModules, 0 );
pNtk->pDesign = pDesign;
pDesign->pManFunc = NULL;
//Io_WriteVerilog( pNtk, "_temp.v" );
// verify the design for cyclic dependence
assert( Vec_PtrSize(pDesign->vModules) > 0 );
if ( Vec_PtrSize(pDesign->vModules) == 1 )
{
// printf( "Warning: The design is not hierarchical.\n" );
Abc_LibFree( pDesign, pNtk );
pNtk->pDesign = NULL;
pNtk->pSpec = Extra_UtilStrsav( pFileName );
}
else
{
// check that there is no cyclic dependency
Abc_NtkIsAcyclicHierarchy( pNtk );
}
return pNtk; return pNtk;
} }
......
...@@ -209,7 +209,7 @@ Abc_NtkPrintStats( stdout, pNtk, 0 ); ...@@ -209,7 +209,7 @@ Abc_NtkPrintStats( stdout, pNtk, 0 );
// convert blackboxes // convert blackboxes
if ( Abc_NtkBlackboxNum(pNtk) > 0 ) if ( Abc_NtkBlackboxNum(pNtk) > 0 )
{ {
printf( "Hierarchy reader converted %d blackboxes.\n", Abc_NtkBlackboxNum(pNtk) ); printf( "Hierarchy reader converted %d instances of blackboxes.\n", Abc_NtkBlackboxNum(pNtk) );
pNtk = Abc_NtkConvertBlackboxes( pTemp = pNtk ); pNtk = Abc_NtkConvertBlackboxes( pTemp = pNtk );
Abc_NtkDelete( pTemp ); Abc_NtkDelete( pTemp );
if ( pNtk == NULL ) if ( pNtk == NULL )
...@@ -219,7 +219,7 @@ Abc_NtkPrintStats( stdout, pNtk, 0 ); ...@@ -219,7 +219,7 @@ Abc_NtkPrintStats( stdout, pNtk, 0 );
} }
} }
// convert the netlist into the logic network // convert the netlist into the logic network
pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk ); pNtk = Abc_NtkToLogic( pTemp = pNtk );
Abc_NtkDelete( pTemp ); Abc_NtkDelete( pTemp );
if ( pNtk == NULL ) if ( pNtk == NULL )
{ {
...@@ -244,7 +244,6 @@ Abc_Ntk_t * Io_ReadHie( char * pFileName, Io_FileType_t FileType, int fCheck ) ...@@ -244,7 +244,6 @@ Abc_Ntk_t * Io_ReadHie( char * pFileName, Io_FileType_t FileType, int fCheck )
{ {
Abc_Ntk_t * pNtk, * pTemp; Abc_Ntk_t * pNtk, * pTemp;
// detect the file type // detect the file type
if ( Io_ReadFileType(pFileName) == IO_FILE_BLIF ) if ( Io_ReadFileType(pFileName) == IO_FILE_BLIF )
pNtk = Io_ReadBlifMv( pFileName, 0, fCheck ); pNtk = Io_ReadBlifMv( pFileName, 0, fCheck );
// else if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV ) // else if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV )
...@@ -274,7 +273,7 @@ Abc_Ntk_t * Io_ReadHie( char * pFileName, Io_FileType_t FileType, int fCheck ) ...@@ -274,7 +273,7 @@ Abc_Ntk_t * Io_ReadHie( char * pFileName, Io_FileType_t FileType, int fCheck )
// convert blackboxes // convert blackboxes
if ( Abc_NtkBlackboxNum(pNtk) > 0 ) if ( Abc_NtkBlackboxNum(pNtk) > 0 )
{ {
printf( "Hierarchy reader converted %d blackboxes.\n", Abc_NtkBlackboxNum(pNtk) ); printf( "Hierarchy reader converted %d instances of blackboxes.\n", Abc_NtkBlackboxNum(pNtk) );
pNtk = Abc_NtkConvertBlackboxes( pTemp = pNtk ); pNtk = Abc_NtkConvertBlackboxes( pTemp = pNtk );
Abc_NtkDelete( pTemp ); Abc_NtkDelete( pTemp );
if ( pNtk == NULL ) if ( pNtk == NULL )
...@@ -284,7 +283,7 @@ Abc_Ntk_t * Io_ReadHie( char * pFileName, Io_FileType_t FileType, int fCheck ) ...@@ -284,7 +283,7 @@ Abc_Ntk_t * Io_ReadHie( char * pFileName, Io_FileType_t FileType, int fCheck )
} }
} }
// convert the netlist into the logic network // convert the netlist into the logic network
pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk ); pNtk = Abc_NtkToLogic( pTemp = pNtk );
Abc_NtkDelete( pTemp ); Abc_NtkDelete( pTemp );
if ( pNtk == NULL ) if ( pNtk == NULL )
{ {
...@@ -350,6 +349,7 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType ) ...@@ -350,6 +349,7 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType )
Io_WriteGml( pNtk, pFileName ); Io_WriteGml( pNtk, pFileName );
return; return;
} }
// convert logic network into netlist // convert logic network into netlist
if ( FileType == IO_FILE_PLA ) if ( FileType == IO_FILE_PLA )
{ {
...@@ -359,13 +359,13 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType ) ...@@ -359,13 +359,13 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType )
return; return;
} }
if ( Abc_NtkIsComb(pNtk) ) if ( Abc_NtkIsComb(pNtk) )
pNtkTemp = Abc_NtkLogicToNetlist( pNtk, 1 ); pNtkTemp = Abc_NtkToNetlist( pNtk, 1 );
else else
{ {
fprintf( stdout, "Latches are writen into the PLA file at PI/PO pairs.\n" ); fprintf( stdout, "Latches are writen into the PLA file at PI/PO pairs.\n" );
pNtkCopy = Abc_NtkDup( pNtk ); pNtkCopy = Abc_NtkDup( pNtk );
Abc_NtkMakeComb( pNtkCopy ); Abc_NtkMakeComb( pNtkCopy );
pNtkTemp = Abc_NtkLogicToNetlist( pNtk, 1 ); pNtkTemp = Abc_NtkToNetlist( pNtk, 1 );
Abc_NtkDelete( pNtkCopy ); Abc_NtkDelete( pNtkCopy );
} }
} }
...@@ -376,31 +376,37 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType ) ...@@ -376,31 +376,37 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType )
fprintf( stdout, "Writing BENCH is available for AIGs.\n" ); fprintf( stdout, "Writing BENCH is available for AIGs.\n" );
return; return;
} }
pNtkTemp = Abc_NtkLogicToNetlistBench( pNtk ); pNtkTemp = Abc_NtkToNetlistBench( pNtk );
} }
else else
pNtkTemp = Abc_NtkLogicToNetlist( pNtk, 0 ); pNtkTemp = Abc_NtkToNetlist( pNtk, 0 );
if ( pNtkTemp == NULL ) if ( pNtkTemp == NULL )
{ {
fprintf( stdout, "Converting to netlist has failed.\n" ); fprintf( stdout, "Converting to netlist has failed.\n" );
return; return;
} }
if ( FileType == IO_FILE_BLIF ) if ( FileType == IO_FILE_BLIF )
{
if ( !Abc_NtkHasSop(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
Abc_NtkToSop( pNtkTemp, 0 );
Io_WriteBlif( pNtkTemp, pFileName, 1 ); Io_WriteBlif( pNtkTemp, pFileName, 1 );
}
else if ( FileType == IO_FILE_BENCH ) else if ( FileType == IO_FILE_BENCH )
Io_WriteBench( pNtkTemp, pFileName ); Io_WriteBench( pNtkTemp, pFileName );
else if ( FileType == IO_FILE_PLA ) else if ( FileType == IO_FILE_PLA )
Io_WritePla( pNtkTemp, pFileName ); Io_WritePla( pNtkTemp, pFileName );
else if ( FileType == IO_FILE_EQN ) else if ( FileType == IO_FILE_EQN )
{ {
if ( Abc_NtkIsSopNetlist(pNtkTemp) ) if ( !Abc_NtkHasAig(pNtkTemp) )
Abc_NtkSopToAig( pNtkTemp ); Abc_NtkToAig( pNtkTemp );
Io_WriteEqn( pNtkTemp, pFileName ); Io_WriteEqn( pNtkTemp, pFileName );
} }
else if ( FileType == IO_FILE_VERILOG ) else if ( FileType == IO_FILE_VERILOG )
{ {
if ( Abc_NtkIsSopNetlist(pNtkTemp) ) if ( !Abc_NtkHasAig(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
Abc_NtkSopToAig( pNtkTemp ); Abc_NtkToAig( pNtkTemp );
Io_WriteVerilog( pNtkTemp, pFileName ); Io_WriteVerilog( pNtkTemp, pFileName );
} }
else else
...@@ -451,25 +457,17 @@ void Io_WriteHie( Abc_Ntk_t * pNtk, char * pBaseName, char * pFileName ) ...@@ -451,25 +457,17 @@ void Io_WriteHie( Abc_Ntk_t * pNtk, char * pBaseName, char * pFileName )
// reintroduce the boxes into the netlist // reintroduce the boxes into the netlist
if ( Abc_NtkBlackboxNum(pNtkBase) > 0 ) if ( Abc_NtkBlackboxNum(pNtkBase) > 0 )
{ {
// bring the current network to the same representation
if ( Abc_NtkIsLogic(pNtk) )
{
if ( Abc_NtkIsSopNetlist(pNtkBase) )
Abc_NtkLogicToSop( pNtk, 0 );
else if ( Abc_NtkIsAigNetlist(pNtkBase) )
Abc_NtkLogicToAig( pNtk );
}
// derive the netlist // derive the netlist
pNtkResult = Abc_NtkLogicToNetlist( pNtk, 0 ); pNtkResult = Abc_NtkToNetlist( pNtk, 0 );
pNtkResult = Abc_NtkInsertNewLogic( pNtkBase, pNtkTemp = pNtkResult ); pNtkResult = Abc_NtkInsertNewLogic( pNtkBase, pNtkTemp = pNtkResult );
Abc_NtkDelete( pNtkTemp ); Abc_NtkDelete( pNtkTemp );
if ( pNtkResult ) if ( pNtkResult )
printf( "Hierarchy writer reintroduced %d blackboxes.\n", Abc_NtkBlackboxNum(pNtkBase) ); printf( "Hierarchy writer reintroduced %d instances of blackboxes.\n", Abc_NtkBlackboxNum(pNtkBase) );
} }
else else
{ {
printf( "Warning: The output network does not contain blackboxes.\n" ); printf( "Warning: The output network does not contain blackboxes.\n" );
pNtkResult = Abc_NtkLogicToNetlist( pNtk, 0 ); pNtkResult = Abc_NtkToNetlist( pNtk, 0 );
} }
Abc_NtkDelete( pNtkBase ); Abc_NtkDelete( pNtkBase );
if ( pNtkResult == NULL ) if ( pNtkResult == NULL )
...@@ -477,11 +475,15 @@ void Io_WriteHie( Abc_Ntk_t * pNtk, char * pBaseName, char * pFileName ) ...@@ -477,11 +475,15 @@ void Io_WriteHie( Abc_Ntk_t * pNtk, char * pBaseName, char * pFileName )
// write the resulting network // write the resulting network
if ( Io_ReadFileType(pFileName) == IO_FILE_BLIF ) if ( Io_ReadFileType(pFileName) == IO_FILE_BLIF )
{
if ( !Abc_NtkHasSop(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
Abc_NtkToSop( pNtkResult, 0 );
Io_WriteBlif( pNtkResult, pFileName, 1 ); Io_WriteBlif( pNtkResult, pFileName, 1 );
}
else if ( Io_ReadFileType(pFileName) == IO_FILE_VERILOG ) else if ( Io_ReadFileType(pFileName) == IO_FILE_VERILOG )
{ {
if ( Abc_NtkIsSopNetlist(pNtkResult) ) if ( !Abc_NtkHasAig(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
Abc_NtkSopToAig( pNtkResult ); Abc_NtkToAig( pNtkResult );
Io_WriteVerilog( pNtkResult, pFileName ); Io_WriteVerilog( pNtkResult, pFileName );
} }
else else
......
...@@ -32,9 +32,9 @@ static void Io_NtkWritePis( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches ); ...@@ -32,9 +32,9 @@ static void Io_NtkWritePis( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches );
static void Io_NtkWritePos( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches ); static void Io_NtkWritePos( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches );
static void Io_NtkWriteSubckt( FILE * pFile, Abc_Obj_t * pNode ); static void Io_NtkWriteSubckt( FILE * pFile, Abc_Obj_t * pNode );
static void Io_NtkWriteAsserts( FILE * pFile, Abc_Ntk_t * pNtk ); static void Io_NtkWriteAsserts( FILE * pFile, Abc_Ntk_t * pNtk );
static void Io_NtkWriteNodeGate( FILE * pFile, Abc_Obj_t * pNode ); static void Io_NtkWriteNodeGate( FILE * pFile, Abc_Obj_t * pNode, int Length );
static void Io_NtkWriteNodeFanins( FILE * pFile, Abc_Obj_t * pNode ); static void Io_NtkWriteNodeFanins( FILE * pFile, Abc_Obj_t * pNode );
static void Io_NtkWriteNode( FILE * pFile, Abc_Obj_t * pNode ); static void Io_NtkWriteNode( FILE * pFile, Abc_Obj_t * pNode, int Length );
static void Io_NtkWriteLatch( FILE * pFile, Abc_Obj_t * pLatch ); static void Io_NtkWriteLatch( FILE * pFile, Abc_Obj_t * pLatch );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -56,7 +56,7 @@ void Io_WriteBlifLogic( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches ) ...@@ -56,7 +56,7 @@ void Io_WriteBlifLogic( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches )
{ {
Abc_Ntk_t * pNtkTemp; Abc_Ntk_t * pNtkTemp;
// derive the netlist // derive the netlist
pNtkTemp = Abc_NtkLogicToNetlist(pNtk,0); pNtkTemp = Abc_NtkToNetlist(pNtk,0);
if ( pNtkTemp == NULL ) if ( pNtkTemp == NULL )
{ {
fprintf( stdout, "Writing BLIF has failed.\n" ); fprintf( stdout, "Writing BLIF has failed.\n" );
...@@ -97,13 +97,22 @@ void Io_WriteBlif( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches ) ...@@ -97,13 +97,22 @@ void Io_WriteBlif( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches )
if ( Abc_NtkBlackboxNum(pNtk) > 0 ) if ( Abc_NtkBlackboxNum(pNtk) > 0 )
{ {
Abc_Ntk_t * pNtkTemp; Abc_Ntk_t * pNtkTemp;
Abc_Obj_t * pObj;
int i; int i;
/*
Abc_Obj_t * pObj;
Abc_NtkForEachBlackbox( pNtk, pObj, i ) Abc_NtkForEachBlackbox( pNtk, pObj, i )
{ {
pNtkTemp = pObj->pData; pNtkTemp = pObj->pData;
assert( pNtkTemp != NULL && Abc_NtkHasBlackbox(pNtkTemp) ); assert( pNtkTemp != NULL && Abc_NtkHasBlackbox(pNtkTemp) );
fprintf( pFile, "\n\n", Abc_NtkName(pNtk) ); fprintf( pFile, "\n\n" );
Io_NtkWrite( pFile, pNtkTemp, fWriteLatches );
}
*/
Vec_PtrForEachEntry( pNtk->pDesign->vModules, pNtkTemp, i )
{
if ( pNtkTemp == pNtk )
continue;
fprintf( pFile, "\n\n" );
Io_NtkWrite( pFile, pNtkTemp, fWriteLatches ); Io_NtkWrite( pFile, pNtkTemp, fWriteLatches );
} }
} }
...@@ -156,7 +165,7 @@ void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches ) ...@@ -156,7 +165,7 @@ void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches )
{ {
ProgressBar * pProgress; ProgressBar * pProgress;
Abc_Obj_t * pNode, * pLatch; Abc_Obj_t * pNode, * pLatch;
int i; int i, Length;
// write the PIs // write the PIs
fprintf( pFile, ".inputs" ); fprintf( pFile, ".inputs" );
...@@ -206,11 +215,12 @@ void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches ) ...@@ -206,11 +215,12 @@ void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches )
} }
// write each internal node // write each internal node
Length = Abc_NtkHasMapping(pNtk)? Mio_LibraryReadGateNameMax(pNtk->pManFunc) : 0;
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
Io_NtkWriteNode( pFile, pNode ); Io_NtkWriteNode( pFile, pNode, Length );
} }
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
} }
...@@ -454,13 +464,13 @@ void Io_NtkWriteLatch( FILE * pFile, Abc_Obj_t * pLatch ) ...@@ -454,13 +464,13 @@ void Io_NtkWriteLatch( FILE * pFile, Abc_Obj_t * pLatch )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Io_NtkWriteNode( FILE * pFile, Abc_Obj_t * pNode ) void Io_NtkWriteNode( FILE * pFile, Abc_Obj_t * pNode, int Length )
{ {
if ( Abc_NtkHasMapping(pNode->pNtk) ) if ( Abc_NtkHasMapping(pNode->pNtk) )
{ {
// write the .gate line // write the .gate line
fprintf( pFile, ".gate" ); fprintf( pFile, ".gate" );
Io_NtkWriteNodeGate( pFile, pNode ); Io_NtkWriteNodeGate( pFile, pNode, Length );
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
} }
else else
...@@ -485,17 +495,17 @@ void Io_NtkWriteNode( FILE * pFile, Abc_Obj_t * pNode ) ...@@ -485,17 +495,17 @@ void Io_NtkWriteNode( FILE * pFile, Abc_Obj_t * pNode )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Io_NtkWriteNodeGate( FILE * pFile, Abc_Obj_t * pNode ) void Io_NtkWriteNodeGate( FILE * pFile, Abc_Obj_t * pNode, int Length )
{ {
Mio_Gate_t * pGate = pNode->pData; Mio_Gate_t * pGate = pNode->pData;
Mio_Pin_t * pGatePin; Mio_Pin_t * pGatePin;
int i; int i;
// write the node // write the node
fprintf( pFile, " %s ", Mio_GateReadName(pGate) ); fprintf( pFile, " %-*s ", Length, Mio_GateReadName(pGate) );
for ( pGatePin = Mio_GateReadPins(pGate), i = 0; pGatePin; pGatePin = Mio_PinReadNext(pGatePin), i++ ) for ( pGatePin = Mio_GateReadPins(pGate), i = 0; pGatePin; pGatePin = Mio_PinReadNext(pGatePin), i++ )
fprintf( pFile, "%s=%s ", Mio_PinReadName(pGatePin), Abc_ObjName( Abc_ObjFanin(pNode,i) ) ); fprintf( pFile, "%s=%s ", Mio_PinReadName(pGatePin), Abc_ObjName( Abc_ObjFanin(pNode,i) ) );
assert ( i == Abc_ObjFaninNum(pNode) ); assert ( i == Abc_ObjFaninNum(pNode) );
fprintf( pFile, "%s=%s", Mio_GateReadOutName(pGate), Abc_ObjName(pNode) ); fprintf( pFile, "%s=%s", Mio_GateReadOutName(pGate), Abc_ObjName( Abc_ObjFanout0(pNode) ) );
} }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -66,7 +66,7 @@ int Io_WriteCnf( Abc_Ntk_t * pNtk, char * pFileName, int fAllPrimes ) ...@@ -66,7 +66,7 @@ int Io_WriteCnf( Abc_Ntk_t * pNtk, char * pFileName, int fAllPrimes )
} }
// convert to logic BDD network // convert to logic BDD network
if ( Abc_NtkIsLogic(pNtk) ) if ( Abc_NtkIsLogic(pNtk) )
Abc_NtkLogicToBdd( pNtk ); Abc_NtkToBdd( pNtk );
// create solver with clauses // create solver with clauses
pSat = Abc_NtkMiterSatCreate( pNtk, fAllPrimes ); pSat = Abc_NtkMiterSatCreate( pNtk, fAllPrimes );
if ( pSat == NULL ) if ( pSat == NULL )
......
...@@ -34,7 +34,7 @@ static void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start ); ...@@ -34,7 +34,7 @@ static void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start );
static void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk ); static void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk );
static void Io_WriteVerilogObjects( FILE * pFile, Abc_Ntk_t * pNtk ); static void Io_WriteVerilogObjects( FILE * pFile, Abc_Ntk_t * pNtk );
static int Io_WriteVerilogWiresCount( Abc_Ntk_t * pNtk ); static int Io_WriteVerilogWiresCount( Abc_Ntk_t * pNtk );
static char * Io_WriteVerilogGetName( Abc_Obj_t * pObj ); static char * Io_WriteVerilogGetName( char * pName );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
...@@ -57,9 +57,9 @@ void Io_WriteVerilog( Abc_Ntk_t * pNtk, char * pFileName ) ...@@ -57,9 +57,9 @@ void Io_WriteVerilog( Abc_Ntk_t * pNtk, char * pFileName )
FILE * pFile; FILE * pFile;
int i; int i;
// can only write nodes represented using local AIGs // can only write nodes represented using local AIGs
if ( !Abc_NtkIsAigNetlist(pNtk) ) if ( !Abc_NtkIsAigNetlist(pNtk) && !Abc_NtkIsMappedNetlist(pNtk) )
{ {
printf( "Io_WriteVerilog(): Can produce Verilog for AIG netlists only.\n" ); printf( "Io_WriteVerilog(): Can produce Verilog for mapped or AIG netlists only.\n" );
return; return;
} }
// start the output stream // start the output stream
...@@ -77,16 +77,17 @@ void Io_WriteVerilog( Abc_Ntk_t * pNtk, char * pFileName ) ...@@ -77,16 +77,17 @@ void Io_WriteVerilog( Abc_Ntk_t * pNtk, char * pFileName )
// write modules // write modules
if ( pNtk->pDesign ) if ( pNtk->pDesign )
{ {
// write the network first
Io_WriteVerilogInt( pFile, pNtk );
// write other things
Vec_PtrForEachEntry( pNtk->pDesign->vModules, pNetlist, i ) Vec_PtrForEachEntry( pNtk->pDesign->vModules, pNetlist, i )
{ {
assert( Abc_NtkIsNetlist(pNetlist) ); assert( Abc_NtkIsNetlist(pNetlist) );
if ( pNetlist == pNtk ) if ( pNetlist == pNtk )
continue; continue;
Io_WriteVerilogInt( pFile, pNetlist );
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
Io_WriteVerilogInt( pFile, pNetlist );
} }
// write the network last
Io_WriteVerilogInt( pFile, pNtk );
} }
else else
{ {
...@@ -185,7 +186,7 @@ void Io_WriteVerilogPis( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -185,7 +186,7 @@ void Io_WriteVerilogPis( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
{ {
pNet = Abc_ObjFanout0(pTerm); pNet = Abc_ObjFanout0(pTerm);
// get the line length after this name is written // get the line length after this name is written
AddedLength = strlen(Io_WriteVerilogGetName(pNet)) + 2; AddedLength = strlen(Io_WriteVerilogGetName(Abc_ObjName(pNet))) + 2;
if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH ) if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
{ // write the line extender { // write the line extender
fprintf( pFile, "\n " ); fprintf( pFile, "\n " );
...@@ -193,7 +194,7 @@ void Io_WriteVerilogPis( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -193,7 +194,7 @@ void Io_WriteVerilogPis( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
LineLength = 3; LineLength = 3;
NameCounter = 0; NameCounter = 0;
} }
fprintf( pFile, " %s%s", Io_WriteVerilogGetName(pNet), (i==Abc_NtkPiNum(pNtk)-1)? "" : "," ); fprintf( pFile, " %s%s", Io_WriteVerilogGetName(Abc_ObjName(pNet)), (i==Abc_NtkPiNum(pNtk)-1)? "" : "," );
LineLength += AddedLength; LineLength += AddedLength;
NameCounter++; NameCounter++;
} }
...@@ -224,7 +225,7 @@ void Io_WriteVerilogPos( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -224,7 +225,7 @@ void Io_WriteVerilogPos( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
{ {
pNet = Abc_ObjFanin0(pTerm); pNet = Abc_ObjFanin0(pTerm);
// get the line length after this name is written // get the line length after this name is written
AddedLength = strlen(Io_WriteVerilogGetName(pNet)) + 2; AddedLength = strlen(Io_WriteVerilogGetName(Abc_ObjName(pNet))) + 2;
if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH ) if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
{ // write the line extender { // write the line extender
fprintf( pFile, "\n " ); fprintf( pFile, "\n " );
...@@ -232,7 +233,7 @@ void Io_WriteVerilogPos( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -232,7 +233,7 @@ void Io_WriteVerilogPos( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
LineLength = 3; LineLength = 3;
NameCounter = 0; NameCounter = 0;
} }
fprintf( pFile, " %s%s", Io_WriteVerilogGetName(pNet), (i==Abc_NtkPoNum(pNtk)-1)? "" : "," ); fprintf( pFile, " %s%s", Io_WriteVerilogGetName(Abc_ObjName(pNet)), (i==Abc_NtkPoNum(pNtk)-1)? "" : "," );
LineLength += AddedLength; LineLength += AddedLength;
NameCounter++; NameCounter++;
} }
...@@ -273,7 +274,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -273,7 +274,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
continue; continue;
Counter++; Counter++;
// get the line length after this name is written // get the line length after this name is written
AddedLength = strlen(Io_WriteVerilogGetName(pNet)) + 2; AddedLength = strlen(Io_WriteVerilogGetName(Abc_ObjName(pNet))) + 2;
if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH ) if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
{ // write the line extender { // write the line extender
fprintf( pFile, "\n " ); fprintf( pFile, "\n " );
...@@ -281,7 +282,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -281,7 +282,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
LineLength = 3; LineLength = 3;
NameCounter = 0; NameCounter = 0;
} }
fprintf( pFile, " %s%s", Io_WriteVerilogGetName(pNet), (Counter==nNodes)? "" : "," ); fprintf( pFile, " %s%s", Io_WriteVerilogGetName(Abc_ObjName(pNet)), (Counter==nNodes)? "" : "," );
LineLength += AddedLength; LineLength += AddedLength;
NameCounter++; NameCounter++;
} }
...@@ -290,7 +291,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -290,7 +291,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
pNet = Abc_ObjFanin0(Abc_ObjFanin0(pObj)); pNet = Abc_ObjFanin0(Abc_ObjFanin0(pObj));
Counter++; Counter++;
// get the line length after this name is written // get the line length after this name is written
AddedLength = strlen(Io_WriteVerilogGetName(pNet)) + 2; AddedLength = strlen(Io_WriteVerilogGetName(Abc_ObjName(pNet))) + 2;
if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH ) if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
{ // write the line extender { // write the line extender
fprintf( pFile, "\n " ); fprintf( pFile, "\n " );
...@@ -298,7 +299,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -298,7 +299,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
LineLength = 3; LineLength = 3;
NameCounter = 0; NameCounter = 0;
} }
fprintf( pFile, " %s%s", Io_WriteVerilogGetName(pNet), (Counter==nNodes)? "" : "," ); fprintf( pFile, " %s%s", Io_WriteVerilogGetName(Abc_ObjName(pNet)), (Counter==nNodes)? "" : "," );
LineLength += AddedLength; LineLength += AddedLength;
NameCounter++; NameCounter++;
} }
...@@ -311,7 +312,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -311,7 +312,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
pNet = Abc_ObjFanin0(pTerm); pNet = Abc_ObjFanin0(pTerm);
Counter++; Counter++;
// get the line length after this name is written // get the line length after this name is written
AddedLength = strlen(Io_WriteVerilogGetName(pNet)) + 2; AddedLength = strlen(Io_WriteVerilogGetName(Abc_ObjName(pNet))) + 2;
if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH ) if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
{ // write the line extender { // write the line extender
fprintf( pFile, "\n " ); fprintf( pFile, "\n " );
...@@ -319,7 +320,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -319,7 +320,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
LineLength = 3; LineLength = 3;
NameCounter = 0; NameCounter = 0;
} }
fprintf( pFile, " %s%s", Io_WriteVerilogGetName(pNet), (Counter==nNodes)? "" : "," ); fprintf( pFile, " %s%s", Io_WriteVerilogGetName(Abc_ObjName(pNet)), (Counter==nNodes)? "" : "," );
LineLength += AddedLength; LineLength += AddedLength;
NameCounter++; NameCounter++;
} }
...@@ -330,7 +331,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -330,7 +331,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
continue; continue;
Counter++; Counter++;
// get the line length after this name is written // get the line length after this name is written
AddedLength = strlen(Io_WriteVerilogGetName(pNet)) + 2; AddedLength = strlen(Io_WriteVerilogGetName(Abc_ObjName(pNet))) + 2;
if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH ) if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
{ // write the line extender { // write the line extender
fprintf( pFile, "\n " ); fprintf( pFile, "\n " );
...@@ -338,7 +339,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -338,7 +339,7 @@ void Io_WriteVerilogWires( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
LineLength = 3; LineLength = 3;
NameCounter = 0; NameCounter = 0;
} }
fprintf( pFile, " %s%s", Io_WriteVerilogGetName(pNet), (Counter==nNodes)? "" : "," ); fprintf( pFile, " %s%s", Io_WriteVerilogGetName(Abc_ObjName(pNet)), (Counter==nNodes)? "" : "," );
LineLength += AddedLength; LineLength += AddedLength;
NameCounter++; NameCounter++;
} }
...@@ -377,7 +378,7 @@ void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -377,7 +378,7 @@ void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
pNet = Abc_ObjFanout0(Abc_ObjFanout0(pLatch)); pNet = Abc_ObjFanout0(Abc_ObjFanout0(pLatch));
Counter++; Counter++;
// get the line length after this name is written // get the line length after this name is written
AddedLength = strlen(Io_WriteVerilogGetName(pNet)) + 2; AddedLength = strlen(Io_WriteVerilogGetName(Abc_ObjName(pNet))) + 2;
if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH ) if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
{ // write the line extender { // write the line extender
fprintf( pFile, "\n " ); fprintf( pFile, "\n " );
...@@ -385,7 +386,7 @@ void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -385,7 +386,7 @@ void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
LineLength = 3; LineLength = 3;
NameCounter = 0; NameCounter = 0;
} }
fprintf( pFile, " %s%s", Io_WriteVerilogGetName(pNet), (Counter==nNodes)? "" : "," ); fprintf( pFile, " %s%s", Io_WriteVerilogGetName(Abc_ObjName(pNet)), (Counter==nNodes)? "" : "," );
LineLength += AddedLength; LineLength += AddedLength;
NameCounter++; NameCounter++;
} }
...@@ -402,35 +403,6 @@ void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start ) ...@@ -402,35 +403,6 @@ void Io_WriteVerilogRegs( FILE * pFile, Abc_Ntk_t * pNtk, int Start )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Io_WriteVerilogLatches2( FILE * pFile, Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pLatch;
int i;
Abc_NtkForEachLatch( pNtk, pLatch, i )
{
// fprintf( pFile, " always @(posedge gclk) begin %s", Abc_ObjName(Abc_ObjFanout0(pLatch)) );
fprintf( pFile, " always begin %s", Io_WriteVerilogGetName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) );
fprintf( pFile, " = %s; end\n", Io_WriteVerilogGetName(Abc_ObjFanin0(Abc_ObjFanin0(pLatch))) );
if ( Abc_LatchInit(pLatch) == ABC_INIT_ZERO )
// fprintf( pFile, " initial begin %s = 1\'b0; end\n", Io_WriteVerilogGetName(Abc_ObjFanout0(pLatch)) );
fprintf( pFile, " initial begin %s = 0; end\n", Io_WriteVerilogGetName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) );
else if ( Abc_LatchInit(pLatch) == ABC_INIT_ONE )
// fprintf( pFile, " initial begin %s = 1\'b1; end\n", Io_WriteVerilogGetName(Abc_ObjFanout0(pLatch)) );
fprintf( pFile, " initial begin %s = 1; end\n", Io_WriteVerilogGetName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) );
}
}
/**Function*************************************************************
Synopsis [Writes the latches.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk ) void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk )
{ {
Abc_Obj_t * pLatch; Abc_Obj_t * pLatch;
...@@ -442,8 +414,8 @@ void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -442,8 +414,8 @@ void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk )
fprintf( pFile, " always begin\n" ); fprintf( pFile, " always begin\n" );
Abc_NtkForEachLatch( pNtk, pLatch, i ) Abc_NtkForEachLatch( pNtk, pLatch, i )
{ {
fprintf( pFile, " %s", Io_WriteVerilogGetName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) ); fprintf( pFile, " %s", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch)))) );
fprintf( pFile, " <= %s;\n", Io_WriteVerilogGetName(Abc_ObjFanin0(Abc_ObjFanin0(pLatch))) ); fprintf( pFile, " <= %s;\n", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin0(pLatch)))) );
} }
fprintf( pFile, " end\n" ); fprintf( pFile, " end\n" );
// check if there are initial values // check if there are initial values
...@@ -453,13 +425,13 @@ void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -453,13 +425,13 @@ void Io_WriteVerilogLatches( FILE * pFile, Abc_Ntk_t * pNtk )
if ( i == Abc_NtkLatchNum(pNtk) ) if ( i == Abc_NtkLatchNum(pNtk) )
return; return;
// write the initial values // write the initial values
fprintf( pFile, " initial begin\n", Io_WriteVerilogGetName(Abc_ObjFanout0(Abc_NtkPi(pNtk,0))) ); fprintf( pFile, " initial begin\n", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(Abc_NtkPi(pNtk,0)))) );
Abc_NtkForEachLatch( pNtk, pLatch, i ) Abc_NtkForEachLatch( pNtk, pLatch, i )
{ {
if ( Abc_LatchInit(pLatch) == ABC_INIT_ZERO ) if ( Abc_LatchInit(pLatch) == ABC_INIT_ZERO )
fprintf( pFile, " %s <= 1\'b0;\n", Io_WriteVerilogGetName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) ); fprintf( pFile, " %s <= 1\'b0;\n", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch)))) );
else if ( Abc_LatchInit(pLatch) == ABC_INIT_ONE ) else if ( Abc_LatchInit(pLatch) == ABC_INIT_ONE )
fprintf( pFile, " %s <= 1\'b1;\n", Io_WriteVerilogGetName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch))) ); fprintf( pFile, " %s <= 1\'b1;\n", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pLatch)))) );
} }
fprintf( pFile, " end\n" ); fprintf( pFile, " end\n" );
} }
...@@ -481,48 +453,73 @@ void Io_WriteVerilogObjects( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -481,48 +453,73 @@ void Io_WriteVerilogObjects( FILE * pFile, Abc_Ntk_t * pNtk )
Abc_Ntk_t * pNtkBox; Abc_Ntk_t * pNtkBox;
Abc_Obj_t * pObj, * pTerm, * pFanin; Abc_Obj_t * pObj, * pTerm, * pFanin;
Hop_Obj_t * pFunc; Hop_Obj_t * pFunc;
int i, k, Counter, nDigits; int i, k, Counter, nDigits, Length;
Counter = 1;
nDigits = Extra_Base10Log( Abc_NtkNodeNum(pNtk) );
// write boxes // write boxes
nDigits = Extra_Base10Log( Abc_NtkBoxNum(pNtk)-Abc_NtkLatchNum(pNtk) );
Counter = 0;
Abc_NtkForEachBox( pNtk, pObj, i ) Abc_NtkForEachBox( pNtk, pObj, i )
{ {
if ( Abc_ObjIsLatch(pObj) ) if ( Abc_ObjIsLatch(pObj) )
continue; continue;
pNtkBox = pObj->pData; pNtkBox = pObj->pData;
fprintf( pFile, " %s g%0*d", pNtkBox->pName, nDigits, Counter++ ); fprintf( pFile, " %s box%0*d", pNtkBox->pName, nDigits, Counter++ );
fprintf( pFile, "(" ); fprintf( pFile, "(" );
Abc_NtkForEachPi( pNtkBox, pTerm, k ) Abc_NtkForEachPi( pNtkBox, pTerm, k )
{ {
fprintf( pFile, ".%s ", Io_WriteVerilogGetName(Abc_ObjFanout0(pTerm)) ); fprintf( pFile, ".%s", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(pTerm))) );
fprintf( pFile, "(%s), ", Io_WriteVerilogGetName(Abc_ObjFanin0(Abc_ObjFanin(pObj,k))) ); fprintf( pFile, "(%s), ", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin(pObj,k)))) );
} }
Abc_NtkForEachPo( pNtkBox, pTerm, k ) Abc_NtkForEachPo( pNtkBox, pTerm, k )
{ {
fprintf( pFile, ".%s ", Io_WriteVerilogGetName(Abc_ObjFanin0(pTerm)) ); fprintf( pFile, ".%s", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanin0(pTerm))) );
fprintf( pFile, "(%s)%s", Io_WriteVerilogGetName(Abc_ObjFanout0(Abc_ObjFanout(pObj,k))), k==Abc_NtkPoNum(pNtkBox)-1? "":", " ); fprintf( pFile, "(%s)%s", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout(pObj,k)))), k==Abc_NtkPoNum(pNtkBox)-1? "":", " );
} }
fprintf( pFile, ");\n" ); fprintf( pFile, ");\n" );
} }
// write nodes // write nodes
vLevels = Vec_VecAlloc( 10 ); if ( Abc_NtkHasMapping(pNtk) )
Abc_NtkForEachNode( pNtk, pObj, i )
{ {
pFunc = pObj->pData; Length = Mio_LibraryReadGateNameMax(pNtk->pManFunc);
fprintf( pFile, " assign %s = ", Io_WriteVerilogGetName(Abc_ObjFanout0(pObj)) ); nDigits = Extra_Base10Log( Abc_NtkNodeNum(pNtk) );
// set the input names Counter = 0;
Abc_ObjForEachFanin( pObj, pFanin, k ) Abc_NtkForEachNode( pNtk, pObj, k )
Hop_IthVar(pNtk->pManFunc, k)->pData = Extra_UtilStrsav(Io_WriteVerilogGetName(pFanin)); {
// write the formula Mio_Gate_t * pGate = pObj->pData;
Hop_ObjPrintVerilog( pFile, pFunc, vLevels, 0 ); Mio_Pin_t * pGatePin;
fprintf( pFile, ";\n" ); // write the node
// clear the input names fprintf( pFile, " %-*s g%0*d", Length, Mio_GateReadName(pGate), nDigits, Counter++ );
Abc_ObjForEachFanin( pObj, pFanin, k ) fprintf( pFile, "(" );
free( Hop_IthVar(pNtk->pManFunc, k)->pData ); for ( pGatePin = Mio_GateReadPins(pGate), i = 0; pGatePin; pGatePin = Mio_PinReadNext(pGatePin), i++ )
{
fprintf( pFile, ".%s", Io_WriteVerilogGetName(Mio_PinReadName(pGatePin)) );
fprintf( pFile, "(%s), ", Io_WriteVerilogGetName(Abc_ObjName( Abc_ObjFanin(pObj,i) )) );
}
assert ( i == Abc_ObjFaninNum(pObj) );
fprintf( pFile, ".%s", Io_WriteVerilogGetName(Mio_GateReadOutName(pGate)) );
fprintf( pFile, "(%s)", Io_WriteVerilogGetName(Abc_ObjName( Abc_ObjFanout0(pObj) )) );
fprintf( pFile, ");\n" );
}
}
else
{
vLevels = Vec_VecAlloc( 10 );
Abc_NtkForEachNode( pNtk, pObj, i )
{
pFunc = pObj->pData;
fprintf( pFile, " assign %s = ", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(pObj))) );
// set the input names
Abc_ObjForEachFanin( pObj, pFanin, k )
Hop_IthVar(pNtk->pManFunc, k)->pData = Extra_UtilStrsav(Io_WriteVerilogGetName(Abc_ObjName(pFanin)));
// write the formula
Hop_ObjPrintVerilog( pFile, pFunc, vLevels, 0 );
fprintf( pFile, ";\n" );
// clear the input names
Abc_ObjForEachFanin( pObj, pFanin, k )
free( Hop_IthVar(pNtk->pManFunc, k)->pData );
}
Vec_VecFree( vLevels );
} }
Vec_VecFree( vLevels );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -577,12 +574,10 @@ int Io_WriteVerilogWiresCount( Abc_Ntk_t * pNtk ) ...@@ -577,12 +574,10 @@ int Io_WriteVerilogWiresCount( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
char * Io_WriteVerilogGetName( Abc_Obj_t * pObj ) char * Io_WriteVerilogGetName( char * pName )
{ {
static char Buffer[500]; static char Buffer[500];
char * pName;
int Length, i; int Length, i;
pName = Abc_ObjName(pObj);
Length = strlen(pName); Length = strlen(pName);
// consider the case of a signal having name "0" or "1" // consider the case of a signal having name "0" or "1"
if ( !(Length == 1 && (pName[0] == '0' || pName[0] == '1')) ) if ( !(Length == 1 && (pName[0] == '0' || pName[0] == '1')) )
......
...@@ -45,18 +45,18 @@ typedef struct Ver_Stream_t_ Ver_Stream_t; ...@@ -45,18 +45,18 @@ typedef struct Ver_Stream_t_ Ver_Stream_t;
struct Ver_Man_t_ struct Ver_Man_t_
{ {
// internal parameters
int fMapped; // mapped verilog
int fUseMemMan; // allocate memory manager in the networks
int fCheck; // checks network for currectness
// input file stream // input file stream
char * pFileName; char * pFileName;
Ver_Stream_t * pReader; Ver_Stream_t * pReader;
int fNameLast; int fNameLast;
ProgressBar * pProgress; ProgressBar * pProgress;
// current network and library // current design
Abc_Ntk_t * pNtkCur; // the network under construction Abc_Lib_t * pDesign;
Abc_Lib_t * pDesign; // the current design // error handling
// parameters
int fUseMemMan; // allocate memory manager in the networks
int fCheck; // checks network for currectness
// error recovery
FILE * Output; FILE * Output;
int fTopLevel; int fTopLevel;
int fError; int fError;
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
***********************************************************************/ ***********************************************************************/
#include "ver.h" #include "ver.h"
#include "mio.h"
#include "main.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// DECLARATIONS /// /// DECLARATIONS ///
...@@ -51,50 +53,29 @@ static void Ver_ParseStop( Ver_Man_t * p ); ...@@ -51,50 +53,29 @@ static void Ver_ParseStop( Ver_Man_t * p );
static void Ver_ParseFreeData( Ver_Man_t * p ); static void Ver_ParseFreeData( Ver_Man_t * p );
static void Ver_ParseInternal( Ver_Man_t * p ); static void Ver_ParseInternal( Ver_Man_t * p );
static int Ver_ParseModule( Ver_Man_t * p ); static int Ver_ParseModule( Ver_Man_t * p );
static int Ver_ParseSignal( Ver_Man_t * p, Ver_SignalType_t SigType ); static int Ver_ParseSignal( Ver_Man_t * p, Abc_Ntk_t * pNtk, Ver_SignalType_t SigType );
static int Ver_ParseAssign( Ver_Man_t * p ); static int Ver_ParseAlways( Ver_Man_t * p, Abc_Ntk_t * pNtk );
static int Ver_ParseAlways( Ver_Man_t * p ); static int Ver_ParseInitial( Ver_Man_t * p, Abc_Ntk_t * pNtk );
static int Ver_ParseInitial( Ver_Man_t * p ); static int Ver_ParseAssign( Ver_Man_t * p, Abc_Ntk_t * pNtk );
static int Ver_ParseGate( Ver_Man_t * p, Abc_Ntk_t * pNtkGate ); static int Ver_ParseGateStandard( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Ver_GateType_t GateType );
static int Ver_ParseGateStandard( Ver_Man_t * pMan, Ver_GateType_t GateType ); static int Ver_ParseGate( Ver_Man_t * p, Abc_Ntk_t * pNtk, Mio_Gate_t * pGate );
static int Ver_ParseBox( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkBox );
static int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox );
static int Vec_ParseAttachBoxes( Ver_Man_t * pMan );
static Abc_Obj_t * Ver_ParseCreatePi( Abc_Ntk_t * pNtk, char * pName ); static Abc_Obj_t * Ver_ParseCreatePi( Abc_Ntk_t * pNtk, char * pName );
static Abc_Obj_t * Ver_ParseCreatePo( Abc_Ntk_t * pNtk, char * pName ); static Abc_Obj_t * Ver_ParseCreatePo( Abc_Ntk_t * pNtk, char * pName );
static Abc_Obj_t * Ver_ParseCreateLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pNetLI, Abc_Obj_t * pNetLO ); static Abc_Obj_t * Ver_ParseCreateLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pNetLI, Abc_Obj_t * pNetLO );
static Abc_Obj_t * Ver_ParseCreateInv( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet ); static Abc_Obj_t * Ver_ParseCreateInv( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet );
static inline int Ver_NtkIsDefined( Abc_Ntk_t * pNtkBox ) { assert( pNtkBox->pName ); return Abc_NtkPiNum(pNtkBox) || Abc_NtkPoNum(pNtkBox); }
static inline int Ver_ObjIsConnected( Abc_Obj_t * pObj ) { assert( Abc_ObjIsBox(pObj) ); return Abc_ObjFaninNum(pObj) || Abc_ObjFanoutNum(pObj); }
int glo_fMapped = 0; // this is bad!
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [File parser.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, int fUseMemMan )
{
Ver_Man_t * p;
Abc_Lib_t * pDesign;
// start the parser
p = Ver_ParseStart( pFileName, pGateLib );
p->fCheck = fCheck;
p->fUseMemMan = fUseMemMan;
// parse the file
Ver_ParseInternal( p );
// save the result
pDesign = p->pDesign;
p->pDesign = NULL;
// stop the parser
Ver_ParseStop( p );
return pDesign;
}
/**Function************************************************************* /**Function*************************************************************
...@@ -114,6 +95,8 @@ Ver_Man_t * Ver_ParseStart( char * pFileName, Abc_Lib_t * pGateLib ) ...@@ -114,6 +95,8 @@ Ver_Man_t * Ver_ParseStart( char * pFileName, Abc_Lib_t * pGateLib )
memset( p, 0, sizeof(Ver_Man_t) ); memset( p, 0, sizeof(Ver_Man_t) );
p->pFileName = pFileName; p->pFileName = pFileName;
p->pReader = Ver_StreamAlloc( pFileName ); p->pReader = Ver_StreamAlloc( pFileName );
if ( p->pReader == NULL )
return NULL;
p->Output = stdout; p->Output = stdout;
p->pProgress = Extra_ProgressBarStart( stdout, Ver_StreamGetFileSize(p->pReader) ); p->pProgress = Extra_ProgressBarStart( stdout, Ver_StreamGetFileSize(p->pReader) );
p->vNames = Vec_PtrAlloc( 100 ); p->vNames = Vec_PtrAlloc( 100 );
...@@ -122,6 +105,7 @@ Ver_Man_t * Ver_ParseStart( char * pFileName, Abc_Lib_t * pGateLib ) ...@@ -122,6 +105,7 @@ Ver_Man_t * Ver_ParseStart( char * pFileName, Abc_Lib_t * pGateLib )
// create the design library and assign the technology library // create the design library and assign the technology library
p->pDesign = Abc_LibCreate( pFileName ); p->pDesign = Abc_LibCreate( pFileName );
p->pDesign->pLibrary = pGateLib; p->pDesign->pLibrary = pGateLib;
p->pDesign->pGenlib = Abc_FrameReadLibGen();
return p; return p;
} }
...@@ -138,7 +122,6 @@ Ver_Man_t * Ver_ParseStart( char * pFileName, Abc_Lib_t * pGateLib ) ...@@ -138,7 +122,6 @@ Ver_Man_t * Ver_ParseStart( char * pFileName, Abc_Lib_t * pGateLib )
***********************************************************************/ ***********************************************************************/
void Ver_ParseStop( Ver_Man_t * p ) void Ver_ParseStop( Ver_Man_t * p )
{ {
assert( p->pNtkCur == NULL );
Ver_StreamFree( p->pReader ); Ver_StreamFree( p->pReader );
Extra_ProgressBarStop( p->pProgress ); Extra_ProgressBarStop( p->pProgress );
Vec_PtrFree( p->vNames ); Vec_PtrFree( p->vNames );
...@@ -146,6 +129,41 @@ void Ver_ParseStop( Ver_Man_t * p ) ...@@ -146,6 +129,41 @@ void Ver_ParseStop( Ver_Man_t * p )
Vec_IntFree( p->vStackOp ); Vec_IntFree( p->vStackOp );
free( p ); free( p );
} }
/**Function*************************************************************
Synopsis [File parser.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, int fUseMemMan )
{
Ver_Man_t * p;
Abc_Lib_t * pDesign;
// start the parser
p = Ver_ParseStart( pFileName, pGateLib );
p->fMapped = glo_fMapped;
p->fCheck = fCheck;
p->fUseMemMan = fUseMemMan;
if ( glo_fMapped )
{
Hop_ManStop(p->pDesign->pManFunc);
p->pDesign->pManFunc = NULL;
}
// parse the file
Ver_ParseInternal( p );
// save the result
pDesign = p->pDesign;
p->pDesign = NULL;
// stop the parser
Ver_ParseStop( p );
return pDesign;
}
/**Function************************************************************* /**Function*************************************************************
...@@ -160,7 +178,11 @@ void Ver_ParseStop( Ver_Man_t * p ) ...@@ -160,7 +178,11 @@ void Ver_ParseStop( Ver_Man_t * p )
***********************************************************************/ ***********************************************************************/
void Ver_ParseInternal( Ver_Man_t * pMan ) void Ver_ParseInternal( Ver_Man_t * pMan )
{ {
Abc_Ntk_t * pNtk;
char * pToken; char * pToken;
int i;
// preparse the modeles
while ( 1 ) while ( 1 )
{ {
// get the next token // get the next token
...@@ -173,30 +195,28 @@ void Ver_ParseInternal( Ver_Man_t * pMan ) ...@@ -173,30 +195,28 @@ void Ver_ParseInternal( Ver_Man_t * pMan )
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return; return;
} }
// parse the module // parse the module
if ( !Ver_ParseModule( pMan ) ) if ( !Ver_ParseModule(pMan) )
return; return;
}
// process defined and undefined boxes
if ( !Vec_ParseAttachBoxes( pMan ) )
return;
// connect the boxes and check
Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
{
// fix the dangling nets
Abc_NtkFinalizeRead( pNtk );
// check the network for correctness // check the network for correctness
if ( pMan->fCheck && !Abc_NtkCheckRead( pMan->pNtkCur ) ) if ( pMan->fCheck && !Abc_NtkCheckRead( pNtk ) )
{
pMan->fTopLevel = 1;
sprintf( pMan->sError, "The network check has failed.", pMan->pNtkCur->pName );
Ver_ParsePrintErrorMessage( pMan );
return;
}
// add the module to the hash table
if ( st_is_member( pMan->pDesign->tModules, pMan->pNtkCur->pName ) )
{ {
pMan->fTopLevel = 1; pMan->fTopLevel = 1;
sprintf( pMan->sError, "Module \"%s\" is defined more than once.", pMan->pNtkCur->pName ); sprintf( pMan->sError, "The network check has failed.", pNtk->pName );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return; return;
} }
Vec_PtrPush( pMan->pDesign->vModules, pMan->pNtkCur );
st_insert( pMan->pDesign->tModules, pMan->pNtkCur->pName, (char *)pMan->pNtkCur );
pMan->pNtkCur = NULL;
} }
} }
...@@ -213,12 +233,6 @@ void Ver_ParseInternal( Ver_Man_t * pMan ) ...@@ -213,12 +233,6 @@ void Ver_ParseInternal( Ver_Man_t * pMan )
***********************************************************************/ ***********************************************************************/
void Ver_ParseFreeData( Ver_Man_t * p ) void Ver_ParseFreeData( Ver_Man_t * p )
{ {
if ( p->pNtkCur )
{
p->pNtkCur->pManFunc = NULL;
Abc_NtkDelete( p->pNtkCur );
p->pNtkCur = NULL;
}
if ( p->pDesign ) if ( p->pDesign )
{ {
Abc_LibFree( p->pDesign, NULL ); Abc_LibFree( p->pDesign, NULL );
...@@ -249,7 +263,105 @@ void Ver_ParsePrintErrorMessage( Ver_Man_t * p ) ...@@ -249,7 +263,105 @@ void Ver_ParsePrintErrorMessage( Ver_Man_t * p )
Ver_ParseFreeData( p ); Ver_ParseFreeData( p );
} }
/**Function*************************************************************
Synopsis [Finds the network by name or create a new blackbox network.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Ver_ParseFindOrCreateNetwork( Ver_Man_t * pMan, char * pName )
{
Abc_Ntk_t * pNtkNew;
// check if the network exists
if ( pNtkNew = Abc_LibFindModelByName( pMan->pDesign, pName ) )
return pNtkNew;
//printf( "Creating network %s.\n", pName );
// create new network
pNtkNew = Abc_NtkAlloc( ABC_NTK_NETLIST, ABC_FUNC_BLACKBOX, pMan->fUseMemMan );
pNtkNew->pName = Extra_UtilStrsav( pName );
pNtkNew->pSpec = NULL;
// add module to the design
Abc_LibAddModel( pMan->pDesign, pNtkNew );
return pNtkNew;
}
/**Function*************************************************************
Synopsis [Finds the network by name or create a new blackbox network.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Obj_t * Ver_ParseFindNet( Abc_Ntk_t * pNtk, char * pName )
{
Abc_Obj_t * pObj;
if ( pObj = Abc_NtkFindNet(pNtk, pName) )
return pObj;
if ( !strcmp( pName, "1\'b0" ) )
return Abc_NtkFindOrCreateNet( pNtk, "1\'b0" );
if ( !strcmp( pName, "1\'b1" ) )
return Abc_NtkFindOrCreateNet( pNtk, "1\'b1" );
return NULL;
}
/**Function*************************************************************
Synopsis [Converts the network from the blackbox type into a different one.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Ver_ParseConvertNetwork( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, int fMapped )
{
if ( fMapped )
{
// convert from the blackbox into the network with local functions representated by AIGs
if ( pNtk->ntkFunc == ABC_FUNC_BLACKBOX )
{
// change network type
assert( pNtk->pManFunc == NULL );
pNtk->ntkFunc = ABC_FUNC_MAP;
pNtk->pManFunc = pMan->pDesign->pGenlib;
}
else if ( pNtk->ntkFunc != ABC_FUNC_MAP )
{
sprintf( pMan->sError, "The network %s appears to have both gates and assign statements. Currently such network are not allowed. One way to fix this problem might be to replace assigns by buffers from the library.", pNtk->pName );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
}
else
{
// convert from the blackbox into the network with local functions representated by AIGs
if ( pNtk->ntkFunc == ABC_FUNC_BLACKBOX )
{
// change network type
assert( pNtk->pManFunc == NULL );
pNtk->ntkFunc = ABC_FUNC_AIG;
pNtk->pManFunc = pMan->pDesign->pManFunc;
}
else if ( pNtk->ntkFunc != ABC_FUNC_AIG )
{
sprintf( pMan->sError, "The network %s appears to have both gates and assign statements. Currently such network are not allowed. One way to fix this problem might be to replace assigns by buffers from the library.", pNtk->pName );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
}
return 1;
}
/**Function************************************************************* /**Function*************************************************************
...@@ -264,26 +376,17 @@ void Ver_ParsePrintErrorMessage( Ver_Man_t * p ) ...@@ -264,26 +376,17 @@ void Ver_ParsePrintErrorMessage( Ver_Man_t * p )
***********************************************************************/ ***********************************************************************/
int Ver_ParseModule( Ver_Man_t * pMan ) int Ver_ParseModule( Ver_Man_t * pMan )
{ {
Mio_Gate_t * pGate;
Ver_Stream_t * p = pMan->pReader; Ver_Stream_t * p = pMan->pReader;
Abc_Ntk_t * pNtk, * pNtkTemp; Abc_Ntk_t * pNtk, * pNtkTemp;
Abc_Obj_t * pNet;
char * pWord, Symbol; char * pWord, Symbol;
int RetValue; int RetValue;
// start the current network
assert( pMan->pNtkCur == NULL );
pNtk = pMan->pNtkCur = Abc_NtkAlloc( ABC_NTK_NETLIST, ABC_FUNC_BLACKBOX, pMan->fUseMemMan );
pNtk->ntkFunc = ABC_FUNC_AIG;
pNtk->pManFunc = pMan->pDesign->pManFunc;
// get the network name // get the network name
pWord = Ver_ParseGetName( pMan ); pWord = Ver_ParseGetName( pMan );
pNtk->pName = Extra_UtilStrsav( pWord );
pNtk->pSpec = NULL;
// create constant nets // get the network with this name
Abc_NtkFindOrCreateNet( pNtk, "1\'b0" ); pNtk = Ver_ParseFindOrCreateNetwork( pMan, pWord );
Abc_NtkFindOrCreateNet( pNtk, "1\'b1" );
// make sure we stopped at the opening paranthesis // make sure we stopped at the opening paranthesis
if ( Ver_StreamPopChar(p) != '(' ) if ( Ver_StreamPopChar(p) != '(' )
...@@ -313,15 +416,15 @@ int Ver_ParseModule( Ver_Man_t * pMan ) ...@@ -313,15 +416,15 @@ int Ver_ParseModule( Ver_Man_t * pMan )
if ( pWord == NULL ) if ( pWord == NULL )
return 0; return 0;
if ( !strcmp( pWord, "input" ) ) if ( !strcmp( pWord, "input" ) )
RetValue = Ver_ParseSignal( pMan, VER_SIG_INPUT ); RetValue = Ver_ParseSignal( pMan, pNtk, VER_SIG_INPUT );
else if ( !strcmp( pWord, "output" ) ) else if ( !strcmp( pWord, "output" ) )
RetValue = Ver_ParseSignal( pMan, VER_SIG_OUTPUT ); RetValue = Ver_ParseSignal( pMan, pNtk, VER_SIG_OUTPUT );
else if ( !strcmp( pWord, "reg" ) ) else if ( !strcmp( pWord, "reg" ) )
RetValue = Ver_ParseSignal( pMan, VER_SIG_REG ); RetValue = Ver_ParseSignal( pMan, pNtk, VER_SIG_REG );
else if ( !strcmp( pWord, "wire" ) ) else if ( !strcmp( pWord, "wire" ) )
RetValue = Ver_ParseSignal( pMan, VER_SIG_WIRE ); RetValue = Ver_ParseSignal( pMan, pNtk, VER_SIG_WIRE );
else if ( !strcmp( pWord, "inout" ) ) else if ( !strcmp( pWord, "inout" ) )
RetValue = Ver_ParseSignal( pMan, VER_SIG_INOUT ); RetValue = Ver_ParseSignal( pMan, pNtk, VER_SIG_INOUT );
else else
break; break;
if ( RetValue == 0 ) if ( RetValue == 0 )
...@@ -334,43 +437,38 @@ int Ver_ParseModule( Ver_Man_t * pMan ) ...@@ -334,43 +437,38 @@ int Ver_ParseModule( Ver_Man_t * pMan )
Extra_ProgressBarUpdate( pMan->pProgress, Ver_StreamGetCurPosition(p), NULL ); Extra_ProgressBarUpdate( pMan->pProgress, Ver_StreamGetCurPosition(p), NULL );
if ( !strcmp( pWord, "and" ) ) if ( !strcmp( pWord, "and" ) )
RetValue = Ver_ParseGateStandard( pMan, VER_GATE_AND ); RetValue = Ver_ParseGateStandard( pMan, pNtk, VER_GATE_AND );
else if ( !strcmp( pWord, "or" ) ) else if ( !strcmp( pWord, "or" ) )
RetValue = Ver_ParseGateStandard( pMan, VER_GATE_OR ); RetValue = Ver_ParseGateStandard( pMan, pNtk, VER_GATE_OR );
else if ( !strcmp( pWord, "xor" ) ) else if ( !strcmp( pWord, "xor" ) )
RetValue = Ver_ParseGateStandard( pMan, VER_GATE_XOR ); RetValue = Ver_ParseGateStandard( pMan, pNtk, VER_GATE_XOR );
else if ( !strcmp( pWord, "buf" ) ) else if ( !strcmp( pWord, "buf" ) )
RetValue = Ver_ParseGateStandard( pMan, VER_GATE_BUF ); RetValue = Ver_ParseGateStandard( pMan, pNtk, VER_GATE_BUF );
else if ( !strcmp( pWord, "nand" ) ) else if ( !strcmp( pWord, "nand" ) )
RetValue = Ver_ParseGateStandard( pMan, VER_GATE_NAND ); RetValue = Ver_ParseGateStandard( pMan, pNtk, VER_GATE_NAND );
else if ( !strcmp( pWord, "nor" ) ) else if ( !strcmp( pWord, "nor" ) )
RetValue = Ver_ParseGateStandard( pMan, VER_GATE_NOR ); RetValue = Ver_ParseGateStandard( pMan, pNtk, VER_GATE_NOR );
else if ( !strcmp( pWord, "xnor" ) ) else if ( !strcmp( pWord, "xnor" ) )
RetValue = Ver_ParseGateStandard( pMan, VER_GATE_XNOR ); RetValue = Ver_ParseGateStandard( pMan, pNtk, VER_GATE_XNOR );
else if ( !strcmp( pWord, "not" ) ) else if ( !strcmp( pWord, "not" ) )
RetValue = Ver_ParseGateStandard( pMan, VER_GATE_NOT ); RetValue = Ver_ParseGateStandard( pMan, pNtk, VER_GATE_NOT );
else if ( !strcmp( pWord, "assign" ) ) else if ( !strcmp( pWord, "assign" ) )
RetValue = Ver_ParseAssign( pMan ); RetValue = Ver_ParseAssign( pMan, pNtk );
else if ( !strcmp( pWord, "always" ) ) else if ( !strcmp( pWord, "always" ) )
RetValue = Ver_ParseAlways( pMan ); RetValue = Ver_ParseAlways( pMan, pNtk );
else if ( !strcmp( pWord, "initial" ) ) else if ( !strcmp( pWord, "initial" ) )
RetValue = Ver_ParseInitial( pMan ); RetValue = Ver_ParseInitial( pMan, pNtk );
else if ( !strcmp( pWord, "endmodule" ) ) else if ( !strcmp( pWord, "endmodule" ) )
break; break;
else if ( pMan->pDesign->pLibrary && st_lookup(pMan->pDesign->pLibrary->tModules, pWord, (char**)&pNtkTemp) ) // gate library else if ( pMan->pDesign->pGenlib && (pGate = Mio_LibraryReadGateByName(pMan->pDesign->pGenlib, pWord)) ) // current design
RetValue = Ver_ParseGate( pMan, pNtkTemp ); RetValue = Ver_ParseGate( pMan, pNtk, pGate );
else if ( pMan->pDesign && st_lookup(pMan->pDesign->tModules, pWord, (char**)&pNtkTemp) ) // current design // else if ( pMan->pDesign->pLibrary && st_lookup(pMan->pDesign->pLibrary->tModules, pWord, (char**)&pNtkTemp) ) // gate library
RetValue = Ver_ParseGate( pMan, pNtkTemp ); // RetValue = Ver_ParseGate( pMan, pNtkTemp );
else else // assume this is the box used in the current design
{ {
printf( "Cannot find \"%s\".\n", pWord ); pNtkTemp = Ver_ParseFindOrCreateNetwork( pMan, pWord );
Ver_StreamSkipToChars( p, ";" ); RetValue = Ver_ParseBox( pMan, pNtk, pNtkTemp );
Ver_StreamPopChar(p);
// sprintf( pMan->sError, "Cannot find \"%s\" in the library.", pWord );
// Ver_ParsePrintErrorMessage( pMan );
// return 0;
} }
if ( RetValue == 0 ) if ( RetValue == 0 )
return 0; return 0;
...@@ -383,28 +481,33 @@ int Ver_ParseModule( Ver_Man_t * pMan ) ...@@ -383,28 +481,33 @@ int Ver_ParseModule( Ver_Man_t * pMan )
return 0; return 0;
} }
// check if constant 0 net is used // convert from the blackbox into the network with local functions representated by AIGs
pNet = Abc_NtkFindOrCreateNet( pNtk, "1\'b0" ); if ( pNtk->ntkFunc == ABC_FUNC_BLACKBOX )
if ( Abc_ObjFanoutNum(pNet) == 0 )
Abc_NtkDeleteObj(pNet);
else
Abc_ObjAddFanin( pNet, Abc_NtkCreateNodeConst0(pNtk) );
// check if constant 1 net is used
pNet = Abc_NtkFindOrCreateNet( pNtk, "1\'b1" );
if ( Abc_ObjFanoutNum(pNet) == 0 )
Abc_NtkDeleteObj(pNet);
else
Abc_ObjAddFanin( pNet, Abc_NtkCreateNodeConst1(pNtk) );
// check the functionality to blackbox if insides are not defined
if ( Abc_NtkNodeNum(pNtk) == 0 && Abc_NtkBoxNum(pNtk) == 0 )
{ {
pNtk->ntkFunc = ABC_FUNC_BLACKBOX; if ( Abc_NtkNodeNum(pNtk) > 0 || Abc_NtkBoxNum(pNtk) > 0 )
pNtk->pManFunc = NULL; {
if ( !Ver_ParseConvertNetwork( pMan, pNtk, pMan->fMapped ) )
return 0;
}
else
{
Abc_Obj_t * pObj, * pBox, * pTerm;
int i;
pBox = Abc_NtkCreateBlackbox(pNtk);
Abc_NtkForEachPi( pNtk, pObj, i )
{
pTerm = Abc_NtkCreateBi(pNtk);
Abc_ObjAddFanin( pTerm, Abc_ObjFanout0(pObj) );
Abc_ObjAddFanin( pBox, pTerm );
}
Abc_NtkForEachPo( pNtk, pObj, i )
{
pTerm = Abc_NtkCreateBo(pNtk);
Abc_ObjAddFanin( pTerm, pBox );
Abc_ObjAddFanin( Abc_ObjFanin0(pObj), pTerm );
}
}
} }
// fix the dangling nets
Abc_NtkFinalizeRead( pNtk );
return 1; return 1;
} }
...@@ -419,19 +522,21 @@ int Ver_ParseModule( Ver_Man_t * pMan ) ...@@ -419,19 +522,21 @@ int Ver_ParseModule( Ver_Man_t * pMan )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ver_ParseSignal( Ver_Man_t * pMan, Ver_SignalType_t SigType ) int Ver_ParseSignal( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Ver_SignalType_t SigType )
{ {
Ver_Stream_t * p = pMan->pReader; Ver_Stream_t * p = pMan->pReader;
Abc_Ntk_t * pNtk = pMan->pNtkCur;
char Buffer[1000]; char Buffer[1000];
int Lower, Upper, i; int Lower, Upper, i;
char * pWord; char * pWord;
char Symbol; char Symbol;
Lower = Upper = 0;
while ( 1 ) while ( 1 )
{ {
pWord = Ver_ParseGetName( pMan ); pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL ) if ( pWord == NULL )
return 0; return 0;
// check if the range is specified
if ( pWord[0] == '[' && !pMan->fNameLast ) if ( pWord[0] == '[' && !pMan->fNameLast )
{ {
Lower = atoi( pWord + 1 ); Lower = atoi( pWord + 1 );
...@@ -472,6 +577,20 @@ int Ver_ParseSignal( Ver_Man_t * pMan, Ver_SignalType_t SigType ) ...@@ -472,6 +577,20 @@ int Ver_ParseSignal( Ver_Man_t * pMan, Ver_SignalType_t SigType )
if ( pWord == NULL ) if ( pWord == NULL )
return 0; return 0;
} }
}
// create signals
if ( Lower == 0 && Upper == 0 )
{
if ( SigType == VER_SIG_INPUT || SigType == VER_SIG_INOUT )
Ver_ParseCreatePi( pNtk, pWord );
if ( SigType == VER_SIG_OUTPUT || SigType == VER_SIG_INOUT )
Ver_ParseCreatePo( pNtk, pWord );
if ( SigType == VER_SIG_WIRE || SigType == VER_SIG_REG )
Abc_NtkFindOrCreateNet( pNtk, pWord );
}
else
{
for ( i = Lower; i <= Upper; i++ ) for ( i = Lower; i <= Upper; i++ )
{ {
sprintf( Buffer, "%s[%d]", pWord, i ); sprintf( Buffer, "%s[%d]", pWord, i );
...@@ -483,15 +602,7 @@ int Ver_ParseSignal( Ver_Man_t * pMan, Ver_SignalType_t SigType ) ...@@ -483,15 +602,7 @@ int Ver_ParseSignal( Ver_Man_t * pMan, Ver_SignalType_t SigType )
Abc_NtkFindOrCreateNet( pNtk, Buffer ); Abc_NtkFindOrCreateNet( pNtk, Buffer );
} }
} }
else
{
if ( SigType == VER_SIG_INPUT || SigType == VER_SIG_INOUT )
Ver_ParseCreatePi( pNtk, pWord );
if ( SigType == VER_SIG_OUTPUT || SigType == VER_SIG_INOUT )
Ver_ParseCreatePo( pNtk, pWord );
if ( SigType == VER_SIG_WIRE || SigType == VER_SIG_REG )
Abc_NtkFindOrCreateNet( pNtk, pWord );
}
Symbol = Ver_StreamPopChar(p); Symbol = Ver_StreamPopChar(p);
if ( Symbol == ',' ) if ( Symbol == ',' )
continue; continue;
...@@ -515,118 +626,90 @@ int Ver_ParseSignal( Ver_Man_t * pMan, Ver_SignalType_t SigType ) ...@@ -515,118 +626,90 @@ int Ver_ParseSignal( Ver_Man_t * pMan, Ver_SignalType_t SigType )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ver_ParseAssign( Ver_Man_t * pMan ) int Ver_ParseAlways( Ver_Man_t * pMan, Abc_Ntk_t * pNtk )
{ {
Ver_Stream_t * p = pMan->pReader; Ver_Stream_t * p = pMan->pReader;
Abc_Ntk_t * pNtk = pMan->pNtkCur; Abc_Obj_t * pNet, * pNet2;
Abc_Obj_t * pNode, * pNet; int fStopAfterOne;
char * pWord, * pName, * pEquation; char * pWord, * pWord2;
Hop_Obj_t * pFunc;
char Symbol; char Symbol;
int i, Length, fReduction; // parse the directive
pWord = Ver_ParseGetName( pMan );
// if ( Ver_StreamGetLineNumber(p) == 2756 ) if ( pWord == NULL )
// {
// int x = 0;
// }
// convert from the mapped netlist into the BDD netlist
if ( pNtk->ntkFunc == ABC_FUNC_BLACKBOX )
{
pNtk->ntkFunc = ABC_FUNC_AIG;
assert( pNtk->pManFunc == NULL );
pNtk->pManFunc = pMan->pDesign->pManFunc;
}
else if ( pNtk->ntkFunc != ABC_FUNC_AIG )
{
sprintf( pMan->sError, "The network %s appears to mapped gates and assign statements. Currently such network are not allowed. One way to fix this problem is to replace assigns by buffers from the library.", pMan->pNtkCur );
Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} if ( pWord[0] == '@' )
while ( 1 )
{ {
// get the name of the output signal Ver_StreamSkipToChars( p, ")" );
Ver_StreamPopChar(p);
// parse the directive
pWord = Ver_ParseGetName( pMan ); pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL ) if ( pWord == NULL )
return 0; return 0;
// consider the case of reduction operations }
fReduction = 0; // decide how many statements to parse
if ( pWord[0] == '{' && !pMan->fNameLast ) fStopAfterOne = 0;
fReduction = 1; if ( strcmp( pWord, "begin" ) )
if ( fReduction ) fStopAfterOne = 1;
// iterate over the initial states
while ( 1 )
{
if ( !fStopAfterOne )
{ {
pWord++; // get the name of the output signal
pWord[strlen(pWord)-1] = 0; pWord = Ver_ParseGetName( pMan );
assert( pWord[0] != '\\' ); if ( pWord == NULL )
return 0;
// look for the end of directive
if ( !strcmp( pWord, "end" ) )
break;
} }
// get the fanout net // get the fanout net
pNet = Abc_NtkFindNet( pNtk, pWord ); pNet = Ver_ParseFindNet( pNtk, pWord );
if ( pNet == NULL ) if ( pNet == NULL )
{ {
sprintf( pMan->sError, "Cannot read the assign statement for %s (output wire is not defined).", pWord ); sprintf( pMan->sError, "Cannot read the always statement for %s (output wire is not defined).", pWord );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
// get the equality sign // get the equality sign
if ( Ver_StreamPopChar(p) != '=' ) Symbol = Ver_StreamPopChar(p);
if ( Symbol != '<' && Symbol != '=' )
{ {
sprintf( pMan->sError, "Cannot read the assign statement for %s (expected equality sign).", pWord ); sprintf( pMan->sError, "Cannot read the assign statement for %s (expected <= or =).", pWord );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
if ( Symbol == '<' )
Ver_StreamPopChar(p);
// skip the comments // skip the comments
if ( !Ver_ParseSkipComments( pMan ) ) if ( !Ver_ParseSkipComments( pMan ) )
return 0; return 0;
// get the second name // get the second name
if ( fReduction ) pWord2 = Ver_ParseGetName( pMan );
pEquation = Ver_StreamGetWord( p, ";" ); if ( pWord2 == NULL )
else
pEquation = Ver_StreamGetWord( p, ",;" );
if ( pEquation == NULL )
{
sprintf( pMan->sError, "Cannot read the equation for %s.", Abc_ObjName(pNet) );
Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
// check if the name is complemented
if ( pWord2[0] == '~' )
{
pNet2 = Ver_ParseFindNet( pNtk, pWord2+1 );
pNet2 = Ver_ParseCreateInv( pNtk, pNet2 );
} }
// parse the formula
if ( fReduction )
pFunc = Ver_FormulaReduction( pEquation, pNtk->pManFunc, pMan->vNames, pMan->sError );
else else
pFunc = Ver_FormulaParser( pEquation, pNtk->pManFunc, pMan->vNames, pMan->vStackFn, pMan->vStackOp, pMan->sError ); pNet2 = Ver_ParseFindNet( pNtk, pWord2 );
if ( pFunc == NULL ) if ( pNet2 == NULL )
{ {
sprintf( pMan->sError, "Cannot read the always statement for %s (input wire is not defined).", pWord2 );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
// create the latch
// create the node with the given inputs Ver_ParseCreateLatch( pNtk, pNet2, pNet );
pNode = Abc_NtkCreateNode( pMan->pNtkCur ); // remove the last symbol
pNode->pData = pFunc;
Abc_ObjAddFanin( pNet, pNode );
// connect to fanin nets
for ( i = 0; i < Vec_PtrSize(pMan->vNames)/2; i++ )
{
// get the name of this signal
Length = (int)Vec_PtrEntry( pMan->vNames, 2*i );
pName = Vec_PtrEntry( pMan->vNames, 2*i + 1 );
pName[Length] = 0;
// find the corresponding net
pNet = Abc_NtkFindNet( pNtk, pName );
if ( pNet == NULL )
{
sprintf( pMan->sError, "Cannot read the assign statement for %s (input wire %d is not defined).", pWord, pName );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
Abc_ObjAddFanin( pNode, pNet );
}
Symbol = Ver_StreamPopChar(p); Symbol = Ver_StreamPopChar(p);
if ( Symbol == ',' ) assert( Symbol == ';' );
continue; // quit if only one directive
if ( Symbol == ';' ) if ( fStopAfterOne )
return 1; break;
} }
return 1; return 1;
} }
...@@ -642,27 +725,17 @@ int Ver_ParseAssign( Ver_Man_t * pMan ) ...@@ -642,27 +725,17 @@ int Ver_ParseAssign( Ver_Man_t * pMan )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ver_ParseAlways( Ver_Man_t * pMan ) int Ver_ParseInitial( Ver_Man_t * pMan, Abc_Ntk_t * pNtk )
{ {
Ver_Stream_t * p = pMan->pReader; Ver_Stream_t * p = pMan->pReader;
Abc_Ntk_t * pNtk = pMan->pNtkCur; Abc_Obj_t * pNode, * pNet;
Abc_Obj_t * pNet, * pNet2;
int fStopAfterOne; int fStopAfterOne;
char * pWord, * pWord2; char * pWord, * pEquation;
char Symbol; char Symbol;
// parse the directive // parse the directive
pWord = Ver_ParseGetName( pMan ); pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL ) if ( pWord == NULL )
return 0; return 0;
if ( pWord[0] == '@' )
{
Ver_StreamSkipToChars( p, ")" );
Ver_StreamPopChar(p);
// parse the directive
pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL )
return 0;
}
// decide how many statements to parse // decide how many statements to parse
fStopAfterOne = 0; fStopAfterOne = 0;
if ( strcmp( pWord, "begin" ) ) if ( strcmp( pWord, "begin" ) )
...@@ -681,10 +754,10 @@ int Ver_ParseAlways( Ver_Man_t * pMan ) ...@@ -681,10 +754,10 @@ int Ver_ParseAlways( Ver_Man_t * pMan )
break; break;
} }
// get the fanout net // get the fanout net
pNet = Abc_NtkFindNet( pNtk, pWord ); pNet = Ver_ParseFindNet( pNtk, pWord );
if ( pNet == NULL ) if ( pNet == NULL )
{ {
sprintf( pMan->sError, "Cannot read the always statement for %s (output wire is not defined).", pWord ); sprintf( pMan->sError, "Cannot read the initial statement for %s (output wire is not defined).", pWord );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
...@@ -702,25 +775,31 @@ int Ver_ParseAlways( Ver_Man_t * pMan ) ...@@ -702,25 +775,31 @@ int Ver_ParseAlways( Ver_Man_t * pMan )
if ( !Ver_ParseSkipComments( pMan ) ) if ( !Ver_ParseSkipComments( pMan ) )
return 0; return 0;
// get the second name // get the second name
pWord2 = Ver_ParseGetName( pMan ); pEquation = Ver_StreamGetWord( p, ";" );
if ( pWord2 == NULL ) if ( pEquation == NULL )
return 0; return 0;
// check if the name is complemented // find the corresponding latch
if ( pWord2[0] == '~' ) if ( Abc_ObjFaninNum(pNet) == 0 )
{ {
pNet2 = Abc_NtkFindNet( pNtk, pWord2+1 ); sprintf( pMan->sError, "Cannot find the latch to assign the initial value." );
pNet2 = Ver_ParseCreateInv( pNtk, pNet2 ); Ver_ParsePrintErrorMessage( pMan );
return 0;
} }
else pNode = Abc_ObjFanin0(Abc_ObjFanin0(pNet));
pNet2 = Abc_NtkFindNet( pNtk, pWord2 ); assert( Abc_ObjIsLatch(pNode) );
if ( pNet2 == NULL ) // set the initial state
if ( !strcmp(pEquation, "0") || !strcmp(pEquation, "1\'b0") )
Abc_LatchSetInit0( pNode );
else if ( !strcmp(pEquation, "1") || !strcmp(pEquation, "1\'b1") )
Abc_LatchSetInit1( pNode );
// else if ( !strcmp(pEquation, "2") )
// Abc_LatchSetInitDc( pNode );
else
{ {
sprintf( pMan->sError, "Cannot read the always statement for %s (input wire is not defined).", pWord2 ); sprintf( pMan->sError, "Incorrect initial value of the latch %s.", Abc_ObjName(pNet) );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
// create the latch
Ver_ParseCreateLatch( pNtk, pNet2, pNet );
// remove the last symbol // remove the last symbol
Symbol = Ver_StreamPopChar(p); Symbol = Ver_StreamPopChar(p);
assert( Symbol == ';' ); assert( Symbol == ';' );
...@@ -742,88 +821,397 @@ int Ver_ParseAlways( Ver_Man_t * pMan ) ...@@ -742,88 +821,397 @@ int Ver_ParseAlways( Ver_Man_t * pMan )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ver_ParseInitial( Ver_Man_t * pMan ) int Ver_ParseAssign( Ver_Man_t * pMan, Abc_Ntk_t * pNtk )
{ {
Ver_Stream_t * p = pMan->pReader; Ver_Stream_t * p = pMan->pReader;
Abc_Ntk_t * pNtk = pMan->pNtkCur;
Abc_Obj_t * pNode, * pNet; Abc_Obj_t * pNode, * pNet;
int fStopAfterOne; char * pWord, * pName, * pEquation;
char * pWord, * pEquation; Hop_Obj_t * pFunc;
char Symbol; char Symbol;
// parse the directive int i, Length, fReduction;
pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL ) // if ( Ver_StreamGetLineNumber(p) == 2756 )
// {
// int x = 0;
// }
// convert from the blackbox into the network with local functions representated by AIGs
if ( !Ver_ParseConvertNetwork( pMan, pNtk, pMan->fMapped ) )
return 0; return 0;
// decide how many statements to parse
fStopAfterOne = 0;
if ( strcmp( pWord, "begin" ) )
fStopAfterOne = 1;
// iterate over the initial states
while ( 1 ) while ( 1 )
{ {
if ( !fStopAfterOne ) // get the name of the output signal
pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL )
return 0;
// consider the case of reduction operations
fReduction = 0;
if ( pWord[0] == '{' && !pMan->fNameLast )
fReduction = 1;
if ( fReduction )
{ {
// get the name of the output signal pWord++;
pWord = Ver_ParseGetName( pMan ); pWord[strlen(pWord)-1] = 0;
if ( pWord == NULL ) assert( pWord[0] != '\\' );
return 0;
// look for the end of directive
if ( !strcmp( pWord, "end" ) )
break;
} }
// get the fanout net // get the fanout net
pNet = Abc_NtkFindNet( pNtk, pWord ); pNet = Ver_ParseFindNet( pNtk, pWord );
if ( pNet == NULL ) if ( pNet == NULL )
{ {
sprintf( pMan->sError, "Cannot read the initial statement for %s (output wire is not defined).", pWord ); sprintf( pMan->sError, "Cannot read the assign statement for %s (output wire is not defined).", pWord );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
// get the equality sign // get the equality sign
Symbol = Ver_StreamPopChar(p); if ( Ver_StreamPopChar(p) != '=' )
if ( Symbol != '<' && Symbol != '=' )
{ {
sprintf( pMan->sError, "Cannot read the assign statement for %s (expected <= or =).", pWord ); sprintf( pMan->sError, "Cannot read the assign statement for %s (expected equality sign).", pWord );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
if ( Symbol == '<' )
Ver_StreamPopChar(p);
// skip the comments // skip the comments
if ( !Ver_ParseSkipComments( pMan ) ) if ( !Ver_ParseSkipComments( pMan ) )
return 0; return 0;
// get the second name // get the second name
pEquation = Ver_StreamGetWord( p, ";" ); if ( fReduction )
pEquation = Ver_StreamGetWord( p, ";" );
else
pEquation = Ver_StreamGetWord( p, ",;" );
if ( pEquation == NULL ) if ( pEquation == NULL )
{
sprintf( pMan->sError, "Cannot read the equation for %s.", Abc_ObjName(pNet) );
Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
// find the corresponding latch }
if ( Abc_ObjFaninNum(pNet) == 0 )
// consider the case of mapped network
if ( pMan->fMapped )
{ {
sprintf( pMan->sError, "Cannot find the latch to assign the initial value." ); Vec_PtrClear( pMan->vNames );
if ( !strcmp( pEquation, "1\'b0" ) )
pFunc = (Hop_Obj_t *)Mio_LibraryReadConst0(Abc_FrameReadLibGen());
else if ( !strcmp( pEquation, "1\'b1" ) )
pFunc = (Hop_Obj_t *)Mio_LibraryReadConst1(Abc_FrameReadLibGen());
else
{
if ( Ver_ParseFindNet(pNtk, pEquation) == NULL )
{
sprintf( pMan->sError, "Cannot read Verilog with non-trivail assignments in the mapped netlist.", pEquation );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
Vec_PtrPush( pMan->vNames, (void *)strlen(pEquation) );
Vec_PtrPush( pMan->vNames, pEquation );
// get the buffer
pFunc = (Hop_Obj_t *)Mio_LibraryReadBuf(Abc_FrameReadLibGen());
}
}
else
{
// parse the formula
if ( fReduction )
pFunc = Ver_FormulaReduction( pEquation, pNtk->pManFunc, pMan->vNames, pMan->sError );
else
pFunc = Ver_FormulaParser( pEquation, pNtk->pManFunc, pMan->vNames, pMan->vStackFn, pMan->vStackOp, pMan->sError );
if ( pFunc == NULL )
{
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
}
// create the node with the given inputs
pNode = Abc_NtkCreateNode( pNtk );
pNode->pData = pFunc;
Abc_ObjAddFanin( pNet, pNode );
// connect to fanin nets
for ( i = 0; i < Vec_PtrSize(pMan->vNames)/2; i++ )
{
// get the name of this signal
Length = (int)Vec_PtrEntry( pMan->vNames, 2*i );
pName = Vec_PtrEntry( pMan->vNames, 2*i + 1 );
pName[Length] = 0;
// find the corresponding net
pNet = Ver_ParseFindNet( pNtk, pName );
if ( pNet == NULL )
{
sprintf( pMan->sError, "Cannot read the assign statement for %s (input wire %d is not defined).", pWord, pName );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
Abc_ObjAddFanin( pNode, pNet );
}
Symbol = Ver_StreamPopChar(p);
if ( Symbol == ',' )
continue;
if ( Symbol == ';' )
return 1;
}
return 1;
}
/**Function*************************************************************
Synopsis [Parses one directive.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Ver_ParseGateStandard( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Ver_GateType_t GateType )
{
Ver_Stream_t * p = pMan->pReader;
Abc_Obj_t * pNet, * pNode;
char * pWord, Symbol;
// convert from the blackbox into the network with local functions representated by AIGs
if ( !Ver_ParseConvertNetwork( pMan, pNtk, pMan->fMapped ) )
return 0;
// this is gate name - throw it away
if ( Ver_StreamPopChar(p) != '(' )
{
sprintf( pMan->sError, "Cannot parse a standard gate (expected opening paranthesis)." );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
Ver_ParseSkipComments( pMan );
// create the node
pNode = Abc_NtkCreateNode( pNtk );
// parse pairs of formal/actural inputs
while ( 1 )
{
// parse the output name
pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL )
return 0;
// get the net corresponding to this output
pNet = Ver_ParseFindNet( pNtk, pWord );
if ( pNet == NULL )
{
sprintf( pMan->sError, "Net is missing in gate %s.", pWord );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
pNode = Abc_ObjFanin0(Abc_ObjFanin0(pNet)); // if this is the first net, add it as an output
assert( Abc_ObjIsLatch(pNode) ); if ( Abc_ObjFanoutNum(pNode) == 0 )
// set the initial state Abc_ObjAddFanin( pNet, pNode );
if ( !strcmp(pEquation, "0") || !strcmp(pEquation, "1\'b0") ) else
Abc_LatchSetInit0( pNode ); Abc_ObjAddFanin( pNode, pNet );
else if ( !strcmp(pEquation, "1") || !strcmp(pEquation, "1\'b1") ) // check if it is the end of gate
Abc_LatchSetInit1( pNode ); Ver_ParseSkipComments( pMan );
// else if ( !strcmp(pEquation, "2") ) Symbol = Ver_StreamPopChar(p);
// Abc_LatchSetInitDc( pNode ); if ( Symbol == ')' )
else break;
// skip comma
if ( Symbol != ',' )
{
sprintf( pMan->sError, "Cannot parse a standard gate %s (expected closing paranthesis).", Abc_ObjName(Abc_ObjFanout0(pNode)) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
Ver_ParseSkipComments( pMan );
}
if ( (GateType == VER_GATE_BUF || GateType == VER_GATE_NOT) && Abc_ObjFaninNum(pNode) != 1 )
{
sprintf( pMan->sError, "Buffer or interver with multiple fanouts %s (currently not supported).", Abc_ObjName(Abc_ObjFanout0(pNode)) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// check if it is the end of gate
Ver_ParseSkipComments( pMan );
if ( Ver_StreamPopChar(p) != ';' )
{
sprintf( pMan->sError, "Cannot read standard gate %s (expected closing semicolumn).", Abc_ObjName(Abc_ObjFanout0(pNode)) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// add logic function
if ( GateType == VER_GATE_AND || GateType == VER_GATE_NAND )
pNode->pData = Hop_CreateAnd( pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_OR || GateType == VER_GATE_NOR )
pNode->pData = Hop_CreateOr( pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_XOR || GateType == VER_GATE_XNOR )
pNode->pData = Hop_CreateExor( pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_BUF || GateType == VER_GATE_NOT )
pNode->pData = Hop_CreateAnd( pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
if ( GateType == VER_GATE_NAND || GateType == VER_GATE_NOR || GateType == VER_GATE_XNOR || GateType == VER_GATE_NOT )
pNode->pData = Hop_Not( pNode->pData );
return 1;
}
/**Function*************************************************************
Synopsis [Parses one directive.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Mio_Gate_t * pGate )
{
Mio_Pin_t * pGatePin;
Ver_Stream_t * p = pMan->pReader;
Abc_Obj_t * pNetActual, * pNode;
char * pWord, Symbol;
// convert from the blackbox into the network with local functions representated by gates
if ( 1 != pMan->fMapped )
{
sprintf( pMan->sError, "The network appears to be mapped. Use \"r -m\" to read mapped Verilog." );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// update the network type if needed
if ( !Ver_ParseConvertNetwork( pMan, pNtk, 1 ) )
return 0;
// parse the directive and set the pointers to the PIs/POs of the gate
pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL )
return 0;
// this is gate name - throw it away
if ( Ver_StreamPopChar(p) != '(' )
{
sprintf( pMan->sError, "Cannot parse gate %s (expected opening paranthesis).", Mio_GateReadName(pGate) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// start the node
pNode = Abc_NtkCreateNode( pNtk );
pNode->pData = pGate;
// parse pairs of formal/actural inputs
pGatePin = Mio_GateReadPins(pGate);
while ( 1 )
{
// process one pair of formal/actual parameters
if ( Ver_StreamPopChar(p) != '.' )
{
sprintf( pMan->sError, "Cannot parse gate %s (expected .).", Mio_GateReadName(pGate) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// parse the formal name
pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL )
return 0;
// make sure that the formal name is the same as the gate's
if ( Mio_GateReadInputs(pGate) == Abc_ObjFaninNum(pNode) )
{
if ( strcmp(pWord, Mio_GateReadOutName(pGate)) )
{
sprintf( pMan->sError, "Formal output name listed %s is different from the name of the gate output %s.", pWord, Mio_GateReadOutName(pGate) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
}
else
{
if ( strcmp(pWord, Mio_PinReadName(pGatePin)) )
{
sprintf( pMan->sError, "Formal input name listed %s is different from the name of the corresponding pin %s.", pWord, Mio_PinReadName(pGatePin) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
}
// open the paranthesis
if ( Ver_StreamPopChar(p) != '(' )
{
sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected opening paranthesis).", pWord, Mio_GateReadName(pGate) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// parse the actual name
pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL )
return 0;
// check if the name is complemented
assert( pWord[0] != '~' );
/*
fCompl = (pWord[0] == '~');
if ( fCompl )
{
fComplUsed = 1;
pWord++;
if ( pNtk->pData == NULL )
pNtk->pData = Extra_MmFlexStart();
}
*/
// get the actual net
pNetActual = Ver_ParseFindNet( pNtk, pWord );
if ( pNetActual == NULL )
{
sprintf( pMan->sError, "Actual net %s is missing.", pWord );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// close the paranthesis
if ( Ver_StreamPopChar(p) != ')' )
{
sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected closing paranthesis).", pWord, Mio_GateReadName(pGate) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// add the fanin
if ( Mio_GateReadInputs(pGate) == Abc_ObjFaninNum(pNode) )
Abc_ObjAddFanin( pNetActual, pNode ); // fanout
else
Abc_ObjAddFanin( pNode, pNetActual ); // fanin
// check if it is the end of gate
Ver_ParseSkipComments( pMan );
Symbol = Ver_StreamPopChar(p);
if ( Symbol == ')' )
break;
// skip comma
if ( Symbol != ',' )
{ {
sprintf( pMan->sError, "Incorrect initial value of the latch %s.", Abc_ObjName(pNet) ); sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected closing paranthesis).", pWord, Mio_GateReadName(pGate) );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
// remove the last symbol Ver_ParseSkipComments( pMan );
Symbol = Ver_StreamPopChar(p);
assert( Symbol == ';' ); // get the next pin
// quit if only one directive pGatePin = Mio_PinReadNext(pGatePin);
if ( fStopAfterOne ) }
break;
// check that the gate as the same number of input
if ( !(Abc_ObjFaninNum(pNode) == Mio_GateReadInputs(pGate) && Abc_ObjFanoutNum(pNode) == 1) )
{
sprintf( pMan->sError, "Parsing of gate %s has failed.", Mio_GateReadName(pGate) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// check if it is the end of gate
Ver_ParseSkipComments( pMan );
if ( Ver_StreamPopChar(p) != ';' )
{
sprintf( pMan->sError, "Cannot read gate %s (expected closing semicolumn).", Mio_GateReadName(pGate) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
} }
return 1; return 1;
} }
...@@ -839,40 +1227,42 @@ int Ver_ParseInitial( Ver_Man_t * pMan ) ...@@ -839,40 +1227,42 @@ int Ver_ParseInitial( Ver_Man_t * pMan )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate ) int Ver_ParseBox( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkBox )
{ {
Ver_Stream_t * p = pMan->pReader; Ver_Stream_t * p = pMan->pReader;
Abc_Ntk_t * pNtk = pMan->pNtkCur; Vec_Ptr_t * vNetPairs;
Abc_Obj_t * pNetFormal, * pNetActual; Abc_Obj_t * pNetFormal, * pNetActual;
Abc_Obj_t * pObj, * pNode, * pTerm; Abc_Obj_t * pNode;
char * pWord, Symbol, * pGateName; char * pWord, Symbol;
int i, fCompl, fComplUsed = 0; int fCompl;
unsigned * pPolarity;
// clean the PI/PO pointers
Abc_NtkForEachPi( pNtkGate, pObj, i )
pObj->pCopy = NULL;
Abc_NtkForEachPo( pNtkGate, pObj, i )
pObj->pCopy = NULL;
// parse the directive and set the pointers to the PIs/POs of the gate // parse the directive and set the pointers to the PIs/POs of the gate
pWord = Ver_ParseGetName( pMan ); pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL ) if ( pWord == NULL )
return 0; return 0;
// this is gate name - throw it away
pGateName = pWord; // create box to represent this gate
pNode = Abc_NtkCreateBlackbox( pNtk );
pNode->pData = pNtkBox;
Abc_ObjAssignName( pNode, pWord, NULL );
// continue parsing the box
if ( Ver_StreamPopChar(p) != '(' ) if ( Ver_StreamPopChar(p) != '(' )
{ {
sprintf( pMan->sError, "Cannot parse gate %s (expected opening paranthesis).", pNtkGate->pName ); sprintf( pMan->sError, "Cannot parse gate %s (expected opening paranthesis).", Abc_ObjName(pNode) );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
// parse pairs of formal/actural inputs // parse pairs of formal/actural inputs
vNetPairs = Vec_PtrAlloc( 16 );
pNode->pCopy = (Abc_Obj_t *)vNetPairs;
while ( 1 ) while ( 1 )
{ {
// process one pair of formal/actual parameters // process one pair of formal/actual parameters
if ( Ver_StreamPopChar(p) != '.' ) if ( Ver_StreamPopChar(p) != '.' )
{ {
sprintf( pMan->sError, "Cannot parse gate %s (expected .).", pNtkGate->pName ); sprintf( pMan->sError, "Cannot parse gate %s (expected .).", Abc_ObjName(pNode) );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
...@@ -882,21 +1272,13 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate ) ...@@ -882,21 +1272,13 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate )
if ( pWord == NULL ) if ( pWord == NULL )
return 0; return 0;
// get the formal net // get the formal net
if ( Abc_NtkIsNetlist(pNtkGate) ) pNetFormal = Abc_NtkFindOrCreateNet( pNtkBox, pWord );
pNetFormal = Abc_NtkFindNet( pNtkGate, pWord ); Vec_PtrPush( vNetPairs, pNetFormal );
else // if ( Abc_NtkIsStrash(pNtkGate) )
assert( 0 );
if ( pNetFormal == NULL )
{
sprintf( pMan->sError, "Formal net is missing in gate %s.", pWord );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// open the paranthesis // open the paranthesis
if ( Ver_StreamPopChar(p) != '(' ) if ( Ver_StreamPopChar(p) != '(' )
{ {
sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected opening paranthesis).", pWord, pNtkGate->pName ); sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected opening paranthesis).", pWord, Abc_ObjName(pNode));
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
...@@ -905,43 +1287,41 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate ) ...@@ -905,43 +1287,41 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate )
pWord = Ver_ParseGetName( pMan ); pWord = Ver_ParseGetName( pMan );
if ( pWord == NULL ) if ( pWord == NULL )
return 0; return 0;
// check if the name is complemented // consider the case of empty name
fCompl = (pWord[0] == '~'); fCompl = 0;
if ( fCompl ) if ( pWord[0] == 0 )
{ {
fComplUsed = 1; // remove the formal net
pWord++; // Vec_PtrPop( vNetPairs );
if ( pMan->pNtkCur->pData == NULL ) pNetActual = Abc_NtkCreateObj( pNtk, ABC_OBJ_NET );
pMan->pNtkCur->pData = Extra_MmFlexStart();
} }
// get the actual net else
pNetActual = Abc_NtkFindNet( pMan->pNtkCur, pWord );
if ( pNetActual == NULL )
{ {
sprintf( pMan->sError, "Actual net is missing in gate %s.", pWord ); /*
Ver_ParsePrintErrorMessage( pMan ); // check if the name is complemented
return 0; fCompl = (pWord[0] == '~');
if ( fCompl )
{
pWord++;
if ( pNtk->pData == NULL )
pNtk->pData = Extra_MmFlexStart();
}
*/
// get the actual net
pNetActual = Ver_ParseFindNet( pNtk, pWord );
if ( pNetActual == NULL )
{
sprintf( pMan->sError, "Actual net is missing in gate %s.", Abc_ObjName(pNode) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
} }
Vec_PtrPush( vNetPairs, Abc_ObjNotCond( pNetActual, fCompl ) );
// close the paranthesis // close the paranthesis
if ( Ver_StreamPopChar(p) != ')' ) if ( Ver_StreamPopChar(p) != ')' )
{ {
sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected closing paranthesis).", pWord, pNtkGate->pName ); sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected closing paranthesis).", pWord, Abc_ObjName(pNode) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
// process the pair
if ( Abc_ObjFaninNum(pNetFormal) > 0 && Abc_ObjIsPi(Abc_ObjFanin0Ntk(pNetFormal)) ) // PI net (with polarity!)
Abc_ObjFanin0Ntk(pNetFormal)->pCopy = Abc_ObjNotCond( pNetActual, fCompl );
else if ( Abc_ObjFanoutNum(pNetFormal) > 0 && Abc_ObjIsPo(Abc_ObjFanout0Ntk(pNetFormal)) ) // P0 net
{
assert( fCompl == 0 );
Abc_ObjFanout0Ntk(pNetFormal)->pCopy = pNetActual; // Abc_ObjNotCond( pNetActual, fCompl );
}
else
{
sprintf( pMan->sError, "Cannot match formal net %s with PI or PO of the gate %s.", pWord, pNtkGate->pName );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
...@@ -954,7 +1334,7 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate ) ...@@ -954,7 +1334,7 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate )
// skip comma // skip comma
if ( Symbol != ',' ) if ( Symbol != ',' )
{ {
sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected closing paranthesis).", pWord, pNtkGate->pName ); sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected closing paranthesis).", pWord, Abc_ObjName(pNode) );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
...@@ -965,160 +1345,277 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate ) ...@@ -965,160 +1345,277 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate )
Ver_ParseSkipComments( pMan ); Ver_ParseSkipComments( pMan );
if ( Ver_StreamPopChar(p) != ';' ) if ( Ver_StreamPopChar(p) != ';' )
{ {
sprintf( pMan->sError, "Cannot read gate %s (expected closing semicolumn).", pNtkGate->pName ); sprintf( pMan->sError, "Cannot read gate %s (expected closing semicolumn).", Abc_ObjName(pNode) );
Ver_ParsePrintErrorMessage( pMan ); Ver_ParsePrintErrorMessage( pMan );
return 0; return 0;
} }
// make sure each input net is driven return 1;
Abc_NtkForEachPi( pNtkGate, pObj, i ) }
if ( pObj->pCopy == NULL )
{
sprintf( pMan->sError, "Formal input %s of gate %s has no actual input.", Abc_ObjName(Abc_ObjFanout0(pObj)), pNtkGate->pName );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
/*
// make sure each output net is driving something
Abc_NtkForEachPo( pNtkGate, pObj, i )
if ( pObj->pCopy == NULL )
{
sprintf( pMan->sError, "Formal output %s of gate %s has no actual output.", Abc_ObjName(Abc_ObjFanin0(pObj)), pNtkGate->pName );
Ver_ParsePrintErrorMessage( pMan );
return 0;
}
*/
// allocate memory to remember the phase /**Function*************************************************************
pPolarity = NULL;
if ( fComplUsed ) Synopsis [Connects one box to the network]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
{
Vec_Ptr_t * vNetPairs = (Vec_Ptr_t *)pBox->pCopy;
Abc_Ntk_t * pNtk = pBox->pNtk;
Abc_Ntk_t * pNtkBox = pBox->pData;
Abc_Obj_t * pNet, * pTerm, * pTermNew;
int i;
assert( !Ver_ObjIsConnected(pBox) );
assert( Ver_NtkIsDefined(pNtkBox) );
assert( !Abc_NtkHasBlackbox(pNtkBox) || Abc_NtkBoxNum(pNtkBox) == 1 );
// clean the PI/PO nets
Abc_NtkForEachPi( pNtkBox, pTerm, i )
Abc_ObjFanout0(pTerm)->pCopy = NULL;
Abc_NtkForEachPo( pNtkBox, pTerm, i )
Abc_ObjFanin0(pTerm)->pCopy = NULL;
// map formal nets into actual nets
Vec_PtrForEachEntry( vNetPairs, pNet, i )
{ {
int nBytes = 4 * Abc_BitWordNum( Abc_NtkPiNum(pNtkGate) ); // get the actual net corresponding to this formal net (pNet)
pPolarity = (unsigned *)Extra_MmFlexEntryFetch( pMan->pNtkCur->pData, nBytes ); pNet->pCopy = Vec_PtrEntry( vNetPairs, ++i );
memset( pPolarity, 0, nBytes ); // make sure the actual net is not complemented (otherwise need to use polarity)
assert( !Abc_ObjIsComplement(pNet->pCopy) );
} }
// create box to represent this gate
if ( Abc_NtkHasBlackbox(pNtkGate) ) // make sure all PI nets are assigned
pNode = Abc_NtkCreateBlackbox( pMan->pNtkCur ); Abc_NtkForEachPi( pNtkBox, pTerm, i )
else
pNode = Abc_NtkCreateWhitebox( pMan->pNtkCur );
pNode->pNext = (Abc_Obj_t *)pPolarity;
pNode->pData = pNtkGate;
// connect to fanin nets
Abc_NtkForEachPi( pNtkGate, pObj, i )
{ {
if ( pPolarity && Abc_ObjIsComplement(pObj->pCopy) ) if ( Abc_ObjFanout0(pTerm)->pCopy == NULL )
{ {
Abc_InfoSetBit( pPolarity, i ); sprintf( pMan->sError, "Input formal net %s of network %s is not driven in box %s.",
pObj->pCopy = Abc_ObjRegular( pObj->pCopy ); Abc_ObjName(Abc_ObjFanout0(pTerm)), pNtkBox->pName, Abc_ObjName(pBox) );
Ver_ParsePrintErrorMessage( pMan );
return 0;
} }
assert( !Abc_ObjIsComplement(pObj->pCopy) ); pTermNew = Abc_NtkCreateBi( pNtk );
// Abc_ObjAddFanin( pNode, pObj->pCopy ); Abc_ObjAddFanin( pBox, pTermNew );
pTerm = Abc_NtkCreateBi( pNtk ); Abc_ObjAddFanin( pTermNew, Abc_ObjFanout0(pTerm)->pCopy );
Abc_ObjAddFanin( pTerm, pObj->pCopy );
Abc_ObjAddFanin( pNode, pTerm );
} }
// connect to fanout nets
Abc_NtkForEachPo( pNtkGate, pObj, i ) // create fanins of the box
Abc_NtkForEachPo( pNtkBox, pTerm, i )
{ {
if ( pObj->pCopy == NULL ) if ( Abc_ObjFanin0(pTerm)->pCopy == NULL )
pObj->pCopy = Abc_NtkFindOrCreateNet(pNtk, NULL); Abc_ObjFanin0(pTerm)->pCopy = Abc_NtkCreateObj( pNtk, ABC_OBJ_NET );
// Abc_ObjAddFanin( pObj->pCopy, pNode ); pTermNew = Abc_NtkCreateBo( pNtk );
pTerm = Abc_NtkCreateBo( pNtk ); Abc_ObjAddFanin( Abc_ObjFanin0(pTerm)->pCopy, pTermNew );
Abc_ObjAddFanin( pTerm, pNode ); Abc_ObjAddFanin( pTermNew, pBox );
Abc_ObjAddFanin( pObj->pCopy, pTerm );
} }
// free the mapping
Vec_PtrFree( vNetPairs );
pBox->pCopy = NULL;
return 1; return 1;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Parses one directive.] Synopsis [Attaches the boxes to the network.]
Description [] Description [Makes sure that the undefined boxes are connected correctly.]
SideEffects [] SideEffects []
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ver_ParseGateStandard( Ver_Man_t * pMan, Ver_GateType_t GateType ) int Vec_ParseAttachBoxes( Ver_Man_t * pMan )
{ {
Ver_Stream_t * p = pMan->pReader; Abc_Ntk_t * pNtk, * pNtkBox;
Hop_Man_t * pAig = pMan->pNtkCur->pManFunc; Vec_Ptr_t * vEnvoys, * vNetPairs, * vPivots;
Abc_Obj_t * pNet, * pNode; Abc_Obj_t * pBox, * pTerm, * pNet, * pNetDr, * pNetAct;
char * pWord, Symbol; int i, k, m, nBoxes;
// this is gate name - throw it away
if ( Ver_StreamPopChar(p) != '(' ) // connect defined boxes
Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
{ {
sprintf( pMan->sError, "Cannot parse a standard gate (expected opening paranthesis)." ); Abc_NtkForEachBlackbox( pNtk, pBox, k )
Ver_ParsePrintErrorMessage( pMan ); {
return 0; if ( pBox->pData && Ver_NtkIsDefined(pBox->pData) )
if ( !Ver_ParseConnectBox( pMan, pBox ) )
return 0;
}
} }
Ver_ParseSkipComments( pMan );
// create the node // convert blackboxes to whiteboxes
pNode = Abc_NtkCreateNode( pMan->pNtkCur ); Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
// parse pairs of formal/actural inputs Abc_NtkForEachBlackbox( pNtk, pBox, k )
while ( 1 ) {
pNtkBox = pBox->pData;
if ( pNtkBox == NULL )
continue;
if ( !strcmp( pNtkBox->pName, "ADDHX1" ) )
{
int x = 0;
}
if ( pBox->pData && !Abc_NtkHasBlackbox(pBox->pData) )
Abc_ObjBlackboxToWhitebox( pBox );
}
// search for undefined boxes
nBoxes = 0;
Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
nBoxes += !Ver_NtkIsDefined(pNtk);
// quit if no undefined boxes are found
if ( nBoxes == 0 )
return 1;
// count how many times each box occurs
Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
{ {
// parse the output name assert( pNtk->pData == NULL );
pWord = Ver_ParseGetName( pMan ); pNtk->pData = NULL;
if ( pWord == NULL ) }
return 0; Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
// get the net corresponding to this output Abc_NtkForEachBlackbox( pNtk, pBox, k )
pNet = Abc_NtkFindNet( pMan->pNtkCur, pWord );
if ( pNet == NULL )
{ {
sprintf( pMan->sError, "Net is missing in gate %s.", pWord ); if ( pBox->pData == NULL )
Ver_ParsePrintErrorMessage( pMan ); continue;
return 0; pNtkBox = pBox->pData;
pNtkBox->pData = (void *)((int)pNtkBox->pData + 1);
} }
// if this is the first net, add it as an output
if ( Abc_ObjFanoutNum(pNode) == 0 ) // print the boxes
Abc_ObjAddFanin( pNet, pNode ); printf( "Warning: The design contains %d undefined objects interpreted as blackboxes:\n", nBoxes );
else Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
Abc_ObjAddFanin( pNode, pNet ); if ( !Ver_NtkIsDefined(pNtk) )
// check if it is the end of gate printf( "%s (%d) ", Abc_NtkName(pNtk), (int)pNtk->pData );
Ver_ParseSkipComments( pMan ); printf( "\n" );
Symbol = Ver_StreamPopChar(p);
if ( Symbol == ')' ) // clean the boxes
break; Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
// skip comma pNtk->pData = NULL;
if ( Symbol != ',' )
// map actual nets into formal nets belonging to the undef boxes
vPivots = Vec_PtrAlloc( 100 );
Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
{
Abc_NtkForEachBlackbox( pNtk, pBox, k )
{ {
sprintf( pMan->sError, "Cannot parse a standard gate %s (expected closing paranthesis).", Abc_ObjName(Abc_ObjFanout0(pNode)) ); if ( pBox->pData == NULL || Ver_NtkIsDefined(pBox->pData) )
Ver_ParsePrintErrorMessage( pMan ); continue;
return 0; vNetPairs = (Vec_Ptr_t *)pBox->pCopy;
Vec_PtrForEachEntry( vNetPairs, pNet, m )
{
pNetAct = Vec_PtrEntry( vNetPairs, ++m );
// skip already driven nets and constants
if ( Abc_ObjFaninNum(pNetAct) == 1 )
continue;
if ( !(strcmp(Abc_ObjName(pNetAct), "1\'b0") && strcmp(Abc_ObjName(pNetAct), "1\'b1")) ) // constant
continue;
// add this net
if ( pNetAct->pData == NULL )
{
pNetAct->pData = Vec_PtrAlloc( 16 );
Vec_PtrPush( vPivots, pNetAct );
}
vEnvoys = pNetAct->pData;
Vec_PtrPush( vEnvoys, pNet );
}
} }
Ver_ParseSkipComments( pMan );
} }
if ( (GateType == VER_GATE_BUF || GateType == VER_GATE_NOT) && Abc_ObjFaninNum(pNode) != 1 )
// for each pivot net, find the driver
Vec_PtrForEachEntry( vPivots, pNetAct, i )
{ {
sprintf( pMan->sError, "Buffer or interver with multiple fanouts %s (currently not supported).", Abc_ObjName(Abc_ObjFanout0(pNode)) ); char * pName = Abc_ObjName(pNetAct);
Ver_ParsePrintErrorMessage( pMan ); /*
return 0; if ( !strcmp( Abc_ObjName(pNetAct), "dma_fifo_ff_cnt[2]" ) )
{
int x = 0;
}
*/
assert( Abc_ObjFaninNum(pNetAct) == 0 );
assert( strcmp(Abc_ObjName(pNetAct), "1\'b0") && strcmp(Abc_ObjName(pNetAct), "1\'b1") );
vEnvoys = pNetAct->pData; pNetAct->pData = NULL;
// find the driver starting from the last nets
pNetDr = NULL;
for ( m = 0; m < 64; m++ )
{
Vec_PtrForEachEntry( vEnvoys, pNet, k )
{
if ( Abc_ObjId(pNet) == 0 )
continue;
if ( (int)Abc_ObjId(pNet) == Abc_NtkObjNumMax(pNet->pNtk) - 1 - m )
{
pNetDr = pNet;
break;
}
}
if ( pNetDr )
break;
}
assert( pNetDr != NULL );
Vec_PtrWriteEntry( vPivots, i, pNetDr );
Vec_PtrFree( vEnvoys );
} }
// check if it is the end of gate // for each pivot net, create driver
Ver_ParseSkipComments( pMan ); Vec_PtrForEachEntry( vPivots, pNetDr, i )
if ( Ver_StreamPopChar(p) != ';' )
{ {
sprintf( pMan->sError, "Cannot read standard gate %s (expected closing semicolumn).", Abc_ObjName(Abc_ObjFanout0(pNode)) ); if ( pNetDr == NULL )
Ver_ParsePrintErrorMessage( pMan ); continue;
return 0; assert( Abc_ObjFaninNum(pNetDr) <= 1 );
if ( Abc_ObjFaninNum(pNetDr) == 1 )
continue;
// drive this net with the box
pTerm = Abc_NtkCreateBo( pNetDr->pNtk );
assert( Abc_NtkBoxNum(pNetDr->pNtk) <= 1 );
pBox = Abc_NtkBoxNum(pNetDr->pNtk)? Abc_NtkBox(pNetDr->pNtk,0) : Abc_NtkCreateBlackbox(pNetDr->pNtk);
Abc_ObjAddFanin( Abc_NtkCreatePo(pNetDr->pNtk), pNetDr );
Abc_ObjAddFanin( pNetDr, pTerm );
Abc_ObjAddFanin( pTerm, pBox );
}
Vec_PtrFree( vPivots );
// connect the remaining boxes
Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
{
if ( Abc_NtkPiNum(pNtk) )
continue;
Abc_NtkForEachNet( pNtk, pNet, k )
{
if ( Abc_ObjFaninNum(pNet) )
continue;
// drive this net
pTerm = Abc_NtkCreateBi( pNet->pNtk );
assert( Abc_NtkBoxNum(pNet->pNtk) <= 1 );
pBox = Abc_NtkBoxNum(pNet->pNtk)? Abc_NtkBox(pNet->pNtk,0) : Abc_NtkCreateBlackbox(pNet->pNtk);
Abc_ObjAddFanin( pBox, pTerm );
Abc_ObjAddFanin( pTerm, pNet );
Abc_ObjAddFanin( pNet, Abc_NtkCreatePi(pNet->pNtk) );
}
}
// connect the remaining boxes
Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
{
Abc_NtkForEachBlackbox( pNtk, pBox, k )
{
char * pName = Abc_ObjName(pBox);
if ( !Ver_ObjIsConnected(pBox) )
if ( !Ver_ParseConnectBox( pMan, pBox ) )
return 0;
}
} }
// add logic function
if ( GateType == VER_GATE_AND || GateType == VER_GATE_NAND )
pNode->pData = Hop_CreateAnd( pAig, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_OR || GateType == VER_GATE_NOR )
pNode->pData = Hop_CreateOr( pAig, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_XOR || GateType == VER_GATE_XNOR )
pNode->pData = Hop_CreateExor( pAig, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_BUF || GateType == VER_GATE_NOT )
pNode->pData = Hop_CreateAnd( pAig, Abc_ObjFaninNum(pNode) );
if ( GateType == VER_GATE_NAND || GateType == VER_GATE_NOR || GateType == VER_GATE_XNOR || GateType == VER_GATE_NOT )
pNode->pData = Hop_Not( pNode->pData );
return 1; return 1;
} }
...@@ -1138,9 +1635,9 @@ Abc_Obj_t * Ver_ParseCreatePi( Abc_Ntk_t * pNtk, char * pName ) ...@@ -1138,9 +1635,9 @@ Abc_Obj_t * Ver_ParseCreatePi( Abc_Ntk_t * pNtk, char * pName )
{ {
Abc_Obj_t * pNet, * pTerm; Abc_Obj_t * pNet, * pTerm;
// get the PI net // get the PI net
pNet = Abc_NtkFindNet( pNtk, pName ); // pNet = Ver_ParseFindNet( pNtk, pName );
if ( pNet ) // if ( pNet )
printf( "Warning: PI \"%s\" appears twice in the list.\n", pName ); // printf( "Warning: PI \"%s\" appears twice in the list.\n", pName );
pNet = Abc_NtkFindOrCreateNet( pNtk, pName ); pNet = Abc_NtkFindOrCreateNet( pNtk, pName );
// add the PI node // add the PI node
pTerm = Abc_NtkCreatePi( pNtk ); pTerm = Abc_NtkCreatePi( pNtk );
...@@ -1163,9 +1660,9 @@ Abc_Obj_t * Ver_ParseCreatePo( Abc_Ntk_t * pNtk, char * pName ) ...@@ -1163,9 +1660,9 @@ Abc_Obj_t * Ver_ParseCreatePo( Abc_Ntk_t * pNtk, char * pName )
{ {
Abc_Obj_t * pNet, * pTerm; Abc_Obj_t * pNet, * pTerm;
// get the PO net // get the PO net
pNet = Abc_NtkFindNet( pNtk, pName ); // pNet = Ver_ParseFindNet( pNtk, pName );
if ( pNet && Abc_ObjFaninNum(pNet) == 0 ) // if ( pNet && Abc_ObjFaninNum(pNet) == 0 )
printf( "Warning: PO \"%s\" appears twice in the list.\n", pName ); // printf( "Warning: PO \"%s\" appears twice in the list.\n", pName );
pNet = Abc_NtkFindOrCreateNet( pNtk, pName ); pNet = Abc_NtkFindOrCreateNet( pNtk, pName );
// add the PO node // add the PO node
pTerm = Abc_NtkCreatePo( pNtk ); pTerm = Abc_NtkCreatePo( pNtk );
...@@ -1224,6 +1721,50 @@ Abc_Obj_t * Ver_ParseCreateInv( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet ) ...@@ -1224,6 +1721,50 @@ Abc_Obj_t * Ver_ParseCreateInv( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet )
return pNet; return pNet;
} }
/*
// allocate memory to remember the phase
pPolarity = NULL;
if ( fComplUsed )
{
int nBytes = 4 * Abc_BitWordNum( Abc_NtkPiNum(pNtkBox) );
pPolarity = (unsigned *)Extra_MmFlexEntryFetch( pNtk->pData, nBytes );
memset( pPolarity, 0, nBytes );
}
// create box to represent this gate
if ( Abc_NtkHasBlackbox(pNtkBox) )
pNode = Abc_NtkCreateBlackbox( pNtk );
else
pNode = Abc_NtkCreateWhitebox( pNtk );
pNode->pNext = (Abc_Obj_t *)pPolarity;
pNode->pData = pNtkBox;
// connect to fanin nets
Abc_NtkForEachPi( pNtkBox, pObj, i )
{
if ( pPolarity && Abc_ObjIsComplement(pObj->pCopy) )
{
Abc_InfoSetBit( pPolarity, i );
pObj->pCopy = Abc_ObjRegular( pObj->pCopy );
}
assert( !Abc_ObjIsComplement(pObj->pCopy) );
// Abc_ObjAddFanin( pNode, pObj->pCopy );
pTerm = Abc_NtkCreateBi( pNtk );
Abc_ObjAddFanin( pTerm, pObj->pCopy );
Abc_ObjAddFanin( pNode, pTerm );
}
// connect to fanout nets
Abc_NtkForEachPo( pNtkBox, pObj, i )
{
if ( pObj->pCopy == NULL )
pObj->pCopy = Abc_NtkFindOrCreateNet(pNtk, NULL);
// Abc_ObjAddFanin( pObj->pCopy, pNode );
pTerm = Abc_NtkCreateBo( pNtk );
Abc_ObjAddFanin( pTerm, pNode );
Abc_ObjAddFanin( pObj->pCopy, pTerm );
}
*/
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -72,8 +72,8 @@ static int Ver_FormulaParserFindVar( char * pString, Vec_Ptr_t * vNames ...@@ -72,8 +72,8 @@ static int Ver_FormulaParserFindVar( char * pString, Vec_Ptr_t * vNames
***********************************************************************/ ***********************************************************************/
void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_Ptr_t * vStackFn, Vec_Int_t * vStackOp, char * pErrorMessage ) void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_Ptr_t * vStackFn, Vec_Int_t * vStackOp, char * pErrorMessage )
{ {
Hop_Obj_t * bFunc, * bTemp;
char * pTemp; char * pTemp;
Hop_Obj_t * bFunc, * bTemp;
int nParans, Flag; int nParans, Flag;
int Oper, Oper1, Oper2; int Oper, Oper1, Oper2;
int v; int v;
......
...@@ -100,7 +100,7 @@ char * Ver_ParseGetName( Ver_Man_t * pMan ) ...@@ -100,7 +100,7 @@ char * Ver_ParseGetName( Ver_Man_t * pMan )
{ {
pMan->fNameLast = 1; pMan->fNameLast = 1;
Ver_StreamPopChar( p ); Ver_StreamPopChar( p );
pWord = Ver_StreamGetWord( p, " " ); pWord = Ver_StreamGetWord( p, " \r\n" );
} }
else else
pWord = Ver_StreamGetWord( p, " \t\n\r(),;" ); pWord = Ver_StreamGetWord( p, " \t\n\r(),;" );
......
...@@ -98,6 +98,7 @@ extern float Mio_LibraryReadDelayAnd2Max( Mio_Library_t * pLib ); ...@@ -98,6 +98,7 @@ extern float Mio_LibraryReadDelayAnd2Max( Mio_Library_t * pLib );
extern float Mio_LibraryReadAreaInv ( Mio_Library_t * pLib ); extern float Mio_LibraryReadAreaInv ( Mio_Library_t * pLib );
extern float Mio_LibraryReadAreaBuf ( Mio_Library_t * pLib ); extern float Mio_LibraryReadAreaBuf ( Mio_Library_t * pLib );
extern float Mio_LibraryReadAreaNand2 ( Mio_Library_t * pLib ); extern float Mio_LibraryReadAreaNand2 ( Mio_Library_t * pLib );
extern int Mio_LibraryReadGateNameMax( Mio_Library_t * pLib );
extern char * Mio_GateReadName ( Mio_Gate_t * pGate ); extern char * Mio_GateReadName ( Mio_Gate_t * pGate );
extern char * Mio_GateReadOutName ( Mio_Gate_t * pGate ); extern char * Mio_GateReadOutName ( Mio_Gate_t * pGate );
extern double Mio_GateReadArea ( Mio_Gate_t * pGate ); extern double Mio_GateReadArea ( Mio_Gate_t * pGate );
...@@ -120,8 +121,8 @@ extern double Mio_PinReadDelayFanoutFall( Mio_Pin_t * pPin ); ...@@ -120,8 +121,8 @@ extern double Mio_PinReadDelayFanoutFall( Mio_Pin_t * pPin );
extern double Mio_PinReadDelayBlockMax ( Mio_Pin_t * pPin ); extern double Mio_PinReadDelayBlockMax ( Mio_Pin_t * pPin );
extern Mio_Pin_t * Mio_PinReadNext ( Mio_Pin_t * pPin ); extern Mio_Pin_t * Mio_PinReadNext ( Mio_Pin_t * pPin );
/*=== mioRead.c =============================================================*/ /*=== mioRead.c =============================================================*/
extern Mio_Library_t * Mio_LibraryRead( Abc_Frame_t * pAbc, char * FileName, char * ExcludeFile, int fVerbose ); extern Mio_Library_t * Mio_LibraryRead( void * pAbc, char * FileName, char * ExcludeFile, int fVerbose );
extern int Mio_LibraryReadExclude( Abc_Frame_t * pAbc, char * ExcludeFile, st_table * tExcludeGate ); extern int Mio_LibraryReadExclude( void * pAbc, char * ExcludeFile, st_table * tExcludeGate );
/*=== mioFunc.c =============================================================*/ /*=== mioFunc.c =============================================================*/
extern int Mio_LibraryParseFormulas( Mio_Library_t * pLib ); extern int Mio_LibraryParseFormulas( Mio_Library_t * pLib );
/*=== mioUtils.c =============================================================*/ /*=== mioUtils.c =============================================================*/
......
...@@ -60,6 +60,30 @@ float Mio_LibraryReadAreaNand2 ( Mio_Library_t * pLib ) { retur ...@@ -60,6 +60,30 @@ float Mio_LibraryReadAreaNand2 ( Mio_Library_t * pLib ) { retur
/**Function************************************************************* /**Function*************************************************************
Synopsis [Returns the longest gate name.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Mio_LibraryReadGateNameMax( Mio_Library_t * pLib )
{
Mio_Gate_t * pGate;
int LenMax = 0, LenCur;
Mio_LibraryForEachGate( pLib, pGate )
{
LenCur = strlen( Mio_GateReadName(pGate) );
if ( LenMax < LenCur )
LenMax = LenCur;
}
return LenMax;
}
/**Function*************************************************************
Synopsis [Read Mvc of the gate by name.] Synopsis [Read Mvc of the gate by name.]
Description [] Description []
......
...@@ -197,7 +197,7 @@ int Abc_NtkResynthesize( Abc_Ntk_t * pNtk, Res_Par_t * pPars ) ...@@ -197,7 +197,7 @@ int Abc_NtkResynthesize( Abc_Ntk_t * pNtk, Res_Par_t * pPars )
Abc_NtkSweep( pNtk, 0 ); Abc_NtkSweep( pNtk, 0 );
// convert into the AIG // convert into the AIG
if ( !Abc_NtkLogicToAig(pNtk) ) if ( !Abc_NtkToAig(pNtk) )
{ {
fprintf( stdout, "Converting to BDD has failed.\n" ); fprintf( stdout, "Converting to BDD has failed.\n" );
Res_ManFree( p ); Res_ManFree( p );
......
...@@ -116,7 +116,7 @@ int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk ) ...@@ -116,7 +116,7 @@ int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk )
extern int Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFrames, int fVerbose ); extern int Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFrames, int fVerbose );
Abc_Ntk_t * pNtkRet; Abc_Ntk_t * pNtkRet;
assert( Abc_NtkIsLogic(pNtk) ); assert( Abc_NtkIsLogic(pNtk) );
Abc_NtkLogicToSop( pNtk, 0 ); Abc_NtkToSop( pNtk, 0 );
// if ( !Abc_NtkCheck( pNtk ) ) // if ( !Abc_NtkCheck( pNtk ) )
// fprintf( stdout, "Abc_NtkRetimeDebug(): Network check has failed.\n" ); // fprintf( stdout, "Abc_NtkRetimeDebug(): Network check has failed.\n" );
// Io_WriteBlifLogic( pNtk, "debug_temp.blif", 1 ); // Io_WriteBlifLogic( pNtk, "debug_temp.blif", 1 );
......
...@@ -50,7 +50,7 @@ Vec_Int_t * Abc_NtkRetimeInitialValues( Abc_Ntk_t * pNtkCone, Vec_Int_t * vValue ...@@ -50,7 +50,7 @@ Vec_Int_t * Abc_NtkRetimeInitialValues( Abc_Ntk_t * pNtkCone, Vec_Int_t * vValue
return Vec_IntDup( vValues ); return Vec_IntDup( vValues );
// convert the target network to AIG // convert the target network to AIG
pNtkLogic = Abc_NtkDup( pNtkCone ); pNtkLogic = Abc_NtkDup( pNtkCone );
Abc_NtkLogicToAig( pNtkLogic ); Abc_NtkToAig( pNtkLogic );
// get the miter // get the miter
pNtkMiter = Abc_NtkCreateTarget( pNtkLogic, pNtkLogic->vCos, vValues ); pNtkMiter = Abc_NtkCreateTarget( pNtkLogic, pNtkLogic->vCos, vValues );
if ( fVerbose ) if ( fVerbose )
......
...@@ -677,7 +677,7 @@ void ABC_Dump_Bench_File( ABC_Manager mng ) ...@@ -677,7 +677,7 @@ void ABC_Dump_Bench_File( ABC_Manager mng )
// derive the netlist // derive the netlist
pNtkAig = Abc_NtkStrash( mng->pNtk, 0, 0 ); pNtkAig = Abc_NtkStrash( mng->pNtk, 0, 0 );
pNtkTemp = Abc_NtkLogicToNetlistBench( pNtkAig ); pNtkTemp = Abc_NtkToNetlistBench( pNtkAig );
Abc_NtkDelete( pNtkAig ); Abc_NtkDelete( pNtkAig );
if ( pNtkTemp == NULL ) if ( pNtkTemp == NULL )
{ printf( "ABC_Dump_Bench_File: Dumping BENCH has failed.\n" ); return; } { printf( "ABC_Dump_Bench_File: Dumping BENCH has failed.\n" ); return; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment