Commit bd640142 by Alan Mishchenko

Version abc50807

parent d0e834d1
...@@ -7,9 +7,10 @@ CP := cp ...@@ -7,9 +7,10 @@ CP := cp
PROG := abc PROG := abc
MODULES := src/base/abc src/base/cmd src/base/io src/base/main \ MODULES := src/base/abc src/base/cmd src/base/io src/base/main \
src/bdd/cudd src/bdd/epd src/bdd/mtr src/bdd/parse \ src/bdd/cudd src/bdd/dsd src/bdd/epd src/bdd/mtr src/bdd/parse src/bdd/reo \
src/map/fpga src/map/mapper src/map/mio src/map/super \ src/map/fpga src/map/mapper src/map/mio src/map/super \
src/misc/extra src/misc/st src/misc/util src/misc/vec \ src/misc/extra src/misc/st src/misc/util src/misc/vec \
src/opt/fxu \
src/sat/asat src/sat/fraig src/sat/msat \ src/sat/asat src/sat/fraig src/sat/msat \
src/seq \ src/seq \
src/sop/ft src/sop/mvc src/sop/ft src/sop/mvc
......
...@@ -189,10 +189,18 @@ SOURCE=.\src\base\abc\abcRenode.c ...@@ -189,10 +189,18 @@ SOURCE=.\src\base\abc\abcRenode.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\abc\abcRes.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abc\abcSat.c SOURCE=.\src\base\abc\abcSat.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\abc\abcShow.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abc\abcSop.c SOURCE=.\src\base\abc\abcSop.c
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -209,6 +217,10 @@ SOURCE=.\src\base\abc\abcTiming.c ...@@ -209,6 +217,10 @@ SOURCE=.\src\base\abc\abcTiming.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\abc\abcUnreach.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abc\abcUtil.c SOURCE=.\src\base\abc\abcUtil.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
No preview for this file type
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
--------------------Configuration: abc - Win32 Debug-------------------- --------------------Configuration: abc - Win32 Debug--------------------
</h3> </h3>
<h3>Command Lines</h3> <h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP448.tmp" with contents Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP84B.tmp" with contents
[ [
/nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\base\abc" /I "src\base\cmd" /I "src\base\io" /I "src\base\main" /I "src\bdd\cudd" /I "src\bdd\epd" /I "src\bdd\mtr" /I "src\bdd\parse" /I "src\bdd\dsd" /I "src\bdd\reo" /I "src\sop\mvc" /I "src\sop\ft" /I "src\sat\asat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\fxa" /I "src\opt\fxu" /I "src\map\fpga" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\util" /I "src\misc\vec" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /D "HAVE_ASSERT_H" /FR"Debug/" /Fp"Debug/abc.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c /nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\base\abc" /I "src\base\cmd" /I "src\base\io" /I "src\base\main" /I "src\bdd\cudd" /I "src\bdd\epd" /I "src\bdd\mtr" /I "src\bdd\parse" /I "src\bdd\dsd" /I "src\bdd\reo" /I "src\sop\mvc" /I "src\sop\ft" /I "src\sat\asat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\fxa" /I "src\opt\fxu" /I "src\map\fpga" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\util" /I "src\misc\vec" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /D "HAVE_ASSERT_H" /FR"Debug/" /Fp"Debug/abc.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"C:\_projects\abc\src\opt\fxu\fxu.c" "C:\_projects\abc\src\base\abc\abcRes.c"
] ]
Creating command line "cl.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP448.tmp" Creating command line "cl.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP84B.tmp"
Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP449.tmp" with contents Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP84C.tmp" with contents
[ [
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/abc.pdb" /debug /machine:I386 /out:"_TEST/abc.exe" /pdbtype:sept kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/abc.pdb" /debug /machine:I386 /out:"_TEST/abc.exe" /pdbtype:sept
.\Debug\abc.obj .\Debug\abc.obj
...@@ -27,6 +27,7 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32 ...@@ -27,6 +27,7 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32
.\Debug\abcFpga.obj .\Debug\abcFpga.obj
.\Debug\abcFraig.obj .\Debug\abcFraig.obj
.\Debug\abcFunc.obj .\Debug\abcFunc.obj
.\Debug\abcFxu.obj
.\Debug\abcLatch.obj .\Debug\abcLatch.obj
.\Debug\abcMap.obj .\Debug\abcMap.obj
.\Debug\abcMinBase.obj .\Debug\abcMinBase.obj
...@@ -36,11 +37,14 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32 ...@@ -36,11 +37,14 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32
.\Debug\abcPrint.obj .\Debug\abcPrint.obj
.\Debug\abcRefs.obj .\Debug\abcRefs.obj
.\Debug\abcRenode.obj .\Debug\abcRenode.obj
.\Debug\abcRes.obj
.\Debug\abcSat.obj .\Debug\abcSat.obj
.\Debug\abcShow.obj
.\Debug\abcSop.obj .\Debug\abcSop.obj
.\Debug\abcStrash.obj .\Debug\abcStrash.obj
.\Debug\abcSweep.obj .\Debug\abcSweep.obj
.\Debug\abcTiming.obj .\Debug\abcTiming.obj
.\Debug\abcUnreach.obj
.\Debug\abcUtil.obj .\Debug\abcUtil.obj
.\Debug\abcVerify.obj .\Debug\abcVerify.obj
.\Debug\cmd.obj .\Debug\cmd.obj
...@@ -188,6 +192,18 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32 ...@@ -188,6 +192,18 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32
.\Debug\fraigTable.obj .\Debug\fraigTable.obj
.\Debug\fraigUtil.obj .\Debug\fraigUtil.obj
.\Debug\fraigVec.obj .\Debug\fraigVec.obj
.\Debug\fxu.obj
.\Debug\fxuCreate.obj
.\Debug\fxuHeapD.obj
.\Debug\fxuHeapS.obj
.\Debug\fxuList.obj
.\Debug\fxuMatrix.obj
.\Debug\fxuPair.obj
.\Debug\fxuPrint.obj
.\Debug\fxuReduce.obj
.\Debug\fxuSelect.obj
.\Debug\fxuSingle.obj
.\Debug\fxuUpdate.obj
.\Debug\fpga.obj .\Debug\fpga.obj
.\Debug\fpgaCore.obj .\Debug\fpgaCore.obj
.\Debug\fpgaCreate.obj .\Debug\fpgaCreate.obj
...@@ -242,26 +258,13 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32 ...@@ -242,26 +258,13 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32
.\Debug\safe_mem.obj .\Debug\safe_mem.obj
.\Debug\strsav.obj .\Debug\strsav.obj
.\Debug\texpand.obj .\Debug\texpand.obj
.\Debug\fxuUpdate.obj
.\Debug\fxu.obj
.\Debug\fxuCreate.obj
.\Debug\fxuHeapD.obj
.\Debug\fxuHeapS.obj
.\Debug\fxuList.obj
.\Debug\fxuMatrix.obj
.\Debug\fxuPair.obj
.\Debug\fxuPrint.obj
.\Debug\fxuReduce.obj
.\Debug\fxuSelect.obj
.\Debug\fxuSingle.obj
.\Debug\abcFxu.obj
] ]
Creating command line "link.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP449.tmp" Creating command line "link.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP84C.tmp"
<h3>Output Window</h3> <h3>Output Window</h3>
Compiling... Compiling...
fxu.c abcRes.c
Linking... Linking...
Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP44A.tmp" with contents Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP84D.tmp" with contents
[ [
/nologo /o"Debug/abc.bsc" /nologo /o"Debug/abc.bsc"
.\Debug\abc.sbr .\Debug\abc.sbr
...@@ -276,6 +279,7 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP44A.tmp" with conte ...@@ -276,6 +279,7 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP44A.tmp" with conte
.\Debug\abcFpga.sbr .\Debug\abcFpga.sbr
.\Debug\abcFraig.sbr .\Debug\abcFraig.sbr
.\Debug\abcFunc.sbr .\Debug\abcFunc.sbr
.\Debug\abcFxu.sbr
.\Debug\abcLatch.sbr .\Debug\abcLatch.sbr
.\Debug\abcMap.sbr .\Debug\abcMap.sbr
.\Debug\abcMinBase.sbr .\Debug\abcMinBase.sbr
...@@ -285,11 +289,14 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP44A.tmp" with conte ...@@ -285,11 +289,14 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP44A.tmp" with conte
.\Debug\abcPrint.sbr .\Debug\abcPrint.sbr
.\Debug\abcRefs.sbr .\Debug\abcRefs.sbr
.\Debug\abcRenode.sbr .\Debug\abcRenode.sbr
.\Debug\abcRes.sbr
.\Debug\abcSat.sbr .\Debug\abcSat.sbr
.\Debug\abcShow.sbr
.\Debug\abcSop.sbr .\Debug\abcSop.sbr
.\Debug\abcStrash.sbr .\Debug\abcStrash.sbr
.\Debug\abcSweep.sbr .\Debug\abcSweep.sbr
.\Debug\abcTiming.sbr .\Debug\abcTiming.sbr
.\Debug\abcUnreach.sbr
.\Debug\abcUtil.sbr .\Debug\abcUtil.sbr
.\Debug\abcVerify.sbr .\Debug\abcVerify.sbr
.\Debug\cmd.sbr .\Debug\cmd.sbr
...@@ -437,6 +444,18 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP44A.tmp" with conte ...@@ -437,6 +444,18 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP44A.tmp" with conte
.\Debug\fraigTable.sbr .\Debug\fraigTable.sbr
.\Debug\fraigUtil.sbr .\Debug\fraigUtil.sbr
.\Debug\fraigVec.sbr .\Debug\fraigVec.sbr
.\Debug\fxu.sbr
.\Debug\fxuCreate.sbr
.\Debug\fxuHeapD.sbr
.\Debug\fxuHeapS.sbr
.\Debug\fxuList.sbr
.\Debug\fxuMatrix.sbr
.\Debug\fxuPair.sbr
.\Debug\fxuPrint.sbr
.\Debug\fxuReduce.sbr
.\Debug\fxuSelect.sbr
.\Debug\fxuSingle.sbr
.\Debug\fxuUpdate.sbr
.\Debug\fpga.sbr .\Debug\fpga.sbr
.\Debug\fpgaCore.sbr .\Debug\fpgaCore.sbr
.\Debug\fpgaCreate.sbr .\Debug\fpgaCreate.sbr
...@@ -490,21 +509,8 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP44A.tmp" with conte ...@@ -490,21 +509,8 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP44A.tmp" with conte
.\Debug\pathsearch.sbr .\Debug\pathsearch.sbr
.\Debug\safe_mem.sbr .\Debug\safe_mem.sbr
.\Debug\strsav.sbr .\Debug\strsav.sbr
.\Debug\texpand.sbr .\Debug\texpand.sbr]
.\Debug\fxuUpdate.sbr Creating command line "bscmake.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP84D.tmp"
.\Debug\fxu.sbr
.\Debug\fxuCreate.sbr
.\Debug\fxuHeapD.sbr
.\Debug\fxuHeapS.sbr
.\Debug\fxuList.sbr
.\Debug\fxuMatrix.sbr
.\Debug\fxuPair.sbr
.\Debug\fxuPrint.sbr
.\Debug\fxuReduce.sbr
.\Debug\fxuSelect.sbr
.\Debug\fxuSingle.sbr
.\Debug\abcFxu.sbr]
Creating command line "bscmake.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP44A.tmp"
Creating browse info file... Creating browse info file...
<h3>Output Window</h3> <h3>Output Window</h3>
......
alias b balance alias b balance
alias clp collapse alias clp collapse
alias esd ext_seq_dcs
alias f fraig alias f fraig
alias fs fraig_sweep alias fs fraig_sweep
alias pf print_factor alias pf print_factor
......
...@@ -21,25 +21,6 @@ ...@@ -21,25 +21,6 @@
#ifndef __ABC_H__ #ifndef __ABC_H__
#define __ABC_H__ #define __ABC_H__
/*
In the netlist, the PI/PO arrays store PI/PO nets.
The names belongs to the nets and are stored in pNet->pData.
When a netlist is made combinational:
- LO/LI nets are added to PI/PO arrays,
- the array of latches is temporarily stored in vLatch2,
- the original number of PIs/POs is remembered in nPisOld/nPosOld.
In a logic network, the PI/PO arrays store PI/PO nodes.
The PO nodes have only one fanin edge, which can be complemented.
The arrays vNamesPi/vNamesPo/vNamesLatch store PI/PO/latch names.
The internal nodes are nameless.
When a logic network is made combinational:
- laches are added to the PI/PO arrays,
- the arrays of names are not changed,
- the array of latches is temporarily stored in vLatch2,
- the original number of PIs/POs is remembered in nPisOld/nPosOld.
*/
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// INCLUDES /// /// INCLUDES ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -103,6 +84,7 @@ typedef struct Abc_Obj_t_ Abc_Obj_t; ...@@ -103,6 +84,7 @@ typedef struct Abc_Obj_t_ Abc_Obj_t;
typedef struct Abc_Ntk_t_ Abc_Ntk_t; typedef struct Abc_Ntk_t_ Abc_Ntk_t;
typedef struct Abc_Aig_t_ Abc_Aig_t; typedef struct Abc_Aig_t_ Abc_Aig_t;
typedef struct Abc_ManTime_t_ Abc_ManTime_t; typedef struct Abc_ManTime_t_ Abc_ManTime_t;
typedef struct Abc_ManRes_t_ Abc_ManRes_t;
typedef struct Abc_Time_t_ Abc_Time_t; typedef struct Abc_Time_t_ Abc_Time_t;
struct Abc_Time_t_ struct Abc_Time_t_
...@@ -182,6 +164,30 @@ struct Abc_Ntk_t_ ...@@ -182,6 +164,30 @@ struct Abc_Ntk_t_
Extra_MmStep_t * pMmStep; // memory manager for arrays Extra_MmStep_t * pMmStep; // memory manager for arrays
}; };
struct Abc_ManRes_t_
{
// user specified parameters
int nNodeSizeMax; // the limit on the size of the supernode
int nConeSizeMax; // the limit on the size of the containing cone
int fVerbose; // the verbosity flag
// internal parameters
DdManager * dd; // the BDD manager
DdNode * bCubeX; // the cube of PI variables
Abc_Obj_t * pNode; // the node currently considered
Vec_Ptr_t * vFaninsNode; // fanins of the supernode
Vec_Ptr_t * vInsideNode; // inside of the supernode
Vec_Ptr_t * vFaninsCone; // fanins of the containing cone
Vec_Ptr_t * vInsideCone; // inside of the containing cone
Vec_Ptr_t * vVisited; // the visited nodes
Vec_Str_t * vCube; // temporary cube for generating covers
Vec_Int_t * vForm; // the factored form (temporary)
// runtime statistics
int time1;
int time2;
int time3;
int time4;
};
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// MACRO DEFITIONS /// /// MACRO DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -380,11 +386,12 @@ extern bool Abc_NtkCheck( Abc_Ntk_t * pNtk ); ...@@ -380,11 +386,12 @@ extern bool Abc_NtkCheck( Abc_Ntk_t * pNtk );
extern bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ); extern bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
/*=== abcCollapse.c ==========================================================*/ /*=== abcCollapse.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose ); extern Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose );
extern DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly );
extern void Abc_NtkFreeGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk );
/*=== abcCreate.c ==========================================================*/ /*=== abcCreate.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type ); extern Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type );
extern Abc_Ntk_t * Abc_NtkStartFrom( Abc_Ntk_t * pNtk, Abc_NtkType_t Type ); extern Abc_Ntk_t * Abc_NtkStartFrom( Abc_Ntk_t * pNtk, Abc_NtkType_t Type );
extern void Abc_NtkFinalize( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew ); extern void Abc_NtkFinalize( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew );
extern void Abc_NtkFinalizeRegular( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew );
extern Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk ); extern Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk );
extern void Abc_NtkDelete( Abc_Ntk_t * pNtk ); extern void Abc_NtkDelete( Abc_Ntk_t * pNtk );
extern Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj ); extern Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj );
...@@ -407,6 +414,7 @@ extern Abc_Obj_t * Abc_NodeCreateBuf( Abc_Ntk_t * pNtk, Abc_Obj_t * pFani ...@@ -407,6 +414,7 @@ extern Abc_Obj_t * Abc_NodeCreateBuf( Abc_Ntk_t * pNtk, Abc_Obj_t * pFani
extern Abc_Obj_t * Abc_NodeCreateAnd( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins ); extern Abc_Obj_t * Abc_NodeCreateAnd( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins );
extern Abc_Obj_t * Abc_NodeCreateOr( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins ); extern Abc_Obj_t * Abc_NodeCreateOr( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins );
extern Abc_Obj_t * Abc_NodeCreateMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0 ); extern Abc_Obj_t * Abc_NodeCreateMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0 );
extern Abc_Obj_t * Abc_NodeClone( Abc_Obj_t * pNode );
/*=== abcDfs.c ==========================================================*/ /*=== abcDfs.c ==========================================================*/
extern Vec_Ptr_t * Abc_NtkDfs( Abc_Ntk_t * pNtk ); extern Vec_Ptr_t * Abc_NtkDfs( Abc_Ntk_t * pNtk );
extern Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk ); extern Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk );
...@@ -415,6 +423,7 @@ extern bool Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk ); ...@@ -415,6 +423,7 @@ extern bool Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk );
/*=== abcFanio.c ==========================================================*/ /*=== abcFanio.c ==========================================================*/
extern void Abc_ObjAddFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin ); extern void Abc_ObjAddFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin );
extern void Abc_ObjDeleteFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin ); extern void Abc_ObjDeleteFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin );
extern void Abc_ObjRemoveFanins( Abc_Obj_t * pObj );
extern void Abc_ObjPatchFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFaninOld, Abc_Obj_t * pFaninNew ); extern void Abc_ObjPatchFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFaninOld, Abc_Obj_t * pFaninNew );
extern void Abc_ObjTransferFanout( Abc_Obj_t * pObjOld, Abc_Obj_t * pObjNew ); extern void Abc_ObjTransferFanout( Abc_Obj_t * pObjOld, Abc_Obj_t * pObjNew );
extern void Abc_ObjReplace( Abc_Obj_t * pObjOld, Abc_Obj_t * pObjNew ); extern void Abc_ObjReplace( Abc_Obj_t * pObjOld, Abc_Obj_t * pObjNew );
...@@ -426,7 +435,7 @@ extern Abc_Ntk_t * Abc_NtkFraigRestore(); ...@@ -426,7 +435,7 @@ extern Abc_Ntk_t * Abc_NtkFraigRestore();
extern void Abc_NtkFraigStoreClean(); extern void Abc_NtkFraigStoreClean();
/*=== abcFunc.c ==========================================================*/ /*=== abcFunc.c ==========================================================*/
extern int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk ); extern int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk );
extern char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFunc, int nFanins, Vec_Str_t * vCube, int fMode ); extern char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFuncOn, DdNode * bFuncOnDc, int nFanins, Vec_Str_t * vCube, int fMode );
extern int Abc_NtkBddToSop( Abc_Ntk_t * pNtk ); extern int Abc_NtkBddToSop( Abc_Ntk_t * pNtk );
extern void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Extra_MmFlex_t * pMmMan, Vec_Str_t * vCube, char ** ppSop0, char ** ppSop1 ); extern void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Extra_MmFlex_t * pMmMan, Vec_Str_t * vCube, char ** ppSop0, char ** ppSop1 );
extern int Abc_CountZddCubes( DdManager * dd, DdNode * zCover ); extern int Abc_CountZddCubes( DdManager * dd, DdNode * zCover );
...@@ -475,6 +484,9 @@ extern int Abc_NodeMffcRemove( Abc_Obj_t * pNode ); ...@@ -475,6 +484,9 @@ extern int Abc_NodeMffcRemove( Abc_Obj_t * pNode );
/*=== abcRenode.c ==========================================================*/ /*=== abcRenode.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkRenode( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple ); extern Abc_Ntk_t * Abc_NtkRenode( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple );
extern DdNode * Abc_NtkRenodeDeriveBdd( DdManager * dd, Abc_Obj_t * pNodeOld, Vec_Ptr_t * vFaninsOld ); extern DdNode * Abc_NtkRenodeDeriveBdd( DdManager * dd, Abc_Obj_t * pNodeOld, Vec_Ptr_t * vFaninsOld );
/*=== abcRes.c ==========================================================*/
extern Abc_ManRes_t * Abc_NtkManResStart();
extern void Abc_NtkManResStop( Abc_ManRes_t * p );
/*=== abcSat.c ==========================================================*/ /*=== abcSat.c ==========================================================*/
extern bool Abc_NtkMiterSat( Abc_Ntk_t * pNtk, int fVerbose ); extern bool Abc_NtkMiterSat( Abc_Ntk_t * pNtk, int fVerbose );
extern solver * Abc_NtkMiterSatCreate( Abc_Ntk_t * pNtk ); extern solver * Abc_NtkMiterSatCreate( Abc_Ntk_t * pNtk );
...@@ -497,7 +509,7 @@ extern bool Abc_SopCheck( char * pSop, int nFanins ); ...@@ -497,7 +509,7 @@ extern bool Abc_SopCheck( char * pSop, int nFanins );
extern void Abc_SopWriteCnf( FILE * pFile, char * pClauses, Vec_Int_t * vVars ); extern void Abc_SopWriteCnf( FILE * pFile, char * pClauses, Vec_Int_t * vVars );
extern void Abc_SopAddCnfToSolver( solver * pSat, char * pClauses, Vec_Int_t * vVars, Vec_Int_t * vTemp ); extern void Abc_SopAddCnfToSolver( solver * pSat, char * pClauses, Vec_Int_t * vVars, Vec_Int_t * vTemp );
/*=== abcStrash.c ==========================================================*/ /*=== abcStrash.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk ); extern Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes );
extern int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ); extern int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 );
extern Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate ); extern Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate );
/*=== abcSweep.c ==========================================================*/ /*=== abcSweep.c ==========================================================*/
...@@ -512,7 +524,7 @@ extern void Abc_NtkTimeSetDefaultArrival( Abc_Ntk_t * pNtk, float ...@@ -512,7 +524,7 @@ extern void Abc_NtkTimeSetDefaultArrival( Abc_Ntk_t * pNtk, float
extern void Abc_NtkTimeSetDefaultRequired( Abc_Ntk_t * pNtk, float Rise, float Fall ); extern void Abc_NtkTimeSetDefaultRequired( Abc_Ntk_t * pNtk, float Rise, float Fall );
extern void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall ); extern void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall );
extern void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall ); extern void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall );
extern void Abc_NtkTimeFinalize( Abc_Ntk_t * pNtk ); extern void Abc_NtkTimeInitialize( Abc_Ntk_t * pNtk );
extern void Abc_ManTimeStop( Abc_ManTime_t * p ); extern void Abc_ManTimeStop( Abc_ManTime_t * p );
extern void Abc_ManTimeDup( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew ); extern void Abc_ManTimeDup( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew );
extern void Abc_NtkSetNodeLevelsArrival( Abc_Ntk_t * pNtk ); extern void Abc_NtkSetNodeLevelsArrival( Abc_Ntk_t * pNtk );
...@@ -549,6 +561,9 @@ extern void Abc_NodeCollectFanouts( Abc_Obj_t * pNode, Vec_Ptr_t * ...@@ -549,6 +561,9 @@ extern void Abc_NodeCollectFanouts( Abc_Obj_t * pNode, Vec_Ptr_t *
extern int Abc_NodeCompareLevelsIncrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 ); extern int Abc_NodeCompareLevelsIncrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 );
extern int Abc_NodeCompareLevelsDecrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 ); extern int Abc_NodeCompareLevelsDecrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 );
extern Vec_Ptr_t * Abc_AigCollectAll( Abc_Ntk_t * pNtk ); extern Vec_Ptr_t * Abc_AigCollectAll( Abc_Ntk_t * pNtk );
extern Vec_Ptr_t * Abc_NodeGetFaninNames( Abc_Obj_t * pNode );
extern void Abc_NodeFreeFaninNames( Vec_Ptr_t * vNames );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -108,11 +108,11 @@ bool Abc_NtkCheck( Abc_Ntk_t * pNtk ) ...@@ -108,11 +108,11 @@ bool Abc_NtkCheck( Abc_Ntk_t * pNtk )
// check the EXDC network if present // check the EXDC network if present
if ( pNtk->pExdc ) if ( pNtk->pExdc )
{ {
if ( pNtk->Type != pNtk->pExdc->Type ) // if ( pNtk->Type != pNtk->pExdc->Type )
{ // {
fprintf( stdout, "NetworkCheck: Network and its EXDC have different types.\n" ); // fprintf( stdout, "NetworkCheck: Network and its EXDC have different types.\n" );
return 0; // return 0;
} // }
return Abc_NtkCheck( pNtk->pExdc ); return Abc_NtkCheck( pNtk->pExdc );
} }
return 1; return 1;
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk );
static DdNode * Abc_NtkGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode ); static DdNode * Abc_NtkGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode );
static Abc_Ntk_t * Abc_NtkFromGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk ); static Abc_Ntk_t * Abc_NtkFromGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk );
static Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc ); static Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode * bFunc );
...@@ -52,33 +51,16 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose ) ...@@ -52,33 +51,16 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose )
assert( Abc_NtkIsAig(pNtk) ); assert( Abc_NtkIsAig(pNtk) );
// perform FPGA mapping // compute the global BDDs
dd = Abc_NtkGlobalBdds( pNtk ); dd = Abc_NtkGlobalBdds( pNtk, 0 );
if ( dd == NULL ) if ( dd == NULL )
return NULL; return NULL;
if ( fVerbose ) if ( fVerbose )
printf( "The shared BDD size is %d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) ); printf( "The shared BDD size is %d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
/*
{
Abc_Obj_t * pNode;
int i;
Abc_NtkForEachPo( pNtk, pNode, i )
{
Cudd_RecursiveDeref( dd, (DdNode *)pNode->pNext );
pNode->pNext = NULL;
}
Abc_NtkForEachLatch( pNtk, pNode, i )
{
Cudd_RecursiveDeref( dd, (DdNode *)pNode->pNext );
pNode->pNext = NULL;
}
}
Extra_StopManager( dd );
return NULL;
*/
// transform the result of mapping into a BDD network // create the new network
pNtkNew = Abc_NtkFromGlobalBdds( dd, pNtk ); pNtkNew = Abc_NtkFromGlobalBdds( dd, pNtk );
Abc_NtkFreeGlobalBdds( dd, pNtk );
if ( pNtkNew == NULL ) if ( pNtkNew == NULL )
{ {
Cudd_Quit( dd ); Cudd_Quit( dd );
...@@ -110,8 +92,9 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose ) ...@@ -110,8 +92,9 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk ) DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fLatchOnly )
{ {
int fReorder = 1;
ProgressBar * pProgress; ProgressBar * pProgress;
Abc_Obj_t * pNode; Abc_Obj_t * pNode;
DdNode * bFunc; DdNode * bFunc;
...@@ -120,7 +103,8 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk ) ...@@ -120,7 +103,8 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk )
// start the manager // start the manager
dd = Cudd_Init( Abc_NtkCiNum(pNtk), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); dd = Cudd_Init( Abc_NtkCiNum(pNtk), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT ); if ( fReorder )
Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT );
// set the elementary variables // set the elementary variables
Abc_NtkCleanCopy( pNtk ); Abc_NtkCleanCopy( pNtk );
...@@ -130,31 +114,60 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk ) ...@@ -130,31 +114,60 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk )
pNode = Abc_AigConst1( pNtk->pManFunc ); pNode = Abc_AigConst1( pNtk->pManFunc );
pNode->pCopy = (Abc_Obj_t *)dd->one; Cudd_Ref( dd->one ); pNode->pCopy = (Abc_Obj_t *)dd->one; Cudd_Ref( dd->one );
// construct the BDDs if ( fLatchOnly )
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
Abc_NtkForEachCo( pNtk, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); // construct the BDDs
bFunc = Abc_NtkGlobalBdds_rec( dd, Abc_ObjFanin0(pNode) ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkLatchNum(pNtk) );
if ( bFunc == NULL ) Abc_NtkForEachLatch( pNtk, pNode, i )
{ {
printf( "Constructing global BDDs timed out.\n" ); Extra_ProgressBarUpdate( pProgress, i, NULL );
Extra_ProgressBarStop( pProgress ); bFunc = Abc_NtkGlobalBdds_rec( dd, Abc_ObjFanin0(pNode) );
Cudd_Quit( dd ); if ( bFunc == NULL )
return NULL; {
printf( "Constructing global BDDs timed out.\n" );
Extra_ProgressBarStop( pProgress );
Cudd_Quit( dd );
return NULL;
}
bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pNode) );
pNode->pNext = (Abc_Obj_t *)bFunc; Cudd_Ref( bFunc );
} }
bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pNode) ); Extra_ProgressBarStop( pProgress );
pNode->pNext = (Abc_Obj_t *)bFunc; Cudd_Ref( bFunc ); }
else
{
// construct the BDDs
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
Abc_NtkForEachCo( pNtk, pNode, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
bFunc = Abc_NtkGlobalBdds_rec( dd, Abc_ObjFanin0(pNode) );
if ( bFunc == NULL )
{
printf( "Constructing global BDDs timed out.\n" );
Extra_ProgressBarStop( pProgress );
Cudd_Quit( dd );
return NULL;
}
bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pNode) );
pNode->pNext = (Abc_Obj_t *)bFunc; Cudd_Ref( bFunc );
}
Extra_ProgressBarStop( pProgress );
} }
Extra_ProgressBarStop( pProgress );
// derefence the intermediate BDDs // derefence the intermediate BDDs
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
if ( pNode->pCopy ) if ( pNode->pCopy )
{
Cudd_RecursiveDeref( dd, (DdNode *)pNode->pCopy ); Cudd_RecursiveDeref( dd, (DdNode *)pNode->pCopy );
Abc_NtkCleanCopy( pNtk ); pNode->pCopy = NULL;
}
// reorder one more time // reorder one more time
Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 0 ); if ( fReorder )
{
Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 );
Cudd_AutodynDisable( dd );
}
return dd; return dd;
} }
...@@ -227,9 +240,6 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk ) ...@@ -227,9 +240,6 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk )
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, (DdNode *)pNode->pNext ); pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, (DdNode *)pNode->pNext );
Abc_ObjAddFanin( pNode->pCopy, pNodeNew ); Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
// deref the BDD of the PO
Cudd_RecursiveDeref( dd, (DdNode *)pNode->pNext );
pNode->pNext = NULL;
} }
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
// transfer the names // transfer the names
...@@ -263,6 +273,30 @@ Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode ...@@ -263,6 +273,30 @@ Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode
return pNodeNew; return pNodeNew;
} }
/**Function*************************************************************
Synopsis [Dereferences global functions of the network.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkFreeGlobalBdds( DdManager * dd, Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pNode;
int i;
Abc_NtkForEachCo( pNtk, pNode, i )
{
if ( pNode->pNext == NULL )
continue;
Cudd_RecursiveDeref( dd, (DdNode *)pNode->pNext );
pNode->pNext = NULL;
}
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -157,34 +157,6 @@ void Abc_NtkFinalize( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew ) ...@@ -157,34 +157,6 @@ void Abc_NtkFinalize( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Finalizes the network using the existing network as a model.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkFinalizeRegular( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
{
Abc_Obj_t * pObj, * pDriver, * pDriverNew;
int i;
assert( !Abc_NtkIsNetlist(pNtk) );
// set the COs of the strashed network
Abc_NtkForEachCo( pNtk, pObj, i )
{
pDriver = Abc_ObjFanin0(pObj);
pDriverNew = pDriver->pCopy;
Abc_ObjAddFanin( pObj->pCopy, pDriverNew );
}
// transfer the names
Abc_NtkDupNameArrays( pNtk, pNtkNew );
Abc_ManTimeDup( pNtk, pNtkNew );
}
/**Function*************************************************************
Synopsis [Duplicate the Ntk.] Synopsis [Duplicate the Ntk.]
Description [] Description []
...@@ -635,7 +607,58 @@ void Abc_NtkRemovePoNode( Abc_Obj_t * pNode ) ...@@ -635,7 +607,58 @@ void Abc_NtkRemovePoNode( Abc_Obj_t * pNode )
***********************************************************************/ ***********************************************************************/
Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName ) Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName )
{ {
return NULL; Abc_Obj_t * pNode, * pDriver;
int i, Num;
// check if the node is among CIs
Abc_NtkForEachCi( pNtk, pNode, i )
{
if ( strcmp( Abc_NtkNameCi(pNtk,i), pName ) == 0 )
{
if ( i < Abc_NtkPiNum(pNtk) )
printf( "Node \"%s\" is a primary input.\n", pName );
else
printf( "Node \"%s\" is a latch output.\n", pName );
return NULL;
}
}
// search the node among COs
Abc_NtkForEachCo( pNtk, pNode, i )
{
if ( strcmp( Abc_NtkNameCo(pNtk,i), pName ) == 0 )
{
pDriver = Abc_ObjFanin0(pNode);
if ( !Abc_ObjIsNode(pDriver) )
{
printf( "Node \"%s\" does not have logic associated with it.\n", pName );
return NULL;
}
return pDriver;
}
}
// find the internal node
if ( pName[0] != '[' || pName[strlen(pName)-1] != ']' )
{
printf( "Node \"%s\" has non-standard name (expected name is \"[integer]\").\n", pName );
return NULL;
}
Num = atoi( pName + 1 );
if ( Num < 0 || Num > Abc_NtkObjNum(pNtk) )
{
printf( "The node \"%s\" with ID %d is not in the current network.\n", pName, Num );
return NULL;
}
pNode = Abc_NtkObj( pNtk, Num );
if ( pNode == NULL )
{
printf( "The node \"%s\" with ID %d has been removed from the current network.\n", pName, Num );
return NULL;
}
if ( !Abc_ObjIsNode(pNode) )
{
printf( "Object with ID %d is not a node.\n", Num );
return NULL;
}
return pNode;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -997,6 +1020,27 @@ Abc_Obj_t * Abc_NodeCreateMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * ...@@ -997,6 +1020,27 @@ Abc_Obj_t * Abc_NodeCreateMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t *
return pNode; return pNode;
} }
/**Function*************************************************************
Synopsis [Clones the given node but does not assign the function.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Obj_t * Abc_NodeClone( Abc_Obj_t * pNode )
{
Abc_Obj_t * pClone, * pFanin;
int i;
assert( Abc_ObjIsNode(pNode) );
pClone = Abc_NtkCreateNode( pNode->pNtk );
Abc_ObjForEachFanin( pNode, pFanin, i )
Abc_ObjAddFanin( pClone, pFanin );
return pClone;
}
......
...@@ -85,6 +85,32 @@ void Abc_ObjDeleteFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin ) ...@@ -85,6 +85,32 @@ void Abc_ObjDeleteFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin )
} }
} }
/**Function*************************************************************
Synopsis [Destroys fanout/fanin relationship between the nodes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_ObjRemoveFanins( Abc_Obj_t * pObj )
{
Vec_Fan_t * vFaninsOld;
Abc_Obj_t * pFanin;
int k;
// remove old fanins
vFaninsOld = &pObj->vFanins;
for ( k = vFaninsOld->nSize - 1; k >= 0; k-- )
{
pFanin = Abc_NtkObj( pObj->pNtk, vFaninsOld->pArray[k].iFan );
Abc_ObjDeleteFanin( pObj, pFanin );
}
}
/**Function************************************************************* /**Function*************************************************************
Synopsis [Replaces a fanin of the node.] Synopsis [Replaces a fanin of the node.]
......
...@@ -435,7 +435,7 @@ int Abc_NtkFraigStore( Abc_Ntk_t * pNtk ) ...@@ -435,7 +435,7 @@ int Abc_NtkFraigStore( Abc_Ntk_t * pNtk )
if ( pStore == NULL ) if ( pStore == NULL )
{ {
// start the stored network // start the stored network
pStore = Abc_NtkStrash( pNtk ); pStore = Abc_NtkStrash( pNtk, 0 );
if ( pStore == NULL ) if ( pStore == NULL )
{ {
printf( "Abc_NtkFraigStore: Initial strashing has failed.\n" ); printf( "Abc_NtkFraigStore: Initial strashing has failed.\n" );
......
...@@ -166,7 +166,7 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk ) ...@@ -166,7 +166,7 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk )
assert( pNode->pData ); assert( pNode->pData );
bFunc = pNode->pData; bFunc = pNode->pData;
//Extra_bddPrint( dd, bFunc ); printf( "\n" ); printf( "\n" ); //Extra_bddPrint( dd, bFunc ); printf( "\n" ); printf( "\n" );
pNode->pData = Abc_ConvertBddToSop( pNtk->pManFunc, dd, bFunc, Abc_ObjFaninNum(pNode), vCube, -1 ); pNode->pData = Abc_ConvertBddToSop( pNtk->pManFunc, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), vCube, -1 );
if ( pNode->pData == NULL ) if ( pNode->pData == NULL )
return 0; return 0;
Cudd_RecursiveDeref( dd, bFunc ); Cudd_RecursiveDeref( dd, bFunc );
...@@ -193,18 +193,20 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk ) ...@@ -193,18 +193,20 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFunc, int nFanins, Vec_Str_t * vCube, int fMode ) char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFuncOn, DdNode * bFuncOnDc, int nFanins, Vec_Str_t * vCube, int fMode )
{ {
int fVerify = 1;
char * pSop; char * pSop;
DdNode * bFuncNew, * bCover, * zCover, * zCover0, * zCover1; DdNode * bFuncNew, * bCover, * zCover, * zCover0, * zCover1;
int nCubes, nCubes0, nCubes1, fPhase; int nCubes, nCubes0, nCubes1, fPhase;
if ( Cudd_IsConstant(bFunc) ) assert( bFuncOn == bFuncOnDc || Cudd_bddLeq( dd, bFuncOn, bFuncOnDc ) );
if ( Cudd_IsConstant(bFuncOn) || Cudd_IsConstant(bFuncOnDc) )
{ {
Vec_StrFill( vCube, nFanins, '-' ); Vec_StrFill( vCube, nFanins, '-' );
Vec_StrPush( vCube, '\0' ); Vec_StrPush( vCube, '\0' );
pSop = Extra_MmFlexEntryFetch( pMan, nFanins + 4 ); pSop = Extra_MmFlexEntryFetch( pMan, nFanins + 4 );
if ( bFunc == Cudd_ReadLogicZero(dd) ) if ( bFuncOn == Cudd_ReadLogicZero(dd) )
sprintf( pSop, "%s 0\n", vCube->pArray ); sprintf( pSop, "%s 0\n", vCube->pArray );
else else
sprintf( pSop, "%s 1\n", vCube->pArray ); sprintf( pSop, "%s 1\n", vCube->pArray );
...@@ -216,14 +218,14 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun ...@@ -216,14 +218,14 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun
{ // try both phases { // try both phases
// get the ZDD of the negative polarity // get the ZDD of the negative polarity
bCover = Cudd_zddIsop( dd, Cudd_Not(bFunc), Cudd_Not(bFunc), &zCover0 ); bCover = Cudd_zddIsop( dd, Cudd_Not(bFuncOnDc), Cudd_Not(bFuncOn), &zCover0 );
Cudd_Ref( zCover0 ); Cudd_Ref( zCover0 );
Cudd_Ref( bCover ); Cudd_Ref( bCover );
Cudd_RecursiveDeref( dd, bCover ); Cudd_RecursiveDeref( dd, bCover );
nCubes0 = Abc_CountZddCubes( dd, zCover0 ); nCubes0 = Abc_CountZddCubes( dd, zCover0 );
// get the ZDD of the positive polarity // get the ZDD of the positive polarity
bCover = Cudd_zddIsop( dd, bFunc, bFunc, &zCover1 ); bCover = Cudd_zddIsop( dd, bFuncOn, bFuncOnDc, &zCover1 );
Cudd_Ref( zCover1 ); Cudd_Ref( zCover1 );
Cudd_Ref( bCover ); Cudd_Ref( bCover );
Cudd_RecursiveDeref( dd, bCover ); Cudd_RecursiveDeref( dd, bCover );
...@@ -248,7 +250,7 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun ...@@ -248,7 +250,7 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun
else if ( fMode == 0 ) else if ( fMode == 0 )
{ {
// get the ZDD of the positive polarity // get the ZDD of the positive polarity
bCover = Cudd_zddIsop( dd, Cudd_Not(bFunc), Cudd_Not(bFunc), &zCover ); bCover = Cudd_zddIsop( dd, Cudd_Not(bFuncOnDc), Cudd_Not(bFuncOn), &zCover );
Cudd_Ref( zCover ); Cudd_Ref( zCover );
Cudd_Ref( bCover ); Cudd_Ref( bCover );
Cudd_RecursiveDeref( dd, bCover ); Cudd_RecursiveDeref( dd, bCover );
...@@ -258,7 +260,7 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun ...@@ -258,7 +260,7 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun
else if ( fMode == 1 ) else if ( fMode == 1 )
{ {
// get the ZDD of the positive polarity // get the ZDD of the positive polarity
bCover = Cudd_zddIsop( dd, bFunc, bFunc, &zCover ); bCover = Cudd_zddIsop( dd, bFuncOn, bFuncOnDc, &zCover );
Cudd_Ref( zCover ); Cudd_Ref( zCover );
Cudd_Ref( bCover ); Cudd_Ref( bCover );
Cudd_RecursiveDeref( dd, bCover ); Cudd_RecursiveDeref( dd, bCover );
...@@ -271,7 +273,10 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun ...@@ -271,7 +273,10 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun
} }
// allocate memory for the cover // allocate memory for the cover
pSop = Extra_MmFlexEntryFetch( pMan, (nFanins + 3) * nCubes + 1 ); if ( pMan )
pSop = Extra_MmFlexEntryFetch( pMan, (nFanins + 3) * nCubes + 1 );
else
pSop = ALLOC( char, (nFanins + 3) * nCubes + 1 );
pSop[(nFanins + 3) * nCubes] = 0; pSop[(nFanins + 3) * nCubes] = 0;
// create the SOP // create the SOP
Vec_StrFill( vCube, nFanins, '-' ); Vec_StrFill( vCube, nFanins, '-' );
...@@ -280,12 +285,21 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun ...@@ -280,12 +285,21 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun
Cudd_RecursiveDerefZdd( dd, zCover ); Cudd_RecursiveDerefZdd( dd, zCover );
// verify // verify
bFuncNew = Abc_ConvertSopToBdd( dd, pSop, nFanins ); Cudd_Ref( bFuncNew ); if ( fVerify )
//Extra_bddPrint( dd, bFunc ); {
//Extra_bddPrint( dd, bFuncNew ); bFuncNew = Abc_ConvertSopToBdd( dd, pSop, nFanins ); Cudd_Ref( bFuncNew );
if ( bFuncNew != bFunc ) if ( bFuncOn == bFuncOnDc )
printf( "Verification failed.\n" ); {
Cudd_RecursiveDeref( dd, bFuncNew ); if ( bFuncNew != bFuncOn )
printf( "Verification failed.\n" );
}
else
{
if ( !Cudd_bddLeq(dd, bFuncOn, bFuncNew) || !Cudd_bddLeq(dd, bFuncNew, bFuncOnDc) )
printf( "Verification failed.\n" );
}
Cudd_RecursiveDeref( dd, bFuncNew );
}
return pSop; return pSop;
} }
...@@ -359,8 +373,8 @@ int Abc_ConvertZddToSop( DdManager * dd, DdNode * zCover, char * pSop, int nFani ...@@ -359,8 +373,8 @@ 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, char ** ppSop0, char ** ppSop1 ) void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Extra_MmFlex_t * pMmMan, Vec_Str_t * vCube, char ** ppSop0, char ** ppSop1 )
{ {
assert( Abc_NtkIsLogicBdd(pNode->pNtk) ); assert( Abc_NtkIsLogicBdd(pNode->pNtk) );
*ppSop0 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, Abc_ObjFaninNum(pNode), vCube, 0 ); *ppSop0 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, pNode->pData, Abc_ObjFaninNum(pNode), vCube, 0 );
*ppSop1 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, Abc_ObjFaninNum(pNode), vCube, 1 ); *ppSop1 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, pNode->pData, Abc_ObjFaninNum(pNode), vCube, 1 );
} }
......
...@@ -52,6 +52,8 @@ static void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p ); ...@@ -52,6 +52,8 @@ static void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p );
***********************************************************************/ ***********************************************************************/
bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p ) bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
{ {
int fCheck = 1;
assert( Abc_NtkIsLogicBdd(pNtk) || Abc_NtkIsLogicSop(pNtk) ); assert( Abc_NtkIsLogicBdd(pNtk) || Abc_NtkIsLogicSop(pNtk) );
// convert nodes to SOPs // convert nodes to SOPs
if ( Abc_NtkIsLogicBdd(pNtk) ) if ( Abc_NtkIsLogicBdd(pNtk) )
...@@ -70,20 +72,19 @@ bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p ) ...@@ -70,20 +72,19 @@ bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
// sweep removes useless nodes // sweep removes useless nodes
Abc_NtkCleanup( pNtk, 0 ); Abc_NtkCleanup( pNtk, 0 );
// collect information about the covers // collect information about the covers
// make sure all covers are SCC free
// allocate literal array for each cover
Abc_NtkFxuCollectInfo( pNtk, p ); Abc_NtkFxuCollectInfo( pNtk, p );
// call the fast extract procedure // call the fast extract procedure
// returns the number of divisor extracted
if ( Fxu_FastExtract(p) > 0 ) if ( Fxu_FastExtract(p) > 0 )
{ {
// update the network // update the network
Abc_NtkFxuReconstruct( pNtk, p ); Abc_NtkFxuReconstruct( pNtk, p );
// make sure everything is okay // make sure everything is okay
if ( !Abc_NtkCheck( pNtk ) ) if ( fCheck && !Abc_NtkCheck( pNtk ) )
printf( "Abc_NtkFastExtract: The network check has failed.\n" ); printf( "Abc_NtkFastExtract: The network check has failed.\n" );
return 1; return 1;
} }
else
printf( "Warning: The network has not been changed by \"fx\".\n" );
return 0; return 0;
} }
...@@ -199,7 +200,6 @@ void Abc_NtkFxuFreeInfo( Fxu_Data_t * p ) ...@@ -199,7 +200,6 @@ void Abc_NtkFxuFreeInfo( Fxu_Data_t * p )
***********************************************************************/ ***********************************************************************/
void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p ) void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
{ {
Vec_Fan_t * vFaninsOld;
Vec_Int_t * vFanins; Vec_Int_t * vFanins;
Abc_Obj_t * pNode, * pFanin; Abc_Obj_t * pNode, * pFanin;
int i, k; int i, k;
...@@ -221,12 +221,7 @@ void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p ) ...@@ -221,12 +221,7 @@ void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
continue; continue;
// remove old fanins // remove old fanins
pNode = Abc_NtkObj( pNtk, i ); pNode = Abc_NtkObj( pNtk, i );
vFaninsOld = &pNode->vFanins; Abc_ObjRemoveFanins( pNode );
for ( k = vFaninsOld->nSize - 1; k >= 0; k-- )
{
pFanin = Abc_NtkObj( pNtk, vFaninsOld->pArray[k].iFan );
Abc_ObjDeleteFanin( pNode, pFanin );
}
// add new fanins // add new fanins
vFanins = p->vFaninsNew->pArray[i]; vFanins = p->vFaninsNew->pArray[i];
for ( k = 0; k < vFanins->nSize; k++ ) for ( k = 0; k < vFanins->nSize; k++ )
......
...@@ -353,7 +353,7 @@ Abc_Obj_t * Abc_NodeFromMapSuper_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap ...@@ -353,7 +353,7 @@ Abc_Obj_t * Abc_NodeFromMapSuper_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap
} }
else else
{ {
assert( 0 ); // assert( 0 );
/* It might happen that a super gate with 5 inputs is constructed that /* It might happen that a super gate with 5 inputs is constructed that
* actually depends only on the first four variables; i.e the fifth is a * actually depends only on the first four variables; i.e the fifth is a
* don't care -- in that case we connect constant node for the fifth * don't care -- in that case we connect constant node for the fifth
......
...@@ -51,8 +51,8 @@ Abc_Ntk_t * Abc_NtkMiter( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ) ...@@ -51,8 +51,8 @@ Abc_Ntk_t * Abc_NtkMiter( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
Abc_Ntk_t * pTemp = NULL; Abc_Ntk_t * pTemp = NULL;
int fRemove1, fRemove2; int fRemove1, fRemove2;
// make sure the circuits are strashed // make sure the circuits are strashed
fRemove1 = (!Abc_NtkIsAig(pNtk1)) && (pNtk1 = Abc_NtkStrash(pNtk1)); fRemove1 = (!Abc_NtkIsAig(pNtk1)) && (pNtk1 = Abc_NtkStrash(pNtk1, 0));
fRemove2 = (!Abc_NtkIsAig(pNtk2)) && (pNtk2 = Abc_NtkStrash(pNtk2)); fRemove2 = (!Abc_NtkIsAig(pNtk2)) && (pNtk2 = Abc_NtkStrash(pNtk2, 0));
if ( pNtk1 && pNtk2 ) if ( pNtk1 && pNtk2 )
{ {
// check that the networks have the same PIs/POs/latches // check that the networks have the same PIs/POs/latches
......
...@@ -52,7 +52,10 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -52,7 +52,10 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk )
fprintf( pFile, " nd = %5d", Abc_NtkNodeNum(pNtk) ); fprintf( pFile, " nd = %5d", Abc_NtkNodeNum(pNtk) );
} }
else if ( Abc_NtkIsAig(pNtk) ) else if ( Abc_NtkIsAig(pNtk) )
{
fprintf( pFile, " and = %5d", Abc_NtkNodeNum(pNtk) ); fprintf( pFile, " and = %5d", Abc_NtkNodeNum(pNtk) );
fprintf( pFile, " choice = %5d", Abc_NtkCountChoiceNodes(pNtk) );
}
else else
fprintf( pFile, " nd = %5d", Abc_NtkNodeNum(pNtk) ); fprintf( pFile, " nd = %5d", Abc_NtkNodeNum(pNtk) );
...@@ -86,19 +89,19 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -86,19 +89,19 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk )
***********************************************************************/ ***********************************************************************/
void Abc_NtkPrintIo( FILE * pFile, Abc_Ntk_t * pNtk ) void Abc_NtkPrintIo( FILE * pFile, Abc_Ntk_t * pNtk )
{ {
Abc_Obj_t * pNet, * pLatch; Abc_Obj_t * pObj, * pLatch;
int i; int i;
if ( Abc_NtkIsNetlist(pNtk) ) if ( Abc_NtkIsNetlist(pNtk) )
{ {
fprintf( pFile, "Primary inputs (%d): ", Abc_NtkPiNum(pNtk) ); fprintf( pFile, "Primary inputs (%d): ", Abc_NtkPiNum(pNtk) );
Abc_NtkForEachPi( pNtk, pNet, i ) Abc_NtkForEachPi( pNtk, pObj, i )
fprintf( pFile, " %s", Abc_ObjName(pNet) ); fprintf( pFile, " %s", Abc_ObjName(pObj) );
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
fprintf( pFile, "Primary outputs (%d):", Abc_NtkPoNum(pNtk) ); fprintf( pFile, "Primary outputs (%d):", Abc_NtkPoNum(pNtk) );
Abc_NtkForEachPo( pNtk, pNet, i ) Abc_NtkForEachPo( pNtk, pObj, i )
fprintf( pFile, " %s", Abc_ObjName(pNet) ); fprintf( pFile, " %s", Abc_ObjName(pObj) );
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
fprintf( pFile, "Latches (%d): ", Abc_NtkLatchNum(pNtk) ); fprintf( pFile, "Latches (%d): ", Abc_NtkLatchNum(pNtk) );
...@@ -109,12 +112,12 @@ void Abc_NtkPrintIo( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -109,12 +112,12 @@ void Abc_NtkPrintIo( FILE * pFile, Abc_Ntk_t * pNtk )
else else
{ {
fprintf( pFile, "Primary inputs (%d): ", Abc_NtkPiNum(pNtk) ); fprintf( pFile, "Primary inputs (%d): ", Abc_NtkPiNum(pNtk) );
Abc_NtkForEachPi( pNtk, pNet, i ) Abc_NtkForEachPi( pNtk, pObj, i )
fprintf( pFile, " %s", pNtk->vNamesPi->pArray[i] ); fprintf( pFile, " %s", pNtk->vNamesPi->pArray[i] );
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
fprintf( pFile, "Primary outputs (%d):", Abc_NtkPoNum(pNtk) ); fprintf( pFile, "Primary outputs (%d):", Abc_NtkPoNum(pNtk) );
Abc_NtkForEachPo( pNtk, pNet, i ) Abc_NtkForEachPo( pNtk, pObj, i )
fprintf( pFile, " %s", pNtk->vNamesPo->pArray[i] ); fprintf( pFile, " %s", pNtk->vNamesPo->pArray[i] );
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
...@@ -280,7 +283,6 @@ void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode ) ...@@ -280,7 +283,6 @@ void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode )
Vec_IntFree( vFactor ); Vec_IntFree( vFactor );
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
/**CFile****************************************************************
FileName [abcShow.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Network and node package.]
Synopsis [Visualization procedures using DOT software and GSView.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: abcShow.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abc.h"
#ifdef WIN32
#include "process.h"
#endif
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Prints the factored form of one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NodePrintBdd( Abc_Obj_t * pNode )
{
FILE * pFile;
Vec_Ptr_t * vNamesIn;
char * FileNameIn;
char * FileNameOut;
char * FileGeneric;
char * pCur, * pNameOut;
char FileNameDot[200];
char FileNamePs[200];
char CommandDot[1000];
#ifndef WIN32
char CommandPs[1000];
#endif
char * pProgDotName;
char * pProgGsViewName;
int RetValue;
assert( Abc_NtkIsLogicBdd(pNode->pNtk) );
#ifdef WIN32
pProgDotName = "dot.exe";
pProgGsViewName = NULL;
#else
pProgDotName = "dot";
pProgGsViewName = "gv";
#endif
FileNameIn = NULL;
FileNameOut = NULL;
// get the generic file name
pNode->pCopy = NULL;
FileGeneric = Abc_ObjName(pNode);
// get rid of not-alpha-numeric characters
for ( pCur = FileGeneric; *pCur; pCur++ )
if ( !((*pCur >= '0' && *pCur <= '9') || (*pCur >= 'a' && *pCur <= 'z') || (*pCur >= 'A' && *pCur <= 'Z')) )
*pCur = '_';
// create the file names
sprintf( FileNameDot, "%s.dot", FileGeneric );
sprintf( FileNamePs, "%s.ps", FileGeneric );
// write the DOT file
if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
{
fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
return;
}
// set the node names
Abc_NtkLogicTransferNames( pNode->pNtk );
vNamesIn = Abc_NodeGetFaninNames( pNode );
pNameOut = Abc_ObjName(pNode);
Cudd_DumpDot( pNode->pNtk->pManFunc, 1, (DdNode **)&pNode->pData, (char **)vNamesIn->pArray, &pNameOut, pFile );
Abc_NodeFreeFaninNames( vNamesIn );
Abc_NtkCleanCopy( pNode->pNtk );
fclose( pFile );
// check that the input file is okay
if ( (pFile = fopen( FileNameDot, "r" )) == NULL )
{
fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
return;
}
fclose( pFile );
// generate the DOT file
sprintf( CommandDot, "%s -Tps -o %s %s", pProgDotName, FileNamePs, FileNameDot );
RetValue = system( CommandDot );
#ifdef WIN32
_unlink( FileNameDot );
#else
unlink( FileNameDot );
#endif
if ( RetValue == -1 )
{
fprintf( stdout, "Cannot find \"%s\".\n", pProgDotName );
return;
}
// check that the input file is okay
if ( (pFile = fopen( FileNamePs, "r" )) == NULL )
{
fprintf( stdout, "Cannot open intermediate file \"%s\".\n", FileNamePs );
return;
}
fclose( pFile );
#ifdef WIN32
if ( _spawnl( _P_NOWAIT, "gsview32.exe", "gsview32.exe", FileNamePs, NULL ) == -1 )
if ( _spawnl( _P_NOWAIT, "C:\\Program Files\\Ghostgum\\gsview\\gsview32.exe",
"C:\\Program Files\\Ghostgum\\gsview\\gsview32.exe", FileNamePs, NULL ) == -1 )
{
fprintf( stdout, "Cannot find \"%s\".\n", "gsview32.exe" );
return;
}
#else
sprintf( CommandPs, "%s %s &", pProgGsViewName, FileNamePs );
if ( system( CommandPs ) == -1 )
{
fprintf( stdout, "Cannot execute \"%s\".\n", FileNamePs );
return;
}
#endif
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// static functions // static functions
static void Abc_NtkStrashPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkAig ); static void Abc_NtkStrashPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkAig, bool fAllNodes );
static Abc_Obj_t * Abc_NodeStrash( Abc_Aig_t * pMan, Abc_Obj_t * pNode ); static Abc_Obj_t * Abc_NodeStrash( Abc_Aig_t * pMan, Abc_Obj_t * pNode );
static Abc_Obj_t * Abc_NodeStrashSop( Abc_Aig_t * pMan, Abc_Obj_t * pNode, char * pSop ); static Abc_Obj_t * Abc_NodeStrashSop( Abc_Aig_t * pMan, Abc_Obj_t * pNode, char * pSop );
static Abc_Obj_t * Abc_NodeStrashFactor( Abc_Aig_t * pMan, Abc_Obj_t * pNode, char * pSop ); static Abc_Obj_t * Abc_NodeStrashFactor( Abc_Aig_t * pMan, Abc_Obj_t * pNode, char * pSop );
...@@ -53,7 +53,7 @@ extern char * Mio_GateReadSop( void * pGate ); ...@@ -53,7 +53,7 @@ extern char * Mio_GateReadSop( void * pGate );
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk ) Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes )
{ {
int fCheck = 1; int fCheck = 1;
Abc_Ntk_t * pNtkAig; Abc_Ntk_t * pNtkAig;
...@@ -68,14 +68,14 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk ) ...@@ -68,14 +68,14 @@ Abc_Ntk_t * Abc_NtkStrash( 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" );
// perform strashing // perform strashing
pNtkAig = Abc_NtkStartFrom( pNtk, ABC_NTK_AIG ); pNtkAig = Abc_NtkStartFrom( pNtk, ABC_NTK_AIG );
Abc_NtkStrashPerform( pNtk, pNtkAig ); Abc_NtkStrashPerform( pNtk, pNtkAig, fAllNodes );
Abc_NtkFinalize( pNtk, pNtkAig ); Abc_NtkFinalize( pNtk, pNtkAig );
// print warning about self-feed latches // print warning about self-feed latches
if ( Abc_NtkCountSelfFeedLatches(pNtkAig) ) if ( Abc_NtkCountSelfFeedLatches(pNtkAig) )
printf( "The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtkAig) ); printf( "The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtkAig) );
// duplicate EXDC // duplicate EXDC
if ( pNtk->pExdc ) if ( pNtk->pExdc )
pNtkAig->pExdc = Abc_NtkStrash( pNtk->pExdc ); pNtkAig->pExdc = Abc_NtkStrash( pNtk->pExdc, 0 );
// make sure everything is okay // make sure everything is okay
if ( fCheck && !Abc_NtkCheck( pNtkAig ) ) if ( fCheck && !Abc_NtkCheck( pNtkAig ) )
{ {
...@@ -97,7 +97,7 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk ) ...@@ -97,7 +97,7 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_NtkStrashPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew ) void Abc_NtkStrashPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, bool fAllNodes )
{ {
ProgressBar * pProgress; ProgressBar * pProgress;
Abc_Aig_t * pMan = pNtkNew->pManFunc; Abc_Aig_t * pMan = pNtkNew->pManFunc;
...@@ -106,8 +106,10 @@ void Abc_NtkStrashPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew ) ...@@ -106,8 +106,10 @@ void Abc_NtkStrashPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
int i; int i;
// perform strashing // perform strashing
vNodes = Abc_NtkDfs( pNtk ); if ( fAllNodes )
// vNodes = Abc_AigCollectAll( pNtk ); vNodes = Abc_AigCollectAll( pNtk );
else
vNodes = Abc_NtkDfs( pNtk );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize ); pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
for ( i = 0; i < vNodes->nSize; i++ ) for ( i = 0; i < vNodes->nSize; i++ )
{ {
...@@ -255,7 +257,7 @@ Abc_Obj_t * Abc_NodeStrashFactor( Abc_Aig_t * pMan, Abc_Obj_t * pRoot, char * pS ...@@ -255,7 +257,7 @@ Abc_Obj_t * Abc_NodeStrashFactor( Abc_Aig_t * pMan, Abc_Obj_t * pRoot, char * pS
assert( vForm->nSize > nVars ); assert( vForm->nSize > nVars );
assert( nVars == Abc_ObjFaninNum(pRoot) ); assert( nVars == Abc_ObjFaninNum(pRoot) );
// check for constant Andtion // check for constant function
pFtNode = Ft_NodeRead( vForm, 0 ); pFtNode = Ft_NodeRead( vForm, 0 );
if ( pFtNode->fConst ) if ( pFtNode->fConst )
{ {
...@@ -268,7 +270,7 @@ Abc_Obj_t * Abc_NodeStrashFactor( Abc_Aig_t * pMan, Abc_Obj_t * pRoot, char * pS ...@@ -268,7 +270,7 @@ Abc_Obj_t * Abc_NodeStrashFactor( Abc_Aig_t * pMan, Abc_Obj_t * pRoot, char * pS
Abc_ObjForEachFanin( pRoot, pFanin, i ) Abc_ObjForEachFanin( pRoot, pFanin, i )
Vec_PtrPush( vAnds, pFanin->pCopy ); Vec_PtrPush( vAnds, pFanin->pCopy );
// compute the Andtions of other nodes // compute the function of other nodes
for ( i = nVars; i < vForm->nSize; i++ ) for ( i = nVars; i < vForm->nSize; i++ )
{ {
pFtNode = Ft_NodeRead( vForm, i ); pFtNode = Ft_NodeRead( vForm, i );
...@@ -322,7 +324,7 @@ int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) ...@@ -322,7 +324,7 @@ int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
Abc_NtkForEachCi( pNtk2, pObj, i ) Abc_NtkForEachCi( pNtk2, pObj, i )
pObj->pCopy = Abc_NtkCi(pNtk1, i); pObj->pCopy = Abc_NtkCi(pNtk1, i);
// add pNtk2 to pNtk1 while strashing // add pNtk2 to pNtk1 while strashing
Abc_NtkStrashPerform( pNtk2, pNtk1 ); Abc_NtkStrashPerform( pNtk2, pNtk1, 1 );
// make sure that everything is okay // make sure that everything is okay
if ( fCheck && !Abc_NtkCheck( pNtk1 ) ) if ( fCheck && !Abc_NtkCheck( pNtk1 ) )
{ {
......
...@@ -61,7 +61,7 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fVerbose ) ...@@ -61,7 +61,7 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fVerbose )
assert( !Abc_NtkIsAig(pNtk) ); assert( !Abc_NtkIsAig(pNtk) );
// derive the AIG // derive the AIG
pNtkAig = Abc_NtkStrash( pNtk ); pNtkAig = Abc_NtkStrash( pNtk, 0 );
// perform fraiging of the AIG // perform fraiging of the AIG
Fraig_ParamsSetDefault( &Params ); Fraig_ParamsSetDefault( &Params );
pMan = Abc_NtkToFraig( pNtkAig, &Params, 0 ); pMan = Abc_NtkToFraig( pNtkAig, &Params, 0 );
......
...@@ -228,7 +228,7 @@ void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall ...@@ -228,7 +228,7 @@ void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_NtkTimeFinalize( Abc_Ntk_t * pNtk ) void Abc_NtkTimeInitialize( Abc_Ntk_t * pNtk )
{ {
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
Abc_Time_t ** ppTimes, * pTime; Abc_Time_t ** ppTimes, * pTime;
...@@ -283,11 +283,12 @@ void Abc_NtkTimePrepare( Abc_Ntk_t * pNtk ) ...@@ -283,11 +283,12 @@ void Abc_NtkTimePrepare( Abc_Ntk_t * pNtk )
if ( pNtk->pManTime == NULL ) if ( pNtk->pManTime == NULL )
{ {
pNtk->pManTime = Abc_ManTimeStart(); pNtk->pManTime = Abc_ManTimeStart();
Abc_NtkTimeFinalize( pNtk ); Abc_NtkTimeInitialize( pNtk );
return; return;
} }
// if timing manager is given, clean arrivals except for PIs // if timing manager is given, expand it if necessary
// and required except for POs Abc_ManTimeExpand( pNtk->pManTime, Abc_NtkObjNum(pNtk), 0 );
// clean arrivals except for PIs
ppTimes = (Abc_Time_t **)pNtk->pManTime->vArrs->pArray; ppTimes = (Abc_Time_t **)pNtk->pManTime->vArrs->pArray;
Abc_NtkForEachNode( pNtk, pObj, i ) Abc_NtkForEachNode( pNtk, pObj, i )
{ {
...@@ -299,6 +300,7 @@ void Abc_NtkTimePrepare( Abc_Ntk_t * pNtk ) ...@@ -299,6 +300,7 @@ void Abc_NtkTimePrepare( Abc_Ntk_t * pNtk )
pTime = ppTimes[pObj->Id]; pTime = ppTimes[pObj->Id];
pTime->Fall = pTime->Rise = pTime->Worst = -ABC_INFINITY; pTime->Fall = pTime->Rise = pTime->Worst = -ABC_INFINITY;
} }
// clean required except for POs
} }
...@@ -392,7 +394,7 @@ void Abc_ManTimeDup( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew ) ...@@ -392,7 +394,7 @@ void Abc_ManTimeDup( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew )
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis [Expends the storage for timing information.]
Description [] Description []
......
...@@ -777,6 +777,47 @@ Vec_Ptr_t * Abc_AigCollectAll( Abc_Ntk_t * pNtk ) ...@@ -777,6 +777,47 @@ Vec_Ptr_t * Abc_AigCollectAll( Abc_Ntk_t * pNtk )
return vNodes; return vNodes;
} }
/**Function*************************************************************
Synopsis [Gets fanin node names.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Abc_NodeGetFaninNames( Abc_Obj_t * pNode )
{
Vec_Ptr_t * vNodes;
Abc_Obj_t * pFanin;
int i;
vNodes = Vec_PtrAlloc( 100 );
Abc_ObjForEachFanin( pNode, pFanin, i )
Vec_PtrPush( vNodes, util_strsav(Abc_ObjName(pFanin)) );
return vNodes;
}
/**Function*************************************************************
Synopsis [Gets fanin node names.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NodeFreeFaninNames( Vec_Ptr_t * vNames )
{
int i;
for ( i = 0; i < vNames->nSize; i++ )
free( vNames->pArray[i] );
Vec_PtrFree( vNames );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -10,6 +10,7 @@ SRC += src/base/abc/abc.c \ ...@@ -10,6 +10,7 @@ SRC += src/base/abc/abc.c \
src/base/abc/abcFpga.c \ src/base/abc/abcFpga.c \
src/base/abc/abcFraig.c \ src/base/abc/abcFraig.c \
src/base/abc/abcFunc.c \ src/base/abc/abcFunc.c \
src/base/abc/abcFxu.c \
src/base/abc/abcLatch.c \ src/base/abc/abcLatch.c \
src/base/abc/abcMap.c \ src/base/abc/abcMap.c \
src/base/abc/abcMinBase.c \ src/base/abc/abcMinBase.c \
...@@ -19,10 +20,13 @@ SRC += src/base/abc/abc.c \ ...@@ -19,10 +20,13 @@ SRC += src/base/abc/abc.c \
src/base/abc/abcPrint.c \ src/base/abc/abcPrint.c \
src/base/abc/abcRefs.c \ src/base/abc/abcRefs.c \
src/base/abc/abcRenode.c \ src/base/abc/abcRenode.c \
src/base/abc/abcRes.c \
src/base/abc/abcSat.c \ src/base/abc/abcSat.c \
src/base/abc/abcShow.c \
src/base/abc/abcSop.c \ src/base/abc/abcSop.c \
src/base/abc/abcStrash.c \ src/base/abc/abcStrash.c \
src/base/abc/abcSweep.c \ src/base/abc/abcSweep.c \
src/base/abc/abcTiming.c \ src/base/abc/abcTiming.c \
src/base/abc/abcUnreach.c \
src/base/abc/abcUtil.c \ src/base/abc/abcUtil.c \
src/base/abc/abcVerify.c src/base/abc/abcVerify.c
...@@ -88,7 +88,7 @@ Abc_Ntk_t * Io_ReadBlif( char * pFileName, int fCheck ) ...@@ -88,7 +88,7 @@ Abc_Ntk_t * Io_ReadBlif( char * pFileName, int fCheck )
Io_ReadBlifFree( p ); Io_ReadBlifFree( p );
return NULL; return NULL;
} }
Abc_NtkTimeFinalize( pNtk ); Abc_NtkTimeInitialize( pNtk );
// read the EXDC network // read the EXDC network
if ( p->fParsingExdc ) if ( p->fParsingExdc )
......
...@@ -84,6 +84,7 @@ extern void Abc_FrameRestart( Abc_Frame_t * p ); ...@@ -84,6 +84,7 @@ extern void Abc_FrameRestart( Abc_Frame_t * p );
extern void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNet ); extern void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNet );
extern void Abc_FrameSwapCurrentAndBackup( Abc_Frame_t * p ); extern void Abc_FrameSwapCurrentAndBackup( Abc_Frame_t * p );
extern void Abc_FrameReplaceCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNet ); extern void Abc_FrameReplaceCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNet );
extern void Abc_FrameUnmapAllNetworks( Abc_Frame_t * p );
extern void Abc_FrameDeleteAllNetworks( Abc_Frame_t * p ); extern void Abc_FrameDeleteAllNetworks( Abc_Frame_t * p );
extern void Abc_FrameSetGlobalFrame( Abc_Frame_t * p ); extern void Abc_FrameSetGlobalFrame( Abc_Frame_t * p );
......
...@@ -205,19 +205,19 @@ bool Abc_FrameSetMode( Abc_Frame_t * p, bool fNameMode ) ...@@ -205,19 +205,19 @@ bool Abc_FrameSetMode( Abc_Frame_t * p, bool fNameMode )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNetNew ) void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNtkNew )
{ {
Abc_Ntk_t * pNet, * pNet2, * pNet3; Abc_Ntk_t * pNtk, * pNtk2, * pNtk3;
int nNetsPresent; int nNetsPresent;
int nNetsToSave; int nNetsToSave;
char * pValue; char * pValue;
// link it to the previous network // link it to the previous network
Abc_NtkSetBackup( pNetNew, p->pNtkCur ); Abc_NtkSetBackup( pNtkNew, p->pNtkCur );
// set the step of this network // set the step of this network
Abc_NtkSetStep( pNetNew, ++p->nSteps ); Abc_NtkSetStep( pNtkNew, ++p->nSteps );
// set this network to be the current network // set this network to be the current network
p->pNtkCur = pNetNew; p->pNtkCur = pNtkNew;
// remove any extra network that may happen to be in the stack // remove any extra network that may happen to be in the stack
pValue = Cmd_FlagReadByName( p, "savesteps" ); pValue = Cmd_FlagReadByName( p, "savesteps" );
...@@ -229,20 +229,20 @@ void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNetNew ) ...@@ -229,20 +229,20 @@ void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNetNew )
// count the network, remember the last one, and the one before the last one // count the network, remember the last one, and the one before the last one
nNetsPresent = 0; nNetsPresent = 0;
pNet2 = pNet3 = NULL; pNtk2 = pNtk3 = NULL;
for ( pNet = p->pNtkCur; pNet; pNet = Abc_NtkBackup(pNet2) ) for ( pNtk = p->pNtkCur; pNtk; pNtk = Abc_NtkBackup(pNtk2) )
{ {
nNetsPresent++; nNetsPresent++;
pNet3 = pNet2; pNtk3 = pNtk2;
pNet2 = pNet; pNtk2 = pNtk;
} }
// remove the earliest backup network if it is more steps away than we store // remove the earliest backup network if it is more steps away than we store
if ( nNetsPresent - 1 > nNetsToSave ) if ( nNetsPresent - 1 > nNetsToSave )
{ // delete the last network { // delete the last network
Abc_NtkDelete( pNet2 ); Abc_NtkDelete( pNtk2 );
// clean the pointer of the network before the last one // clean the pointer of the network before the last one
Abc_NtkSetBackup( pNet3, NULL ); Abc_NtkSetBackup( pNtk3, NULL );
} }
} }
...@@ -259,31 +259,31 @@ void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNetNew ) ...@@ -259,31 +259,31 @@ void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNetNew )
***********************************************************************/ ***********************************************************************/
void Abc_FrameSwapCurrentAndBackup( Abc_Frame_t * p ) void Abc_FrameSwapCurrentAndBackup( Abc_Frame_t * p )
{ {
Abc_Ntk_t * pNtkCur, * pNetBack, * pNetBack2; Abc_Ntk_t * pNtkCur, * pNtkBack, * pNtkBack2;
int iStepCur, iStepBack; int iStepCur, iStepBack;
pNtkCur = p->pNtkCur; pNtkCur = p->pNtkCur;
pNetBack = Abc_NtkBackup( pNtkCur ); pNtkBack = Abc_NtkBackup( pNtkCur );
iStepCur = Abc_NtkStep ( pNtkCur ); iStepCur = Abc_NtkStep ( pNtkCur );
// if there is no backup nothing to reset // if there is no backup nothing to reset
if ( pNetBack == NULL ) if ( pNtkBack == NULL )
return; return;
// remember the backup of the backup // remember the backup of the backup
pNetBack2 = Abc_NtkBackup( pNetBack ); pNtkBack2 = Abc_NtkBackup( pNtkBack );
iStepBack = Abc_NtkStep ( pNetBack ); iStepBack = Abc_NtkStep ( pNtkBack );
// set pNtkCur to be the next after the backup's backup // set pNtkCur to be the next after the backup's backup
Abc_NtkSetBackup( pNtkCur, pNetBack2 ); Abc_NtkSetBackup( pNtkCur, pNtkBack2 );
Abc_NtkSetStep ( pNtkCur, iStepBack ); Abc_NtkSetStep ( pNtkCur, iStepBack );
// set pNtkCur to be the next after the backup // set pNtkCur to be the next after the backup
Abc_NtkSetBackup( pNetBack, pNtkCur ); Abc_NtkSetBackup( pNtkBack, pNtkCur );
Abc_NtkSetStep ( pNetBack, iStepCur ); Abc_NtkSetStep ( pNtkBack, iStepCur );
// set the current network // set the current network
p->pNtkCur = pNetBack; p->pNtkCur = pNtkBack;
} }
...@@ -299,26 +299,45 @@ void Abc_FrameSwapCurrentAndBackup( Abc_Frame_t * p ) ...@@ -299,26 +299,45 @@ void Abc_FrameSwapCurrentAndBackup( Abc_Frame_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_FrameReplaceCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNet ) void Abc_FrameReplaceCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNtk )
{ {
if ( pNet == NULL ) if ( pNtk == NULL )
return; return;
// transfer the parameters to the new network // transfer the parameters to the new network
if ( p->pNtkCur ) if ( p->pNtkCur )
{ {
Abc_NtkSetBackup( pNet, Abc_NtkBackup(p->pNtkCur) ); Abc_NtkSetBackup( pNtk, Abc_NtkBackup(p->pNtkCur) );
Abc_NtkSetStep( pNet, Abc_NtkStep(p->pNtkCur) ); Abc_NtkSetStep( pNtk, Abc_NtkStep(p->pNtkCur) );
// delete the current network // delete the current network
Abc_NtkDelete( p->pNtkCur ); Abc_NtkDelete( p->pNtkCur );
} }
else else
{ {
Abc_NtkSetBackup( pNet, NULL ); Abc_NtkSetBackup( pNtk, NULL );
Abc_NtkSetStep( pNet, ++p->nSteps ); Abc_NtkSetStep( pNtk, ++p->nSteps );
} }
// set the new current network // set the new current network
p->pNtkCur = pNet; p->pNtkCur = pNtk;
}
/**Function*************************************************************
Synopsis [Removes library binding of all currently stored networks.]
Description [This procedure is called when the library is freed.]
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_FrameUnmapAllNetworks( Abc_Frame_t * p )
{
Abc_Ntk_t * pNtk;
for ( pNtk = p->pNtkCur; pNtk; pNtk = Abc_NtkBackup(pNtk) )
if ( Abc_NtkIsLogicMap(pNtk) )
Abc_NtkUnmap( pNtk );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -334,14 +353,14 @@ void Abc_FrameReplaceCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNet ) ...@@ -334,14 +353,14 @@ void Abc_FrameReplaceCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNet )
***********************************************************************/ ***********************************************************************/
void Abc_FrameDeleteAllNetworks( Abc_Frame_t * p ) void Abc_FrameDeleteAllNetworks( Abc_Frame_t * p )
{ {
Abc_Ntk_t * pNet, * pNet2; Abc_Ntk_t * pNtk, * pNtk2;
// delete all the currently saved networks // delete all the currently saved networks
for ( pNet = p->pNtkCur, for ( pNtk = p->pNtkCur,
pNet2 = pNet? Abc_NtkBackup(pNet): NULL; pNtk2 = pNtk? Abc_NtkBackup(pNtk): NULL;
pNet; pNtk;
pNet = pNet2, pNtk = pNtk2,
pNet2 = pNet? Abc_NtkBackup(pNet): NULL ) pNtk2 = pNtk? Abc_NtkBackup(pNtk): NULL )
Abc_NtkDelete( pNet ); Abc_NtkDelete( pNtk );
// set the current network empty // set the current network empty
p->pNtkCur = NULL; p->pNtkCur = NULL;
fprintf( p->Out, "All networks have been deleted.\n" ); fprintf( p->Out, "All networks have been deleted.\n" );
......
...@@ -88,6 +88,7 @@ extern Dsd_Node_t * Dsd_NodeReadDec ( Dsd_Node_t * p, int i ); ...@@ -88,6 +88,7 @@ extern Dsd_Node_t * Dsd_NodeReadDec ( Dsd_Node_t * p, int i );
extern int Dsd_NodeReadDecsNum( Dsd_Node_t * p ); extern int Dsd_NodeReadDecsNum( Dsd_Node_t * p );
extern int Dsd_NodeReadMark( Dsd_Node_t * p ); extern int Dsd_NodeReadMark( Dsd_Node_t * p );
extern void Dsd_NodeSetMark( Dsd_Node_t * p, int Mark ); extern void Dsd_NodeSetMark( Dsd_Node_t * p, int Mark );
extern DdManager * Dsd_ManagerReadDd( Dsd_Manager_t * pMan );
extern Dsd_Node_t * Dsd_ManagerReadRoot( Dsd_Manager_t * pMan, int i ); extern Dsd_Node_t * Dsd_ManagerReadRoot( Dsd_Manager_t * pMan, int i );
extern Dsd_Node_t * Dsd_ManagerReadInput( Dsd_Manager_t * pMan, int i ); extern Dsd_Node_t * Dsd_ManagerReadInput( Dsd_Manager_t * pMan, int i );
/*=== dsdMan.c =======================================================*/ /*=== dsdMan.c =======================================================*/
...@@ -95,6 +96,7 @@ extern Dsd_Manager_t * Dsd_ManagerStart( DdManager * dd, int nSuppMax, int fVerb ...@@ -95,6 +96,7 @@ extern Dsd_Manager_t * Dsd_ManagerStart( DdManager * dd, int nSuppMax, int fVerb
extern void Dsd_ManagerStop( Dsd_Manager_t * dMan ); extern void Dsd_ManagerStop( Dsd_Manager_t * dMan );
/*=== dsdProc.c =======================================================*/ /*=== dsdProc.c =======================================================*/
extern void Dsd_Decompose( Dsd_Manager_t * dMan, DdNode ** pbFuncs, int nFuncs ); extern void Dsd_Decompose( Dsd_Manager_t * dMan, DdNode ** pbFuncs, int nFuncs );
extern Dsd_Node_t * Dsd_DecomposeOne( Dsd_Manager_t * pDsdMan, DdNode * bFunc );
/*=== dsdTree.c =======================================================*/ /*=== dsdTree.c =======================================================*/
extern void Dsd_TreeNodeGetInfo( Dsd_Manager_t * dMan, int * DepthMax, int * GateSizeMax ); extern void Dsd_TreeNodeGetInfo( Dsd_Manager_t * dMan, int * DepthMax, int * GateSizeMax );
extern void Dsd_TreeNodeGetInfoOne( Dsd_Node_t * pNode, int * DepthMax, int * GateSizeMax ); extern void Dsd_TreeNodeGetInfoOne( Dsd_Node_t * pNode, int * DepthMax, int * GateSizeMax );
...@@ -104,6 +106,7 @@ extern int Dsd_TreeCountPrimeNodes( Dsd_Manager_t * pDsdMan ); ...@@ -104,6 +106,7 @@ extern int Dsd_TreeCountPrimeNodes( Dsd_Manager_t * pDsdMan );
extern int Dsd_TreeCountPrimeNodesOne( Dsd_Node_t * pRoot ); extern int Dsd_TreeCountPrimeNodesOne( Dsd_Node_t * pRoot );
extern int Dsd_TreeCollectDecomposableVars( Dsd_Manager_t * dMan, int * pVars ); extern int Dsd_TreeCollectDecomposableVars( Dsd_Manager_t * dMan, int * pVars );
extern Dsd_Node_t ** Dsd_TreeCollectNodesDfs( Dsd_Manager_t * dMan, int * pnNodes ); extern Dsd_Node_t ** Dsd_TreeCollectNodesDfs( Dsd_Manager_t * dMan, int * pnNodes );
extern Dsd_Node_t ** Dsd_TreeCollectNodesDfsOne( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pNode, int * pnNodes );
extern void Dsd_TreePrint( FILE * pFile, Dsd_Manager_t * dMan, char * pInputNames[], char * pOutputNames[], int fShortNames, int Output ); extern void Dsd_TreePrint( FILE * pFile, Dsd_Manager_t * dMan, char * pInputNames[], char * pOutputNames[], int fShortNames, int Output );
/*=== dsdLocal.c =======================================================*/ /*=== dsdLocal.c =======================================================*/
extern DdNode * Dsd_TreeGetPrimeFunction( DdManager * dd, Dsd_Node_t * pNode ); extern DdNode * Dsd_TreeGetPrimeFunction( DdManager * dd, Dsd_Node_t * pNode );
......
...@@ -89,6 +89,7 @@ void Dsd_NodeSetMark( Dsd_Node_t * p, int Mark ){ p->Mark = Mark; } ...@@ -89,6 +89,7 @@ void Dsd_NodeSetMark( Dsd_Node_t * p, int Mark ){ p->Mark = Mark; }
***********************************************************************/ ***********************************************************************/
Dsd_Node_t * Dsd_ManagerReadRoot( Dsd_Manager_t * pMan, int i ) { return pMan->pRoots[i]; } Dsd_Node_t * Dsd_ManagerReadRoot( Dsd_Manager_t * pMan, int i ) { return pMan->pRoots[i]; }
Dsd_Node_t * Dsd_ManagerReadInput( Dsd_Manager_t * pMan, int i ) { return pMan->pInputs[i]; } Dsd_Node_t * Dsd_ManagerReadInput( Dsd_Manager_t * pMan, int i ) { return pMan->pInputs[i]; }
DdManager * Dsd_ManagerReadDd( Dsd_Manager_t * pMan ) { return pMan->dd; }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -61,6 +61,8 @@ struct Dsd_Node_t_ ...@@ -61,6 +61,8 @@ struct Dsd_Node_t_
/// MACRO DEFITIONS /// /// MACRO DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#define MAXINPUTS 1000
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// PARAMETERS /// /// PARAMETERS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -225,6 +225,22 @@ s_Loops2Useless = 0; ...@@ -225,6 +225,22 @@ s_Loops2Useless = 0;
/**Function************************************************************* /**Function*************************************************************
Synopsis [Performs decomposition for one function.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Dsd_Node_t * Dsd_DecomposeOne( Dsd_Manager_t * pDsdMan, DdNode * bFunc )
{
return dsdKernelDecompose_rec( pDsdMan, bFunc );
}
/**Function*************************************************************
Synopsis [The main function of this module. Recursive implementation of DSD.] Synopsis [The main function of this module. Recursive implementation of DSD.]
Description [] Description []
...@@ -1053,7 +1069,7 @@ if ( s_Show ) ...@@ -1053,7 +1069,7 @@ if ( s_Show )
// go through the decomposition list of pPrev and find components // go through the decomposition list of pPrev and find components
// whose support does not overlap with supp(Lower) // whose support does not overlap with supp(Lower)
Dsd_Node_t ** pNonOverlap = ALLOC( Dsd_Node_t *, dd->size ); static Dsd_Node_t * pNonOverlap[MAXINPUTS];
int i, nNonOverlap = 0; int i, nNonOverlap = 0;
for ( i = 0; i < pPrev->nDecs; i++ ) for ( i = 0; i < pPrev->nDecs; i++ )
{ {
...@@ -1089,7 +1105,6 @@ if ( s_Show ) ...@@ -1089,7 +1105,6 @@ if ( s_Show )
// assign the support to be subtracted from both components // assign the support to be subtracted from both components
bSuppSubract = pDENew->S; bSuppSubract = pDENew->S;
} }
free( pNonOverlap );
} }
// subtract its support from the support of upper component // subtract its support from the support of upper component
...@@ -1106,8 +1121,8 @@ if ( s_Show ) ...@@ -1106,8 +1121,8 @@ if ( s_Show )
} // end of if ( !fEqualLevel ) } // end of if ( !fEqualLevel )
else // if ( fEqualLevel ) -- they have the same top level var else // if ( fEqualLevel ) -- they have the same top level var
{ {
Dsd_Node_t ** pMarkedLeft = ALLOC( Dsd_Node_t *, dd->size ); // the pointers to the marked blocks static Dsd_Node_t * pMarkedLeft[MAXINPUTS]; // the pointers to the marked blocks
char * pMarkedPols = ALLOC( char, dd->size ); // polarities of the marked blocks static char pMarkedPols[MAXINPUTS]; // polarities of the marked blocks
int nMarkedLeft = 0; int nMarkedLeft = 0;
int fPolarity = 0; int fPolarity = 0;
...@@ -1198,9 +1213,6 @@ if ( s_Show ) ...@@ -1198,9 +1213,6 @@ if ( s_Show )
SuppH = Cudd_bddExistAbstract( dd, bTemp = SuppH, bSuppSubract ), Cudd_Ref( SuppH ); SuppH = Cudd_bddExistAbstract( dd, bTemp = SuppH, bSuppSubract ), Cudd_Ref( SuppH );
Cudd_RecursiveDeref(dd, bTemp); Cudd_RecursiveDeref(dd, bTemp);
free( pMarkedLeft );
free( pMarkedPols );
} // end of if ( fEqualLevel ) } // end of if ( fEqualLevel )
} // end of decomposition list comparison } // end of decomposition list comparison
...@@ -1333,7 +1345,7 @@ Dsd_Node_t * dsdKernelFindContainingComponent( Dsd_Manager_t * pDsdMan, Dsd_Node ...@@ -1333,7 +1345,7 @@ Dsd_Node_t * dsdKernelFindContainingComponent( Dsd_Manager_t * pDsdMan, Dsd_Node
***********************************************************************/ ***********************************************************************/
int dsdKernelFindCommonComponents( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pL, Dsd_Node_t * pH, Dsd_Node_t *** pCommon, Dsd_Node_t ** pLastDiffL, Dsd_Node_t ** pLastDiffH ) int dsdKernelFindCommonComponents( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pL, Dsd_Node_t * pH, Dsd_Node_t *** pCommon, Dsd_Node_t ** pLastDiffL, Dsd_Node_t ** pLastDiffH )
{ {
Dsd_Node_t ** Common = ALLOC( Dsd_Node_t *, pDsdMan->dd->size ); static Dsd_Node_t * Common[MAXINPUTS];
int nCommon = 0; int nCommon = 0;
// pointers to the current decomposition entries // pointers to the current decomposition entries
...@@ -1402,7 +1414,6 @@ int dsdKernelFindCommonComponents( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pL, Dsd ...@@ -1402,7 +1414,6 @@ int dsdKernelFindCommonComponents( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pL, Dsd
// return the pointer to the array // return the pointer to the array
*pCommon = Common; *pCommon = Common;
// return the number of common components // return the number of common components
free( Common );
return nCommon; return nCommon;
} }
...@@ -1567,7 +1578,7 @@ int dsdKernelVerifyDecomposition( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pDE ) ...@@ -1567,7 +1578,7 @@ int dsdKernelVerifyDecomposition( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pDE )
else if ( pR->Type == DSD_NODE_PRIME ) else if ( pR->Type == DSD_NODE_PRIME )
{ {
int i; int i;
DdNode ** bGVars = ALLOC( DdNode *, dd->size ); static DdNode * bGVars[MAXINPUTS];
// transform the function of this block, so that it depended on inputs // transform the function of this block, so that it depended on inputs
// corresponding to the formal inputs // corresponding to the formal inputs
DdNode * bNewFunc = Dsd_TreeGetPrimeFunctionOld( dd, pR, 1 ); Cudd_Ref( bNewFunc ); DdNode * bNewFunc = Dsd_TreeGetPrimeFunctionOld( dd, pR, 1 ); Cudd_Ref( bNewFunc );
...@@ -1589,7 +1600,6 @@ int dsdKernelVerifyDecomposition( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pDE ) ...@@ -1589,7 +1600,6 @@ int dsdKernelVerifyDecomposition( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pDE )
RetValue = (int)( bRes == pR->G );//|| bRes == Cudd_Not(pR->G) ); RetValue = (int)( bRes == pR->G );//|| bRes == Cudd_Not(pR->G) );
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
Cudd_Deref( bRes ); Cudd_Deref( bRes );
free( bGVars );
} }
else else
{ {
......
...@@ -517,6 +517,33 @@ Dsd_Node_t ** Dsd_TreeCollectNodesDfs( Dsd_Manager_t * pDsdMan, int * pnNodes ) ...@@ -517,6 +517,33 @@ Dsd_Node_t ** Dsd_TreeCollectNodesDfs( Dsd_Manager_t * pDsdMan, int * pnNodes )
return ppNodes; return ppNodes;
} }
/**Function*************************************************************
Synopsis [Creates the DFS ordered array of DSD nodes in the tree.]
Description [The collected nodes do not include the terminal nodes
and the constant 1 node. The array of nodes is returned. The number
of entries in the array is returned in the variale pnNodes.]
SideEffects []
SeeAlso []
***********************************************************************/
Dsd_Node_t ** Dsd_TreeCollectNodesDfsOne( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pNode, int * pnNodes )
{
Dsd_Node_t ** ppNodes;
int nNodes, nNodesAlloc;
nNodesAlloc = Dsd_TreeCountNonTerminalNodesOne(pNode);
nNodes = 0;
ppNodes = ALLOC( Dsd_Node_t *, nNodesAlloc );
Dsd_TreeCollectNodesDfs_rec( Dsd_Regular(pNode), ppNodes, &nNodes );
Dsd_TreeUnmark_rec(Dsd_Regular(pNode));
assert( nNodesAlloc == nNodes );
*pnNodes = nNodes;
return ppNodes;
}
/**Function************************************************************* /**Function*************************************************************
...@@ -777,9 +804,7 @@ DdNode * Dsd_TreeGetPrimeFunctionOld( DdManager * dd, Dsd_Node_t * pNode, int fR ...@@ -777,9 +804,7 @@ DdNode * Dsd_TreeGetPrimeFunctionOld( DdManager * dd, Dsd_Node_t * pNode, int fR
DdNode * bCof0, * bCof1, * bCube0, * bCube1, * bNewFunc, * bTemp; DdNode * bCof0, * bCof1, * bCube0, * bCube1, * bNewFunc, * bTemp;
int i; int i;
int fAllBuffs = 1; int fAllBuffs = 1;
int * pPermute; static int Permute[MAXINPUTS];
pPermute = ALLOC( int, dd->size );
assert( pNode ); assert( pNode );
assert( !Dsd_IsComplement( pNode ) ); assert( !Dsd_IsComplement( pNode ) );
...@@ -821,14 +846,13 @@ DdNode * Dsd_TreeGetPrimeFunctionOld( DdManager * dd, Dsd_Node_t * pNode, int fR ...@@ -821,14 +846,13 @@ DdNode * Dsd_TreeGetPrimeFunctionOld( DdManager * dd, Dsd_Node_t * pNode, int fR
// remap the function to the first variables of the manager // remap the function to the first variables of the manager
for ( i = 0; i < pNode->nDecs; i++ ) for ( i = 0; i < pNode->nDecs; i++ )
// Permute[ pNode->pDecs[i]->S->index ] = dd->invperm[i]; // Permute[ pNode->pDecs[i]->S->index ] = dd->invperm[i];
pPermute[ pNode->pDecs[i]->S->index ] = i; Permute[ pNode->pDecs[i]->S->index ] = i;
bNewFunc = Cudd_bddPermute( dd, bTemp = bNewFunc, pPermute ); Cudd_Ref( bNewFunc ); bNewFunc = Cudd_bddPermute( dd, bTemp = bNewFunc, Permute ); Cudd_Ref( bNewFunc );
Cudd_RecursiveDeref( dd, bTemp ); Cudd_RecursiveDeref( dd, bTemp );
} }
Cudd_Deref( bNewFunc ); Cudd_Deref( bNewFunc );
free( pPermute );
return bNewFunc; return bNewFunc;
} }
......
...@@ -172,7 +172,7 @@ Fpga_Man_t * Fpga_ManCreate( int nInputs, int nOutputs, int fVerbose ) ...@@ -172,7 +172,7 @@ Fpga_Man_t * Fpga_ManCreate( int nInputs, int nOutputs, int fVerbose )
p->fAreaRecovery = 1; p->fAreaRecovery = 1;
p->fTree = 0; p->fTree = 0;
p->fRefCount = 1; p->fRefCount = 1;
p->fEpsilon = (float)0.00001; p->fEpsilon = (float)0.001;
Fpga_TableCreate( p ); Fpga_TableCreate( p );
//if ( p->fVerbose ) //if ( p->fVerbose )
......
...@@ -193,7 +193,6 @@ Map_Man_t * Map_ManCreate( int nInputs, int nOutputs, int fVerbose ) ...@@ -193,7 +193,6 @@ Map_Man_t * Map_ManCreate( int nInputs, int nOutputs, int fVerbose )
p->pSuperLib = Abc_FrameReadLibSuper(Abc_FrameGetGlobalFrame()); p->pSuperLib = Abc_FrameReadLibSuper(Abc_FrameGetGlobalFrame());
p->nVarsMax = p->pSuperLib->nVarsMax; p->nVarsMax = p->pSuperLib->nVarsMax;
p->fVerbose = fVerbose; p->fVerbose = fVerbose;
// p->fEpsilon = (float)0.00001;
p->fEpsilon = (float)0.001; p->fEpsilon = (float)0.001;
assert( p->nVarsMax > 0 ); assert( p->nVarsMax > 0 );
......
...@@ -213,7 +213,7 @@ int Mio_GateParseFormula( Mio_Gate_t * pGate ) ...@@ -213,7 +213,7 @@ int Mio_GateParseFormula( Mio_Gate_t * pGate )
Cudd_Ref( pGate->bFunc ); Cudd_Ref( pGate->bFunc );
// derive the cover (SOP) // derive the cover (SOP)
pGate->pSop = Abc_ConvertBddToSop( pGate->pLib->pMmFlex, dd, pGate->bFunc, nPins, pGate->pLib->vCube, -1 ); pGate->pSop = Abc_ConvertBddToSop( pGate->pLib->pMmFlex, dd, pGate->bFunc, pGate->bFunc, nPins, pGate->pLib->vCube, -1 );
return 0; return 0;
} }
......
...@@ -48,7 +48,7 @@ void Mio_LibraryDelete( Mio_Library_t * pLib ) ...@@ -48,7 +48,7 @@ void Mio_LibraryDelete( Mio_Library_t * pLib )
if ( pLib == NULL ) if ( pLib == NULL )
return; return;
// free the bindings of nodes to gates from this library for all networks // free the bindings of nodes to gates from this library for all networks
// Mv_FrameFreeNetworkBindings( Mv_FrameGetGlobalFrame() ); Abc_FrameUnmapAllNetworks( Abc_FrameGetGlobalFrame() );
// free the library // free the library
FREE( pLib->pName ); FREE( pLib->pName );
Mio_LibraryForEachGateSafe( pLib, pGate, pGate2 ) Mio_LibraryForEachGateSafe( pLib, pGate, pGate2 )
......
...@@ -111,6 +111,7 @@ extern int * Extra_SupportArray( DdManager * dd, DdNode * F, int * suppor ...@@ -111,6 +111,7 @@ extern int * Extra_SupportArray( DdManager * dd, DdNode * F, int * suppor
extern int * Extra_VectorSupportArray( DdManager * dd, DdNode ** F, int n, int * support ); extern int * Extra_VectorSupportArray( DdManager * dd, DdNode ** F, int n, int * support );
extern DdNode * Extra_bddFindOneCube( DdManager * dd, DdNode * bF ); extern DdNode * Extra_bddFindOneCube( DdManager * dd, DdNode * bF );
extern DdNode * Extra_bddGetOneCube( DdManager * dd, DdNode * bFunc ); extern DdNode * Extra_bddGetOneCube( DdManager * dd, DdNode * bFunc );
extern DdNode * Extra_bddComputeRangeCube( DdManager * dd, int iStart, int iStop );
/*=== extraUtilFile.c ========================================================*/ /*=== extraUtilFile.c ========================================================*/
......
...@@ -656,6 +656,34 @@ DdNode * Extra_bddGetOneCube( DdManager * dd, DdNode * bFunc ) ...@@ -656,6 +656,34 @@ DdNode * Extra_bddGetOneCube( DdManager * dd, DdNode * bFunc )
return bRes; return bRes;
} }
/**Function********************************************************************
Synopsis [Performs the reordering-sensitive step of Extra_bddMove().]
Description []
SideEffects []
SeeAlso []
******************************************************************************/
DdNode * Extra_bddComputeRangeCube( DdManager * dd, int iStart, int iStop )
{
DdNode * bTemp, * bProd;
int i;
assert( iStart <= iStop );
assert( iStart >= 0 && iStart <= dd->size );
assert( iStop >= 0 && iStop <= dd->size );
bProd = b1; Cudd_Ref( bProd );
for ( i = iStart; i < iStop; i++ )
{
bProd = Cudd_bddAnd( dd, bTemp = bProd, dd->vars[i] ); Cudd_Ref( bProd );
Cudd_RecursiveDeref( dd, bTemp );
}
Cudd_Deref( bProd );
return bProd;
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Definition of internal functions */ /* Definition of internal functions */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
......
...@@ -57,6 +57,8 @@ struct Vec_Fan_t_ ...@@ -57,6 +57,8 @@ struct Vec_Fan_t_
/// MACRO DEFITIONS /// /// MACRO DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#define Vec_FanForEachEntry( vVec, Entry, i ) \
for ( i = 0; (i < Vec_FanSize(vVec)) && (((Entry) = Vec_FanEntry(vVec, i)), 1); i++ )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS /// /// FUNCTION DEFITIONS ///
......
...@@ -48,6 +48,9 @@ struct Vec_Int_t_ ...@@ -48,6 +48,9 @@ struct Vec_Int_t_
/// MACRO DEFITIONS /// /// MACRO DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#define Vec_IntForEachEntry( vVec, Entry, i ) \
for ( i = 0; (i < Vec_IntSize(vVec)) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS /// /// FUNCTION DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -48,6 +48,9 @@ struct Vec_Ptr_t_ ...@@ -48,6 +48,9 @@ struct Vec_Ptr_t_
/// MACRO DEFITIONS /// /// MACRO DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#define Vec_PtrForEachEntry( vVec, pEntry, i ) \
for ( i = 0; (i < Vec_PtrSize(vVec)) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS /// /// FUNCTION DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -418,6 +421,29 @@ static inline void * Vec_PtrPop( Vec_Ptr_t * p ) ...@@ -418,6 +421,29 @@ static inline void * Vec_PtrPop( Vec_Ptr_t * p )
/**Function************************************************************* /**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Vec_PtrRemove( Vec_Ptr_t * p, void * Entry )
{
int i;
for ( i = 0; i < p->nSize; i++ )
if ( p->pArray[i] == Entry )
break;
assert( i < p->nSize );
for ( i++; i < p->nSize; i++ )
p->pArray[i-1] = p->pArray[i];
p->nSize--;
}
/**Function*************************************************************
Synopsis [Moves the first nItems to the end.] Synopsis [Moves the first nItems to the end.]
Description [] Description []
......
...@@ -48,6 +48,9 @@ struct Vec_Str_t_ ...@@ -48,6 +48,9 @@ struct Vec_Str_t_
/// MACRO DEFITIONS /// /// MACRO DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#define Vec_StrForEachEntry( vVec, Entry, i ) \
for ( i = 0; (i < Vec_StrSize(vVec)) && (((Entry) = Vec_StrEntry(vVec, i)), 1); i++ )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS /// /// FUNCTION DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -39,21 +39,14 @@ static int s_MemoryPeak; ...@@ -39,21 +39,14 @@ static int s_MemoryPeak;
Synopsis [Performs fast_extract on a set of covers.] Synopsis [Performs fast_extract on a set of covers.]
Description [All the covers are given in the array p->ppCovers. Description [All the covers are given in the array p->vSops.
The resulting covers are returned in the array p->ppCoversNew. The resulting covers are returned in the array p->vSopsNew.
The number of entries in both cover arrays is equal to the number The entries in these arrays correspond to objects in the network.
of all values in the current nodes plus the max expected number The entries corresponding to the PI and objects with trivial covers are NULL.
of extracted nodes (p->nValuesCi + p->nValuesInt + p->nValuesExtMax). The number of extracted covers (not exceeding p->nNodesExt) is returned.
The first p->nValuesCi entries, corresponding to the CI nodes, are NULL.
The next p->nValuesInt entries, corresponding to the int nodes, are covers
from which the divisors are extracted. The last p->nValuesExtMax entries
are reserved for the new covers to be extracted. The number of extracted
covers is returned. This number does not exceed the given number (p->nNodesExt).
Two other things are important for the correct operation of this procedure: Two other things are important for the correct operation of this procedure:
(1) The input covers should be SCC-free. (2) The literal array (pCover->pLits) (1) The input covers do not have duplicated fanins and are SCC-free.
is allocated in each cover. The i-th entry in the literal array of a cover (2) The fanins array contains the numbers of the fanin objects.]
is the number of the cover in the array p->ppCovers, which represents this
literal (variable value) in the given cover.]
SideEffects [] SideEffects []
......
...@@ -48,37 +48,8 @@ struct FxuDataStruct ...@@ -48,37 +48,8 @@ struct FxuDataStruct
bool fUse0; // set to 1 to have 0-weight also extracted bool fUse0; // set to 1 to have 0-weight also extracted
bool fUseCompl; // set to 1 to have complement taken into account bool fUseCompl; // set to 1 to have complement taken into account
bool fVerbose; // set to 1 to have verbose output bool fVerbose; // set to 1 to have verbose output
int nPairsMax; // the maximum number of cube pairs to consider
/*
// parameters of the network
int fMvNetwork; // the network has some MV nodes
// the information about nodes
int nNodesCi; // the number of CI nodes of the network
int nNodesInt; // the number of internal nodes of the network
int nNodesOld; // the number of CI and int nodes
int nNodesNew; // the number of added nodes
int nNodesExt; // the max number of (binary) nodes to be added by FX
int nNodesAlloc; // the total number of all nodes
int * pNode2Value; // for each node, the number of its first value
// the information about values
int nValuesCi; // the total number of values of CI nodes
int nValuesInt; // the total number of values of int nodes
int nValuesOld; // the number of CI and int values
int nValuesNew; // the number of values added nodes
int nValuesExt; // the total number of values of the added nodes
int nValuesAlloc; // the total number of all values of all nodes
int * pValue2Node; // for each value, the number of its node
// the information about covers
Mvc_Cover_t ** ppCovers; // for each value, the corresponding cover
Mvc_Cover_t ** ppCoversNew; // for each value, the corresponding cover after FX
// the MVC manager
Mvc_Manager_t * pManMvc;
*/
// statistics
int nNodesOld; // the old number of nodes
int nNodesExt; // the number of divisors to extract int nNodesExt; // the number of divisors to extract
int nNodesNew; // the number of divisors extracted int nPairsMax; // the maximum number of cube pairs to consider
// the input information // the input information
Vec_Ptr_t * vSops; // the SOPs for each node in the network Vec_Ptr_t * vSops; // the SOPs for each node in the network
Vec_Ptr_t * vFanins; // the fanins of each node in the network Vec_Ptr_t * vFanins; // the fanins of each node in the network
...@@ -87,6 +58,9 @@ struct FxuDataStruct ...@@ -87,6 +58,9 @@ struct FxuDataStruct
Vec_Ptr_t * vFaninsNew; // the fanins of each node in the network after extraction Vec_Ptr_t * vFaninsNew; // the fanins of each node in the network after extraction
// the SOP manager // the SOP manager
Extra_MmFlex_t * pManSop; Extra_MmFlex_t * pManSop;
// statistics
int nNodesOld; // the old number of nodes
int nNodesNew; // the number of divisors actually extracted
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -24,21 +24,21 @@ ...@@ -24,21 +24,21 @@
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
extern int Fxu_PreprocessCubePairs( Fxu_Matrix * p, Vec_Ptr_t * vCovers, int nPairsTotal, int nPairsMax );
static void Fxu_CreateMatrixAddCube( Fxu_Matrix * p, Fxu_Cube * pCube, char * pSopCube, Vec_Fan_t * vFanins, int * pOrder ); static void Fxu_CreateMatrixAddCube( Fxu_Matrix * p, Fxu_Cube * pCube, char * pSopCube, Vec_Fan_t * vFanins, int * pOrder );
static int Fxu_CreateMatrixLitCompare( int * ptrX, int * ptrY ); static int Fxu_CreateMatrixLitCompare( int * ptrX, int * ptrY );
static void Fxu_CreateCoversNode( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode, Fxu_Cube * pCubeFirst, Fxu_Cube * pCubeNext ); static void Fxu_CreateCoversNode( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode, Fxu_Cube * pCubeFirst, Fxu_Cube * pCubeNext );
static Fxu_Cube * Fxu_CreateCoversFirstCube( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode ); static Fxu_Cube * Fxu_CreateCoversFirstCube( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode );
static Abc_Fan_t * s_pLits; static Abc_Fan_t * s_pLits;
extern int Fxu_PreprocessCubePairs( Fxu_Matrix * p, Vec_Ptr_t * vCovers, int nPairsTotal, int nPairsMax );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS /// /// FUNCTION DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/**Function************************************************************* /**Function*************************************************************
Synopsis [Creates the sparse matrix from the array of Sop covers.] Synopsis [Creates the sparse matrix from the array of SOPs.]
Description [] Description []
...@@ -53,6 +53,7 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData ) ...@@ -53,6 +53,7 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData )
Fxu_Var * pVar; Fxu_Var * pVar;
Fxu_Cube * pCubeFirst, * pCubeNew; Fxu_Cube * pCubeFirst, * pCubeNew;
Fxu_Cube * pCube1, * pCube2; Fxu_Cube * pCube1, * pCube2;
Vec_Fan_t * vFanins;
char * pSopCover; char * pSopCover;
char * pSopCube; char * pSopCube;
int * pOrder, nBitsMax; int * pOrder, nBitsMax;
...@@ -63,12 +64,11 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData ) ...@@ -63,12 +64,11 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData )
int nCubes; int nCubes;
int iCube, iPair; int iCube, iPair;
int nFanins; int nFanins;
Vec_Fan_t * vFanins;
// collect all sorts of statistics // collect all sorts of statistics
nCubesTotal = 0; nCubesTotal = 0;
nPairsTotal = 0; nPairsTotal = 0;
nPairsStore = 0; nPairsStore = 0;
nBitsMax = -1; nBitsMax = -1;
for ( i = 0; i < pData->nNodesOld; i++ ) for ( i = 0; i < pData->nNodesOld; i++ )
if ( pSopCover = pData->vSops->pArray[i] ) if ( pSopCover = pData->vSops->pArray[i] )
...@@ -158,12 +158,11 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData ) ...@@ -158,12 +158,11 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData )
Abc_SopForEachCube( pSopCover, nFanins, pSopCube ) Abc_SopForEachCube( pSopCover, nFanins, pSopCube )
{ {
// create the cube // create the cube
pCubeNew = Fxu_MatrixAddCube( p, pVar, c ); pCubeNew = Fxu_MatrixAddCube( p, pVar, c++ );
Fxu_CreateMatrixAddCube( p, pCubeNew, pSopCube, vFanins, pOrder ); Fxu_CreateMatrixAddCube( p, pCubeNew, pSopCube, vFanins, pOrder );
if ( pCubeFirst == NULL ) if ( pCubeFirst == NULL )
pCubeFirst = pCubeNew; pCubeFirst = pCubeNew;
pCubeNew->pFirst = pCubeFirst; pCubeNew->pFirst = pCubeFirst;
c++;
} }
// set the first cube of this var // set the first cube of this var
pVar->pFirst = pCubeFirst; pVar->pFirst = pCubeFirst;
...@@ -185,10 +184,7 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData ) ...@@ -185,10 +184,7 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData )
// add the var pairs to the heap // add the var pairs to the heap
Fxu_MatrixComputeSingles( p ); Fxu_MatrixComputeSingles( p );
// allocate temporary storage for pairs // print stats
if ( pData->nPairsMax < 1000 )
pData->nPairsMax = 1000;
p->pPairsTemp = ALLOC( Fxu_Pair *, pData->nPairsMax * 10 + 100 );
if ( pData->fVerbose ) if ( pData->fVerbose )
{ {
double Density; double Density;
...@@ -254,8 +250,8 @@ void Fxu_CreateMatrixAddCube( Fxu_Matrix * p, Fxu_Cube * pCube, char * pSopCube, ...@@ -254,8 +250,8 @@ void Fxu_CreateMatrixAddCube( Fxu_Matrix * p, Fxu_Cube * pCube, char * pSopCube,
void Fxu_CreateCovers( Fxu_Matrix * p, Fxu_Data_t * pData ) void Fxu_CreateCovers( Fxu_Matrix * p, Fxu_Data_t * pData )
{ {
Fxu_Cube * pCube, * pCubeFirst, * pCubeNext; Fxu_Cube * pCube, * pCubeFirst, * pCubeNext;
int iNode, n;
char * pSopCover; char * pSopCover;
int iNode, n;
// get the first cube of the first internal node // get the first cube of the first internal node
pCubeFirst = Fxu_CreateCoversFirstCube( p, pData, 0 ); pCubeFirst = Fxu_CreateCoversFirstCube( p, pData, 0 );
...@@ -306,13 +302,11 @@ void Fxu_CreateCovers( Fxu_Matrix * p, Fxu_Data_t * pData ) ...@@ -306,13 +302,11 @@ void Fxu_CreateCovers( Fxu_Matrix * p, Fxu_Data_t * pData )
void Fxu_CreateCoversNode( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode, Fxu_Cube * pCubeFirst, Fxu_Cube * pCubeNext ) void Fxu_CreateCoversNode( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode, Fxu_Cube * pCubeFirst, Fxu_Cube * pCubeNext )
{ {
Vec_Int_t * vInputsNew; Vec_Int_t * vInputsNew;
char * pSopCover; char * pSopCover, * pSopCube;
char * pSopCube;
Fxu_Var * pVar; Fxu_Var * pVar;
Fxu_Cube * pCube; Fxu_Cube * pCube;
Fxu_Lit * pLit; Fxu_Lit * pLit;
int iNum, nCubes, v; int iNum, nCubes, v;
int fEmptyCube;
// collect positive polarity variable in the cubes between pCubeFirst and pCubeNext // collect positive polarity variable in the cubes between pCubeFirst and pCubeNext
Fxu_MatrixRingVarsStart( p ); Fxu_MatrixRingVarsStart( p );
...@@ -362,7 +356,6 @@ void Fxu_CreateCoversNode( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode, Fxu_Cu ...@@ -362,7 +356,6 @@ void Fxu_CreateCoversNode( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode, Fxu_Cu
// get hold of the SOP cube // get hold of the SOP cube
pSopCube = pSopCover + nCubes * (vInputsNew->nSize + 3); pSopCube = pSopCover + nCubes * (vInputsNew->nSize + 3);
// insert literals // insert literals
fEmptyCube = 1;
for ( pLit = pCube->lLits.pHead; pLit; pLit = pLit->pHNext ) for ( pLit = pCube->lLits.pHead; pLit; pLit = pLit->pHNext )
{ {
iNum = pLit->pVar->lLits.nItems; // hack - reuse lLits.nItems iNum = pLit->pVar->lLits.nItems; // hack - reuse lLits.nItems
...@@ -371,14 +364,13 @@ void Fxu_CreateCoversNode( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode, Fxu_Cu ...@@ -371,14 +364,13 @@ void Fxu_CreateCoversNode( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode, Fxu_Cu
pSopCube[iNum] = (pLit->pVar->iVar & 1)? '0' : '1'; // reverse CST pSopCube[iNum] = (pLit->pVar->iVar & 1)? '0' : '1'; // reverse CST
else else
pSopCube[iNum] = (pLit->pVar->iVar & 1)? '1' : '0'; // no CST pSopCube[iNum] = (pLit->pVar->iVar & 1)? '1' : '0'; // no CST
fEmptyCube = 0;
} }
assert( !fEmptyCube );
// count the cube // count the cube
nCubes++; nCubes++;
} }
assert( nCubes == Abc_SopGetCubeNum(pSopCover) ); assert( nCubes == Abc_SopGetCubeNum(pSopCover) );
// set the new cover and the array of fanins
pData->vSopsNew->pArray[iNode] = pSopCover; pData->vSopsNew->pArray[iNode] = pSopCover;
pData->vFaninsNew->pArray[iNode] = vInputsNew; pData->vFaninsNew->pArray[iNode] = vInputsNew;
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "util.h" #include "util.h"
#include "extra.h" #include "extra.h"
#include "vec.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// PARAMETERS /// /// PARAMETERS ///
...@@ -158,9 +159,6 @@ struct FxuHeapSingle ...@@ -158,9 +159,6 @@ struct FxuHeapSingle
// sparse matrix // sparse matrix
struct FxuMatrix // ~ 30 words struct FxuMatrix // ~ 30 words
{ {
// information about the network
// int fMvNetwork; // set to 1 if the network has MV nodes
// int * pValue2Node; // the mapping of values into nodes
// the cubes // the cubes
Fxu_ListCube lCubes; // the double linked list of cubes Fxu_ListCube lCubes; // the double linked list of cubes
// the values (binary literals) // the values (binary literals)
...@@ -185,9 +183,7 @@ struct FxuMatrix // ~ 30 words ...@@ -185,9 +183,7 @@ struct FxuMatrix // ~ 30 words
Fxu_Var * pOrderVars; Fxu_Var * pOrderVars;
Fxu_Var ** ppTailVars; Fxu_Var ** ppTailVars;
// temporary storage for pairs // temporary storage for pairs
Fxu_Pair ** pPairsTemp; Vec_Ptr_t * vPairs;
int nPairsTemp;
// int nPairsMax;
// statistics // statistics
int nEntries; // the total number of entries in the sparse matrix int nEntries; // the total number of entries in the sparse matrix
int nDivs1; // the single cube divisors taken int nDivs1; // the single cube divisors taken
......
...@@ -77,6 +77,7 @@ Fxu_Matrix * Fxu_MatrixAllocate() ...@@ -77,6 +77,7 @@ Fxu_Matrix * Fxu_MatrixAllocate()
#endif #endif
p->pHeapDouble = Fxu_HeapDoubleStart(); p->pHeapDouble = Fxu_HeapDoubleStart();
p->pHeapSingle = Fxu_HeapSingleStart(); p->pHeapSingle = Fxu_HeapSingleStart();
p->vPairs = Vec_PtrAlloc( 100 );
return p; return p;
} }
...@@ -132,9 +133,10 @@ void Fxu_MatrixDelete( Fxu_Matrix * p ) ...@@ -132,9 +133,10 @@ void Fxu_MatrixDelete( Fxu_Matrix * p )
Extra_MmFixedStop( p->pMemMan, 0 ); Extra_MmFixedStop( p->pMemMan, 0 );
#endif #endif
Vec_PtrFree( p->vPairs );
FREE( p->pppPairs ); FREE( p->pppPairs );
FREE( p->ppPairs ); FREE( p->ppPairs );
FREE( p->pPairsTemp ); // FREE( p->pPairsTemp );
FREE( p->pTable ); FREE( p->pTable );
FREE( p->ppVars ); FREE( p->ppVars );
FREE( p ); FREE( p );
...@@ -305,20 +307,8 @@ void Fxu_MatrixAddDivisor( Fxu_Matrix * p, Fxu_Cube * pCube1, Fxu_Cube * pCube2 ...@@ -305,20 +307,8 @@ void Fxu_MatrixAddDivisor( Fxu_Matrix * p, Fxu_Cube * pCube1, Fxu_Cube * pCube2
// canonicize the pair // canonicize the pair
Fxu_PairCanonicize( &pCube1, &pCube2 ); Fxu_PairCanonicize( &pCube1, &pCube2 );
/*
// compute the hash key // compute the hash key
if ( p->fMvNetwork ) Key = Fxu_PairHashKey( p, pCube1, pCube2, &nBase, &nLits1, &nLits2 );
// if ( 0 )
{ // in case of MV network, if all the values in the cube-free divisor
// belong to the same MV variable, this cube pair is not a divisor
Key = Fxu_PairHashKeyMv( p, pCube1, pCube2, &nBase, &nLits1, &nLits2 );
if ( Key == 0 )
return;
}
else
*/
Key = Fxu_PairHashKey( p, pCube1, pCube2, &nBase, &nLits1, &nLits2 );
// create the cube pair // create the cube pair
pPair = Fxu_PairAlloc( p, pCube1, pCube2 ); pPair = Fxu_PairAlloc( p, pCube1, pCube2 );
...@@ -330,11 +320,13 @@ void Fxu_MatrixAddDivisor( Fxu_Matrix * p, Fxu_Cube * pCube1, Fxu_Cube * pCube2 ...@@ -330,11 +320,13 @@ void Fxu_MatrixAddDivisor( Fxu_Matrix * p, Fxu_Cube * pCube1, Fxu_Cube * pCube2
fFound = 0; fFound = 0;
Key %= p->nTableSize; Key %= p->nTableSize;
Fxu_TableForEachDouble( p, Key, pDiv ) Fxu_TableForEachDouble( p, Key, pDiv )
{
if ( Fxu_PairCompare( pPair, pDiv->lPairs.pTail ) ) // they are equal if ( Fxu_PairCompare( pPair, pDiv->lPairs.pTail ) ) // they are equal
{ {
fFound = 1; fFound = 1;
break; break;
} }
}
if ( !fFound ) if ( !fFound )
{ // create the new divisor { // create the new divisor
......
...@@ -287,10 +287,12 @@ void Fxu_UpdateDoublePairs( Fxu_Matrix * p, Fxu_Double * pDouble, Fxu_Var * pVar ...@@ -287,10 +287,12 @@ void Fxu_UpdateDoublePairs( Fxu_Matrix * p, Fxu_Double * pDouble, Fxu_Var * pVar
// collect and sort the pairs // collect and sort the pairs
Fxu_UpdatePairsSort( p, pDouble ); Fxu_UpdatePairsSort( p, pDouble );
for ( i = 0; i < p->nPairsTemp; i++ ) // for ( i = 0; i < p->nPairsTemp; i++ )
for ( i = 0; i < p->vPairs->nSize; i++ )
{ {
// get the pair // get the pair
pPair = p->pPairsTemp[i]; // pPair = p->pPairsTemp[i];
pPair = p->vPairs->pArray[i];
// out of the two cubes, select the one which comes earlier // out of the two cubes, select the one which comes earlier
pCubeUse = Fxu_PairMinCube( pPair ); pCubeUse = Fxu_PairMinCube( pPair );
pCubeRem = Fxu_PairMaxCube( pPair ); pCubeRem = Fxu_PairMaxCube( pPair );
...@@ -312,7 +314,7 @@ void Fxu_UpdateDoublePairs( Fxu_Matrix * p, Fxu_Double * pDouble, Fxu_Var * pVar ...@@ -312,7 +314,7 @@ void Fxu_UpdateDoublePairs( Fxu_Matrix * p, Fxu_Double * pDouble, Fxu_Var * pVar
// remove the pair // remove the pair
MEM_FREE_FXU( p, Fxu_Pair, 1, pPair ); MEM_FREE_FXU( p, Fxu_Pair, 1, pPair );
} }
p->nPairsTemp = 0; p->vPairs->nSize = 0;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -575,18 +577,17 @@ void Fxu_UpdateMatrixSingleClean( Fxu_Matrix * p, Fxu_Var * pVar1, Fxu_Var * pVa ...@@ -575,18 +577,17 @@ void Fxu_UpdateMatrixSingleClean( Fxu_Matrix * p, Fxu_Var * pVar1, Fxu_Var * pVa
void Fxu_UpdatePairsSort( Fxu_Matrix * p, Fxu_Double * pDouble ) void Fxu_UpdatePairsSort( Fxu_Matrix * p, Fxu_Double * pDouble )
{ {
Fxu_Pair * pPair; Fxu_Pair * pPair;
// order the pairs by the first cube to ensure that // order the pairs by the first cube to ensure that new literals are added
// new literals are added to the matrix from top to bottom // to the matrix from top to bottom - collect pairs into the array
// collect pairs into the array p->vPairs->nSize = 0;
p->nPairsTemp = 0;
Fxu_DoubleForEachPair( pDouble, pPair ) Fxu_DoubleForEachPair( pDouble, pPair )
p->pPairsTemp[ p->nPairsTemp++ ] = pPair; Vec_PtrPush( p->vPairs, pPair );
if ( p->nPairsTemp > 1 ) if ( p->vPairs->nSize < 2 )
{ // sort return;
qsort( (void *)p->pPairsTemp, p->nPairsTemp, sizeof(Fxu_Pair *), // sort
(int (*)(const void *, const void *)) Fxu_UpdatePairCompare ); qsort( (void *)p->vPairs->pArray, p->vPairs->nSize, sizeof(Fxu_Pair *),
assert( Fxu_UpdatePairCompare( p->pPairsTemp, p->pPairsTemp + p->nPairsTemp - 1 ) < 0 ); (int (*)(const void *, const void *)) Fxu_UpdatePairCompare );
} assert( Fxu_UpdatePairCompare( (Fxu_Pair**)p->vPairs->pArray, (Fxu_Pair**)p->vPairs->pArray + p->vPairs->nSize - 1 ) < 0 );
} }
/**Function************************************************************* /**Function*************************************************************
......
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