summaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/base')
-rw-r--r--src/base/abc/abc.h60
-rw-r--r--src/base/abc/abcLatch.c107
-rw-r--r--src/base/abci/abc.c73
-rw-r--r--src/base/abci/abcDar.c26
-rw-r--r--src/base/abci/abcPrint.c2
-rw-r--r--src/base/abci/xaaaa.c155
-rw-r--r--src/base/io/io.c61
-rw-r--r--src/base/io/ioReadAiger.c15
-rw-r--r--src/base/io/ioReadBench.c95
-rw-r--r--src/base/io/ioWriteAiger.c3
10 files changed, 399 insertions, 198 deletions
diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h
index bca3f33a..2e2b379b 100644
--- a/src/base/abc/abc.h
+++ b/src/base/abc/abc.h
@@ -638,6 +638,8 @@ extern int Abc_NtkCountSelfFeedLatches( Abc_Ntk_t * pNtk );
extern int Abc_NtkRemoveSelfFeedLatches( Abc_Ntk_t * pNtk );
extern Vec_Int_t * Abc_NtkCollectLatchValues( Abc_Ntk_t * pNtk );
extern void Abc_NtkInsertLatchValues( Abc_Ntk_t * pNtk, Vec_Int_t * vValues );
+extern Abc_Obj_t * Abc_NtkAddLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pDriver, Abc_InitType_t Init );
+extern void Abc_NtkConvertDcLatches( Abc_Ntk_t * pNtk );
/*=== abcLib.c ==========================================================*/
extern Abc_Lib_t * Abc_LibCreate( char * pName );
extern void Abc_LibFree( Abc_Lib_t * pLib, Abc_Ntk_t * pNtk );
@@ -662,35 +664,6 @@ extern Abc_Ntk_t * Abc_NtkMiterQuantifyPis( Abc_Ntk_t * pNtk );
extern int Abc_NtkMiterIsConstant( Abc_Ntk_t * pMiter );
extern void Abc_NtkMiterReport( Abc_Ntk_t * pMiter );
extern Abc_Ntk_t * Abc_NtkFrames( Abc_Ntk_t * pNtk, int nFrames, int fInitial );
-/*=== abcObj.c ==========================================================*/
-extern Abc_Obj_t * Abc_ObjAlloc( Abc_Ntk_t * pNtk, Abc_ObjType_t Type );
-extern void Abc_ObjRecycle( Abc_Obj_t * pObj );
-extern Abc_Obj_t * Abc_NtkCreateObj( Abc_Ntk_t * pNtk, Abc_ObjType_t Type );
-extern void Abc_NtkDeleteObj( Abc_Obj_t * pObj );
-extern void Abc_NtkDeleteObj_rec( Abc_Obj_t * pObj, int fOnlyNodes );
-extern void Abc_NtkDeleteAll_rec( Abc_Obj_t * pObj );
-extern Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName );
-extern Abc_Obj_t * Abc_NtkDupBox( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pBox, int fCopyName );
-extern Abc_Obj_t * Abc_NtkCloneObj( Abc_Obj_t * pNode );
-extern Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName );
-extern Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName );
-extern Abc_Obj_t * Abc_NtkFindCi( Abc_Ntk_t * pNtk, char * pName );
-extern Abc_Obj_t * Abc_NtkFindCo( Abc_Ntk_t * pNtk, char * pName );
-extern Abc_Obj_t * Abc_NtkFindOrCreateNet( Abc_Ntk_t * pNtk, char * pName );
-extern Abc_Obj_t * Abc_NtkCreateNodeConst0( Abc_Ntk_t * pNtk );
-extern Abc_Obj_t * Abc_NtkCreateNodeConst1( Abc_Ntk_t * pNtk );
-extern Abc_Obj_t * Abc_NtkCreateNodeInv( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin );
-extern Abc_Obj_t * Abc_NtkCreateNodeBuf( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin );
-extern Abc_Obj_t * Abc_NtkCreateNodeAnd( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins );
-extern Abc_Obj_t * Abc_NtkCreateNodeOr( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins );
-extern Abc_Obj_t * Abc_NtkCreateNodeExor( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins );
-extern Abc_Obj_t * Abc_NtkCreateNodeMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0 );
-extern bool Abc_NodeIsConst( Abc_Obj_t * pNode );
-extern bool Abc_NodeIsConst0( Abc_Obj_t * pNode );
-extern bool Abc_NodeIsConst1( Abc_Obj_t * pNode );
-extern bool Abc_NodeIsBuf( Abc_Obj_t * pNode );
-extern bool Abc_NodeIsInv( Abc_Obj_t * pNode );
-extern void Abc_NodeComplement( Abc_Obj_t * pNode );
/*=== abcNames.c ====================================================*/
extern char * Abc_ObjName( Abc_Obj_t * pNode );
extern char * Abc_ObjAssignName( Abc_Obj_t * pObj, char * pName, char * pSuffix );
@@ -737,6 +710,35 @@ extern Abc_Ntk_t * Abc_NtkCreateWithNode( char * pSop );
extern void Abc_NtkDelete( Abc_Ntk_t * pNtk );
extern void Abc_NtkFixNonDrivenNets( Abc_Ntk_t * pNtk );
extern void Abc_NtkMakeComb( Abc_Ntk_t * pNtk );
+/*=== abcObj.c ==========================================================*/
+extern Abc_Obj_t * Abc_ObjAlloc( Abc_Ntk_t * pNtk, Abc_ObjType_t Type );
+extern void Abc_ObjRecycle( Abc_Obj_t * pObj );
+extern Abc_Obj_t * Abc_NtkCreateObj( Abc_Ntk_t * pNtk, Abc_ObjType_t Type );
+extern void Abc_NtkDeleteObj( Abc_Obj_t * pObj );
+extern void Abc_NtkDeleteObj_rec( Abc_Obj_t * pObj, int fOnlyNodes );
+extern void Abc_NtkDeleteAll_rec( Abc_Obj_t * pObj );
+extern Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName );
+extern Abc_Obj_t * Abc_NtkDupBox( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pBox, int fCopyName );
+extern Abc_Obj_t * Abc_NtkCloneObj( Abc_Obj_t * pNode );
+extern Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName );
+extern Abc_Obj_t * Abc_NtkFindNet( Abc_Ntk_t * pNtk, char * pName );
+extern Abc_Obj_t * Abc_NtkFindCi( Abc_Ntk_t * pNtk, char * pName );
+extern Abc_Obj_t * Abc_NtkFindCo( Abc_Ntk_t * pNtk, char * pName );
+extern Abc_Obj_t * Abc_NtkFindOrCreateNet( Abc_Ntk_t * pNtk, char * pName );
+extern Abc_Obj_t * Abc_NtkCreateNodeConst0( Abc_Ntk_t * pNtk );
+extern Abc_Obj_t * Abc_NtkCreateNodeConst1( Abc_Ntk_t * pNtk );
+extern Abc_Obj_t * Abc_NtkCreateNodeInv( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin );
+extern Abc_Obj_t * Abc_NtkCreateNodeBuf( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin );
+extern Abc_Obj_t * Abc_NtkCreateNodeAnd( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins );
+extern Abc_Obj_t * Abc_NtkCreateNodeOr( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins );
+extern Abc_Obj_t * Abc_NtkCreateNodeExor( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins );
+extern Abc_Obj_t * Abc_NtkCreateNodeMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0 );
+extern bool Abc_NodeIsConst( Abc_Obj_t * pNode );
+extern bool Abc_NodeIsConst0( Abc_Obj_t * pNode );
+extern bool Abc_NodeIsConst1( Abc_Obj_t * pNode );
+extern bool Abc_NodeIsBuf( Abc_Obj_t * pNode );
+extern bool Abc_NodeIsInv( Abc_Obj_t * pNode );
+extern void Abc_NodeComplement( Abc_Obj_t * pNode );
/*=== abcPrint.c ==========================================================*/
extern void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored );
extern void Abc_NtkPrintIo( FILE * pFile, Abc_Ntk_t * pNtk );
diff --git a/src/base/abc/abcLatch.c b/src/base/abc/abcLatch.c
index cf3ddaba..d96bbfac 100644
--- a/src/base/abc/abcLatch.c
+++ b/src/base/abc/abcLatch.c
@@ -211,6 +211,113 @@ void Abc_NtkInsertLatchValues( Abc_Ntk_t * pNtk, Vec_Int_t * vValues )
pLatch->pData = (void *)(vValues? (Vec_IntEntry(vValues,i)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC);
}
+/**Function*************************************************************
+
+ Synopsis [Creates latch with the given initial value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Obj_t * Abc_NtkAddLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pDriver, Abc_InitType_t Init )
+{
+ Abc_Obj_t * pLatchOut, * pLatch, * pLatchIn;
+ pLatchOut = Abc_NtkCreateBo(pNtk);
+ pLatch = Abc_NtkCreateLatch(pNtk);
+ pLatchIn = Abc_NtkCreateBi(pNtk);
+ Abc_ObjAssignName( pLatchOut, Abc_ObjName(pLatch), "_lo" );
+ Abc_ObjAssignName( pLatchIn, Abc_ObjName(pLatch), "_li" );
+ Abc_ObjAddFanin( pLatchOut, pLatch );
+ Abc_ObjAddFanin( pLatch, pLatchIn );
+ Abc_ObjAddFanin( pLatchIn, pDriver );
+ pLatch->pData = (void *)Init;
+ return pLatchOut;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates MUX.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkNodeConvertToMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0, Abc_Obj_t * pMux )
+{
+ assert( Abc_NtkIsLogic(pNtk) );
+ Abc_ObjAddFanin( pMux, pNodeC );
+ Abc_ObjAddFanin( pMux, pNode1 );
+ Abc_ObjAddFanin( pMux, pNode0 );
+ if ( Abc_NtkHasSop(pNtk) )
+ pMux->pData = Abc_SopRegister( pNtk->pManFunc, "11- 1\n0-1 1\n" );
+ else if ( Abc_NtkHasBdd(pNtk) )
+ pMux->pData = Cudd_bddIte(pNtk->pManFunc,Cudd_bddIthVar(pNtk->pManFunc,0),Cudd_bddIthVar(pNtk->pManFunc,1),Cudd_bddIthVar(pNtk->pManFunc,2)), Cudd_Ref( pMux->pData );
+ else if ( Abc_NtkHasAig(pNtk) )
+ pMux->pData = Hop_Mux(pNtk->pManFunc,Hop_IthVar(pNtk->pManFunc,0),Hop_IthVar(pNtk->pManFunc,1),Hop_IthVar(pNtk->pManFunc,2));
+ else
+ assert( 0 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Converts registers with DC values into additional PIs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkConvertDcLatches( Abc_Ntk_t * pNtk )
+{
+ Abc_Obj_t * pCtrl, * pLatch, * pMux, * pPi;
+ Abc_InitType_t Init = ABC_INIT_ZERO;
+ int i, fFound = 0, Counter;
+ // check if there are latches with DC values
+ Abc_NtkForEachLatch( pNtk, pLatch, i )
+ if ( Abc_LatchIsInitDc(pLatch) )
+ {
+ fFound = 1;
+ break;
+ }
+ if ( !fFound )
+ return;
+ // add control latch
+ pCtrl = Abc_NtkAddLatch( pNtk, Abc_NtkCreateNodeConst1(pNtk), Init );
+ // add fanouts for each latch with DC values
+ Counter = 0;
+ Abc_NtkForEachLatch( pNtk, pLatch, i )
+ {
+ if ( !Abc_LatchIsInitDc(pLatch) )
+ continue;
+ // change latch value
+ pLatch->pData = (void *)Init;
+ // if the latch output has the same name as a PO, rename it
+ if ( Abc_NodeFindCoFanout( Abc_ObjFanout0(pLatch) ) )
+ {
+ Nm_ManDeleteIdName( pLatch->pNtk->pManName, Abc_ObjFanout0(pLatch)->Id );
+ Abc_ObjAssignName( Abc_ObjFanout0(pLatch), Abc_ObjName(pLatch), "_lo" );
+ }
+ // create new PIs
+ pPi = Abc_NtkCreatePi( pNtk );
+ Abc_ObjAssignName( pPi, Abc_ObjName(pLatch), "_pi" );
+ // create a new node and transfer fanout from latch output to the new node
+ pMux = Abc_NtkCreateNode( pNtk );
+ Abc_ObjTransferFanout( Abc_ObjFanout0(pLatch), pMux );
+ // convert the node into a mux
+ Abc_NtkNodeConvertToMux( pNtk, pCtrl, Abc_ObjFanout0(pLatch), pPi, pMux );
+ Counter++;
+ }
+ printf( "The number of converted latches with DC values = %d.\n", Counter );
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index bbaa80a4..18fbad38 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -161,6 +161,7 @@ static int Abc_CommandIf ( Abc_Frame_t * pAbc, int argc, char ** arg
static int Abc_CommandScut ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandInit ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandZero ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandUndc ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPipe ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSeq ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandUnseq ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -329,6 +330,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
// Cmd_CommandAdd( pAbc, "Sequential", "scut", Abc_CommandScut, 0 );
Cmd_CommandAdd( pAbc, "Sequential", "init", Abc_CommandInit, 1 );
Cmd_CommandAdd( pAbc, "Sequential", "zero", Abc_CommandZero, 1 );
+ Cmd_CommandAdd( pAbc, "Sequential", "undc", Abc_CommandUndc, 1 );
// Cmd_CommandAdd( pAbc, "Sequential", "pipe", Abc_CommandPipe, 1 );
Cmd_CommandAdd( pAbc, "Sequential", "retime", Abc_CommandRetime, 1 );
// Cmd_CommandAdd( pAbc, "Sequential", "sfpga", Abc_CommandSeqFpga, 1 );
@@ -6318,12 +6320,18 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
*/
-
+/*
if ( !Abc_NtkIsStrash(pNtk) )
{
fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
+*/
+ if ( Abc_NtkIsStrash(pNtk) )
+ {
+ fprintf( stdout, "Currently only works for logic circuits.\n" );
+ return 0;
+ }
// pNtkRes = Abc_NtkDar( pNtk );
// pNtkRes = Abc_NtkDarRetime( pNtk, nLevels, 1 );
@@ -10459,6 +10467,69 @@ usage:
SeeAlso []
***********************************************************************/
+int Abc_CommandUndc( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk;
+ int c;
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+ pOut = Abc_FrameReadOut(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ // set defaults
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+
+ if ( Abc_NtkIsComb(pNtk) )
+ {
+ fprintf( pErr, "The current network is combinational.\n" );
+ return 0;
+ }
+
+ if ( !Abc_NtkIsLogic(pNtk) )
+ {
+ fprintf( pErr, "This command works only for logic networks.\n" );
+ return 0;
+ }
+
+ // get the new network
+ Abc_NtkConvertDcLatches( pNtk );
+ return 0;
+
+usage:
+ fprintf( pErr, "usage: undc [-h]\n" );
+ fprintf( pErr, "\t converts latches with DC init values into free PIs\n" );
+ fprintf( pErr, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
int Abc_CommandPipe( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr;
diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c
index 06e425d5..f7616abc 100644
--- a/src/base/abci/abcDar.c
+++ b/src/base/abci/abcDar.c
@@ -85,7 +85,10 @@ Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fRegisters )
pMan->pName = Extra_UtilStrsav( pNtk->pName );
// save the number of registers
if ( fRegisters )
+ {
pMan->nRegs = Abc_NtkLatchNum(pNtk);
+ pMan->vFlopNums = Vec_IntStartNatural( pMan->nRegs );
+ }
// transfer the pointers to the basic nodes
Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)Aig_ManConst1(pMan);
Abc_NtkForEachCi( pNtk, pObj, i )
@@ -114,6 +117,7 @@ Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fRegisters )
// remove dangling nodes
if ( nNodes = Aig_ManCleanup( pMan ) )
printf( "Abc_NtkToDar(): Unexpected %d dangling nodes when converting to AIG!\n", nNodes );
+Aig_ManDumpVerilog( pMan, "test.v" );
if ( !Aig_ManCheck( pMan ) )
{
printf( "Abc_NtkToDar: AIG check has failed.\n" );
@@ -141,7 +145,7 @@ Abc_Ntk_t * Abc_NtkFromDar( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
Abc_Obj_t * pObjNew;
Aig_Obj_t * pObj;
int i;
- assert( Aig_ManRegNum(pMan) == Abc_NtkLatchNum(pNtkOld) );
+// assert( Aig_ManRegNum(pMan) == Abc_NtkLatchNum(pNtkOld) );
// perform strashing
pNtkNew = Abc_NtkStartFrom( pNtkOld, ABC_NTK_STRASH, ABC_FUNC_AIG );
// transfer the pointers to the basic nodes
@@ -192,7 +196,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
{
Vec_Ptr_t * vNodes;
Abc_Ntk_t * pNtkNew;
- Abc_Obj_t * pObjNew;
+ Abc_Obj_t * pObjNew, * pLatch;
Aig_Obj_t * pObj, * pObjLo, * pObjLi;
int i;
// assert( Aig_ManRegNum(pMan) != Abc_NtkLatchNum(pNtkOld) );
@@ -212,7 +216,19 @@ Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
Abc_ObjAddFanin( pObjLo->pData, pObjNew );
Abc_LatchSetInit0( pObjNew );
}
- Abc_NtkAddDummyBoxNames( pNtkNew );
+ if ( pMan->vFlopNums == NULL )
+ Abc_NtkAddDummyBoxNames( pNtkNew );
+ else
+ {
+ assert( Abc_NtkBoxNum(pNtkOld) == Abc_NtkLatchNum(pNtkOld) );
+ Abc_NtkForEachLatch( pNtkNew, pObjNew, i )
+ {
+ pLatch = Abc_NtkBox( pNtkOld, Vec_IntEntry( pMan->vFlopNums, i ) );
+ Abc_ObjAssignName( pObjNew, Abc_ObjName(pLatch), NULL );
+ Abc_ObjAssignName( Abc_ObjFanin0(pObjNew), Abc_ObjName(Abc_ObjFanin0(pLatch)), NULL );
+ Abc_ObjAssignName( Abc_ObjFanout0(pObjNew), Abc_ObjName(Abc_ObjFanout0(pLatch)), NULL );
+ }
+ }
// rebuild the AIG
vNodes = Aig_ManDfs( pMan );
Vec_PtrForEachEntry( vNodes, pObj, i )
@@ -959,8 +975,8 @@ Abc_Ntk_t * Abc_NtkDarSeqSweep( Abc_Ntk_t * pNtk, int nFramesP, int nFramesK, in
// so fraiging does not reduce the number of functions represented by nodes
Fraig_ParamsSetDefault( &Params );
Params.nBTLimit = 100000;
- pNtkFraig = Abc_NtkFraig( pNtk, &Params, 0, 0 );
-// pNtkFraig = Abc_NtkDup( pNtk );
+// pNtkFraig = Abc_NtkFraig( pNtk, &Params, 0, 0 );
+ pNtkFraig = Abc_NtkDup( pNtk );
if ( fVerbose )
{
PRT( "Initial fraiging time", clock() - clk );
diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c
index f9b053ba..7c3fb33c 100644
--- a/src/base/abci/abcPrint.c
+++ b/src/base/abci/abcPrint.c
@@ -314,7 +314,7 @@ void Abc_NtkPrintLatch( FILE * pFile, Abc_Ntk_t * pNtk )
}
else
{
- if ( Abc_LatchIsInit1(pLatch) == Abc_NodeIsConst1(pLatch) )
+ if ( Abc_LatchIsInit1(pLatch) == Abc_NodeIsConst1(Abc_ObjFanin0(Abc_ObjFanin0(pLatch))) )
Counter2++;
}
}
diff --git a/src/base/abci/xaaaa.c b/src/base/abci/xaaaa.c
deleted file mode 100644
index ea39ad02..00000000
--- a/src/base/abci/xaaaa.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/**CFile****************************************************************
-
- FileName [abc_.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Network and node package.]
-
- Synopsis []
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: abc_.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "abc.h"
-#include "kit.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abc_NtkPrintMeasures( unsigned * pTruth, int nVars )
-{
- unsigned uCofs[10][32];
- int i, k, nOnes;
-
- // total pairs
- nOnes = Kit_TruthCountOnes( uCofs[0], nVars );
- printf( "Total = %d.\n", nOnes * ((1 << nVars) - nOnes) );
-
- // print measures for individual variables
- for ( i = 0; i < nVars; i++ )
- {
- Kit_TruthUniqueNew( uCofs[0], pTruth, nVars, i );
- nOnes = Kit_TruthCountOnes( uCofs[0], nVars );
- printf( "%7d ", nOnes );
- }
- printf( "\n" );
-
- // consider pairs
- for ( i = 0; i < nVars; i++ )
- for ( k = 0; k < nVars; k++ )
- {
- if ( i == k )
- {
- printf( " " );
- continue;
- }
- Kit_TruthCofactor0New( uCofs[0], pTruth, nVars, i );
- Kit_TruthCofactor1New( uCofs[1], pTruth, nVars, i );
-
- Kit_TruthCofactor0New( uCofs[2], uCofs[0], nVars, k ); // 00
- Kit_TruthCofactor1New( uCofs[3], uCofs[0], nVars, k ); // 01
- Kit_TruthCofactor0New( uCofs[4], uCofs[1], nVars, k ); // 10
- Kit_TruthCofactor1New( uCofs[5], uCofs[1], nVars, k ); // 11
-
- Kit_TruthAndPhase( uCofs[6], uCofs[2], uCofs[5], nVars, 0, 1 ); // 00 & 11'
- Kit_TruthAndPhase( uCofs[7], uCofs[2], uCofs[5], nVars, 1, 0 ); // 00' & 11
- Kit_TruthAndPhase( uCofs[8], uCofs[3], uCofs[4], nVars, 0, 1 ); // 01 & 10'
- Kit_TruthAndPhase( uCofs[9], uCofs[3], uCofs[4], nVars, 1, 0 ); // 01' & 10
-
- nOnes = Kit_TruthCountOnes( uCofs[6], nVars ) +
- Kit_TruthCountOnes( uCofs[7], nVars ) +
- Kit_TruthCountOnes( uCofs[8], nVars ) +
- Kit_TruthCountOnes( uCofs[9], nVars );
-
- printf( "%7d ", nOnes );
- if ( k == nVars - 1 )
- printf( "\n" );
- }
- printf( "\n" );
-}
-
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abc_Ntk4VarTable( Abc_Ntk_t * pNtk )
-{
- static u4VarTts[222] = {
- 0x0000, 0x0001, 0x0003, 0x0006, 0x0007, 0x000f, 0x0016, 0x0017, 0x0018, 0x0019,
- 0x001b, 0x001e, 0x001f, 0x003c, 0x003d, 0x003f, 0x0069, 0x006b, 0x006f, 0x007e,
- 0x007f, 0x00ff, 0x0116, 0x0117, 0x0118, 0x0119, 0x011a, 0x011b, 0x011e, 0x011f,
- 0x012c, 0x012d, 0x012f, 0x013c, 0x013d, 0x013e, 0x013f, 0x0168, 0x0169, 0x016a,
- 0x016b, 0x016e, 0x016f, 0x017e, 0x017f, 0x0180, 0x0181, 0x0182, 0x0183, 0x0186,
- 0x0187, 0x0189, 0x018b, 0x018f, 0x0196, 0x0197, 0x0198, 0x0199, 0x019a, 0x019b,
- 0x019e, 0x019f, 0x01a8, 0x01a9, 0x01aa, 0x01ab, 0x01ac, 0x01ad, 0x01ae, 0x01af,
- 0x01bc, 0x01bd, 0x01be, 0x01bf, 0x01e8, 0x01e9, 0x01ea, 0x01eb, 0x01ee, 0x01ef,
- 0x01fe, 0x033c, 0x033d, 0x033f, 0x0356, 0x0357, 0x0358, 0x0359, 0x035a, 0x035b,
- 0x035e, 0x035f, 0x0368, 0x0369, 0x036a, 0x036b, 0x036c, 0x036d, 0x036e, 0x036f,
- 0x037c, 0x037d, 0x037e, 0x03c0, 0x03c1, 0x03c3, 0x03c5, 0x03c6, 0x03c7, 0x03cf,
- 0x03d4, 0x03d5, 0x03d6, 0x03d7, 0x03d8, 0x03d9, 0x03db, 0x03dc, 0x03dd, 0x03de,
- 0x03fc, 0x0660, 0x0661, 0x0662, 0x0663, 0x0666, 0x0667, 0x0669, 0x066b, 0x066f,
- 0x0672, 0x0673, 0x0676, 0x0678, 0x0679, 0x067a, 0x067b, 0x067e, 0x0690, 0x0691,
- 0x0693, 0x0696, 0x0697, 0x069f, 0x06b0, 0x06b1, 0x06b2, 0x06b3, 0x06b4, 0x06b5,
- 0x06b6, 0x06b7, 0x06b9, 0x06bd, 0x06f0, 0x06f1, 0x06f2, 0x06f6, 0x06f9, 0x0776,
- 0x0778, 0x0779, 0x077a, 0x077e, 0x07b0, 0x07b1, 0x07b4, 0x07b5, 0x07b6, 0x07bc,
- 0x07e0, 0x07e1, 0x07e2, 0x07e3, 0x07e6, 0x07e9, 0x07f0, 0x07f1, 0x07f2, 0x07f8,
- 0x0ff0, 0x1668, 0x1669, 0x166a, 0x166b, 0x166e, 0x167e, 0x1681, 0x1683, 0x1686,
- 0x1687, 0x1689, 0x168b, 0x168e, 0x1696, 0x1697, 0x1698, 0x1699, 0x169a, 0x169b,
- 0x169e, 0x16a9, 0x16ac, 0x16ad, 0x16bc, 0x16e9, 0x177e, 0x178e, 0x1796, 0x1798,
- 0x179a, 0x17ac, 0x17e8, 0x18e7, 0x19e1, 0x19e3, 0x19e6, 0x1bd8, 0x1be4, 0x1ee1,
- 0x3cc3, 0x6996
- };
- int Counters[222];
-
- Vec_Ptr_t * vNodes;
- Abc_Obj_t * pObj;
- int i;
-
- // set elementary truth tables
- Abc_NtkForEachPi( pNtk, pObj, i )
- pObj
-
- Abc_NtkForEachPo( pNtk, pObj, i )
- {
- vNodes = Abc_NtkDfsNodes( pNtk, &pObj, i );
- Vec_PtrFree( vNodes );
- }
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/base/io/io.c b/src/base/io/io.c
index 20caeb57..ca4cab95 100644
--- a/src/base/io/io.c
+++ b/src/base/io/io.c
@@ -34,6 +34,7 @@ static int IoCommandReadBench ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadDsd ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadEdif ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadEqn ( Abc_Frame_t * pAbc, int argc, char **argv );
+static int IoCommandReadInit ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadPla ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadTruth ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadVerilog ( Abc_Frame_t * pAbc, int argc, char **argv );
@@ -86,6 +87,7 @@ void Io_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "I/O", "read_dsd", IoCommandReadDsd, 1 );
// Cmd_CommandAdd( pAbc, "I/O", "read_edif", IoCommandReadEdif, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_eqn", IoCommandReadEqn, 1 );
+ Cmd_CommandAdd( pAbc, "I/O", "read_init", IoCommandReadInit, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_pla", IoCommandReadPla, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_truth", IoCommandReadTruth, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_verilog", IoCommandReadVerilog, 1 );
@@ -654,6 +656,65 @@ usage:
SeeAlso []
***********************************************************************/
+int IoCommandReadInit( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk;
+ char * pFileName;
+ int c;
+ extern void Io_ReadBenchInit( Abc_Ntk_t * pNtk, char * pFileName );
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+ pOut = Abc_FrameReadOut(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( argc != globalUtilOptind + 1 )
+ goto usage;
+
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ // get the input file name
+ pFileName = argv[globalUtilOptind];
+ // read the file using the corresponding file reader
+ pNtk = Abc_NtkDup( pNtk );
+ Io_ReadBenchInit( pNtk, pFileName );
+ // replace the current network
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ return 0;
+
+usage:
+ fprintf( pAbc->Err, "usage: read_init [-h] <file>\n" );
+ fprintf( pAbc->Err, "\t reads initial state of the network in BENCH format\n" );
+ fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
+ fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
int IoCommandReadPla( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk;
diff --git a/src/base/io/ioReadAiger.c b/src/base/io/ioReadAiger.c
index be80dc82..d3c4c878 100644
--- a/src/base/io/ioReadAiger.c
+++ b/src/base/io/ioReadAiger.c
@@ -245,6 +245,21 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck )
// printf( "Io_ReadAiger(): I/O/register names are not given. Generating short names.\n" );
Abc_NtkShortNames( pNtkNew );
}
+
+ // read the name of the model if given
+ if ( *pCur == 'c' )
+ {
+ if ( !strncmp( pCur + 2, ".model", 6 ) )
+ {
+ char * pTemp;
+ for ( pTemp = pCur + 9; *pTemp && *pTemp != '\n'; pTemp++ );
+ *pTemp = 0;
+ free( pNtkNew->pName );
+ pNtkNew->pName = Extra_UtilStrsav( pCur + 9 );
+ }
+ }
+
+
// skipping the comments
free( pContents );
Vec_PtrFree( vNodes );
diff --git a/src/base/io/ioReadBench.c b/src/base/io/ioReadBench.c
index ba622e40..007147bc 100644
--- a/src/base/io/ioReadBench.c
+++ b/src/base/io/ioReadBench.c
@@ -66,6 +66,7 @@ Abc_Ntk_t * Io_ReadBench( char * pFileName, int fCheck )
}
return pNtk;
}
+
/**Function*************************************************************
Synopsis []
@@ -82,7 +83,7 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
ProgressBar * pProgress;
Vec_Ptr_t * vTokens;
Abc_Ntk_t * pNtk;
- Abc_Obj_t * pNode;
+ Abc_Obj_t * pNode, * pNet;
Vec_Str_t * vString;
unsigned uTruth[8];
char * pType, ** ppNames, * pString;
@@ -241,11 +242,34 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
Extra_ProgressBarStop( pProgress );
Vec_StrFree( vString );
- // check if constant have been added
-// if ( pNet = Abc_NtkFindNet( pNtk, "vdd" ) )
-// Io_ReadCreateConst( pNtk, "vdd", 1 );
-// if ( pNet = Abc_NtkFindNet( pNtk, "gnd" ) )
-// Io_ReadCreateConst( pNtk, "gnd", 0 );
+ // check if constant 0 is present
+ if ( (pNet = Abc_NtkFindNet( pNtk, "gnd" )) )
+ {
+ if ( Abc_ObjFaninNum(pNet) == 0 )
+ Io_ReadCreateConst( pNtk, "gnd", 0 );
+ }
+ if ( (pNet = Abc_NtkFindNet( pNtk, "1" )) )
+ {
+ if ( Abc_ObjFaninNum(pNet) == 0 )
+ {
+ printf( "Io_ReadBenchNetwork(): Adding constant 0 fanin to non-driven net \"1\".\n" );
+ Io_ReadCreateConst( pNtk, "1", 0 );
+ }
+ }
+ // check if constant 1 is present
+ if ( (pNet = Abc_NtkFindNet( pNtk, "vdd" )) )
+ {
+ if ( Abc_ObjFaninNum(pNet) == 0 )
+ Io_ReadCreateConst( pNtk, "vdd", 1 );
+ }
+ if ( (pNet = Abc_NtkFindNet( pNtk, "2" )) )
+ {
+ if ( Abc_ObjFaninNum(pNet) == 0 )
+ {
+ printf( "Io_ReadBenchNetwork(): Adding constant 1 fanin to non-driven net \"2\".\n" );
+ Io_ReadCreateConst( pNtk, "2", 1 );
+ }
+ }
Abc_NtkFinalizeRead( pNtk );
@@ -269,6 +293,65 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
}
+/**Function*************************************************************
+
+ Synopsis [Reads initial state in BENCH format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Io_ReadBenchInit( Abc_Ntk_t * pNtk, char * pFileName )
+{
+ char pBuffer[1000];
+ FILE * pFile;
+ char * pToken;
+ Abc_Obj_t * pObj;
+ int Num;
+ pFile = fopen( pFileName, "r" );
+ if ( pFile == NULL )
+ {
+ printf( "Io_ReadBenchInit(): Failed to open file \"%s\".\n", pFileName );
+ return;
+ }
+ while ( fgets( pBuffer, 999, pFile ) )
+ {
+ pToken = strtok( pBuffer, " \n\t\r" );
+ // find the latch output
+ Num = Nm_ManFindIdByName( pNtk->pManName, pToken, ABC_OBJ_BO );
+ if ( Num < 0 )
+ {
+ printf( "Io_ReadBenchInit(): Cannot find register with output %s.\n", pToken );
+ continue;
+ }
+ pObj = Abc_ObjFanin0( Abc_NtkObj( pNtk, Num ) );
+ if ( !Abc_ObjIsLatch(pObj) )
+ {
+ printf( "Io_ReadBenchInit(): The signal is not a register output %s.\n", pToken );
+ continue;
+ }
+ // assign the new init state
+ pToken = strtok( NULL, " \n\t\r" );
+ if ( pToken[0] == '0' )
+ Abc_LatchSetInit0( pObj );
+ else if ( pToken[0] == '1' )
+ Abc_LatchSetInit1( pObj );
+ else if ( pToken[0] == '2' )
+ Abc_LatchSetInitDc( pObj );
+ else
+ {
+ printf( "Io_ReadBenchInit(): The signal %s has unknown initial value (%s).\n",
+ Abc_ObjName(Abc_ObjFanout0(pObj)), pToken );
+ continue;
+ }
+ }
+ fclose( pFile );
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/base/io/ioWriteAiger.c b/src/base/io/ioWriteAiger.c
index e805fbc2..ff34b177 100644
--- a/src/base/io/ioWriteAiger.c
+++ b/src/base/io/ioWriteAiger.c
@@ -248,7 +248,8 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols )
// write the comment
fprintf( pFile, "c\n" );
- fprintf( pFile, "%s\n", pNtk->pName );
+ if ( pNtk->pName && strlen(pNtk->pName) > 0 )
+ fprintf( pFile, ".model %s\n", pNtk->pName );
fprintf( pFile, "This file was produced by ABC on %s\n", Extra_TimeStamp() );
fprintf( pFile, "For information about AIGER format, refer to %s\n", "http://fmv.jku.at/aiger" );
fclose( pFile );