Commit c5277d33 by Alan Mishchenko

Version abc70712

parent 06672607
......@@ -10,7 +10,8 @@ MODULES := src/base/abc src/base/abci src/base/cmd \
src/base/io src/base/main src/base/ver \
src/aig/ivy src/aig/hop src/aig/rwt src/aig/deco \
src/aig/mem src/aig/dar src/aig/fra src/aig/cnf \
src/aig/csw src/aig/ec \
src/aig/csw src/aig/ec src/aig/aig src/aig/kit \
src/aig/bdc \
src/bdd/cudd src/bdd/dsd src/bdd/epd src/bdd/mtr \
src/bdd/parse src/bdd/reo src/bdd/cas \
src/map/fpga src/map/mapper src/map/mio \
......@@ -19,8 +20,7 @@ MODULES := src/base/abc src/base/abci src/base/cmd \
src/misc/espresso src/misc/nm src/misc/vec \
src/misc/hash \
src/opt/cut src/opt/dec src/opt/fxu src/opt/rwr \
src/opt/sim src/opt/ret src/opt/res src/opt/kit \
src/opt/lpk \
src/opt/sim src/opt/ret src/opt/res src/opt/lpk \
src/sat/bsat src/sat/csat src/sat/msat src/sat/fraig \
src/phys/place
......
......@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "src\base\abc" /I "src\base\abci" /I "src\base\abcs" /I "src\base\seq" /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\ft" /I "src\sat\asat" /I "src\sat\bsat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\cut" /I "src\opt\dec" /I "src\opt\fxu" /I "src\opt\sim" /I "src\opt\rwr" /I "src\opt\kit" /I "src\opt\res" /I "src\opt\lpk" /I "src\opt\bdc" /I "src\map\fpga" /I "src\map\if" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\mvc" /I "src\misc\util" /I "src\misc\npn" /I "src\misc\vec" /I "src\misc\espresso" /I "src\misc\nm" /I "src\misc\hash" /I "src\aig\ivy" /I "src\aig\hop" /I "src\aig\rwt" /I "src\aig\deco" /I "src\aig\mem" /I "src\aig\dar" /I "src\aig\cnf" /I "src\aig\fra" /I "src\temp\esop" /I "src\phys\place" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "src\base\abc" /I "src\base\abci" /I "src\base\abcs" /I "src\base\seq" /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\ft" /I "src\sat\asat" /I "src\sat\bsat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\cut" /I "src\opt\dec" /I "src\opt\fxu" /I "src\opt\sim" /I "src\opt\rwr" /I "src\opt\res" /I "src\opt\lpk" /I "src\map\fpga" /I "src\map\if" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\mvc" /I "src\misc\util" /I "src\misc\npn" /I "src\misc\vec" /I "src\misc\espresso" /I "src\misc\nm" /I "src\misc\hash" /I "src\aig\ivy" /I "src\aig\hop" /I "src\aig\rwt" /I "src\aig\deco" /I "src\aig\mem" /I "src\aig\aig" /I "src\aig\dar" /I "src\aig\cnf" /I "src\aig\fra" /I "src\aig\kit" /I "src\aig\bdc" /I "src\temp\esop" /I "src\phys\place" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
......@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "src\base\abc" /I "src\base\abci" /I "src\base\abcs" /I "src\base\seq" /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\ft" /I "src\sat\asat" /I "src\sat\bsat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\cut" /I "src\opt\dec" /I "src\opt\fxu" /I "src\opt\sim" /I "src\opt\rwr" /I "src\opt\kit" /I "src\opt\res" /I "src\opt\lpk" /I "src\opt\bdc" /I "src\map\fpga" /I "src\map\if" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\mvc" /I "src\misc\util" /I "src\misc\npn" /I "src\misc\vec" /I "src\misc\espresso" /I "src\misc\nm" /I "src\misc\hash" /I "src\aig\ivy" /I "src\aig\hop" /I "src\aig\rwt" /I "src\aig\deco" /I "src\aig\mem" /I "src\aig\dar" /I "src\aig\cnf" /I "src\aig\fra" /I "src\temp\esop" /I "src\phys\place" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "src\base\abc" /I "src\base\abci" /I "src\base\abcs" /I "src\base\seq" /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\ft" /I "src\sat\asat" /I "src\sat\bsat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\cut" /I "src\opt\dec" /I "src\opt\fxu" /I "src\opt\sim" /I "src\opt\rwr" /I "src\opt\res" /I "src\opt\lpk" /I "src\map\fpga" /I "src\map\if" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\mvc" /I "src\misc\util" /I "src\misc\npn" /I "src\misc\vec" /I "src\misc\espresso" /I "src\misc\nm" /I "src\misc\hash" /I "src\aig\ivy" /I "src\aig\hop" /I "src\aig\rwt" /I "src\aig\deco" /I "src\aig\mem" /I "src\aig\aig" /I "src\aig\dar" /I "src\aig\cnf" /I "src\aig\fra" /I "src\aig\kit" /I "src\aig\bdc" /I "src\temp\esop" /I "src\phys\place" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /FR /YX /FD /GZ /c
# SUBTRACT CPP /X
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
......@@ -614,2123 +614,2139 @@ SOURCE=.\src\base\ver\verStream.c
# PROP Default_Filter ""
# End Group
# End Group
# Begin Group "aig"
# Begin Group "bdd"
# PROP Default_Filter ""
# Begin Group "hop"
# Begin Group "cudd"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\hop\hop.h
SOURCE=.\src\bdd\cudd\cudd.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\hop\hopBalance.c
SOURCE=.\src\bdd\cudd\cuddAddAbs.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\hop\hopCheck.c
SOURCE=.\src\bdd\cudd\cuddAddApply.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\hop\hopDfs.c
SOURCE=.\src\bdd\cudd\cuddAddFind.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\hop\hopMan.c
SOURCE=.\src\bdd\cudd\cuddAddInv.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\hop\hopMem.c
SOURCE=.\src\bdd\cudd\cuddAddIte.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\hop\hopObj.c
SOURCE=.\src\bdd\cudd\cuddAddNeg.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\hop\hopOper.c
SOURCE=.\src\bdd\cudd\cuddAddWalsh.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\hop\hopTable.c
SOURCE=.\src\bdd\cudd\cuddAndAbs.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\hop\hopUtil.c
SOURCE=.\src\bdd\cudd\cuddAnneal.c
# End Source File
# End Group
# Begin Group "ivy"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\ivy\ivy.h
SOURCE=.\src\bdd\cudd\cuddApa.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyBalance.c
SOURCE=.\src\bdd\cudd\cuddAPI.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyCanon.c
SOURCE=.\src\bdd\cudd\cuddApprox.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyCheck.c
SOURCE=.\src\bdd\cudd\cuddBddAbs.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyCut.c
SOURCE=.\src\bdd\cudd\cuddBddCorr.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyCutTrav.c
SOURCE=.\src\bdd\cudd\cuddBddIte.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyDfs.c
SOURCE=.\src\bdd\cudd\cuddBridge.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyDsd.c
SOURCE=.\src\bdd\cudd\cuddCache.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyFanout.c
SOURCE=.\src\bdd\cudd\cuddCheck.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyFastMap.c
SOURCE=.\src\bdd\cudd\cuddClip.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyFraig.c
SOURCE=.\src\bdd\cudd\cuddCof.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyHaig.c
SOURCE=.\src\bdd\cudd\cuddCompose.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyMan.c
SOURCE=.\src\bdd\cudd\cuddDecomp.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyMem.c
SOURCE=.\src\bdd\cudd\cuddEssent.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyMulti.c
SOURCE=.\src\bdd\cudd\cuddExact.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyObj.c
SOURCE=.\src\bdd\cudd\cuddExport.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyOper.c
SOURCE=.\src\bdd\cudd\cuddGenCof.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyResyn.c
SOURCE=.\src\bdd\cudd\cuddGenetic.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyRwr.c
SOURCE=.\src\bdd\cudd\cuddGroup.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivySeq.c
SOURCE=.\src\bdd\cudd\cuddHarwell.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyShow.c
SOURCE=.\src\bdd\cudd\cuddInit.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyTable.c
SOURCE=.\src\bdd\cudd\cuddInt.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\ivy\ivyUtil.c
SOURCE=.\src\bdd\cudd\cuddInteract.c
# End Source File
# End Group
# Begin Group "rwt"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\rwt\rwt.h
SOURCE=.\src\bdd\cudd\cuddLCache.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\rwt\rwtDec.c
SOURCE=.\src\bdd\cudd\cuddLevelQ.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\rwt\rwtMan.c
SOURCE=.\src\bdd\cudd\cuddLinear.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\rwt\rwtUtil.c
SOURCE=.\src\bdd\cudd\cuddLiteral.c
# End Source File
# End Group
# Begin Group "deco"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\deco\deco.h
SOURCE=.\src\bdd\cudd\cuddMatMult.c
# End Source File
# End Group
# Begin Group "mem"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\mem\mem.c
SOURCE=.\src\bdd\cudd\cuddPriority.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\mem\mem.h
SOURCE=.\src\bdd\cudd\cuddRead.c
# End Source File
# End Group
# Begin Group "ec"
# PROP Default_Filter ""
# End Group
# Begin Group "dar"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\dar\dar.h
SOURCE=.\src\bdd\cudd\cuddRef.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darBalance.c
SOURCE=.\src\bdd\cudd\cuddReorder.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darCheck.c
SOURCE=.\src\bdd\cudd\cuddSat.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darCore.c
SOURCE=.\src\bdd\cudd\cuddSign.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darCut.c
SOURCE=.\src\bdd\cudd\cuddSolve.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darData.c
SOURCE=.\src\bdd\cudd\cuddSplit.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darDfs.c
SOURCE=.\src\bdd\cudd\cuddSubsetHB.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darLib.c
SOURCE=.\src\bdd\cudd\cuddSubsetSP.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darMan.c
SOURCE=.\src\bdd\cudd\cuddSymmetry.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darMem.c
SOURCE=.\src\bdd\cudd\cuddTable.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darObj.c
SOURCE=.\src\bdd\cudd\cuddUtil.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darOper.c
SOURCE=.\src\bdd\cudd\cuddWindow.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darSeq.c
SOURCE=.\src\bdd\cudd\cuddZddCount.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darTable.c
SOURCE=.\src\bdd\cudd\cuddZddFuncs.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darTruth.c
SOURCE=.\src\bdd\cudd\cuddZddGroup.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\dar\darUtil.c
SOURCE=.\src\bdd\cudd\cuddZddIsop.c
# End Source File
# End Group
# Begin Group "fra"
# Begin Source File
# PROP Default_Filter ""
SOURCE=.\src\bdd\cudd\cuddZddLin.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\fra\fra.h
SOURCE=.\src\bdd\cudd\cuddZddMisc.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\fra\fraAnd.c
SOURCE=.\src\bdd\cudd\cuddZddPort.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\fra\fraClass.c
SOURCE=.\src\bdd\cudd\cuddZddReord.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\fra\fraCnf.c
SOURCE=.\src\bdd\cudd\cuddZddSetop.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\fra\fraCore.c
SOURCE=.\src\bdd\cudd\cuddZddSymm.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\fra\fraMan.c
SOURCE=.\src\bdd\cudd\cuddZddUtil.c
# End Source File
# End Group
# Begin Group "epd"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\fra\fraSat.c
SOURCE=.\src\bdd\epd\epd.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\fra\fraSim.c
SOURCE=.\src\bdd\epd\epd.h
# End Source File
# End Group
# Begin Group "cnf"
# Begin Group "mtr"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\cnf\cnf.h
SOURCE=.\src\bdd\mtr\mtr.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\cnf\cnfCore.c
SOURCE=.\src\bdd\mtr\mtrBasic.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\cnf\cnfCut.c
SOURCE=.\src\bdd\mtr\mtrGroup.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\cnf\cnfData.c
SOURCE=.\src\bdd\mtr\mtrInt.h
# End Source File
# End Group
# Begin Group "parse"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\cnf\cnfMan.c
SOURCE=.\src\bdd\parse\parse.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\cnf\cnfMap.c
SOURCE=.\src\bdd\parse\parseCore.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\cnf\cnfPost.c
SOURCE=.\src\bdd\parse\parseEqn.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\cnf\cnfUtil.c
SOURCE=.\src\bdd\parse\parseInt.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\cnf\cnfWrite.c
SOURCE=.\src\bdd\parse\parseStack.c
# End Source File
# End Group
# Begin Group "csw"
# Begin Group "dsd"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\aig\csw\csw.h
SOURCE=.\src\bdd\dsd\dsd.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\csw\cswCore.c
SOURCE=.\src\bdd\dsd\dsdApi.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\csw\cswCut.c
SOURCE=.\src\bdd\dsd\dsdCheck.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\csw\cswInt.h
SOURCE=.\src\bdd\dsd\dsdInt.h
# End Source File
# Begin Source File
SOURCE=.\src\aig\csw\cswMan.c
SOURCE=.\src\bdd\dsd\dsdLocal.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\csw\cswTable.c
SOURCE=.\src\bdd\dsd\dsdMan.c
# End Source File
# End Group
# End Group
# Begin Group "bdd"
# PROP Default_Filter ""
# Begin Group "cudd"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\cudd\cudd.h
SOURCE=.\src\bdd\dsd\dsdProc.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddAddAbs.c
SOURCE=.\src\bdd\dsd\dsdTree.c
# End Source File
# End Group
# Begin Group "reo"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddAddApply.c
SOURCE=.\src\bdd\reo\reo.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddAddFind.c
SOURCE=.\src\bdd\reo\reoApi.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddAddInv.c
SOURCE=.\src\bdd\reo\reoCore.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddAddIte.c
SOURCE=.\src\bdd\reo\reoProfile.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddAddNeg.c
SOURCE=.\src\bdd\reo\reoSift.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddAddWalsh.c
SOURCE=.\src\bdd\reo\reoSwap.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddAndAbs.c
SOURCE=.\src\bdd\reo\reoTest.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddAnneal.c
SOURCE=.\src\bdd\reo\reoTransfer.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddApa.c
SOURCE=.\src\bdd\reo\reoUnits.c
# End Source File
# End Group
# Begin Group "cas"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddAPI.c
SOURCE=.\src\bdd\cas\cas.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddApprox.c
SOURCE=.\src\bdd\cas\casCore.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddBddAbs.c
SOURCE=.\src\bdd\cas\casDec.c
# End Source File
# End Group
# End Group
# Begin Group "sat"
# PROP Default_Filter ""
# Begin Group "msat"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddBddCorr.c
SOURCE=.\src\sat\msat\msat.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddBddIte.c
SOURCE=.\src\sat\msat\msatActivity.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddBridge.c
SOURCE=.\src\sat\msat\msatClause.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddCache.c
SOURCE=.\src\sat\msat\msatClauseVec.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddCheck.c
SOURCE=.\src\sat\msat\msatInt.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddClip.c
SOURCE=.\src\sat\msat\msatMem.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddCof.c
SOURCE=.\src\sat\msat\msatOrderH.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddCompose.c
SOURCE=.\src\sat\msat\msatQueue.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddDecomp.c
SOURCE=.\src\sat\msat\msatRead.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddEssent.c
SOURCE=.\src\sat\msat\msatSolverApi.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddExact.c
SOURCE=.\src\sat\msat\msatSolverCore.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddExport.c
SOURCE=.\src\sat\msat\msatSolverIo.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddGenCof.c
SOURCE=.\src\sat\msat\msatSolverSearch.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddGenetic.c
SOURCE=.\src\sat\msat\msatSort.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddGroup.c
SOURCE=.\src\sat\msat\msatVec.c
# End Source File
# Begin Source File
# End Group
# Begin Group "fraig"
SOURCE=.\src\bdd\cudd\cuddHarwell.c
# End Source File
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddInit.c
SOURCE=.\src\sat\fraig\fraig.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddInt.h
SOURCE=.\src\sat\fraig\fraigApi.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddInteract.c
SOURCE=.\src\sat\fraig\fraigCanon.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddLCache.c
SOURCE=.\src\sat\fraig\fraigChoice.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddLevelQ.c
SOURCE=.\src\sat\fraig\fraigFanout.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddLinear.c
SOURCE=.\src\sat\fraig\fraigFeed.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddLiteral.c
SOURCE=.\src\sat\fraig\fraigInt.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddMatMult.c
SOURCE=.\src\sat\fraig\fraigMan.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddPriority.c
SOURCE=.\src\sat\fraig\fraigMem.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddRead.c
SOURCE=.\src\sat\fraig\fraigNode.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddRef.c
SOURCE=.\src\sat\fraig\fraigPrime.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddReorder.c
SOURCE=.\src\sat\fraig\fraigSat.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddSat.c
SOURCE=.\src\sat\fraig\fraigTable.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddSign.c
SOURCE=.\src\sat\fraig\fraigUtil.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddSolve.c
SOURCE=.\src\sat\fraig\fraigVec.c
# End Source File
# Begin Source File
# End Group
# Begin Group "csat"
SOURCE=.\src\bdd\cudd\cuddSplit.c
# End Source File
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddSubsetHB.c
SOURCE=.\src\sat\csat\csat_apis.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddSubsetSP.c
SOURCE=.\src\sat\csat\csat_apis.h
# End Source File
# End Group
# Begin Group "bsat"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddSymmetry.c
SOURCE=.\src\sat\bsat\satInter.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddTable.c
SOURCE=.\src\sat\bsat\satMem.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddUtil.c
SOURCE=.\src\sat\bsat\satMem.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddWindow.c
SOURCE=.\src\sat\bsat\satSolver.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddCount.c
SOURCE=.\src\sat\bsat\satSolver.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddFuncs.c
SOURCE=.\src\sat\bsat\satStore.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddGroup.c
SOURCE=.\src\sat\bsat\satStore.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddIsop.c
SOURCE=.\src\sat\bsat\satTrace.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddLin.c
SOURCE=.\src\sat\bsat\satUtil.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddMisc.c
SOURCE=.\src\sat\bsat\satVec.h
# End Source File
# End Group
# Begin Group "proof"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddPort.c
SOURCE=.\src\sat\proof\pr.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddReord.c
SOURCE=.\src\sat\proof\pr.h
# End Source File
# End Group
# End Group
# Begin Group "opt"
# PROP Default_Filter ""
# Begin Group "fxu"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddSetop.c
SOURCE=.\src\opt\fxu\fxu.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddSymm.c
SOURCE=.\src\opt\fxu\fxu.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cudd\cuddZddUtil.c
SOURCE=.\src\opt\fxu\fxuCreate.c
# End Source File
# End Group
# Begin Group "epd"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\epd\epd.c
SOURCE=.\src\opt\fxu\fxuHeapD.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\epd\epd.h
SOURCE=.\src\opt\fxu\fxuHeapS.c
# End Source File
# End Group
# Begin Group "mtr"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\mtr\mtr.h
SOURCE=.\src\opt\fxu\fxuInt.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\mtr\mtrBasic.c
SOURCE=.\src\opt\fxu\fxuList.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\mtr\mtrGroup.c
SOURCE=.\src\opt\fxu\fxuMatrix.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\mtr\mtrInt.h
SOURCE=.\src\opt\fxu\fxuPair.c
# End Source File
# End Group
# Begin Group "parse"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\parse\parse.h
SOURCE=.\src\opt\fxu\fxuPrint.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\parse\parseCore.c
SOURCE=.\src\opt\fxu\fxuReduce.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\parse\parseEqn.c
SOURCE=.\src\opt\fxu\fxuSelect.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\parse\parseInt.h
SOURCE=.\src\opt\fxu\fxuSingle.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\parse\parseStack.c
SOURCE=.\src\opt\fxu\fxuUpdate.c
# End Source File
# End Group
# Begin Group "dsd"
# Begin Group "rwr"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\dsd\dsd.h
SOURCE=.\src\opt\rwr\rwr.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\dsd\dsdApi.c
SOURCE=.\src\opt\rwr\rwrDec.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\dsd\dsdCheck.c
SOURCE=.\src\opt\rwr\rwrEva.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\dsd\dsdInt.h
SOURCE=.\src\opt\rwr\rwrExp.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\dsd\dsdLocal.c
SOURCE=.\src\opt\rwr\rwrLib.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\dsd\dsdMan.c
SOURCE=.\src\opt\rwr\rwrMan.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\dsd\dsdProc.c
SOURCE=.\src\opt\rwr\rwrPrint.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\dsd\dsdTree.c
SOURCE=.\src\opt\rwr\rwrTemp.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\rwr\rwrUtil.c
# End Source File
# End Group
# Begin Group "reo"
# Begin Group "cut"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\bdd\reo\reo.h
SOURCE=.\src\opt\cut\cut.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\reo\reoApi.c
SOURCE=.\src\opt\cut\cutApi.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\reo\reoCore.c
SOURCE=.\src\opt\cut\cutCut.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\reo\reoProfile.c
SOURCE=.\src\opt\cut\cutExpand.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\reo\reoSift.c
SOURCE=.\src\opt\cut\cutInt.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\reo\reoSwap.c
SOURCE=.\src\opt\cut\cutList.h
# End Source File
# Begin Source File
SOURCE=.\src\bdd\reo\reoTest.c
SOURCE=.\src\opt\cut\cutMan.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\reo\reoTransfer.c
SOURCE=.\src\opt\cut\cutMerge.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\reo\reoUnits.c
SOURCE=.\src\opt\cut\cutNode.c
# End Source File
# End Group
# Begin Group "cas"
# Begin Source File
# PROP Default_Filter ""
SOURCE=.\src\opt\cut\cutOracle.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cas\cas.h
SOURCE=.\src\opt\cut\cutPre22.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cas\casCore.c
SOURCE=.\src\opt\cut\cutSeq.c
# End Source File
# Begin Source File
SOURCE=.\src\bdd\cas\casDec.c
SOURCE=.\src\opt\cut\cutTruth.c
# End Source File
# End Group
# End Group
# Begin Group "sat"
# Begin Group "dec"
# PROP Default_Filter ""
# Begin Group "msat"
# Begin Source File
# PROP Default_Filter ""
SOURCE=.\src\opt\dec\dec.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msat.h
SOURCE=.\src\opt\dec\decAbc.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatActivity.c
SOURCE=.\src\opt\dec\decFactor.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatClause.c
SOURCE=.\src\opt\dec\decMan.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatClauseVec.c
SOURCE=.\src\opt\dec\decPrint.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatInt.h
SOURCE=.\src\opt\dec\decUtil.c
# End Source File
# End Group
# Begin Group "sim"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\sat\msat\msatMem.c
SOURCE=.\src\opt\sim\sim.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatOrderH.c
SOURCE=.\src\opt\sim\simMan.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatQueue.c
SOURCE=.\src\opt\sim\simSat.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatRead.c
SOURCE=.\src\opt\sim\simSeq.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatSolverApi.c
SOURCE=.\src\opt\sim\simSupp.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatSolverCore.c
SOURCE=.\src\opt\sim\simSwitch.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatSolverIo.c
SOURCE=.\src\opt\sim\simSym.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatSolverSearch.c
SOURCE=.\src\opt\sim\simSymSat.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatSort.c
SOURCE=.\src\opt\sim\simSymSim.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\msat\msatVec.c
SOURCE=.\src\opt\sim\simSymStr.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simUtils.c
# End Source File
# End Group
# Begin Group "fraig"
# Begin Group "ret"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\sat\fraig\fraig.h
SOURCE=.\src\opt\ret\retArea.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigApi.c
SOURCE=.\src\opt\ret\retCore.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigCanon.c
SOURCE=.\src\opt\ret\retDelay.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigChoice.c
SOURCE=.\src\opt\ret\retFlow.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigFanout.c
SOURCE=.\src\opt\ret\retIncrem.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigFeed.c
SOURCE=.\src\opt\ret\retInit.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigInt.h
SOURCE=.\src\opt\ret\retInt.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigMan.c
SOURCE=.\src\opt\ret\retLvalue.c
# End Source File
# End Group
# Begin Group "res"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\sat\fraig\fraigMem.c
SOURCE=.\src\opt\res\res.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigNode.c
SOURCE=.\src\opt\res\resCore.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigPrime.c
SOURCE=.\src\opt\res\resDivs.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigSat.c
SOURCE=.\src\opt\res\resFilter.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigTable.c
SOURCE=.\src\opt\res\resInt.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigUtil.c
SOURCE=.\src\opt\res\resSat.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\fraig\fraigVec.c
SOURCE=.\src\opt\res\resSim.c
# End Source File
# End Group
# Begin Group "csat"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\sat\csat\csat_apis.c
SOURCE=.\src\opt\res\resStrash.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\csat\csat_apis.h
SOURCE=.\src\opt\res\resWin.c
# End Source File
# End Group
# Begin Group "bsat"
# Begin Group "lpk"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\sat\bsat\satInter.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satMem.c
SOURCE=.\src\opt\lpk\lpk.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satMem.h
SOURCE=.\src\opt\lpk\lpkCore.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satSolver.c
SOURCE=.\src\opt\lpk\lpkCut.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satSolver.h
SOURCE=.\src\opt\lpk\lpkInt.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satStore.c
SOURCE=.\src\opt\lpk\lpkMan.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satStore.h
SOURCE=.\src\opt\lpk\lpkMap.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satTrace.c
SOURCE=.\src\opt\lpk\lpkMulti.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satUtil.c
SOURCE=.\src\opt\lpk\lpkMux.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\bsat\satVec.h
SOURCE=.\src\opt\lpk\lpkSets.c
# End Source File
# End Group
# Begin Group "proof"
# End Group
# Begin Group "map"
# PROP Default_Filter ""
# Begin Group "fpga"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\sat\proof\pr.c
SOURCE=.\src\map\fpga\fpga.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\proof\pr.h
SOURCE=.\src\map\fpga\fpga.h
# End Source File
# End Group
# End Group
# Begin Group "opt"
# Begin Source File
# PROP Default_Filter ""
# Begin Group "fxu"
SOURCE=.\src\map\fpga\fpgaCore.c
# End Source File
# Begin Source File
# PROP Default_Filter ""
SOURCE=.\src\map\fpga\fpgaCreate.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxu.c
SOURCE=.\src\map\fpga\fpgaCut.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxu.h
SOURCE=.\src\map\fpga\fpgaCutUtils.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuCreate.c
SOURCE=.\src\map\fpga\fpgaFanout.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuHeapD.c
SOURCE=.\src\map\fpga\fpgaInt.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuHeapS.c
SOURCE=.\src\map\fpga\fpgaLib.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuInt.h
SOURCE=.\src\map\fpga\fpgaMatch.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuList.c
SOURCE=.\src\map\fpga\fpgaSwitch.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuMatrix.c
SOURCE=.\src\map\fpga\fpgaTime.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuPair.c
SOURCE=.\src\map\fpga\fpgaTruth.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuPrint.c
SOURCE=.\src\map\fpga\fpgaUtils.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuReduce.c
SOURCE=.\src\map\fpga\fpgaVec.c
# End Source File
# End Group
# Begin Group "mapper"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\opt\fxu\fxuSelect.c
SOURCE=.\src\map\mapper\mapper.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuSingle.c
SOURCE=.\src\map\mapper\mapper.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\fxu\fxuUpdate.c
SOURCE=.\src\map\mapper\mapperCanon.c
# End Source File
# End Group
# Begin Group "rwr"
# Begin Source File
# PROP Default_Filter ""
SOURCE=.\src\map\mapper\mapperCore.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\rwr\rwr.h
SOURCE=.\src\map\mapper\mapperCreate.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\rwr\rwrDec.c
SOURCE=.\src\map\mapper\mapperCut.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\rwr\rwrEva.c
SOURCE=.\src\map\mapper\mapperCutUtils.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\rwr\rwrExp.c
SOURCE=.\src\map\mapper\mapperFanout.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\rwr\rwrLib.c
SOURCE=.\src\map\mapper\mapperInt.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\rwr\rwrMan.c
SOURCE=.\src\map\mapper\mapperLib.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\rwr\rwrPrint.c
SOURCE=.\src\map\mapper\mapperMatch.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\rwr\rwrTemp.c
SOURCE=.\src\map\mapper\mapperRefs.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\rwr\rwrUtil.c
SOURCE=.\src\map\mapper\mapperSuper.c
# End Source File
# End Group
# Begin Group "cut"
# Begin Source File
# PROP Default_Filter ""
SOURCE=.\src\map\mapper\mapperSwitch.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cut.h
SOURCE=.\src\map\mapper\mapperTable.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutApi.c
SOURCE=.\src\map\mapper\mapperTime.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutCut.c
SOURCE=.\src\map\mapper\mapperTree.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutExpand.c
SOURCE=.\src\map\mapper\mapperTruth.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutInt.h
SOURCE=.\src\map\mapper\mapperUtils.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutList.h
SOURCE=.\src\map\mapper\mapperVec.c
# End Source File
# End Group
# Begin Group "mio"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\opt\cut\cutMan.c
SOURCE=.\src\map\mio\mio.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutMerge.c
SOURCE=.\src\map\mio\mio.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutNode.c
SOURCE=.\src\map\mio\mioApi.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutOracle.c
SOURCE=.\src\map\mio\mioFunc.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutPre22.c
SOURCE=.\src\map\mio\mioInt.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutSeq.c
SOURCE=.\src\map\mio\mioRead.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutTruth.c
SOURCE=.\src\map\mio\mioUtils.c
# End Source File
# End Group
# Begin Group "dec"
# Begin Group "super"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\opt\dec\dec.h
SOURCE=.\src\map\super\super.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\dec\decAbc.c
SOURCE=.\src\map\super\super.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\dec\decFactor.c
SOURCE=.\src\map\super\superAnd.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\dec\decMan.c
SOURCE=.\src\map\super\superGate.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\dec\decPrint.c
SOURCE=.\src\map\super\superInt.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\dec\decUtil.c
SOURCE=.\src\map\super\superWrite.c
# End Source File
# End Group
# Begin Group "sim"
# Begin Group "if"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\opt\sim\sim.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simMan.c
SOURCE=.\src\map\if\if.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simSat.c
SOURCE=.\src\map\if\ifCore.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simSeq.c
SOURCE=.\src\map\if\ifCut.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simSupp.c
SOURCE=.\src\map\if\ifMan.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simSwitch.c
SOURCE=.\src\map\if\ifMap.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simSym.c
SOURCE=.\src\map\if\ifReduce.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simSymSat.c
SOURCE=.\src\map\if\ifSeq.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simSymSim.c
SOURCE=.\src\map\if\ifTime.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simSymStr.c
SOURCE=.\src\map\if\ifTruth.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sim\simUtils.c
SOURCE=.\src\map\if\ifUtil.c
# End Source File
# End Group
# Begin Group "ret"
# End Group
# Begin Group "misc"
# PROP Default_Filter ""
# Begin Source File
# Begin Group "extra"
SOURCE=.\src\opt\ret\retArea.c
# End Source File
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\opt\ret\retCore.c
SOURCE=.\src\misc\extra\extra.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\ret\retDelay.c
SOURCE=.\src\misc\extra\extraBddAuto.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\ret\retFlow.c
SOURCE=.\src\misc\extra\extraBddCas.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\ret\retIncrem.c
SOURCE=.\src\misc\extra\extraBddKmap.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\ret\retInit.c
SOURCE=.\src\misc\extra\extraBddMisc.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\ret\retInt.h
SOURCE=.\src\misc\extra\extraBddSymm.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\ret\retLvalue.c
SOURCE=.\src\misc\extra\extraBddUnate.c
# End Source File
# End Group
# Begin Group "kit"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\opt\kit\kit.h
SOURCE=.\src\misc\extra\extraUtilBitMatrix.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\kit\kitBdd.c
SOURCE=.\src\misc\extra\extraUtilCanon.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\kit\kitDsd.c
SOURCE=.\src\misc\extra\extraUtilFile.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\kit\kitFactor.c
SOURCE=.\src\misc\extra\extraUtilMemory.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\kit\kitGraph.c
SOURCE=.\src\misc\extra\extraUtilMisc.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\kit\kitHop.c
SOURCE=.\src\misc\extra\extraUtilProgress.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\kit\kitIsop.c
SOURCE=.\src\misc\extra\extraUtilReader.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\kit\kitSop.c
SOURCE=.\src\misc\extra\extraUtilTruth.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\kit\kitTruth.c
SOURCE=.\src\misc\extra\extraUtilUtil.c
# End Source File
# End Group
# Begin Group "res"
# Begin Group "st"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\opt\res\res.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\res\resCore.c
SOURCE=.\src\misc\st\st.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\res\resDivs.c
SOURCE=.\src\misc\st\st.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\res\resFilter.c
SOURCE=.\src\misc\st\stmm.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\res\resInt.h
SOURCE=.\src\misc\st\stmm.h
# End Source File
# Begin Source File
# End Group
# Begin Group "mvc"
SOURCE=.\src\opt\res\resSat.c
# End Source File
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\opt\res\resSim.c
SOURCE=.\src\misc\mvc\mvc.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\res\resStrash.c
SOURCE=.\src\misc\mvc\mvc.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\res\resWin.c
SOURCE=.\src\misc\mvc\mvcApi.c
# End Source File
# End Group
# Begin Group "bdc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\opt\bdc\bdc.h
SOURCE=.\src\misc\mvc\mvcCompare.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\bdc\bdcCore.c
SOURCE=.\src\misc\mvc\mvcContain.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\bdc\bdcDec.c
SOURCE=.\src\misc\mvc\mvcCover.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\bdc\bdcInt.h
SOURCE=.\src\misc\mvc\mvcCube.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\bdc\bdcTable.c
SOURCE=.\src\misc\mvc\mvcDivide.c
# End Source File
# End Group
# Begin Group "lpk"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\opt\lpk\lpk.h
SOURCE=.\src\misc\mvc\mvcDivisor.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\lpk\lpkCore.c
SOURCE=.\src\misc\mvc\mvcList.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\lpk\lpkCut.c
SOURCE=.\src\misc\mvc\mvcLits.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\lpk\lpkInt.h
SOURCE=.\src\misc\mvc\mvcMan.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\lpk\lpkMan.c
SOURCE=.\src\misc\mvc\mvcOpAlg.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\lpk\lpkMap.c
SOURCE=.\src\misc\mvc\mvcOpBool.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\lpk\lpkMulti.c
SOURCE=.\src\misc\mvc\mvcPrint.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\lpk\lpkMux.c
SOURCE=.\src\misc\mvc\mvcSort.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\lpk\lpkSets.c
SOURCE=.\src\misc\mvc\mvcUtils.c
# End Source File
# End Group
# End Group
# Begin Group "map"
# PROP Default_Filter ""
# Begin Group "fpga"
# Begin Group "vec"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\map\fpga\fpga.c
SOURCE=.\src\misc\vec\vec.h
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpga.h
SOURCE=.\src\misc\vec\vecAtt.h
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaCore.c
SOURCE=.\src\misc\vec\vecFlt.h
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaCreate.c
SOURCE=.\src\misc\vec\vecInt.h
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaCut.c
SOURCE=.\src\misc\vec\vecPtr.h
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaCutUtils.c
SOURCE=.\src\misc\vec\vecStr.h
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaFanout.c
SOURCE=.\src\misc\vec\vecVec.h
# End Source File
# End Group
# Begin Group "espresso"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\map\fpga\fpgaInt.h
SOURCE=.\src\misc\espresso\cofactor.c
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaLib.c
SOURCE=.\src\misc\espresso\cols.c
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaMatch.c
SOURCE=.\src\misc\espresso\compl.c
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaSwitch.c
SOURCE=.\src\misc\espresso\contain.c
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaTime.c
SOURCE=.\src\misc\espresso\cubehack.c
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaTruth.c
SOURCE=.\src\misc\espresso\cubestr.c
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaUtils.c
SOURCE=.\src\misc\espresso\cvrin.c
# End Source File
# Begin Source File
SOURCE=.\src\map\fpga\fpgaVec.c
SOURCE=.\src\misc\espresso\cvrm.c
# End Source File
# End Group
# Begin Group "mapper"
# Begin Source File
# PROP Default_Filter ""
SOURCE=.\src\misc\espresso\cvrmisc.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapper.c
SOURCE=.\src\misc\espresso\cvrout.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapper.h
SOURCE=.\src\misc\espresso\dominate.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperCanon.c
SOURCE=.\src\misc\espresso\equiv.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperCore.c
SOURCE=.\src\misc\espresso\espresso.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperCreate.c
SOURCE=.\src\misc\espresso\espresso.h
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperCut.c
SOURCE=.\src\misc\espresso\essen.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperCutUtils.c
SOURCE=.\src\misc\espresso\exact.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperFanout.c
SOURCE=.\src\misc\espresso\expand.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperInt.h
SOURCE=.\src\misc\espresso\gasp.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperLib.c
SOURCE=.\src\misc\espresso\gimpel.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperMatch.c
SOURCE=.\src\misc\espresso\globals.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperRefs.c
SOURCE=.\src\misc\espresso\hack.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperSuper.c
SOURCE=.\src\misc\espresso\indep.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperSwitch.c
SOURCE=.\src\misc\espresso\irred.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperTable.c
SOURCE=.\src\misc\espresso\map.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperTime.c
SOURCE=.\src\misc\espresso\matrix.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperTree.c
SOURCE=.\src\misc\espresso\mincov.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperTruth.c
SOURCE=.\src\misc\espresso\mincov.h
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperUtils.c
SOURCE=.\src\misc\espresso\mincov_int.h
# End Source File
# Begin Source File
SOURCE=.\src\map\mapper\mapperVec.c
SOURCE=.\src\misc\espresso\opo.c
# End Source File
# End Group
# Begin Group "mio"
# Begin Source File
# PROP Default_Filter ""
SOURCE=.\src\misc\espresso\pair.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mio\mio.c
SOURCE=.\src\misc\espresso\part.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mio\mio.h
SOURCE=.\src\misc\espresso\primes.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mio\mioApi.c
SOURCE=.\src\misc\espresso\reduce.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mio\mioFunc.c
SOURCE=.\src\misc\espresso\rows.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mio\mioInt.h
SOURCE=.\src\misc\espresso\set.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mio\mioRead.c
SOURCE=.\src\misc\espresso\setc.c
# End Source File
# Begin Source File
SOURCE=.\src\map\mio\mioUtils.c
SOURCE=.\src\misc\espresso\sharp.c
# End Source File
# End Group
# Begin Group "super"
# Begin Source File
# PROP Default_Filter ""
SOURCE=.\src\misc\espresso\sminterf.c
# End Source File
# Begin Source File
SOURCE=.\src\map\super\super.c
SOURCE=.\src\misc\espresso\solution.c
# End Source File
# Begin Source File
SOURCE=.\src\map\super\super.h
SOURCE=.\src\misc\espresso\sparse.c
# End Source File
# Begin Source File
SOURCE=.\src\map\super\superAnd.c
SOURCE=.\src\misc\espresso\sparse.h
# End Source File
# Begin Source File
SOURCE=.\src\map\super\superGate.c
SOURCE=.\src\misc\espresso\sparse_int.h
# End Source File
# Begin Source File
SOURCE=.\src\map\super\superInt.h
SOURCE=.\src\misc\espresso\unate.c
# End Source File
# Begin Source File
SOURCE=.\src\map\super\superWrite.c
SOURCE=.\src\misc\espresso\verify.c
# End Source File
# End Group
# Begin Group "if"
# Begin Group "util"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\map\if\if.h
SOURCE=.\src\misc\util\util_hack.h
# End Source File
# Begin Source File
# End Group
# Begin Group "nm"
SOURCE=.\src\map\if\ifCore.c
# End Source File
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\map\if\ifCut.c
SOURCE=.\src\misc\nm\nm.h
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifMan.c
SOURCE=.\src\misc\nm\nmApi.c
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifMap.c
SOURCE=.\src\misc\nm\nmInt.h
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifReduce.c
SOURCE=.\src\misc\nm\nmTable.c
# End Source File
# End Group
# Begin Group "hash"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\map\if\ifSeq.c
SOURCE=.\src\misc\hash\hash.h
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifTime.c
SOURCE=.\src\misc\hash\hashFlt.h
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifTruth.c
SOURCE=.\src\misc\hash\hashInt.h
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifUtil.c
SOURCE=.\src\misc\hash\hashPtr.h
# End Source File
# End Group
# End Group
# Begin Group "misc"
# Begin Group "phys"
# PROP Default_Filter ""
# Begin Group "extra"
# Begin Group "place"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\extra\extra.h
SOURCE=.\src\phys\place\libhmetis.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraBddAuto.c
SOURCE=.\src\phys\place\place_base.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraBddCas.c
SOURCE=.\src\phys\place\place_base.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraBddKmap.c
SOURCE=.\src\phys\place\place_bin.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraBddMisc.c
SOURCE=.\src\phys\place\place_genqp.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraBddSymm.c
SOURCE=.\src\phys\place\place_gordian.c
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_gordian.h
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_legalize.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraBddUnate.c
SOURCE=.\src\phys\place\place_pads.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilBitMatrix.c
SOURCE=.\src\phys\place\place_partition.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilCanon.c
SOURCE=.\src\phys\place\place_qpsolver.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilFile.c
SOURCE=.\src\phys\place\place_qpsolver.h
# End Source File
# End Group
# End Group
# Begin Group "ai"
# PROP Default_Filter ""
# Begin Group "hop"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilMemory.c
SOURCE=.\src\aig\hop\hop.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilMisc.c
SOURCE=.\src\aig\hop\hopBalance.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilProgress.c
SOURCE=.\src\aig\hop\hopCheck.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilReader.c
SOURCE=.\src\aig\hop\hopDfs.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilTruth.c
SOURCE=.\src\aig\hop\hopMan.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilUtil.c
SOURCE=.\src\aig\hop\hopMem.c
# End Source File
# End Group
# Begin Group "st"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\st\st.c
SOURCE=.\src\aig\hop\hopObj.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\st\st.h
SOURCE=.\src\aig\hop\hopOper.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\st\stmm.c
SOURCE=.\src\aig\hop\hopTable.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\st\stmm.h
SOURCE=.\src\aig\hop\hopUtil.c
# End Source File
# End Group
# Begin Group "mvc"
# Begin Group "ivy"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\mvc\mvc.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvc.h
SOURCE=.\src\aig\ivy\ivy.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcApi.c
SOURCE=.\src\aig\ivy\ivyBalance.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcCompare.c
SOURCE=.\src\aig\ivy\ivyCanon.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcContain.c
SOURCE=.\src\aig\ivy\ivyCheck.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcCover.c
SOURCE=.\src\aig\ivy\ivyCut.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcCube.c
SOURCE=.\src\aig\ivy\ivyCutTrav.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcDivide.c
SOURCE=.\src\aig\ivy\ivyDfs.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcDivisor.c
SOURCE=.\src\aig\ivy\ivyDsd.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcList.c
SOURCE=.\src\aig\ivy\ivyFanout.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcLits.c
SOURCE=.\src\aig\ivy\ivyFastMap.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcMan.c
SOURCE=.\src\aig\ivy\ivyFraig.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcOpAlg.c
SOURCE=.\src\aig\ivy\ivyHaig.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcOpBool.c
SOURCE=.\src\aig\ivy\ivyMan.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcPrint.c
SOURCE=.\src\aig\ivy\ivyMem.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcSort.c
SOURCE=.\src\aig\ivy\ivyMulti.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\mvc\mvcUtils.c
SOURCE=.\src\aig\ivy\ivyObj.c
# End Source File
# End Group
# Begin Group "vec"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\vec\vec.h
SOURCE=.\src\aig\ivy\ivyOper.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecAtt.h
SOURCE=.\src\aig\ivy\ivyResyn.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecFlt.h
SOURCE=.\src\aig\ivy\ivyRwr.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecInt.h
SOURCE=.\src\aig\ivy\ivySeq.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecPtr.h
SOURCE=.\src\aig\ivy\ivyShow.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecStr.h
SOURCE=.\src\aig\ivy\ivyTable.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecVec.h
SOURCE=.\src\aig\ivy\ivyUtil.c
# End Source File
# End Group
# Begin Group "espresso"
# Begin Group "rwt"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\espresso\cofactor.c
SOURCE=.\src\aig\rwt\rwt.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\cols.c
SOURCE=.\src\aig\rwt\rwtDec.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\compl.c
SOURCE=.\src\aig\rwt\rwtMan.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\contain.c
SOURCE=.\src\aig\rwt\rwtUtil.c
# End Source File
# Begin Source File
# End Group
# Begin Group "deco"
SOURCE=.\src\misc\espresso\cubehack.c
# End Source File
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\espresso\cubestr.c
SOURCE=.\src\aig\deco\deco.h
# End Source File
# End Group
# Begin Group "mem"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\espresso\cvrin.c
SOURCE=.\src\aig\mem\mem.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\cvrm.c
SOURCE=.\src\aig\mem\mem.h
# End Source File
# End Group
# Begin Group "ec"
# PROP Default_Filter ""
# End Group
# Begin Group "dar"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\espresso\cvrmisc.c
SOURCE=.\src\aig\dar\dar.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\cvrout.c
SOURCE=.\src\aig\dar\darBalance.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\dominate.c
SOURCE=.\src\aig\dar\darCore.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\equiv.c
SOURCE=.\src\aig\dar\darCut.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\espresso.c
SOURCE=.\src\aig\dar\darData.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\espresso.h
SOURCE=.\src\aig\dar\darInt.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\essen.c
SOURCE=.\src\aig\dar\darLib.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\exact.c
SOURCE=.\src\aig\dar\darMan.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\expand.c
SOURCE=.\src\aig\dar\darTruth.c
# End Source File
# End Group
# Begin Group "fra"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\espresso\gasp.c
SOURCE=.\src\aig\fra\fra.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\gimpel.c
SOURCE=.\src\aig\fra\fraAnd.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\globals.c
SOURCE=.\src\aig\fra\fraClass.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\hack.c
SOURCE=.\src\aig\fra\fraCnf.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\indep.c
SOURCE=.\src\aig\fra\fraCore.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\irred.c
SOURCE=.\src\aig\fra\fraMan.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\map.c
SOURCE=.\src\aig\fra\fraSat.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\matrix.c
SOURCE=.\src\aig\fra\fraSim.c
# End Source File
# End Group
# Begin Group "cnf"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\espresso\mincov.c
SOURCE=.\src\aig\cnf\cnf.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\mincov.h
SOURCE=.\src\aig\cnf\cnfCore.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\mincov_int.h
SOURCE=.\src\aig\cnf\cnfCut.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\opo.c
SOURCE=.\src\aig\cnf\cnfData.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\pair.c
SOURCE=.\src\aig\cnf\cnfMan.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\part.c
SOURCE=.\src\aig\cnf\cnfMap.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\primes.c
SOURCE=.\src\aig\cnf\cnfPost.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\reduce.c
SOURCE=.\src\aig\cnf\cnfUtil.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\rows.c
SOURCE=.\src\aig\cnf\cnfWrite.c
# End Source File
# End Group
# Begin Group "csw"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\espresso\set.c
SOURCE=.\src\aig\csw\csw.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\setc.c
SOURCE=.\src\aig\csw\cswCore.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\sharp.c
SOURCE=.\src\aig\csw\cswCut.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\sminterf.c
SOURCE=.\src\aig\csw\cswInt.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\solution.c
SOURCE=.\src\aig\csw\cswMan.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\sparse.c
SOURCE=.\src\aig\csw\cswTable.c
# End Source File
# End Group
# Begin Group "kit"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\espresso\sparse.h
SOURCE=.\src\aig\kit\kit.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\sparse_int.h
SOURCE=.\src\aig\kit\kitBdd.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\unate.c
SOURCE=.\src\aig\kit\kitDsd.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\espresso\verify.c
SOURCE=.\src\aig\kit\kitFactor.c
# End Source File
# End Group
# Begin Group "util"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\util\util_hack.h
SOURCE=.\src\aig\kit\kitGraph.c
# End Source File
# End Group
# Begin Group "nm"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\nm\nm.h
SOURCE=.\src\aig\kit\kitHop.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\nm\nmApi.c
SOURCE=.\src\aig\kit\kitIsop.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\nm\nmInt.h
SOURCE=.\src\aig\kit\kitSop.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\nm\nmTable.c
SOURCE=.\src\aig\kit\kitTruth.c
# End Source File
# End Group
# Begin Group "hash"
# Begin Group "bdc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\misc\hash\hash.h
SOURCE=.\src\aig\bdc\bdc.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\hash\hashFlt.h
SOURCE=.\src\aig\bdc\bdcCore.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\hash\hashInt.h
SOURCE=.\src\aig\bdc\bdcDec.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\hash\hashPtr.h
SOURCE=.\src\aig\bdc\bdcInt.h
# End Source File
# End Group
# End Group
# Begin Group "phys"
# PROP Default_Filter ""
# Begin Group "place"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\phys\place\libhmetis.h
SOURCE=.\src\aig\bdc\bdcTable.c
# End Source File
# Begin Source File
# End Group
# Begin Group "aig"
SOURCE=.\src\phys\place\place_base.c
# End Source File
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\phys\place\place_base.h
SOURCE=.\src\aig\aig\aig.h
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_bin.c
SOURCE=.\src\aig\aig\aigCheck.c
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_genqp.c
SOURCE=.\src\aig\aig\aigDfs.c
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_gordian.c
SOURCE=.\src\aig\aig\aigMan.c
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_gordian.h
SOURCE=.\src\aig\aig\aigMem.c
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_legalize.c
SOURCE=.\src\aig\aig\aigObj.c
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_pads.c
SOURCE=.\src\aig\aig\aigOper.c
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_partition.c
SOURCE=.\src\aig\aig\aigSeq.c
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_qpsolver.c
SOURCE=.\src\aig\aig\aigTable.c
# End Source File
# Begin Source File
SOURCE=.\src\phys\place\place_qpsolver.h
SOURCE=.\src\aig\aig\aigUtil.c
# End Source File
# End Group
# End Group
......
......@@ -166,6 +166,8 @@ alias tst6 "r i10_if6.blif; st; ps; r x/rec6_16_.blif; st; rec_start; r i10_
#alias t "r pj/pj1.blif; st; dfraig -v"
#alias t "r c/16/csat_2.bench; st; dfraig -C 100 -v -r"
#alias t "r c/16/csat_147.bench; st; dfraig -C 10 -v -r"
alias t "r i10.blif; st; ps; csweep; ps; cec"
#alias t "r i10.blif; st; ps; csweep; ps; cec"
#alias t "r c/5/csat_777.bench; st; csweep -v"
alias t "r i10.blif; st; drw -v"
/**CFile****************************************************************
FileName [aig.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [AIG package.]
Synopsis [External declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: aig.h,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef __AIG_H__
#define __AIG_H__
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include "vec.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
typedef struct Aig_Man_t_ Aig_Man_t;
typedef struct Aig_Obj_t_ Aig_Obj_t;
typedef struct Aig_MmFixed_t_ Aig_MmFixed_t;
typedef struct Aig_MmFlex_t_ Aig_MmFlex_t;
typedef struct Aig_MmStep_t_ Aig_MmStep_t;
// object types
typedef enum {
AIG_OBJ_NONE, // 0: non-existent object
AIG_OBJ_CONST1, // 1: constant 1
AIG_OBJ_PI, // 2: primary input
AIG_OBJ_PO, // 3: primary output
AIG_OBJ_BUF, // 4: buffer node
AIG_OBJ_AND, // 5: AND node
AIG_OBJ_EXOR, // 6: EXOR node
AIG_OBJ_LATCH, // 7: latch
AIG_OBJ_VOID // 8: unused object
} Aig_Type_t;
// the AIG node
struct Aig_Obj_t_ // 8 words
{
void * pData; // misc (cuts, copy, etc)
Aig_Obj_t * pNext; // strashing table
Aig_Obj_t * pFanin0; // fanin
Aig_Obj_t * pFanin1; // fanin
unsigned long Type : 3; // object type
unsigned long fPhase : 1; // value under 000...0 pattern
unsigned long fMarkA : 1; // multipurpose mask
unsigned long fMarkB : 1; // multipurpose mask
unsigned long nRefs : 26; // reference count
unsigned Level : 24; // the level of this node
unsigned nCuts : 8; // the number of cuts
int TravId; // unique ID of last traversal involving the node
int Id; // unique ID of the node
};
// the AIG manager
struct Aig_Man_t_
{
// AIG nodes
Vec_Ptr_t * vPis; // the array of PIs
Vec_Ptr_t * vPos; // the array of POs
Vec_Ptr_t * vObjs; // the array of all nodes (optional)
Aig_Obj_t * pConst1; // the constant 1 node
Aig_Obj_t Ghost; // the ghost node
// AIG node counters
int nObjs[AIG_OBJ_VOID];// the number of objects by type
int nCreated; // the number of created objects
int nDeleted; // the number of deleted objects
// structural hash table
Aig_Obj_t ** pTable; // structural hash table
int nTableSize; // structural hash table size
// various data members
Aig_MmFixed_t * pMemObjs; // memory manager for objects
Vec_Int_t * vRequired; // the required times
int nLevelMax; // maximum number of levels
void * pData; // the temporary data
int nTravIds; // the current traversal ID
int fCatchExor; // enables EXOR nodes
// timing statistics
int time1;
int time2;
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
#define AIG_MIN(a,b) (((a) < (b))? (a) : (b))
#define AIG_MAX(a,b) (((a) > (b))? (a) : (b))
#define AIG_INFINITY (100000000)
#ifndef PRT
#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))
#endif
static inline int Aig_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); }
static inline int Aig_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
static inline int Aig_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
static inline void Aig_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); }
static inline void Aig_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); }
static inline unsigned Aig_ObjCutSign( unsigned ObjId ) { return (1 << (ObjId & 31)); }
static inline Aig_Obj_t * Aig_Regular( Aig_Obj_t * p ) { return (Aig_Obj_t *)((unsigned long)(p) & ~01); }
static inline Aig_Obj_t * Aig_Not( Aig_Obj_t * p ) { return (Aig_Obj_t *)((unsigned long)(p) ^ 01); }
static inline Aig_Obj_t * Aig_NotCond( Aig_Obj_t * p, int c ) { return (Aig_Obj_t *)((unsigned long)(p) ^ (c)); }
static inline int Aig_IsComplement( Aig_Obj_t * p ) { return (int )(((unsigned long)p) & 01); }
static inline Aig_Obj_t * Aig_ManConst0( Aig_Man_t * p ) { return Aig_Not(p->pConst1); }
static inline Aig_Obj_t * Aig_ManConst1( Aig_Man_t * p ) { return p->pConst1; }
static inline Aig_Obj_t * Aig_ManGhost( Aig_Man_t * p ) { return &p->Ghost; }
static inline Aig_Obj_t * Aig_ManPi( Aig_Man_t * p, int i ) { return (Aig_Obj_t *)Vec_PtrEntry(p->vPis, i); }
static inline Aig_Obj_t * Aig_ManPo( Aig_Man_t * p, int i ) { return (Aig_Obj_t *)Vec_PtrEntry(p->vPos, i); }
static inline Aig_Obj_t * Aig_ManObj( Aig_Man_t * p, int i ) { return p->vObjs ? (Aig_Obj_t *)Vec_PtrEntry(p->vObjs, i) : NULL; }
static inline int Aig_ManPiNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_PI]; }
static inline int Aig_ManPoNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_PO]; }
static inline int Aig_ManBufNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_BUF]; }
static inline int Aig_ManAndNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_AND]; }
static inline int Aig_ManExorNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_EXOR]; }
static inline int Aig_ManLatchNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_LATCH]; }
static inline int Aig_ManNodeNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_AND]+p->nObjs[AIG_OBJ_EXOR]; }
static inline int Aig_ManGetCost( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_AND]+3*p->nObjs[AIG_OBJ_EXOR]; }
static inline int Aig_ManObjNum( Aig_Man_t * p ) { return p->nCreated - p->nDeleted; }
static inline int Aig_ManObjIdMax( Aig_Man_t * p ) { return Vec_PtrSize(p->vObjs); }
static inline Aig_Type_t Aig_ObjType( Aig_Obj_t * pObj ) { return (Aig_Type_t)pObj->Type; }
static inline int Aig_ObjIsNone( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_NONE; }
static inline int Aig_ObjIsConst1( Aig_Obj_t * pObj ) { assert(!Aig_IsComplement(pObj)); return pObj->Type == AIG_OBJ_CONST1; }
static inline int Aig_ObjIsPi( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_PI; }
static inline int Aig_ObjIsPo( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_PO; }
static inline int Aig_ObjIsBuf( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_BUF; }
static inline int Aig_ObjIsAnd( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_AND; }
static inline int Aig_ObjIsExor( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_EXOR; }
static inline int Aig_ObjIsLatch( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_LATCH; }
static inline int Aig_ObjIsNode( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_AND || pObj->Type == AIG_OBJ_EXOR; }
static inline int Aig_ObjIsTerm( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_PI || pObj->Type == AIG_OBJ_PO || pObj->Type == AIG_OBJ_CONST1; }
static inline int Aig_ObjIsHash( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_AND || pObj->Type == AIG_OBJ_EXOR || pObj->Type == AIG_OBJ_LATCH; }
static inline int Aig_ObjIsMarkA( Aig_Obj_t * pObj ) { return pObj->fMarkA; }
static inline void Aig_ObjSetMarkA( Aig_Obj_t * pObj ) { pObj->fMarkA = 1; }
static inline void Aig_ObjClearMarkA( Aig_Obj_t * pObj ) { pObj->fMarkA = 0; }
static inline void Aig_ObjSetTravId( Aig_Obj_t * pObj, int TravId ) { pObj->TravId = TravId; }
static inline void Aig_ObjSetTravIdCurrent( Aig_Man_t * p, Aig_Obj_t * pObj ) { pObj->TravId = p->nTravIds; }
static inline void Aig_ObjSetTravIdPrevious( Aig_Man_t * p, Aig_Obj_t * pObj ) { pObj->TravId = p->nTravIds - 1; }
static inline int Aig_ObjIsTravIdCurrent( Aig_Man_t * p, Aig_Obj_t * pObj ) { return (int)(pObj->TravId == p->nTravIds); }
static inline int Aig_ObjIsTravIdPrevious( Aig_Man_t * p, Aig_Obj_t * pObj ) { return (int)(pObj->TravId == p->nTravIds - 1); }
static inline int Aig_ObjTravId( Aig_Obj_t * pObj ) { return (int)pObj->pData; }
static inline int Aig_ObjPhase( Aig_Obj_t * pObj ) { return pObj->fPhase; }
static inline int Aig_ObjRefs( Aig_Obj_t * pObj ) { return pObj->nRefs; }
static inline void Aig_ObjRef( Aig_Obj_t * pObj ) { pObj->nRefs++; }
static inline void Aig_ObjDeref( Aig_Obj_t * pObj ) { assert( pObj->nRefs > 0 ); pObj->nRefs--; }
static inline void Aig_ObjClearRef( Aig_Obj_t * pObj ) { pObj->nRefs = 0; }
static inline int Aig_ObjFaninC0( Aig_Obj_t * pObj ) { return Aig_IsComplement(pObj->pFanin0); }
static inline int Aig_ObjFaninC1( Aig_Obj_t * pObj ) { return Aig_IsComplement(pObj->pFanin1); }
static inline Aig_Obj_t * Aig_ObjFanin0( Aig_Obj_t * pObj ) { return Aig_Regular(pObj->pFanin0); }
static inline Aig_Obj_t * Aig_ObjFanin1( Aig_Obj_t * pObj ) { return Aig_Regular(pObj->pFanin1); }
static inline Aig_Obj_t * Aig_ObjChild0( Aig_Obj_t * pObj ) { return pObj->pFanin0; }
static inline Aig_Obj_t * Aig_ObjChild1( Aig_Obj_t * pObj ) { return pObj->pFanin1; }
static inline Aig_Obj_t * Aig_ObjChild0Copy( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj)) : NULL; }
static inline Aig_Obj_t * Aig_ObjChild1Copy( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin1(pObj)->pData, Aig_ObjFaninC1(pObj)) : NULL; }
static inline int Aig_ObjLevel( Aig_Obj_t * pObj ) { return pObj->nRefs; }
static inline int Aig_ObjLevelNew( Aig_Obj_t * pObj ) { return 1 + Aig_ObjIsExor(pObj) + AIG_MAX(Aig_ObjFanin0(pObj)->Level, Aig_ObjFanin1(pObj)->Level); }
static inline int Aig_ObjFaninPhase( Aig_Obj_t * pObj ) { return Aig_Regular(pObj)->fPhase ^ Aig_IsComplement(pObj); }
static inline void Aig_ObjClean( Aig_Obj_t * pObj ) { memset( pObj, 0, sizeof(Aig_Obj_t) ); }
static inline int Aig_ObjWhatFanin( Aig_Obj_t * pObj, Aig_Obj_t * pFanin )
{
if ( Aig_ObjFanin0(pObj) == pFanin ) return 0;
if ( Aig_ObjFanin1(pObj) == pFanin ) return 1;
assert(0); return -1;
}
static inline int Aig_ObjFanoutC( Aig_Obj_t * pObj, Aig_Obj_t * pFanout )
{
if ( Aig_ObjFanin0(pFanout) == pObj ) return Aig_ObjFaninC0(pObj);
if ( Aig_ObjFanin1(pFanout) == pObj ) return Aig_ObjFaninC1(pObj);
assert(0); return -1;
}
// create the ghost of the new node
static inline Aig_Obj_t * Aig_ObjCreateGhost( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1, Aig_Type_t Type )
{
Aig_Obj_t * pGhost;
assert( Type != AIG_OBJ_AND || !Aig_ObjIsConst1(Aig_Regular(p0)) );
assert( p1 == NULL || !Aig_ObjIsConst1(Aig_Regular(p1)) );
assert( Type == AIG_OBJ_PI || Aig_Regular(p0) != Aig_Regular(p1) );
pGhost = Aig_ManGhost(p);
pGhost->Type = Type;
if ( p1 == NULL || Aig_Regular(p0)->Id < Aig_Regular(p1)->Id )
{
pGhost->pFanin0 = p0;
pGhost->pFanin1 = p1;
}
else
{
pGhost->pFanin0 = p1;
pGhost->pFanin1 = p0;
}
return pGhost;
}
// internal memory manager
static inline Aig_Obj_t * Aig_ManFetchMemory( Aig_Man_t * p )
{
extern char * Aig_MmFixedEntryFetch( Aig_MmFixed_t * p );
Aig_Obj_t * pTemp;
pTemp = (Aig_Obj_t *)Aig_MmFixedEntryFetch( p->pMemObjs );
memset( pTemp, 0, sizeof(Aig_Obj_t) );
Vec_PtrPush( p->vObjs, pTemp );
pTemp->Id = p->nCreated++;
return pTemp;
}
static inline void Aig_ManRecycleMemory( Aig_Man_t * p, Aig_Obj_t * pEntry )
{
extern void Aig_MmFixedEntryRecycle( Aig_MmFixed_t * p, char * pEntry );
assert( pEntry->nRefs == 0 );
pEntry->Type = AIG_OBJ_NONE; // distinquishes a dead node from a live node
Aig_MmFixedEntryRecycle( p->pMemObjs, (char *)pEntry );
p->nDeleted++;
}
////////////////////////////////////////////////////////////////////////
/// ITERATORS ///
////////////////////////////////////////////////////////////////////////
// iterator over the primary inputs
#define Aig_ManForEachPi( p, pObj, i ) \
Vec_PtrForEachEntry( p->vPis, pObj, i )
// iterator over the primary outputs
#define Aig_ManForEachPo( p, pObj, i ) \
Vec_PtrForEachEntry( p->vPos, pObj, i )
// iterator over all objects, including those currently not used
#define Aig_ManForEachObj( p, pObj, i ) \
Vec_PtrForEachEntry( p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
// iterator over all nodes
#define Aig_ManForEachNode( p, pObj, i ) \
Vec_PtrForEachEntry( p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsNode(pObj) ) {} else
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== aigCheck.c ========================================================*/
extern int Aig_ManCheck( Aig_Man_t * p );
/*=== aigDfs.c ==========================================================*/
extern Vec_Ptr_t * Aig_ManDfs( Aig_Man_t * p );
extern Vec_Ptr_t * Aig_ManDfsNodes( Aig_Man_t * p, Aig_Obj_t ** ppNodes, int nNodes );
extern int Aig_ManCountLevels( Aig_Man_t * p );
extern void Aig_ManCreateRefs( Aig_Man_t * p );
extern int Aig_DagSize( Aig_Obj_t * pObj );
extern void Aig_ConeUnmark_rec( Aig_Obj_t * pObj );
extern Aig_Obj_t * Aig_Transfer( Aig_Man_t * pSour, Aig_Man_t * pDest, Aig_Obj_t * pObj, int nVars );
extern Aig_Obj_t * Aig_Compose( Aig_Man_t * p, Aig_Obj_t * pRoot, Aig_Obj_t * pFunc, int iVar );
/*=== aigMan.c ==========================================================*/
extern Aig_Man_t * Aig_ManStart();
extern Aig_Man_t * Aig_ManStartFrom( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManDup( Aig_Man_t * p );
extern void Aig_ManStop( Aig_Man_t * p );
extern int Aig_ManCleanup( Aig_Man_t * p );
extern void Aig_ManPrintStats( Aig_Man_t * p );
/*=== aigMem.c ==========================================================*/
extern void Aig_ManStartMemory( Aig_Man_t * p );
extern void Aig_ManStopMemory( Aig_Man_t * p );
/*=== aigObj.c ==========================================================*/
extern Aig_Obj_t * Aig_ObjCreatePi( Aig_Man_t * p );
extern Aig_Obj_t * Aig_ObjCreatePo( Aig_Man_t * p, Aig_Obj_t * pDriver );
extern Aig_Obj_t * Aig_ObjCreate( Aig_Man_t * p, Aig_Obj_t * pGhost );
extern void Aig_ObjConnect( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFan0, Aig_Obj_t * pFan1 );
extern void Aig_ObjDisconnect( Aig_Man_t * p, Aig_Obj_t * pObj );
extern void Aig_ObjDelete( Aig_Man_t * p, Aig_Obj_t * pObj );
extern void Aig_ObjDelete_rec( Aig_Man_t * p, Aig_Obj_t * pObj, int fFreeTop );
extern void Aig_ObjPatchFanin0( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFaninNew );
extern void Aig_ObjReplace( Aig_Man_t * p, Aig_Obj_t * pObjOld, Aig_Obj_t * pObjNew, int fNodesOnly );
/*=== aigOper.c =========================================================*/
extern Aig_Obj_t * Aig_IthVar( Aig_Man_t * p, int i );
extern Aig_Obj_t * Aig_Oper( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1, Aig_Type_t Type );
extern Aig_Obj_t * Aig_And( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 );
extern Aig_Obj_t * Aig_Latch( Aig_Man_t * p, Aig_Obj_t * pObj, int fInitOne );
extern Aig_Obj_t * Aig_Or( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 );
extern Aig_Obj_t * Aig_Exor( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 );
extern Aig_Obj_t * Aig_Mux( Aig_Man_t * p, Aig_Obj_t * pC, Aig_Obj_t * p1, Aig_Obj_t * p0 );
extern Aig_Obj_t * Aig_Maj( Aig_Man_t * p, Aig_Obj_t * pA, Aig_Obj_t * pB, Aig_Obj_t * pC );
extern Aig_Obj_t * Aig_Miter( Aig_Man_t * p, Vec_Ptr_t * vPairs );
extern Aig_Obj_t * Aig_CreateAnd( Aig_Man_t * p, int nVars );
extern Aig_Obj_t * Aig_CreateOr( Aig_Man_t * p, int nVars );
extern Aig_Obj_t * Aig_CreateExor( Aig_Man_t * p, int nVars );
/*=== aigSeq.c ========================================================*/
extern int Aig_ManSeqStrash( Aig_Man_t * p, int nLatches, int * pInits );
/*=== aigTable.c ========================================================*/
extern Aig_Obj_t * Aig_TableLookup( Aig_Man_t * p, Aig_Obj_t * pGhost );
extern void Aig_TableInsert( Aig_Man_t * p, Aig_Obj_t * pObj );
extern void Aig_TableDelete( Aig_Man_t * p, Aig_Obj_t * pObj );
extern int Aig_TableCountEntries( Aig_Man_t * p );
extern void Aig_TableProfile( Aig_Man_t * p );
/*=== aigUtil.c =========================================================*/
extern unsigned Aig_PrimeCudd( unsigned p );
extern void Aig_ManIncrementTravId( Aig_Man_t * p );
extern int Aig_ManLevels( Aig_Man_t * p );
extern void Aig_ManCleanData( Aig_Man_t * p );
extern void Aig_ObjCleanData_rec( Aig_Obj_t * pObj );
extern void Aig_ObjCollectMulti( Aig_Obj_t * pFunc, Vec_Ptr_t * vSuper );
extern int Aig_ObjIsMuxType( Aig_Obj_t * pObj );
extern int Aig_ObjRecognizeExor( Aig_Obj_t * pObj, Aig_Obj_t ** ppFan0, Aig_Obj_t ** ppFan1 );
extern Aig_Obj_t * Aig_ObjRecognizeMux( Aig_Obj_t * pObj, Aig_Obj_t ** ppObjT, Aig_Obj_t ** ppObjE );
extern Aig_Obj_t * Aig_ObjReal_rec( Aig_Obj_t * pObj );
extern void Aig_ObjPrintEqn( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, int Level );
extern void Aig_ObjPrintVerilog( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, int Level );
extern void Aig_ObjPrintVerbose( Aig_Obj_t * pObj, int fHaig );
extern void Aig_ManPrintVerbose( Aig_Man_t * p, int fHaig );
extern void Aig_ManDumpBlif( Aig_Man_t * p, char * pFileName );
/*=== aigMem.c ===========================================================*/
// fixed-size-block memory manager
extern Aig_MmFixed_t * Aig_MmFixedStart( int nEntrySize, int nEntriesMax );
extern void Aig_MmFixedStop( Aig_MmFixed_t * p, int fVerbose );
extern char * Aig_MmFixedEntryFetch( Aig_MmFixed_t * p );
extern void Aig_MmFixedEntryRecycle( Aig_MmFixed_t * p, char * pEntry );
extern void Aig_MmFixedRestart( Aig_MmFixed_t * p );
extern int Aig_MmFixedReadMemUsage( Aig_MmFixed_t * p );
extern int Aig_MmFixedReadMaxEntriesUsed( Aig_MmFixed_t * p );
// flexible-size-block memory manager
extern Aig_MmFlex_t * Aig_MmFlexStart();
extern void Aig_MmFlexStop( Aig_MmFlex_t * p, int fVerbose );
extern char * Aig_MmFlexEntryFetch( Aig_MmFlex_t * p, int nBytes );
extern void Aig_MmFlexRestart( Aig_MmFlex_t * p );
extern int Aig_MmFlexReadMemUsage( Aig_MmFlex_t * p );
// hierarchical memory manager
extern Aig_MmStep_t * Aig_MmStepStart( int nSteps );
extern void Aig_MmStepStop( Aig_MmStep_t * p, int fVerbose );
extern char * Aig_MmStepEntryFetch( Aig_MmStep_t * p, int nBytes );
extern void Aig_MmStepEntryRecycle( Aig_MmStep_t * p, char * pEntry, int nBytes );
extern int Aig_MmStepReadMemUsage( Aig_MmStep_t * p );
#ifdef __cplusplus
}
#endif
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [darCheck.c]
FileName [aigCheck.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting.]
PackageName [AIG package.]
Synopsis [AIG checking procedures.]
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: darCheck.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
Revision [$Id: aigCheck.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#include "dar.h"
#include "aig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -39,77 +39,77 @@
SeeAlso []
***********************************************************************/
int Dar_ManCheck( Dar_Man_t * p )
int Aig_ManCheck( Aig_Man_t * p )
{
Dar_Obj_t * pObj, * pObj2;
Aig_Obj_t * pObj, * pObj2;
int i;
// check primary inputs
Dar_ManForEachPi( p, pObj, i )
Aig_ManForEachPi( p, pObj, i )
{
if ( Dar_ObjFanin0(pObj) || Dar_ObjFanin1(pObj) )
if ( Aig_ObjFanin0(pObj) || Aig_ObjFanin1(pObj) )
{
printf( "Dar_ManCheck: The PI node \"%p\" has fanins.\n", pObj );
printf( "Aig_ManCheck: The PI node \"%p\" has fanins.\n", pObj );
return 0;
}
}
// check primary outputs
Dar_ManForEachPo( p, pObj, i )
Aig_ManForEachPo( p, pObj, i )
{
if ( !Dar_ObjFanin0(pObj) )
if ( !Aig_ObjFanin0(pObj) )
{
printf( "Dar_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj );
printf( "Aig_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj );
return 0;
}
if ( Dar_ObjFanin1(pObj) )
if ( Aig_ObjFanin1(pObj) )
{
printf( "Dar_ManCheck: The PO node \"%p\" has second fanin.\n", pObj );
printf( "Aig_ManCheck: The PO node \"%p\" has second fanin.\n", pObj );
return 0;
}
}
// check internal nodes
Dar_ManForEachObj( p, pObj, i )
Aig_ManForEachObj( p, pObj, i )
{
if ( !Dar_ObjIsNode(pObj) )
if ( !Aig_ObjIsNode(pObj) )
continue;
if ( !Dar_ObjFanin0(pObj) || !Dar_ObjFanin1(pObj) )
if ( !Aig_ObjFanin0(pObj) || !Aig_ObjFanin1(pObj) )
{
printf( "Dar_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj );
printf( "Aig_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj );
return 0;
}
if ( Dar_ObjFanin0(pObj)->Id >= Dar_ObjFanin1(pObj)->Id )
if ( Aig_ObjFanin0(pObj)->Id >= Aig_ObjFanin1(pObj)->Id )
{
printf( "Dar_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj );
printf( "Aig_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj );
return 0;
}
pObj2 = Dar_TableLookup( p, pObj );
pObj2 = Aig_TableLookup( p, pObj );
if ( pObj2 != pObj )
{
printf( "Dar_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj );
printf( "Aig_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj );
return 0;
}
}
// count the total number of nodes
if ( Dar_ManObjNum(p) != 1 + Dar_ManPiNum(p) + Dar_ManPoNum(p) + Dar_ManBufNum(p) + Dar_ManAndNum(p) + Dar_ManExorNum(p) + Dar_ManLatchNum(p) )
if ( Aig_ManObjNum(p) != 1 + Aig_ManPiNum(p) + Aig_ManPoNum(p) + Aig_ManBufNum(p) + Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) )
{
printf( "Dar_ManCheck: The number of created nodes is wrong.\n" );
printf( "Aig_ManCheck: The number of created nodes is wrong.\n" );
printf( "C1 = %d. Pi = %d. Po = %d. Buf = %d. And = %d. Xor = %d. Lat = %d. Total = %d.\n",
1, Dar_ManPiNum(p), Dar_ManPoNum(p), Dar_ManBufNum(p), Dar_ManAndNum(p), Dar_ManExorNum(p), Dar_ManLatchNum(p),
1 + Dar_ManPiNum(p) + Dar_ManPoNum(p) + Dar_ManBufNum(p) + Dar_ManAndNum(p) + Dar_ManExorNum(p) + Dar_ManLatchNum(p) );
1, Aig_ManPiNum(p), Aig_ManPoNum(p), Aig_ManBufNum(p), Aig_ManAndNum(p), Aig_ManExorNum(p), Aig_ManLatchNum(p),
1 + Aig_ManPiNum(p) + Aig_ManPoNum(p) + Aig_ManBufNum(p) + Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) );
printf( "Created = %d. Deleted = %d. Existing = %d.\n",
p->nCreated, p->nDeleted, p->nCreated - p->nDeleted );
return 0;
}
// count the number of nodes in the table
if ( Dar_TableCountEntries(p) != Dar_ManAndNum(p) + Dar_ManExorNum(p) + Dar_ManLatchNum(p) )
if ( Aig_TableCountEntries(p) != Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) )
{
printf( "Dar_ManCheck: The number of nodes in the structural hashing table is wrong.\n" );
printf( "Aig_ManCheck: The number of nodes in the structural hashing table is wrong.\n" );
printf( "Entries = %d. And = %d. Xor = %d. Lat = %d. Total = %d.\n",
Dar_TableCountEntries(p), Dar_ManAndNum(p), Dar_ManExorNum(p), Dar_ManLatchNum(p),
Dar_ManAndNum(p) + Dar_ManExorNum(p) + Dar_ManLatchNum(p) );
Aig_TableCountEntries(p), Aig_ManAndNum(p), Aig_ManExorNum(p), Aig_ManLatchNum(p),
Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) );
return 0;
}
// if ( !Dar_ManIsAcyclic(p) )
// if ( !Aig_ManIsAcyclic(p) )
// return 0;
return 1;
}
......
/**CFile****************************************************************
FileName [darDfs.c]
FileName [aigDfs.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting.]
PackageName [AIG package.]
Synopsis [DFS traversal procedures.]
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: darDfs.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
Revision [$Id: aigDfs.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#include "dar.h"
#include "aig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -39,18 +39,18 @@
SeeAlso []
***********************************************************************/
void Dar_ManDfs_rec( Dar_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vNodes )
void Aig_ManDfs_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vNodes )
{
assert( !Dar_IsComplement(pObj) );
assert( !Aig_IsComplement(pObj) );
if ( pObj == NULL )
return;
if ( Dar_ObjIsTravIdCurrent(p, pObj) )
if ( Aig_ObjIsTravIdCurrent(p, pObj) )
return;
assert( Dar_ObjIsNode(pObj) || Dar_ObjIsBuf(pObj) );
Dar_ManDfs_rec( p, Dar_ObjFanin0(pObj), vNodes );
Dar_ManDfs_rec( p, Dar_ObjFanin1(pObj), vNodes );
assert( !Dar_ObjIsTravIdCurrent(p, pObj) ); // loop detection
Dar_ObjSetTravIdCurrent(p, pObj);
assert( Aig_ObjIsNode(pObj) || Aig_ObjIsBuf(pObj) );
Aig_ManDfs_rec( p, Aig_ObjFanin0(pObj), vNodes );
Aig_ManDfs_rec( p, Aig_ObjFanin1(pObj), vNodes );
assert( !Aig_ObjIsTravIdCurrent(p, pObj) ); // loop detection
Aig_ObjSetTravIdCurrent(p, pObj);
Vec_PtrPush( vNodes, pObj );
}
......@@ -65,26 +65,26 @@ void Dar_ManDfs_rec( Dar_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vNodes )
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Dar_ManDfs( Dar_Man_t * p )
Vec_Ptr_t * Aig_ManDfs( Aig_Man_t * p )
{
Vec_Ptr_t * vNodes;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
Dar_ManIncrementTravId( p );
Aig_ManIncrementTravId( p );
// mark constant and PIs
Dar_ObjSetTravIdCurrent( p, Dar_ManConst1(p) );
Dar_ManForEachPi( p, pObj, i )
Dar_ObjSetTravIdCurrent( p, pObj );
Aig_ObjSetTravIdCurrent( p, Aig_ManConst1(p) );
Aig_ManForEachPi( p, pObj, i )
Aig_ObjSetTravIdCurrent( p, pObj );
// if there are latches, mark them
if ( Dar_ManLatchNum(p) > 0 )
Dar_ManForEachObj( p, pObj, i )
if ( Dar_ObjIsLatch(pObj) )
Dar_ObjSetTravIdCurrent( p, pObj );
if ( Aig_ManLatchNum(p) > 0 )
Aig_ManForEachObj( p, pObj, i )
if ( Aig_ObjIsLatch(pObj) )
Aig_ObjSetTravIdCurrent( p, pObj );
// go through the nodes
vNodes = Vec_PtrAlloc( Dar_ManNodeNum(p) );
Dar_ManForEachObj( p, pObj, i )
if ( Dar_ObjIsNode(pObj) || Dar_ObjIsBuf(pObj) )
Dar_ManDfs_rec( p, pObj, vNodes );
vNodes = Vec_PtrAlloc( Aig_ManNodeNum(p) );
Aig_ManForEachObj( p, pObj, i )
if ( Aig_ObjIsNode(pObj) || Aig_ObjIsBuf(pObj) )
Aig_ManDfs_rec( p, pObj, vNodes );
return vNodes;
}
......@@ -99,21 +99,21 @@ Vec_Ptr_t * Dar_ManDfs( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Dar_ManDfsNodes( Dar_Man_t * p, Dar_Obj_t ** ppNodes, int nNodes )
Vec_Ptr_t * Aig_ManDfsNodes( Aig_Man_t * p, Aig_Obj_t ** ppNodes, int nNodes )
{
Vec_Ptr_t * vNodes;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
assert( Dar_ManLatchNum(p) == 0 );
Dar_ManIncrementTravId( p );
assert( Aig_ManLatchNum(p) == 0 );
Aig_ManIncrementTravId( p );
// mark constant and PIs
Dar_ObjSetTravIdCurrent( p, Dar_ManConst1(p) );
Dar_ManForEachPi( p, pObj, i )
Dar_ObjSetTravIdCurrent( p, pObj );
Aig_ObjSetTravIdCurrent( p, Aig_ManConst1(p) );
Aig_ManForEachPi( p, pObj, i )
Aig_ObjSetTravIdCurrent( p, pObj );
// go through the nodes
vNodes = Vec_PtrAlloc( Dar_ManNodeNum(p) );
vNodes = Vec_PtrAlloc( Aig_ManNodeNum(p) );
for ( i = 0; i < nNodes; i++ )
Dar_ManDfs_rec( p, ppNodes[i], vNodes );
Aig_ManDfs_rec( p, ppNodes[i], vNodes );
return vNodes;
}
......@@ -128,28 +128,28 @@ Vec_Ptr_t * Dar_ManDfsNodes( Dar_Man_t * p, Dar_Obj_t ** ppNodes, int nNodes )
SeeAlso []
***********************************************************************/
int Dar_ManCountLevels( Dar_Man_t * p )
int Aig_ManCountLevels( Aig_Man_t * p )
{
Vec_Ptr_t * vNodes;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i, LevelsMax, Level0, Level1;
// initialize the levels
Dar_ManConst1(p)->pData = NULL;
Dar_ManForEachPi( p, pObj, i )
Aig_ManConst1(p)->pData = NULL;
Aig_ManForEachPi( p, pObj, i )
pObj->pData = NULL;
// compute levels in a DFS order
vNodes = Dar_ManDfs( p );
vNodes = Aig_ManDfs( p );
Vec_PtrForEachEntry( vNodes, pObj, i )
{
Level0 = (int)Dar_ObjFanin0(pObj)->pData;
Level1 = (int)Dar_ObjFanin1(pObj)->pData;
pObj->pData = (void *)(1 + Dar_ObjIsExor(pObj) + DAR_MAX(Level0, Level1));
Level0 = (int)Aig_ObjFanin0(pObj)->pData;
Level1 = (int)Aig_ObjFanin1(pObj)->pData;
pObj->pData = (void *)(1 + Aig_ObjIsExor(pObj) + AIG_MAX(Level0, Level1));
}
Vec_PtrFree( vNodes );
// get levels of the POs
LevelsMax = 0;
Dar_ManForEachPo( p, pObj, i )
LevelsMax = DAR_MAX( LevelsMax, (int)Dar_ObjFanin0(pObj)->pData );
Aig_ManForEachPo( p, pObj, i )
LevelsMax = AIG_MAX( LevelsMax, (int)Aig_ObjFanin0(pObj)->pData );
return LevelsMax;
}
......@@ -164,15 +164,15 @@ int Dar_ManCountLevels( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
void Dar_ConeMark_rec( Dar_Obj_t * pObj )
void Aig_ConeMark_rec( Aig_Obj_t * pObj )
{
assert( !Dar_IsComplement(pObj) );
if ( !Dar_ObjIsNode(pObj) || Dar_ObjIsMarkA(pObj) )
assert( !Aig_IsComplement(pObj) );
if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
return;
Dar_ConeMark_rec( Dar_ObjFanin0(pObj) );
Dar_ConeMark_rec( Dar_ObjFanin1(pObj) );
assert( !Dar_ObjIsMarkA(pObj) ); // loop detection
Dar_ObjSetMarkA( pObj );
Aig_ConeMark_rec( Aig_ObjFanin0(pObj) );
Aig_ConeMark_rec( Aig_ObjFanin1(pObj) );
assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
Aig_ObjSetMarkA( pObj );
}
/**Function*************************************************************
......@@ -186,15 +186,15 @@ void Dar_ConeMark_rec( Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Dar_ConeCleanAndMark_rec( Dar_Obj_t * pObj )
void Aig_ConeCleanAndMark_rec( Aig_Obj_t * pObj )
{
assert( !Dar_IsComplement(pObj) );
if ( !Dar_ObjIsNode(pObj) || Dar_ObjIsMarkA(pObj) )
assert( !Aig_IsComplement(pObj) );
if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
return;
Dar_ConeCleanAndMark_rec( Dar_ObjFanin0(pObj) );
Dar_ConeCleanAndMark_rec( Dar_ObjFanin1(pObj) );
assert( !Dar_ObjIsMarkA(pObj) ); // loop detection
Dar_ObjSetMarkA( pObj );
Aig_ConeCleanAndMark_rec( Aig_ObjFanin0(pObj) );
Aig_ConeCleanAndMark_rec( Aig_ObjFanin1(pObj) );
assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
Aig_ObjSetMarkA( pObj );
pObj->pData = NULL;
}
......@@ -209,16 +209,16 @@ void Dar_ConeCleanAndMark_rec( Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
int Dar_ConeCountAndMark_rec( Dar_Obj_t * pObj )
int Aig_ConeCountAndMark_rec( Aig_Obj_t * pObj )
{
int Counter;
assert( !Dar_IsComplement(pObj) );
if ( !Dar_ObjIsNode(pObj) || Dar_ObjIsMarkA(pObj) )
assert( !Aig_IsComplement(pObj) );
if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
return 0;
Counter = 1 + Dar_ConeCountAndMark_rec( Dar_ObjFanin0(pObj) ) +
Dar_ConeCountAndMark_rec( Dar_ObjFanin1(pObj) );
assert( !Dar_ObjIsMarkA(pObj) ); // loop detection
Dar_ObjSetMarkA( pObj );
Counter = 1 + Aig_ConeCountAndMark_rec( Aig_ObjFanin0(pObj) ) +
Aig_ConeCountAndMark_rec( Aig_ObjFanin1(pObj) );
assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
Aig_ObjSetMarkA( pObj );
return Counter;
}
......@@ -233,15 +233,15 @@ int Dar_ConeCountAndMark_rec( Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Dar_ConeUnmark_rec( Dar_Obj_t * pObj )
void Aig_ConeUnmark_rec( Aig_Obj_t * pObj )
{
assert( !Dar_IsComplement(pObj) );
if ( !Dar_ObjIsNode(pObj) || !Dar_ObjIsMarkA(pObj) )
assert( !Aig_IsComplement(pObj) );
if ( !Aig_ObjIsNode(pObj) || !Aig_ObjIsMarkA(pObj) )
return;
Dar_ConeUnmark_rec( Dar_ObjFanin0(pObj) );
Dar_ConeUnmark_rec( Dar_ObjFanin1(pObj) );
assert( Dar_ObjIsMarkA(pObj) ); // loop detection
Dar_ObjClearMarkA( pObj );
Aig_ConeUnmark_rec( Aig_ObjFanin0(pObj) );
Aig_ConeUnmark_rec( Aig_ObjFanin1(pObj) );
assert( Aig_ObjIsMarkA(pObj) ); // loop detection
Aig_ObjClearMarkA( pObj );
}
/**Function*************************************************************
......@@ -255,11 +255,11 @@ void Dar_ConeUnmark_rec( Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
int Dar_DagSize( Dar_Obj_t * pObj )
int Aig_DagSize( Aig_Obj_t * pObj )
{
int Counter;
Counter = Dar_ConeCountAndMark_rec( Dar_Regular(pObj) );
Dar_ConeUnmark_rec( Dar_Regular(pObj) );
Counter = Aig_ConeCountAndMark_rec( Aig_Regular(pObj) );
Aig_ConeUnmark_rec( Aig_Regular(pObj) );
return Counter;
}
......@@ -274,16 +274,16 @@ int Dar_DagSize( Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Dar_Transfer_rec( Dar_Man_t * pDest, Dar_Obj_t * pObj )
void Aig_Transfer_rec( Aig_Man_t * pDest, Aig_Obj_t * pObj )
{
assert( !Dar_IsComplement(pObj) );
if ( !Dar_ObjIsNode(pObj) || Dar_ObjIsMarkA(pObj) )
assert( !Aig_IsComplement(pObj) );
if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
return;
Dar_Transfer_rec( pDest, Dar_ObjFanin0(pObj) );
Dar_Transfer_rec( pDest, Dar_ObjFanin1(pObj) );
pObj->pData = Dar_And( pDest, Dar_ObjChild0Copy(pObj), Dar_ObjChild1Copy(pObj) );
assert( !Dar_ObjIsMarkA(pObj) ); // loop detection
Dar_ObjSetMarkA( pObj );
Aig_Transfer_rec( pDest, Aig_ObjFanin0(pObj) );
Aig_Transfer_rec( pDest, Aig_ObjFanin1(pObj) );
pObj->pData = Aig_And( pDest, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
Aig_ObjSetMarkA( pObj );
}
/**Function*************************************************************
......@@ -297,27 +297,27 @@ void Dar_Transfer_rec( Dar_Man_t * pDest, Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Transfer( Dar_Man_t * pSour, Dar_Man_t * pDest, Dar_Obj_t * pRoot, int nVars )
Aig_Obj_t * Aig_Transfer( Aig_Man_t * pSour, Aig_Man_t * pDest, Aig_Obj_t * pRoot, int nVars )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
// solve simple cases
if ( pSour == pDest )
return pRoot;
if ( Dar_ObjIsConst1( Dar_Regular(pRoot) ) )
return Dar_NotCond( Dar_ManConst1(pDest), Dar_IsComplement(pRoot) );
if ( Aig_ObjIsConst1( Aig_Regular(pRoot) ) )
return Aig_NotCond( Aig_ManConst1(pDest), Aig_IsComplement(pRoot) );
// set the PI mapping
Dar_ManForEachPi( pSour, pObj, i )
Aig_ManForEachPi( pSour, pObj, i )
{
if ( i == nVars )
break;
pObj->pData = Dar_IthVar(pDest, i);
pObj->pData = Aig_IthVar(pDest, i);
}
// transfer and set markings
Dar_Transfer_rec( pDest, Dar_Regular(pRoot) );
Aig_Transfer_rec( pDest, Aig_Regular(pRoot) );
// clear the markings
Dar_ConeUnmark_rec( Dar_Regular(pRoot) );
return Dar_NotCond( Dar_Regular(pRoot)->pData, Dar_IsComplement(pRoot) );
Aig_ConeUnmark_rec( Aig_Regular(pRoot) );
return Aig_NotCond( Aig_Regular(pRoot)->pData, Aig_IsComplement(pRoot) );
}
/**Function*************************************************************
......@@ -331,21 +331,21 @@ Dar_Obj_t * Dar_Transfer( Dar_Man_t * pSour, Dar_Man_t * pDest, Dar_Obj_t * pRoo
SeeAlso []
***********************************************************************/
void Dar_Compose_rec( Dar_Man_t * p, Dar_Obj_t * pObj, Dar_Obj_t * pFunc, Dar_Obj_t * pVar )
void Aig_Compose_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFunc, Aig_Obj_t * pVar )
{
assert( !Dar_IsComplement(pObj) );
if ( Dar_ObjIsMarkA(pObj) )
assert( !Aig_IsComplement(pObj) );
if ( Aig_ObjIsMarkA(pObj) )
return;
if ( Dar_ObjIsConst1(pObj) || Dar_ObjIsPi(pObj) )
if ( Aig_ObjIsConst1(pObj) || Aig_ObjIsPi(pObj) )
{
pObj->pData = pObj == pVar ? pFunc : pObj;
return;
}
Dar_Compose_rec( p, Dar_ObjFanin0(pObj), pFunc, pVar );
Dar_Compose_rec( p, Dar_ObjFanin1(pObj), pFunc, pVar );
pObj->pData = Dar_And( p, Dar_ObjChild0Copy(pObj), Dar_ObjChild1Copy(pObj) );
assert( !Dar_ObjIsMarkA(pObj) ); // loop detection
Dar_ObjSetMarkA( pObj );
Aig_Compose_rec( p, Aig_ObjFanin0(pObj), pFunc, pVar );
Aig_Compose_rec( p, Aig_ObjFanin1(pObj), pFunc, pVar );
pObj->pData = Aig_And( p, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
Aig_ObjSetMarkA( pObj );
}
/**Function*************************************************************
......@@ -359,19 +359,19 @@ void Dar_Compose_rec( Dar_Man_t * p, Dar_Obj_t * pObj, Dar_Obj_t * pFunc, Dar_Ob
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Compose( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Obj_t * pFunc, int iVar )
Aig_Obj_t * Aig_Compose( Aig_Man_t * p, Aig_Obj_t * pRoot, Aig_Obj_t * pFunc, int iVar )
{
// quit if the PI variable is not defined
if ( iVar >= Dar_ManPiNum(p) )
if ( iVar >= Aig_ManPiNum(p) )
{
printf( "Dar_Compose(): The PI variable %d is not defined.\n", iVar );
printf( "Aig_Compose(): The PI variable %d is not defined.\n", iVar );
return NULL;
}
// recursively perform composition
Dar_Compose_rec( p, Dar_Regular(pRoot), pFunc, Dar_ManPi(p, iVar) );
Aig_Compose_rec( p, Aig_Regular(pRoot), pFunc, Aig_ManPi(p, iVar) );
// clear the markings
Dar_ConeUnmark_rec( Dar_Regular(pRoot) );
return Dar_NotCond( Dar_Regular(pRoot)->pData, Dar_IsComplement(pRoot) );
Aig_ConeUnmark_rec( Aig_Regular(pRoot) );
return Aig_NotCond( Aig_Regular(pRoot)->pData, Aig_IsComplement(pRoot) );
}
////////////////////////////////////////////////////////////////////////
......
/**CFile****************************************************************
FileName [aigMan.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [AIG package.]
Synopsis [AIG manager.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: aigMan.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#include "aig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Starts the AIG manager.]
Description [The argument of this procedure is a soft limit on the
the number of nodes, or 0 if the limit is unknown.]
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Man_t * Aig_ManStart( int nNodesMax )
{
Aig_Man_t * p;
if ( nNodesMax <= 0 )
nNodesMax = 10007;
// start the manager
p = ALLOC( Aig_Man_t, 1 );
memset( p, 0, sizeof(Aig_Man_t) );
// perform initializations
p->nTravIds = 1;
p->fCatchExor = 0;
// allocate arrays for nodes
p->vPis = Vec_PtrAlloc( 100 );
p->vPos = Vec_PtrAlloc( 100 );
p->vObjs = Vec_PtrAlloc( 1000 );
// prepare the internal memory manager
p->pMemObjs = Aig_MmFixedStart( sizeof(Aig_Obj_t), nNodesMax );
// create the constant node
p->pConst1 = Aig_ManFetchMemory( p );
p->pConst1->Type = AIG_OBJ_CONST1;
p->pConst1->fPhase = 1;
p->nObjs[AIG_OBJ_CONST1]++;
// start the table
p->nTableSize = Aig_PrimeCudd( nNodesMax );
p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
return p;
}
/**Function*************************************************************
Synopsis [Duplicates the AIG manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Man_t * Aig_ManStartFrom( Aig_Man_t * p )
{
Aig_Man_t * pNew;
Aig_Obj_t * pObj;
int i;
// create the new manager
pNew = Aig_ManStart( Aig_ManObjIdMax(p) + 1 );
// create the PIs
Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
Aig_ManForEachPi( p, pObj, i )
pObj->pData = Aig_ObjCreatePi(pNew);
return pNew;
}
/**Function*************************************************************
Synopsis [Duplicates the AIG manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Man_t * Aig_ManDup( Aig_Man_t * p )
{
Aig_Man_t * pNew;
Aig_Obj_t * pObj;
int i;
// create the new manager
pNew = Aig_ManStart( Aig_ManObjIdMax(p) + 1 );
// create the PIs
Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
Aig_ManForEachPi( p, pObj, i )
pObj->pData = Aig_ObjCreatePi(pNew);
// duplicate internal nodes
Aig_ManForEachObj( p, pObj, i )
if ( Aig_ObjIsBuf(pObj) )
pObj->pData = Aig_ObjChild0Copy(pObj);
else if ( Aig_ObjIsNode(pObj) )
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
// add the POs
Aig_ManForEachPo( p, pObj, i )
Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
// check the resulting network
if ( !Aig_ManCheck(pNew) )
printf( "Aig_ManDup(): The check has failed.\n" );
return pNew;
}
/**Function*************************************************************
Synopsis [Stops the AIG manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Aig_ManStop( Aig_Man_t * p )
{
Aig_Obj_t * pObj;
int i;
// print time
if ( p->time1 ) { PRT( "time1", p->time1 ); }
if ( p->time2 ) { PRT( "time2", p->time2 ); }
// make sure the nodes have clean marks
Aig_ManForEachObj( p, pObj, i )
assert( !pObj->fMarkA && !pObj->fMarkB );
// Aig_TableProfile( p );
Aig_MmFixedStop( p->pMemObjs, 0 );
if ( p->vPis ) Vec_PtrFree( p->vPis );
if ( p->vPos ) Vec_PtrFree( p->vPos );
if ( p->vObjs ) Vec_PtrFree( p->vObjs );
if ( p->vRequired ) Vec_IntFree( p->vRequired );
free( p->pTable );
free( p );
}
/**Function*************************************************************
Synopsis [Returns the number of dangling nodes removed.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Aig_ManCleanup( Aig_Man_t * p )
{
Vec_Ptr_t * vObjs;
Aig_Obj_t * pNode;
int i, nNodesOld;
nNodesOld = Aig_ManNodeNum(p);
// collect roots of dangling nodes
vObjs = Vec_PtrAlloc( 100 );
Aig_ManForEachObj( p, pNode, i )
if ( Aig_ObjIsNode(pNode) && Aig_ObjRefs(pNode) == 0 )
Vec_PtrPush( vObjs, pNode );
// recursively remove dangling nodes
Vec_PtrForEachEntry( vObjs, pNode, i )
Aig_ObjDelete_rec( p, pNode, 1 );
Vec_PtrFree( vObjs );
return nNodesOld - Aig_ManNodeNum(p);
}
/**Function*************************************************************
Synopsis [Stops the AIG manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Aig_ManPrintStats( Aig_Man_t * p )
{
printf( "PI/PO/Lat = %5d/%5d/%5d ", Aig_ManPiNum(p), Aig_ManPoNum(p), Aig_ManLatchNum(p) );
printf( "A = %6d. ", Aig_ManAndNum(p) );
if ( Aig_ManExorNum(p) )
printf( "X = %5d. ", Aig_ManExorNum(p) );
// if ( Aig_ManBufNum(p) )
printf( "B = %3d. ", Aig_ManBufNum(p) );
printf( "Cre = %6d. ", p->nCreated );
printf( "Del = %6d. ", p->nDeleted );
// printf( "Lev = %3d. ", Aig_ManCountLevels(p) );
printf( "\n" );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
/**CFile****************************************************************
FileName [darMem.c]
FileName [aigMem.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting.]
PackageName [AIG package.]
Synopsis [Memory managers.]
......@@ -14,21 +14,17 @@
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: darMem.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
Revision [$Id: aigMem.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "dar.h"
#include "aig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
struct Dar_MmFixed_t_
struct Aig_MmFixed_t_
{
// information about individual entries
int nEntrySize; // the size of one entry
......@@ -48,7 +44,7 @@ struct Dar_MmFixed_t_
int nMemoryAlloc; // memory allocated
};
struct Dar_MmFlex_t_
struct Aig_MmFlex_t_
{
// information about individual entries
int nEntriesUsed; // the number of entries allocated
......@@ -66,12 +62,12 @@ struct Dar_MmFlex_t_
int nMemoryAlloc; // memory allocated
};
struct Dar_MmStep_t_
struct Aig_MmStep_t_
{
int nMems; // the number of fixed memory managers employed
Dar_MmFixed_t ** pMems; // memory managers: 2^1 words, 2^2 words, etc
Aig_MmFixed_t ** pMems; // memory managers: 2^1 words, 2^2 words, etc
int nMapSize; // the size of the memory array
Dar_MmFixed_t ** pMap; // maps the number of bytes into its memory manager
Aig_MmFixed_t ** pMap; // maps the number of bytes into its memory manager
};
#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))
......@@ -96,12 +92,12 @@ struct Dar_MmStep_t_
SeeAlso []
***********************************************************************/
Dar_MmFixed_t * Dar_MmFixedStart( int nEntrySize, int nEntriesMax )
Aig_MmFixed_t * Aig_MmFixedStart( int nEntrySize, int nEntriesMax )
{
Dar_MmFixed_t * p;
Aig_MmFixed_t * p;
p = ALLOC( Dar_MmFixed_t, 1 );
memset( p, 0, sizeof(Dar_MmFixed_t) );
p = ALLOC( Aig_MmFixed_t, 1 );
memset( p, 0, sizeof(Aig_MmFixed_t) );
p->nEntrySize = nEntrySize;
p->nEntriesAlloc = 0;
......@@ -132,7 +128,7 @@ Dar_MmFixed_t * Dar_MmFixedStart( int nEntrySize, int nEntriesMax )
SeeAlso []
***********************************************************************/
void Dar_MmFixedStop( Dar_MmFixed_t * p, int fVerbose )
void Aig_MmFixedStop( Aig_MmFixed_t * p, int fVerbose )
{
int i;
if ( p == NULL )
......@@ -161,7 +157,7 @@ void Dar_MmFixedStop( Dar_MmFixed_t * p, int fVerbose )
SeeAlso []
***********************************************************************/
char * Dar_MmFixedEntryFetch( Dar_MmFixed_t * p )
char * Aig_MmFixedEntryFetch( Aig_MmFixed_t * p )
{
char * pTemp;
int i;
......@@ -212,7 +208,7 @@ char * Dar_MmFixedEntryFetch( Dar_MmFixed_t * p )
SeeAlso []
***********************************************************************/
void Dar_MmFixedEntryRecycle( Dar_MmFixed_t * p, char * pEntry )
void Aig_MmFixedEntryRecycle( Aig_MmFixed_t * p, char * pEntry )
{
// decrement the counter of used entries
p->nEntriesUsed--;
......@@ -232,7 +228,7 @@ void Dar_MmFixedEntryRecycle( Dar_MmFixed_t * p, char * pEntry )
SeeAlso []
***********************************************************************/
void Dar_MmFixedRestart( Dar_MmFixed_t * p )
void Aig_MmFixedRestart( Aig_MmFixed_t * p )
{
int i;
char * pTemp;
......@@ -270,7 +266,7 @@ void Dar_MmFixedRestart( Dar_MmFixed_t * p )
SeeAlso []
***********************************************************************/
int Dar_MmFixedReadMemUsage( Dar_MmFixed_t * p )
int Aig_MmFixedReadMemUsage( Aig_MmFixed_t * p )
{
return p->nMemoryAlloc;
}
......@@ -286,7 +282,7 @@ int Dar_MmFixedReadMemUsage( Dar_MmFixed_t * p )
SeeAlso []
***********************************************************************/
int Dar_MmFixedReadMaxEntriesUsed( Dar_MmFixed_t * p )
int Aig_MmFixedReadMaxEntriesUsed( Aig_MmFixed_t * p )
{
return p->nEntriesMax;
}
......@@ -304,12 +300,12 @@ int Dar_MmFixedReadMaxEntriesUsed( Dar_MmFixed_t * p )
SeeAlso []
***********************************************************************/
Dar_MmFlex_t * Dar_MmFlexStart()
Aig_MmFlex_t * Aig_MmFlexStart()
{
Dar_MmFlex_t * p;
Aig_MmFlex_t * p;
p = ALLOC( Dar_MmFlex_t, 1 );
memset( p, 0, sizeof(Dar_MmFlex_t) );
p = ALLOC( Aig_MmFlex_t, 1 );
memset( p, 0, sizeof(Aig_MmFlex_t) );
p->nEntriesUsed = 0;
p->pCurrent = NULL;
......@@ -336,7 +332,7 @@ Dar_MmFlex_t * Dar_MmFlexStart()
SeeAlso []
***********************************************************************/
void Dar_MmFlexStop( Dar_MmFlex_t * p, int fVerbose )
void Aig_MmFlexStop( Aig_MmFlex_t * p, int fVerbose )
{
int i;
if ( p == NULL )
......@@ -365,7 +361,7 @@ void Dar_MmFlexStop( Dar_MmFlex_t * p, int fVerbose )
SeeAlso []
***********************************************************************/
char * Dar_MmFlexEntryFetch( Dar_MmFlex_t * p, int nBytes )
char * Aig_MmFlexEntryFetch( Aig_MmFlex_t * p, int nBytes )
{
char * pTemp;
// check if there are still free entries
......@@ -410,7 +406,7 @@ char * Dar_MmFlexEntryFetch( Dar_MmFlex_t * p, int nBytes )
SeeAlso []
***********************************************************************/
void Dar_MmFlexRestart( Dar_MmFlex_t * p )
void Aig_MmFlexRestart( Aig_MmFlex_t * p )
{
int i;
if ( p->nChunks == 0 )
......@@ -438,7 +434,7 @@ void Dar_MmFlexRestart( Dar_MmFlex_t * p )
SeeAlso []
***********************************************************************/
int Dar_MmFlexReadMemUsage( Dar_MmFlex_t * p )
int Aig_MmFlexReadMemUsage( Aig_MmFlex_t * p )
{
return p->nMemoryUsed;
}
......@@ -467,20 +463,20 @@ int Dar_MmFlexReadMemUsage( Dar_MmFlex_t * p )
SeeAlso []
***********************************************************************/
Dar_MmStep_t * Dar_MmStepStart( int nSteps )
Aig_MmStep_t * Aig_MmStepStart( int nSteps )
{
Dar_MmStep_t * p;
Aig_MmStep_t * p;
int i, k;
p = ALLOC( Dar_MmStep_t, 1 );
memset( p, 0, sizeof(Dar_MmStep_t) );
p = ALLOC( Aig_MmStep_t, 1 );
memset( p, 0, sizeof(Aig_MmStep_t) );
p->nMems = nSteps;
// start the fixed memory managers
p->pMems = ALLOC( Dar_MmFixed_t *, p->nMems );
p->pMems = ALLOC( Aig_MmFixed_t *, p->nMems );
for ( i = 0; i < p->nMems; i++ )
p->pMems[i] = Dar_MmFixedStart( (8<<i), (1<<13) );
p->pMems[i] = Aig_MmFixedStart( (8<<i), (1<<13) );
// set up the mapping of the required memory size into the corresponding manager
p->nMapSize = (4<<p->nMems);
p->pMap = ALLOC( Dar_MmFixed_t *, p->nMapSize+1 );
p->pMap = ALLOC( Aig_MmFixed_t *, p->nMapSize+1 );
p->pMap[0] = NULL;
for ( k = 1; k <= 4; k++ )
p->pMap[k] = p->pMems[0];
......@@ -503,11 +499,11 @@ Dar_MmStep_t * Dar_MmStepStart( int nSteps )
SeeAlso []
***********************************************************************/
void Dar_MmStepStop( Dar_MmStep_t * p, int fVerbose )
void Aig_MmStepStop( Aig_MmStep_t * p, int fVerbose )
{
int i;
for ( i = 0; i < p->nMems; i++ )
Dar_MmFixedStop( p->pMems[i], fVerbose );
Aig_MmFixedStop( p->pMems[i], fVerbose );
// if ( p->pLargeChunks )
// {
// for ( i = 0; i < p->nLargeChunks; i++ )
......@@ -530,7 +526,7 @@ void Dar_MmStepStop( Dar_MmStep_t * p, int fVerbose )
SeeAlso []
***********************************************************************/
char * Dar_MmStepEntryFetch( Dar_MmStep_t * p, int nBytes )
char * Aig_MmStepEntryFetch( Aig_MmStep_t * p, int nBytes )
{
if ( nBytes == 0 )
return NULL;
......@@ -550,7 +546,7 @@ char * Dar_MmStepEntryFetch( Dar_MmStep_t * p, int nBytes )
*/
return ALLOC( char, nBytes );
}
return Dar_MmFixedEntryFetch( p->pMap[nBytes] );
return Aig_MmFixedEntryFetch( p->pMap[nBytes] );
}
......@@ -565,7 +561,7 @@ char * Dar_MmStepEntryFetch( Dar_MmStep_t * p, int nBytes )
SeeAlso []
***********************************************************************/
void Dar_MmStepEntryRecycle( Dar_MmStep_t * p, char * pEntry, int nBytes )
void Aig_MmStepEntryRecycle( Aig_MmStep_t * p, char * pEntry, int nBytes )
{
if ( nBytes == 0 )
return;
......@@ -574,7 +570,7 @@ void Dar_MmStepEntryRecycle( Dar_MmStep_t * p, char * pEntry, int nBytes )
free( pEntry );
return;
}
Dar_MmFixedEntryRecycle( p->pMap[nBytes], pEntry );
Aig_MmFixedEntryRecycle( p->pMap[nBytes], pEntry );
}
/**Function*************************************************************
......@@ -588,7 +584,7 @@ void Dar_MmStepEntryRecycle( Dar_MmStep_t * p, char * pEntry, int nBytes )
SeeAlso []
***********************************************************************/
int Dar_MmStepReadMemUsage( Dar_MmStep_t * p )
int Aig_MmStepReadMemUsage( Aig_MmStep_t * p )
{
int i, nMemTotal = 0;
for ( i = 0; i < p->nMems; i++ )
......
/**CFile****************************************************************
FileName [darObj.c]
FileName [aigObj.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting.]
PackageName [AIG package.]
Synopsis [Adding/removing objects.]
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: darObj.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
Revision [$Id: aigObj.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#include "dar.h"
#include "aig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -39,13 +39,13 @@
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_ObjCreatePi( Dar_Man_t * p )
Aig_Obj_t * Aig_ObjCreatePi( Aig_Man_t * p )
{
Dar_Obj_t * pObj;
pObj = Dar_ManFetchMemory( p );
pObj->Type = DAR_AIG_PI;
Aig_Obj_t * pObj;
pObj = Aig_ManFetchMemory( p );
pObj->Type = AIG_OBJ_PI;
Vec_PtrPush( p->vPis, pObj );
p->nObjs[DAR_AIG_PI]++;
p->nObjs[AIG_OBJ_PI]++;
return pObj;
}
......@@ -60,16 +60,16 @@ Dar_Obj_t * Dar_ObjCreatePi( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_ObjCreatePo( Dar_Man_t * p, Dar_Obj_t * pDriver )
Aig_Obj_t * Aig_ObjCreatePo( Aig_Man_t * p, Aig_Obj_t * pDriver )
{
Dar_Obj_t * pObj;
pObj = Dar_ManFetchMemory( p );
pObj->Type = DAR_AIG_PO;
Aig_Obj_t * pObj;
pObj = Aig_ManFetchMemory( p );
pObj->Type = AIG_OBJ_PO;
Vec_PtrPush( p->vPos, pObj );
// add connections
Dar_ObjConnect( p, pObj, pDriver, NULL );
Aig_ObjConnect( p, pObj, pDriver, NULL );
// update node counters of the manager
p->nObjs[DAR_AIG_PO]++;
p->nObjs[AIG_OBJ_PO]++;
return pObj;
}
......@@ -85,19 +85,19 @@ Dar_Obj_t * Dar_ObjCreatePo( Dar_Man_t * p, Dar_Obj_t * pDriver )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_ObjCreate( Dar_Man_t * p, Dar_Obj_t * pGhost )
Aig_Obj_t * Aig_ObjCreate( Aig_Man_t * p, Aig_Obj_t * pGhost )
{
Dar_Obj_t * pObj;
assert( !Dar_IsComplement(pGhost) );
assert( Dar_ObjIsHash(pGhost) );
Aig_Obj_t * pObj;
assert( !Aig_IsComplement(pGhost) );
assert( Aig_ObjIsHash(pGhost) );
assert( pGhost == &p->Ghost );
// get memory for the new object
pObj = Dar_ManFetchMemory( p );
pObj = Aig_ManFetchMemory( p );
pObj->Type = pGhost->Type;
// add connections
Dar_ObjConnect( p, pObj, pGhost->pFanin0, pGhost->pFanin1 );
Aig_ObjConnect( p, pObj, pGhost->pFanin0, pGhost->pFanin1 );
// update node counters of the manager
p->nObjs[Dar_ObjType(pObj)]++;
p->nObjs[Aig_ObjType(pObj)]++;
assert( pObj->pData == NULL );
return pObj;
}
......@@ -113,38 +113,38 @@ Dar_Obj_t * Dar_ObjCreate( Dar_Man_t * p, Dar_Obj_t * pGhost )
SeeAlso []
***********************************************************************/
void Dar_ObjConnect( Dar_Man_t * p, Dar_Obj_t * pObj, Dar_Obj_t * pFan0, Dar_Obj_t * pFan1 )
void Aig_ObjConnect( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFan0, Aig_Obj_t * pFan1 )
{
assert( !Dar_IsComplement(pObj) );
assert( !Dar_ObjIsPi(pObj) );
assert( !Aig_IsComplement(pObj) );
assert( !Aig_ObjIsPi(pObj) );
// add the first fanin
pObj->pFanin0 = pFan0;
pObj->pFanin1 = pFan1;
// increment references of the fanins and add their fanouts
if ( pFan0 != NULL )
{
assert( Dar_ObjFanin0(pObj)->Type > 0 );
Dar_ObjRef( Dar_ObjFanin0(pObj) );
assert( Aig_ObjFanin0(pObj)->Type > 0 );
Aig_ObjRef( Aig_ObjFanin0(pObj) );
}
if ( pFan1 != NULL )
{
assert( Dar_ObjFanin1(pObj)->Type > 0 );
Dar_ObjRef( Dar_ObjFanin1(pObj) );
assert( Aig_ObjFanin1(pObj)->Type > 0 );
Aig_ObjRef( Aig_ObjFanin1(pObj) );
}
// set level and phase
if ( pFan1 != NULL )
{
pObj->Level = Dar_ObjLevelNew( pObj );
pObj->fPhase = Dar_ObjFaninPhase(pFan0) & Dar_ObjFaninPhase(pFan1);
pObj->Level = Aig_ObjLevelNew( pObj );
pObj->fPhase = Aig_ObjFaninPhase(pFan0) & Aig_ObjFaninPhase(pFan1);
}
else
{
pObj->Level = pFan0->Level;
pObj->fPhase = Dar_ObjFaninPhase(pFan0);
pObj->fPhase = Aig_ObjFaninPhase(pFan0);
}
// add the node to the structural hash table
if ( Dar_ObjIsHash(pObj) )
Dar_TableInsert( p, pObj );
if ( Aig_ObjIsHash(pObj) )
Aig_TableInsert( p, pObj );
}
/**Function*************************************************************
......@@ -158,17 +158,17 @@ void Dar_ObjConnect( Dar_Man_t * p, Dar_Obj_t * pObj, Dar_Obj_t * pFan0, Dar_Obj
SeeAlso []
***********************************************************************/
void Dar_ObjDisconnect( Dar_Man_t * p, Dar_Obj_t * pObj )
void Aig_ObjDisconnect( Aig_Man_t * p, Aig_Obj_t * pObj )
{
assert( !Dar_IsComplement(pObj) );
assert( !Aig_IsComplement(pObj) );
// remove connections
if ( pObj->pFanin0 != NULL )
Dar_ObjDeref(Dar_ObjFanin0(pObj));
Aig_ObjDeref(Aig_ObjFanin0(pObj));
if ( pObj->pFanin1 != NULL )
Dar_ObjDeref(Dar_ObjFanin1(pObj));
Aig_ObjDeref(Aig_ObjFanin1(pObj));
// remove the node from the structural hash table
if ( Dar_ObjIsHash(pObj) )
Dar_TableDelete( p, pObj );
if ( Aig_ObjIsHash(pObj) )
Aig_TableDelete( p, pObj );
// add the first fanin
pObj->pFanin0 = NULL;
pObj->pFanin1 = NULL;
......@@ -185,14 +185,14 @@ void Dar_ObjDisconnect( Dar_Man_t * p, Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Dar_ObjDelete( Dar_Man_t * p, Dar_Obj_t * pObj )
void Aig_ObjDelete( Aig_Man_t * p, Aig_Obj_t * pObj )
{
assert( !Dar_IsComplement(pObj) );
assert( !Dar_ObjIsTerm(pObj) );
assert( Dar_ObjRefs(pObj) == 0 );
assert( !Aig_IsComplement(pObj) );
assert( !Aig_ObjIsTerm(pObj) );
assert( Aig_ObjRefs(pObj) == 0 );
p->nObjs[pObj->Type]--;
Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL );
Dar_ManRecycleMemory( p, pObj );
Aig_ManRecycleMemory( p, pObj );
}
/**Function*************************************************************
......@@ -206,22 +206,22 @@ void Dar_ObjDelete( Dar_Man_t * p, Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Dar_ObjDelete_rec( Dar_Man_t * p, Dar_Obj_t * pObj, int fFreeTop )
void Aig_ObjDelete_rec( Aig_Man_t * p, Aig_Obj_t * pObj, int fFreeTop )
{
Dar_Obj_t * pFanin0, * pFanin1;
assert( !Dar_IsComplement(pObj) );
if ( Dar_ObjIsConst1(pObj) || Dar_ObjIsPi(pObj) )
Aig_Obj_t * pFanin0, * pFanin1;
assert( !Aig_IsComplement(pObj) );
if ( Aig_ObjIsConst1(pObj) || Aig_ObjIsPi(pObj) )
return;
assert( !Dar_ObjIsPo(pObj) );
pFanin0 = Dar_ObjFanin0(pObj);
pFanin1 = Dar_ObjFanin1(pObj);
Dar_ObjDisconnect( p, pObj );
assert( !Aig_ObjIsPo(pObj) );
pFanin0 = Aig_ObjFanin0(pObj);
pFanin1 = Aig_ObjFanin1(pObj);
Aig_ObjDisconnect( p, pObj );
if ( fFreeTop )
Dar_ObjDelete( p, pObj );
if ( pFanin0 && !Dar_ObjIsNone(pFanin0) && Dar_ObjRefs(pFanin0) == 0 )
Dar_ObjDelete_rec( p, pFanin0, 1 );
if ( pFanin1 && !Dar_ObjIsNone(pFanin1) && Dar_ObjRefs(pFanin1) == 0 )
Dar_ObjDelete_rec( p, pFanin1, 1 );
Aig_ObjDelete( p, pObj );
if ( pFanin0 && !Aig_ObjIsNone(pFanin0) && Aig_ObjRefs(pFanin0) == 0 )
Aig_ObjDelete_rec( p, pFanin0, 1 );
if ( pFanin1 && !Aig_ObjIsNone(pFanin1) && Aig_ObjRefs(pFanin1) == 0 )
Aig_ObjDelete_rec( p, pFanin1, 1 );
}
/**Function*************************************************************
......@@ -235,20 +235,20 @@ void Dar_ObjDelete_rec( Dar_Man_t * p, Dar_Obj_t * pObj, int fFreeTop )
SeeAlso []
***********************************************************************/
void Dar_ObjPatchFanin0( Dar_Man_t * p, Dar_Obj_t * pObj, Dar_Obj_t * pFaninNew )
void Aig_ObjPatchFanin0( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFaninNew )
{
Dar_Obj_t * pFaninOld;
assert( !Dar_IsComplement(pObj) );
pFaninOld = Dar_ObjFanin0(pObj);
Aig_Obj_t * pFaninOld;
assert( !Aig_IsComplement(pObj) );
pFaninOld = Aig_ObjFanin0(pObj);
// decrement ref and remove fanout
Dar_ObjDeref( pFaninOld );
Aig_ObjDeref( pFaninOld );
// update the fanin
pObj->pFanin0 = pFaninNew;
// increment ref and add fanout
Dar_ObjRef( Dar_Regular(pFaninNew) );
Aig_ObjRef( Aig_Regular(pFaninNew) );
// get rid of old fanin
if ( !Dar_ObjIsPi(pFaninOld) && !Dar_ObjIsConst1(pFaninOld) && Dar_ObjRefs(pFaninOld) == 0 )
Dar_ObjDelete_rec( p, pFaninOld, 1 );
if ( !Aig_ObjIsPi(pFaninOld) && !Aig_ObjIsConst1(pFaninOld) && Aig_ObjRefs(pFaninOld) == 0 )
Aig_ObjDelete_rec( p, pFaninOld, 1 );
}
/**Function*************************************************************
......@@ -264,39 +264,39 @@ void Dar_ObjPatchFanin0( Dar_Man_t * p, Dar_Obj_t * pObj, Dar_Obj_t * pFaninNew
SeeAlso []
***********************************************************************/
void Dar_ObjReplace( Dar_Man_t * p, Dar_Obj_t * pObjOld, Dar_Obj_t * pObjNew, int fNodesOnly )
void Aig_ObjReplace( Aig_Man_t * p, Aig_Obj_t * pObjOld, Aig_Obj_t * pObjNew, int fNodesOnly )
{
Dar_Obj_t * pObjNewR = Dar_Regular(pObjNew);
Aig_Obj_t * pObjNewR = Aig_Regular(pObjNew);
// the object to be replaced cannot be complemented
assert( !Dar_IsComplement(pObjOld) );
assert( !Aig_IsComplement(pObjOld) );
// the object to be replaced cannot be a terminal
assert( !Dar_ObjIsPi(pObjOld) && !Dar_ObjIsPo(pObjOld) );
assert( !Aig_ObjIsPi(pObjOld) && !Aig_ObjIsPo(pObjOld) );
// the object to be used cannot be a buffer or a PO
assert( !Dar_ObjIsBuf(pObjNewR) && !Dar_ObjIsPo(pObjNewR) );
assert( !Aig_ObjIsBuf(pObjNewR) && !Aig_ObjIsPo(pObjNewR) );
// the object cannot be the same
assert( pObjOld != pObjNewR );
// make sure object is not pointing to itself
assert( pObjOld != Dar_ObjFanin0(pObjNewR) );
assert( pObjOld != Dar_ObjFanin1(pObjNewR) );
assert( pObjOld != Aig_ObjFanin0(pObjNewR) );
assert( pObjOld != Aig_ObjFanin1(pObjNewR) );
// recursively delete the old node - but leave the object there
pObjNewR->nRefs++;
Dar_ObjDelete_rec( p, pObjOld, 0 );
Aig_ObjDelete_rec( p, pObjOld, 0 );
pObjNewR->nRefs--;
// if the new object is complemented or already used, create a buffer
p->nObjs[pObjOld->Type]--;
if ( Dar_IsComplement(pObjNew) || Dar_ObjRefs(pObjNew) > 0 || (fNodesOnly && !Dar_ObjIsNode(pObjNew)) )
if ( Aig_IsComplement(pObjNew) || Aig_ObjRefs(pObjNew) > 0 || (fNodesOnly && !Aig_ObjIsNode(pObjNew)) )
{
pObjOld->Type = DAR_AIG_BUF;
Dar_ObjConnect( p, pObjOld, pObjNew, NULL );
pObjOld->Type = AIG_OBJ_BUF;
Aig_ObjConnect( p, pObjOld, pObjNew, NULL );
}
else
{
Dar_Obj_t * pFanin0 = pObjNew->pFanin0;
Dar_Obj_t * pFanin1 = pObjNew->pFanin1;
Aig_Obj_t * pFanin0 = pObjNew->pFanin0;
Aig_Obj_t * pFanin1 = pObjNew->pFanin1;
pObjOld->Type = pObjNew->Type;
Dar_ObjDisconnect( p, pObjNew );
Dar_ObjConnect( p, pObjOld, pFanin0, pFanin1 );
Dar_ObjDelete( p, pObjNew );
Aig_ObjDisconnect( p, pObjNew );
Aig_ObjConnect( p, pObjOld, pFanin0, pFanin1 );
Aig_ObjDelete( p, pObjNew );
}
p->nObjs[pObjOld->Type]++;
}
......
/**CFile****************************************************************
FileName [darOper.c]
FileName [aigOper.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting.]
PackageName [AIG package.]
Synopsis [AIG operations.]
......@@ -14,31 +14,31 @@
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: darOper.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
Revision [$Id: aigOper.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#include "dar.h"
#include "aig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
// procedure to detect an EXOR gate
static inline int Dar_ObjIsExorType( Dar_Obj_t * p0, Dar_Obj_t * p1, Dar_Obj_t ** ppFan0, Dar_Obj_t ** ppFan1 )
static inline int Aig_ObjIsExorType( Aig_Obj_t * p0, Aig_Obj_t * p1, Aig_Obj_t ** ppFan0, Aig_Obj_t ** ppFan1 )
{
if ( !Dar_IsComplement(p0) || !Dar_IsComplement(p1) )
if ( !Aig_IsComplement(p0) || !Aig_IsComplement(p1) )
return 0;
p0 = Dar_Regular(p0);
p1 = Dar_Regular(p1);
if ( !Dar_ObjIsAnd(p0) || !Dar_ObjIsAnd(p1) )
p0 = Aig_Regular(p0);
p1 = Aig_Regular(p1);
if ( !Aig_ObjIsAnd(p0) || !Aig_ObjIsAnd(p1) )
return 0;
if ( Dar_ObjFanin0(p0) != Dar_ObjFanin0(p1) || Dar_ObjFanin1(p0) != Dar_ObjFanin1(p1) )
if ( Aig_ObjFanin0(p0) != Aig_ObjFanin0(p1) || Aig_ObjFanin1(p0) != Aig_ObjFanin1(p1) )
return 0;
if ( Dar_ObjFaninC0(p0) == Dar_ObjFaninC0(p1) || Dar_ObjFaninC1(p0) == Dar_ObjFaninC1(p1) )
if ( Aig_ObjFaninC0(p0) == Aig_ObjFaninC0(p1) || Aig_ObjFaninC1(p0) == Aig_ObjFaninC1(p1) )
return 0;
*ppFan0 = Dar_ObjChild0(p0);
*ppFan1 = Dar_ObjChild1(p0);
*ppFan0 = Aig_ObjChild0(p0);
*ppFan1 = Aig_ObjChild1(p0);
return 1;
}
......@@ -57,13 +57,13 @@ static inline int Dar_ObjIsExorType( Dar_Obj_t * p0, Dar_Obj_t * p1, Dar_Obj_t *
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_IthVar( Dar_Man_t * p, int i )
Aig_Obj_t * Aig_IthVar( Aig_Man_t * p, int i )
{
int v;
for ( v = Dar_ManPiNum(p); v <= i; v++ )
Dar_ObjCreatePi( p );
for ( v = Aig_ManPiNum(p); v <= i; v++ )
Aig_ObjCreatePi( p );
assert( i < Vec_PtrSize(p->vPis) );
return Dar_ManPi( p, i );
return Aig_ManPi( p, i );
}
/**Function*************************************************************
......@@ -77,12 +77,12 @@ Dar_Obj_t * Dar_IthVar( Dar_Man_t * p, int i )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Oper( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1, Dar_Type_t Type )
Aig_Obj_t * Aig_Oper( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1, Aig_Type_t Type )
{
if ( Type == DAR_AIG_AND )
return Dar_And( p, p0, p1 );
if ( Type == DAR_AIG_EXOR )
return Dar_Exor( p, p0, p1 );
if ( Type == AIG_OBJ_AND )
return Aig_And( p, p0, p1 );
if ( Type == AIG_OBJ_EXOR )
return Aig_Exor( p, p0, p1 );
assert( 0 );
return NULL;
}
......@@ -98,30 +98,30 @@ Dar_Obj_t * Dar_Oper( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1, Dar_Type_t
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_CanonPair_rec( Dar_Man_t * p, Dar_Obj_t * pGhost )
Aig_Obj_t * Aig_CanonPair_rec( Aig_Man_t * p, Aig_Obj_t * pGhost )
{
Dar_Obj_t * pResult, * pLat0, * pLat1;
Aig_Obj_t * pResult, * pLat0, * pLat1;
int fCompl0, fCompl1;
Dar_Type_t Type;
assert( Dar_ObjIsNode(pGhost) );
Aig_Type_t Type;
assert( Aig_ObjIsNode(pGhost) );
// consider the case when the pair is canonical
if ( !Dar_ObjIsLatch(Dar_ObjFanin0(pGhost)) || !Dar_ObjIsLatch(Dar_ObjFanin1(pGhost)) )
if ( !Aig_ObjIsLatch(Aig_ObjFanin0(pGhost)) || !Aig_ObjIsLatch(Aig_ObjFanin1(pGhost)) )
{
if ( pResult = Dar_TableLookup( p, pGhost ) )
if ( pResult = Aig_TableLookup( p, pGhost ) )
return pResult;
return Dar_ObjCreate( p, pGhost );
return Aig_ObjCreate( p, pGhost );
}
/// remember the latches
pLat0 = Dar_ObjFanin0(pGhost);
pLat1 = Dar_ObjFanin1(pGhost);
pLat0 = Aig_ObjFanin0(pGhost);
pLat1 = Aig_ObjFanin1(pGhost);
// remember type and compls
Type = Dar_ObjType(pGhost);
fCompl0 = Dar_ObjFaninC0(pGhost);
fCompl1 = Dar_ObjFaninC1(pGhost);
Type = Aig_ObjType(pGhost);
fCompl0 = Aig_ObjFaninC0(pGhost);
fCompl1 = Aig_ObjFaninC1(pGhost);
// call recursively
pResult = Dar_Oper( p, Dar_NotCond(Dar_ObjChild0(pLat0), fCompl0), Dar_NotCond(Dar_ObjChild0(pLat1), fCompl1), Type );
pResult = Aig_Oper( p, Aig_NotCond(Aig_ObjChild0(pLat0), fCompl0), Aig_NotCond(Aig_ObjChild0(pLat1), fCompl1), Type );
// build latch on top of this
return Dar_Latch( p, pResult, (Type == DAR_AIG_AND)? fCompl0 & fCompl1 : fCompl0 ^ fCompl1 );
return Aig_Latch( p, pResult, (Type == AIG_OBJ_AND)? fCompl0 & fCompl1 : fCompl0 ^ fCompl1 );
}
/**Function*************************************************************
......@@ -135,24 +135,24 @@ Dar_Obj_t * Dar_CanonPair_rec( Dar_Man_t * p, Dar_Obj_t * pGhost )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_And( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1 )
Aig_Obj_t * Aig_And( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
{
Dar_Obj_t * pGhost, * pResult;
// Dar_Obj_t * pFan0, * pFan1;
Aig_Obj_t * pGhost, * pResult;
// Aig_Obj_t * pFan0, * pFan1;
// check trivial cases
if ( p0 == p1 )
return p0;
if ( p0 == Dar_Not(p1) )
return Dar_Not(p->pConst1);
if ( Dar_Regular(p0) == p->pConst1 )
return p0 == p->pConst1 ? p1 : Dar_Not(p->pConst1);
if ( Dar_Regular(p1) == p->pConst1 )
return p1 == p->pConst1 ? p0 : Dar_Not(p->pConst1);
if ( p0 == Aig_Not(p1) )
return Aig_Not(p->pConst1);
if ( Aig_Regular(p0) == p->pConst1 )
return p0 == p->pConst1 ? p1 : Aig_Not(p->pConst1);
if ( Aig_Regular(p1) == p->pConst1 )
return p1 == p->pConst1 ? p0 : Aig_Not(p->pConst1);
// check if it can be an EXOR gate
// if ( Dar_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) )
// return Dar_Exor( p, pFan0, pFan1 );
pGhost = Dar_ObjCreateGhost( p, p0, p1, DAR_AIG_AND );
pResult = Dar_CanonPair_rec( p, pGhost );
// if ( Aig_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) )
// return Aig_Exor( p, pFan0, pFan1 );
pGhost = Aig_ObjCreateGhost( p, p0, p1, AIG_OBJ_AND );
pResult = Aig_CanonPair_rec( p, pGhost );
return pResult;
}
......@@ -167,14 +167,14 @@ Dar_Obj_t * Dar_And( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1 )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Latch( Dar_Man_t * p, Dar_Obj_t * pObj, int fInitOne )
Aig_Obj_t * Aig_Latch( Aig_Man_t * p, Aig_Obj_t * pObj, int fInitOne )
{
Dar_Obj_t * pGhost, * pResult;
pGhost = Dar_ObjCreateGhost( p, Dar_NotCond(pObj, fInitOne), NULL, DAR_AIG_LATCH );
pResult = Dar_TableLookup( p, pGhost );
Aig_Obj_t * pGhost, * pResult;
pGhost = Aig_ObjCreateGhost( p, Aig_NotCond(pObj, fInitOne), NULL, AIG_OBJ_LATCH );
pResult = Aig_TableLookup( p, pGhost );
if ( pResult == NULL )
pResult = Dar_ObjCreate( p, pGhost );
return Dar_NotCond( pResult, fInitOne );
pResult = Aig_ObjCreate( p, pGhost );
return Aig_NotCond( pResult, fInitOne );
}
/**Function*************************************************************
......@@ -188,26 +188,26 @@ Dar_Obj_t * Dar_Latch( Dar_Man_t * p, Dar_Obj_t * pObj, int fInitOne )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Exor( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1 )
Aig_Obj_t * Aig_Exor( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
{
/*
Dar_Obj_t * pGhost, * pResult;
Aig_Obj_t * pGhost, * pResult;
// check trivial cases
if ( p0 == p1 )
return Dar_Not(p->pConst1);
if ( p0 == Dar_Not(p1) )
return Aig_Not(p->pConst1);
if ( p0 == Aig_Not(p1) )
return p->pConst1;
if ( Dar_Regular(p0) == p->pConst1 )
return Dar_NotCond( p1, p0 == p->pConst1 );
if ( Dar_Regular(p1) == p->pConst1 )
return Dar_NotCond( p0, p1 == p->pConst1 );
if ( Aig_Regular(p0) == p->pConst1 )
return Aig_NotCond( p1, p0 == p->pConst1 );
if ( Aig_Regular(p1) == p->pConst1 )
return Aig_NotCond( p0, p1 == p->pConst1 );
// check the table
pGhost = Dar_ObjCreateGhost( p, p0, p1, DAR_AIG_EXOR );
if ( pResult = Dar_TableLookup( p, pGhost ) )
pGhost = Aig_ObjCreateGhost( p, p0, p1, AIG_OBJ_EXOR );
if ( pResult = Aig_TableLookup( p, pGhost ) )
return pResult;
return Dar_ObjCreate( p, pGhost );
return Aig_ObjCreate( p, pGhost );
*/
return Dar_Or( p, Dar_And(p, p0, Dar_Not(p1)), Dar_And(p, Dar_Not(p0), p1) );
return Aig_Or( p, Aig_And(p, p0, Aig_Not(p1)), Aig_And(p, Aig_Not(p0), p1) );
}
/**Function*************************************************************
......@@ -221,9 +221,9 @@ Dar_Obj_t * Dar_Exor( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1 )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Or( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1 )
Aig_Obj_t * Aig_Or( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
{
return Dar_Not( Dar_And( p, Dar_Not(p0), Dar_Not(p1) ) );
return Aig_Not( Aig_And( p, Aig_Not(p0), Aig_Not(p1) ) );
}
/**Function*************************************************************
......@@ -237,48 +237,48 @@ Dar_Obj_t * Dar_Or( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1 )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Mux( Dar_Man_t * p, Dar_Obj_t * pC, Dar_Obj_t * p1, Dar_Obj_t * p0 )
Aig_Obj_t * Aig_Mux( Aig_Man_t * p, Aig_Obj_t * pC, Aig_Obj_t * p1, Aig_Obj_t * p0 )
{
/*
Dar_Obj_t * pTempA1, * pTempA2, * pTempB1, * pTempB2, * pTemp;
Aig_Obj_t * pTempA1, * pTempA2, * pTempB1, * pTempB2, * pTemp;
int Count0, Count1;
// consider trivial cases
if ( p0 == Dar_Not(p1) )
return Dar_Exor( p, pC, p0 );
if ( p0 == Aig_Not(p1) )
return Aig_Exor( p, pC, p0 );
// other cases can be added
// implement the first MUX (F = C * x1 + C' * x0)
// check for constants here!!!
pTempA1 = Dar_TableLookup( p, Dar_ObjCreateGhost(p, pC, p1, DAR_AIG_AND) );
pTempA2 = Dar_TableLookup( p, Dar_ObjCreateGhost(p, Dar_Not(pC), p0, DAR_AIG_AND) );
pTempA1 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, pC, p1, AIG_OBJ_AND) );
pTempA2 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pC), p0, AIG_OBJ_AND) );
if ( pTempA1 && pTempA2 )
{
pTemp = Dar_TableLookup( p, Dar_ObjCreateGhost(p, Dar_Not(pTempA1), Dar_Not(pTempA2), DAR_AIG_AND) );
if ( pTemp ) return Dar_Not(pTemp);
pTemp = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pTempA1), Aig_Not(pTempA2), AIG_OBJ_AND) );
if ( pTemp ) return Aig_Not(pTemp);
}
Count0 = (pTempA1 != NULL) + (pTempA2 != NULL);
// implement the second MUX (F' = C * x1' + C' * x0')
pTempB1 = Dar_TableLookup( p, Dar_ObjCreateGhost(p, pC, Dar_Not(p1), DAR_AIG_AND) );
pTempB2 = Dar_TableLookup( p, Dar_ObjCreateGhost(p, Dar_Not(pC), Dar_Not(p0), DAR_AIG_AND) );
pTempB1 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, pC, Aig_Not(p1), AIG_OBJ_AND) );
pTempB2 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pC), Aig_Not(p0), AIG_OBJ_AND) );
if ( pTempB1 && pTempB2 )
{
pTemp = Dar_TableLookup( p, Dar_ObjCreateGhost(p, Dar_Not(pTempB1), Dar_Not(pTempB2), DAR_AIG_AND) );
pTemp = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pTempB1), Aig_Not(pTempB2), AIG_OBJ_AND) );
if ( pTemp ) return pTemp;
}
Count1 = (pTempB1 != NULL) + (pTempB2 != NULL);
// compare and decide which one to implement
if ( Count0 >= Count1 )
{
pTempA1 = pTempA1? pTempA1 : Dar_And(p, pC, p1);
pTempA2 = pTempA2? pTempA2 : Dar_And(p, Dar_Not(pC), p0);
return Dar_Or( p, pTempA1, pTempA2 );
pTempA1 = pTempA1? pTempA1 : Aig_And(p, pC, p1);
pTempA2 = pTempA2? pTempA2 : Aig_And(p, Aig_Not(pC), p0);
return Aig_Or( p, pTempA1, pTempA2 );
}
pTempB1 = pTempB1? pTempB1 : Dar_And(p, pC, Dar_Not(p1));
pTempB2 = pTempB2? pTempB2 : Dar_And(p, Dar_Not(pC), Dar_Not(p0));
return Dar_Not( Dar_Or( p, pTempB1, pTempB2 ) );
pTempB1 = pTempB1? pTempB1 : Aig_And(p, pC, Aig_Not(p1));
pTempB2 = pTempB2? pTempB2 : Aig_And(p, Aig_Not(pC), Aig_Not(p0));
return Aig_Not( Aig_Or( p, pTempB1, pTempB2 ) );
*/
return Dar_Or( p, Dar_And(p, pC, p1), Dar_And(p, Dar_Not(pC), p0) );
return Aig_Or( p, Aig_And(p, pC, p1), Aig_And(p, Aig_Not(pC), p0) );
}
/**Function*************************************************************
......@@ -292,9 +292,9 @@ Dar_Obj_t * Dar_Mux( Dar_Man_t * p, Dar_Obj_t * pC, Dar_Obj_t * p1, Dar_Obj_t *
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Maj( Dar_Man_t * p, Dar_Obj_t * pA, Dar_Obj_t * pB, Dar_Obj_t * pC )
Aig_Obj_t * Aig_Maj( Aig_Man_t * p, Aig_Obj_t * pA, Aig_Obj_t * pB, Aig_Obj_t * pC )
{
return Dar_Or( p, Dar_Or(p, Dar_And(p, pA, pB), Dar_And(p, pA, pC)), Dar_And(p, pB, pC) );
return Aig_Or( p, Aig_Or(p, Aig_And(p, pA, pB), Aig_And(p, pA, pC)), Aig_And(p, pB, pC) );
}
/**Function*************************************************************
......@@ -308,14 +308,14 @@ Dar_Obj_t * Dar_Maj( Dar_Man_t * p, Dar_Obj_t * pA, Dar_Obj_t * pB, Dar_Obj_t *
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Multi_rec( Dar_Man_t * p, Dar_Obj_t ** ppObjs, int nObjs, Dar_Type_t Type )
Aig_Obj_t * Aig_Multi_rec( Aig_Man_t * p, Aig_Obj_t ** ppObjs, int nObjs, Aig_Type_t Type )
{
Dar_Obj_t * pObj1, * pObj2;
Aig_Obj_t * pObj1, * pObj2;
if ( nObjs == 1 )
return ppObjs[0];
pObj1 = Dar_Multi_rec( p, ppObjs, nObjs/2, Type );
pObj2 = Dar_Multi_rec( p, ppObjs + nObjs/2, nObjs - nObjs/2, Type );
return Dar_Oper( p, pObj1, pObj2, Type );
pObj1 = Aig_Multi_rec( p, ppObjs, nObjs/2, Type );
pObj2 = Aig_Multi_rec( p, ppObjs + nObjs/2, nObjs - nObjs/2, Type );
return Aig_Oper( p, pObj1, pObj2, Type );
}
/**Function*************************************************************
......@@ -329,11 +329,11 @@ Dar_Obj_t * Dar_Multi_rec( Dar_Man_t * p, Dar_Obj_t ** ppObjs, int nObjs, Dar_Ty
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Multi( Dar_Man_t * p, Dar_Obj_t ** pArgs, int nArgs, Dar_Type_t Type )
Aig_Obj_t * Aig_Multi( Aig_Man_t * p, Aig_Obj_t ** pArgs, int nArgs, Aig_Type_t Type )
{
assert( Type == DAR_AIG_AND || Type == DAR_AIG_EXOR );
assert( Type == AIG_OBJ_AND || Type == AIG_OBJ_EXOR );
assert( nArgs > 0 );
return Dar_Multi_rec( p, pArgs, nArgs, Type );
return Aig_Multi_rec( p, pArgs, nArgs, Type );
}
/**Function*************************************************************
......@@ -347,16 +347,16 @@ Dar_Obj_t * Dar_Multi( Dar_Man_t * p, Dar_Obj_t ** pArgs, int nArgs, Dar_Type_t
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_Miter( Dar_Man_t * p, Vec_Ptr_t * vPairs )
Aig_Obj_t * Aig_Miter( Aig_Man_t * p, Vec_Ptr_t * vPairs )
{
int i;
assert( vPairs->nSize > 0 );
assert( vPairs->nSize % 2 == 0 );
// go through the cubes of the node's SOP
for ( i = 0; i < vPairs->nSize; i += 2 )
vPairs->pArray[i/2] = Dar_Not( Dar_Exor( p, vPairs->pArray[i], vPairs->pArray[i+1] ) );
vPairs->pArray[i/2] = Aig_Not( Aig_Exor( p, vPairs->pArray[i], vPairs->pArray[i+1] ) );
vPairs->nSize = vPairs->nSize/2;
return Dar_Not( Dar_Multi_rec( p, (Dar_Obj_t **)vPairs->pArray, vPairs->nSize, DAR_AIG_AND ) );
return Aig_Not( Aig_Multi_rec( p, (Aig_Obj_t **)vPairs->pArray, vPairs->nSize, AIG_OBJ_AND ) );
}
/**Function*************************************************************
......@@ -370,13 +370,13 @@ Dar_Obj_t * Dar_Miter( Dar_Man_t * p, Vec_Ptr_t * vPairs )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_CreateAnd( Dar_Man_t * p, int nVars )
Aig_Obj_t * Aig_CreateAnd( Aig_Man_t * p, int nVars )
{
Dar_Obj_t * pFunc;
Aig_Obj_t * pFunc;
int i;
pFunc = Dar_ManConst1( p );
pFunc = Aig_ManConst1( p );
for ( i = 0; i < nVars; i++ )
pFunc = Dar_And( p, pFunc, Dar_IthVar(p, i) );
pFunc = Aig_And( p, pFunc, Aig_IthVar(p, i) );
return pFunc;
}
......@@ -391,13 +391,13 @@ Dar_Obj_t * Dar_CreateAnd( Dar_Man_t * p, int nVars )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_CreateOr( Dar_Man_t * p, int nVars )
Aig_Obj_t * Aig_CreateOr( Aig_Man_t * p, int nVars )
{
Dar_Obj_t * pFunc;
Aig_Obj_t * pFunc;
int i;
pFunc = Dar_ManConst0( p );
pFunc = Aig_ManConst0( p );
for ( i = 0; i < nVars; i++ )
pFunc = Dar_Or( p, pFunc, Dar_IthVar(p, i) );
pFunc = Aig_Or( p, pFunc, Aig_IthVar(p, i) );
return pFunc;
}
......@@ -412,13 +412,13 @@ Dar_Obj_t * Dar_CreateOr( Dar_Man_t * p, int nVars )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_CreateExor( Dar_Man_t * p, int nVars )
Aig_Obj_t * Aig_CreateExor( Aig_Man_t * p, int nVars )
{
Dar_Obj_t * pFunc;
Aig_Obj_t * pFunc;
int i;
pFunc = Dar_ManConst0( p );
pFunc = Aig_ManConst0( p );
for ( i = 0; i < nVars; i++ )
pFunc = Dar_Exor( p, pFunc, Dar_IthVar(p, i) );
pFunc = Aig_Exor( p, pFunc, Aig_IthVar(p, i) );
return pFunc;
}
......
/**CFile****************************************************************
FileName [darSeq.c]
FileName [aigSeq.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting.]
PackageName [AIG package.]
Synopsis []
Synopsis [Sequential strashing.]
Author [Alan Mishchenko]
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: darSeq.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
Revision [$Id: aigSeq.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#include "dar.h"
#include "aig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -39,33 +39,33 @@
SeeAlso []
***********************************************************************/
void Dar_ManSeqStrashConvert( Dar_Man_t * p, int nLatches, int * pInits )
void Aig_ManSeqStrashConvert( Aig_Man_t * p, int nLatches, int * pInits )
{
Dar_Obj_t * pObjLi, * pObjLo, * pLatch;
Aig_Obj_t * pObjLi, * pObjLo, * pLatch;
int i;
// collect the POs to be converted into latches
for ( i = 0; i < nLatches; i++ )
{
// get the corresponding PI/PO pair
pObjLi = Dar_ManPo( p, Dar_ManPoNum(p) - nLatches + i );
pObjLo = Dar_ManPi( p, Dar_ManPiNum(p) - nLatches + i );
pObjLi = Aig_ManPo( p, Aig_ManPoNum(p) - nLatches + i );
pObjLo = Aig_ManPi( p, Aig_ManPiNum(p) - nLatches + i );
// create latch
pLatch = Dar_Latch( p, Dar_ObjChild0(pObjLi), pInits? pInits[i] : 0 );
pLatch = Aig_Latch( p, Aig_ObjChild0(pObjLi), pInits? pInits[i] : 0 );
// recycle the old PO object
Dar_ObjDisconnect( p, pObjLi );
Aig_ObjDisconnect( p, pObjLi );
Vec_PtrWriteEntry( p->vObjs, pObjLi->Id, NULL );
Dar_ManRecycleMemory( p, pObjLi );
Aig_ManRecycleMemory( p, pObjLi );
// convert the corresponding PI to be a buffer and connect it to the latch
pObjLo->Type = DAR_AIG_BUF;
Dar_ObjConnect( p, pObjLo, pLatch, NULL );
pObjLo->Type = AIG_OBJ_BUF;
Aig_ObjConnect( p, pObjLo, pLatch, NULL );
}
// shrink the arrays
Vec_PtrShrink( p->vPis, Dar_ManPiNum(p) - nLatches );
Vec_PtrShrink( p->vPos, Dar_ManPoNum(p) - nLatches );
Vec_PtrShrink( p->vPis, Aig_ManPiNum(p) - nLatches );
Vec_PtrShrink( p->vPos, Aig_ManPoNum(p) - nLatches );
// update the counters of different objects
p->nObjs[DAR_AIG_PI] -= nLatches;
p->nObjs[DAR_AIG_PO] -= nLatches;
p->nObjs[DAR_AIG_BUF] += nLatches;
p->nObjs[AIG_OBJ_PI] -= nLatches;
p->nObjs[AIG_OBJ_PO] -= nLatches;
p->nObjs[AIG_OBJ_BUF] += nLatches;
}
/**Function*************************************************************
......@@ -79,20 +79,20 @@ void Dar_ManSeqStrashConvert( Dar_Man_t * p, int nLatches, int * pInits )
SeeAlso []
***********************************************************************/
void Dar_ManDfsSeq_rec( Dar_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vNodes )
void Aig_ManDfsSeq_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vNodes )
{
assert( !Dar_IsComplement(pObj) );
assert( !Aig_IsComplement(pObj) );
if ( pObj == NULL )
return;
if ( Dar_ObjIsTravIdCurrent( p, pObj ) )
if ( Aig_ObjIsTravIdCurrent( p, pObj ) )
return;
Dar_ObjSetTravIdCurrent( p, pObj );
if ( Dar_ObjIsPi(pObj) || Dar_ObjIsConst1(pObj) )
Aig_ObjSetTravIdCurrent( p, pObj );
if ( Aig_ObjIsPi(pObj) || Aig_ObjIsConst1(pObj) )
return;
Dar_ManDfsSeq_rec( p, Dar_ObjFanin0(pObj), vNodes );
Dar_ManDfsSeq_rec( p, Dar_ObjFanin1(pObj), vNodes );
// if ( (Dar_ObjFanin0(pObj) == NULL || Dar_ObjIsBuf(Dar_ObjFanin0(pObj))) &&
// (Dar_ObjFanin1(pObj) == NULL || Dar_ObjIsBuf(Dar_ObjFanin1(pObj))) )
Aig_ManDfsSeq_rec( p, Aig_ObjFanin0(pObj), vNodes );
Aig_ManDfsSeq_rec( p, Aig_ObjFanin1(pObj), vNodes );
// if ( (Aig_ObjFanin0(pObj) == NULL || Aig_ObjIsBuf(Aig_ObjFanin0(pObj))) &&
// (Aig_ObjFanin1(pObj) == NULL || Aig_ObjIsBuf(Aig_ObjFanin1(pObj))) )
Vec_PtrPush( vNodes, pObj );
}
......@@ -107,15 +107,15 @@ void Dar_ManDfsSeq_rec( Dar_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vNodes )
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Dar_ManDfsSeq( Dar_Man_t * p )
Vec_Ptr_t * Aig_ManDfsSeq( Aig_Man_t * p )
{
Vec_Ptr_t * vNodes;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
Dar_ManIncrementTravId( p );
vNodes = Vec_PtrAlloc( Dar_ManNodeNum(p) );
Dar_ManForEachPo( p, pObj, i )
Dar_ManDfsSeq_rec( p, Dar_ObjFanin0(pObj), vNodes );
Aig_ManIncrementTravId( p );
vNodes = Vec_PtrAlloc( Aig_ManNodeNum(p) );
Aig_ManForEachPo( p, pObj, i )
Aig_ManDfsSeq_rec( p, Aig_ObjFanin0(pObj), vNodes );
return vNodes;
}
......@@ -130,21 +130,21 @@ Vec_Ptr_t * Dar_ManDfsSeq( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
void Dar_ManDfsUnreach_rec( Dar_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vNodes )
void Aig_ManDfsUnreach_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vNodes )
{
assert( !Dar_IsComplement(pObj) );
assert( !Aig_IsComplement(pObj) );
if ( pObj == NULL )
return;
if ( Dar_ObjIsTravIdPrevious(p, pObj) || Dar_ObjIsTravIdCurrent(p, pObj) )
if ( Aig_ObjIsTravIdPrevious(p, pObj) || Aig_ObjIsTravIdCurrent(p, pObj) )
return;
Dar_ObjSetTravIdPrevious( p, pObj ); // assume unknown
Dar_ManDfsUnreach_rec( p, Dar_ObjFanin0(pObj), vNodes );
Dar_ManDfsUnreach_rec( p, Dar_ObjFanin1(pObj), vNodes );
if ( Dar_ObjIsTravIdPrevious(p, Dar_ObjFanin0(pObj)) &&
(Dar_ObjFanin1(pObj) == NULL || Dar_ObjIsTravIdPrevious(p, Dar_ObjFanin1(pObj))) )
Aig_ObjSetTravIdPrevious( p, pObj ); // assume unknown
Aig_ManDfsUnreach_rec( p, Aig_ObjFanin0(pObj), vNodes );
Aig_ManDfsUnreach_rec( p, Aig_ObjFanin1(pObj), vNodes );
if ( Aig_ObjIsTravIdPrevious(p, Aig_ObjFanin0(pObj)) &&
(Aig_ObjFanin1(pObj) == NULL || Aig_ObjIsTravIdPrevious(p, Aig_ObjFanin1(pObj))) )
Vec_PtrPush( vNodes, pObj );
else
Dar_ObjSetTravIdCurrent( p, pObj );
Aig_ObjSetTravIdCurrent( p, pObj );
}
/**Function*************************************************************
......@@ -158,25 +158,25 @@ void Dar_ManDfsUnreach_rec( Dar_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vNodes
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Dar_ManDfsUnreach( Dar_Man_t * p )
Vec_Ptr_t * Aig_ManDfsUnreach( Aig_Man_t * p )
{
Vec_Ptr_t * vNodes;
Dar_Obj_t * pObj, * pFanin;
Aig_Obj_t * pObj, * pFanin;
int i, k;//, RetValue;
// collect unreachable nodes
Dar_ManIncrementTravId( p );
Dar_ManIncrementTravId( p );
Aig_ManIncrementTravId( p );
Aig_ManIncrementTravId( p );
// mark the constant and PIs
Dar_ObjSetTravIdPrevious( p, Dar_ManConst1(p) );
Dar_ManForEachPi( p, pObj, i )
Dar_ObjSetTravIdCurrent( p, pObj );
Aig_ObjSetTravIdPrevious( p, Aig_ManConst1(p) );
Aig_ManForEachPi( p, pObj, i )
Aig_ObjSetTravIdCurrent( p, pObj );
// curr marks visited nodes reachable from PIs
// prev marks visited nodes unreachable or unknown
// collect the unreachable nodes
vNodes = Vec_PtrAlloc( 32 );
Dar_ManForEachPo( p, pObj, i )
Dar_ManDfsUnreach_rec( p, Dar_ObjFanin0(pObj), vNodes );
Aig_ManForEachPo( p, pObj, i )
Aig_ManDfsUnreach_rec( p, Aig_ObjFanin0(pObj), vNodes );
// refine resulting nodes
do
......@@ -184,32 +184,32 @@ Vec_Ptr_t * Dar_ManDfsUnreach( Dar_Man_t * p )
k = 0;
Vec_PtrForEachEntry( vNodes, pObj, i )
{
assert( Dar_ObjIsTravIdPrevious(p, pObj) );
if ( Dar_ObjIsLatch(pObj) || Dar_ObjIsBuf(pObj) )
assert( Aig_ObjIsTravIdPrevious(p, pObj) );
if ( Aig_ObjIsLatch(pObj) || Aig_ObjIsBuf(pObj) )
{
pFanin = Dar_ObjFanin0(pObj);
assert( Dar_ObjIsTravIdPrevious(p, pFanin) || Dar_ObjIsTravIdCurrent(p, pFanin) );
if ( Dar_ObjIsTravIdCurrent(p, pFanin) )
pFanin = Aig_ObjFanin0(pObj);
assert( Aig_ObjIsTravIdPrevious(p, pFanin) || Aig_ObjIsTravIdCurrent(p, pFanin) );
if ( Aig_ObjIsTravIdCurrent(p, pFanin) )
{
Dar_ObjSetTravIdCurrent( p, pObj );
Aig_ObjSetTravIdCurrent( p, pObj );
continue;
}
}
else // AND gate
{
assert( Dar_ObjIsNode(pObj) );
pFanin = Dar_ObjFanin0(pObj);
assert( Dar_ObjIsTravIdPrevious(p, pFanin) || Dar_ObjIsTravIdCurrent(p, pFanin) );
if ( Dar_ObjIsTravIdCurrent(p, pFanin) )
assert( Aig_ObjIsNode(pObj) );
pFanin = Aig_ObjFanin0(pObj);
assert( Aig_ObjIsTravIdPrevious(p, pFanin) || Aig_ObjIsTravIdCurrent(p, pFanin) );
if ( Aig_ObjIsTravIdCurrent(p, pFanin) )
{
Dar_ObjSetTravIdCurrent( p, pObj );
Aig_ObjSetTravIdCurrent( p, pObj );
continue;
}
pFanin = Dar_ObjFanin1(pObj);
assert( Dar_ObjIsTravIdPrevious(p, pFanin) || Dar_ObjIsTravIdCurrent(p, pFanin) );
if ( Dar_ObjIsTravIdCurrent(p, pFanin) )
pFanin = Aig_ObjFanin1(pObj);
assert( Aig_ObjIsTravIdPrevious(p, pFanin) || Aig_ObjIsTravIdCurrent(p, pFanin) );
if ( Aig_ObjIsTravIdCurrent(p, pFanin) )
{
Dar_ObjSetTravIdCurrent( p, pObj );
Aig_ObjSetTravIdCurrent( p, pObj );
continue;
}
}
......@@ -234,9 +234,9 @@ Vec_Ptr_t * Dar_ManDfsUnreach( Dar_Man_t * p )
RetValue = Vec_PtrSize(vNodes);
// mark these nodes
Dar_ManIncrementTravId( p );
Aig_ManIncrementTravId( p );
Vec_PtrForEachEntry( vNodes, pObj, i )
Dar_ObjSetTravIdCurrent( p, pObj );
Aig_ObjSetTravIdCurrent( p, pObj );
Vec_PtrFree( vNodes );
return RetValue;
*/
......@@ -254,21 +254,21 @@ Vec_Ptr_t * Dar_ManDfsUnreach( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
int Dar_ManRemoveUnmarked( Dar_Man_t * p )
int Aig_ManRemoveUnmarked( Aig_Man_t * p )
{
Vec_Ptr_t * vNodes;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i, RetValue;
// collect unmarked nodes
vNodes = Vec_PtrAlloc( 100 );
Dar_ManForEachObj( p, pObj, i )
Aig_ManForEachObj( p, pObj, i )
{
if ( Dar_ObjIsTerm(pObj) )
if ( Aig_ObjIsTerm(pObj) )
continue;
if ( Dar_ObjIsTravIdCurrent(p, pObj) )
if ( Aig_ObjIsTravIdCurrent(p, pObj) )
continue;
//Dar_ObjPrintVerbose( pObj, 0 );
Dar_ObjDisconnect( p, pObj );
//Aig_ObjPrintVerbose( pObj, 0 );
Aig_ObjDisconnect( p, pObj );
Vec_PtrPush( vNodes, pObj );
}
if ( Vec_PtrSize(vNodes) == 0 )
......@@ -279,7 +279,7 @@ int Dar_ManRemoveUnmarked( Dar_Man_t * p )
// remove the dangling objects
RetValue = Vec_PtrSize(vNodes);
Vec_PtrForEachEntry( vNodes, pObj, i )
Dar_ObjDelete( p, pObj );
Aig_ObjDelete( p, pObj );
// printf( "Removed %d dangling.\n", Vec_PtrSize(vNodes) );
Vec_PtrFree( vNodes );
return RetValue;
......@@ -296,38 +296,38 @@ int Dar_ManRemoveUnmarked( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
int Dar_ManSeqRehashOne( Dar_Man_t * p, Vec_Ptr_t * vNodes, Vec_Ptr_t * vUnreach )
int Aig_ManSeqRehashOne( Aig_Man_t * p, Vec_Ptr_t * vNodes, Vec_Ptr_t * vUnreach )
{
Dar_Obj_t * pObj, * pObjNew, * pFanin0, * pFanin1;
Aig_Obj_t * pObj, * pObjNew, * pFanin0, * pFanin1;
int i, RetValue = 0, Counter = 0, Counter2 = 0;
// mark the unreachable nodes
Dar_ManIncrementTravId( p );
Aig_ManIncrementTravId( p );
Vec_PtrForEachEntry( vUnreach, pObj, i )
Dar_ObjSetTravIdCurrent(p, pObj);
Aig_ObjSetTravIdCurrent(p, pObj);
/*
// count the number of unreachable object connections
// that is the number of unreachable objects connected to main objects
Dar_ManForEachObj( p, pObj, i )
Aig_ManForEachObj( p, pObj, i )
{
if ( Dar_ObjIsTravIdCurrent(p, pObj) )
if ( Aig_ObjIsTravIdCurrent(p, pObj) )
continue;
pFanin0 = Dar_ObjFanin0(pObj);
pFanin0 = Aig_ObjFanin0(pObj);
if ( pFanin0 == NULL )
continue;
if ( Dar_ObjIsTravIdCurrent(p, pFanin0) )
if ( Aig_ObjIsTravIdCurrent(p, pFanin0) )
pFanin0->fMarkA = 1;
pFanin1 = Dar_ObjFanin1(pObj);
pFanin1 = Aig_ObjFanin1(pObj);
if ( pFanin1 == NULL )
continue;
if ( Dar_ObjIsTravIdCurrent(p, pFanin1) )
if ( Aig_ObjIsTravIdCurrent(p, pFanin1) )
pFanin1->fMarkA = 1;
}
// count the objects
Dar_ManForEachObj( p, pObj, i )
Aig_ManForEachObj( p, pObj, i )
Counter2 += pObj->fMarkA, pObj->fMarkA = 0;
printf( "Connections = %d.\n", Counter2 );
*/
......@@ -336,36 +336,36 @@ int Dar_ManSeqRehashOne( Dar_Man_t * p, Vec_Ptr_t * vNodes, Vec_Ptr_t * vUnreach
Vec_PtrForEachEntry( vNodes, pObj, i )
{
// skip nodes unreachable from the PIs
if ( Dar_ObjIsTravIdCurrent(p, pObj) )
if ( Aig_ObjIsTravIdCurrent(p, pObj) )
continue;
// process the node
if ( Dar_ObjIsPo(pObj) )
if ( Aig_ObjIsPo(pObj) )
{
if ( !Dar_ObjIsBuf(Dar_ObjFanin0(pObj)) )
if ( !Aig_ObjIsBuf(Aig_ObjFanin0(pObj)) )
continue;
pFanin0 = Dar_ObjReal_rec( Dar_ObjChild0(pObj) );
Dar_ObjPatchFanin0( p, pObj, pFanin0 );
pFanin0 = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
Aig_ObjPatchFanin0( p, pObj, pFanin0 );
continue;
}
if ( Dar_ObjIsLatch(pObj) )
if ( Aig_ObjIsLatch(pObj) )
{
if ( !Dar_ObjIsBuf(Dar_ObjFanin0(pObj)) )
if ( !Aig_ObjIsBuf(Aig_ObjFanin0(pObj)) )
continue;
pObjNew = Dar_ObjReal_rec( Dar_ObjChild0(pObj) );
pObjNew = Dar_Latch( p, pObjNew, 0 );
Dar_ObjReplace( p, pObj, pObjNew, 1 );
pObjNew = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
pObjNew = Aig_Latch( p, pObjNew, 0 );
Aig_ObjReplace( p, pObj, pObjNew, 1 );
RetValue = 1;
Counter++;
continue;
}
if ( Dar_ObjIsNode(pObj) )
if ( Aig_ObjIsNode(pObj) )
{
if ( !Dar_ObjIsBuf(Dar_ObjFanin0(pObj)) && !Dar_ObjIsBuf(Dar_ObjFanin1(pObj)) )
if ( !Aig_ObjIsBuf(Aig_ObjFanin0(pObj)) && !Aig_ObjIsBuf(Aig_ObjFanin1(pObj)) )
continue;
pFanin0 = Dar_ObjReal_rec( Dar_ObjChild0(pObj) );
pFanin1 = Dar_ObjReal_rec( Dar_ObjChild1(pObj) );
pObjNew = Dar_And( p, pFanin0, pFanin1 );
Dar_ObjReplace( p, pObj, pObjNew, 1 );
pFanin0 = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
pFanin1 = Aig_ObjReal_rec( Aig_ObjChild1(pObj) );
pObjNew = Aig_And( p, pFanin0, pFanin1 );
Aig_ObjReplace( p, pObj, pObjNew, 1 );
RetValue = 1;
Counter++;
continue;
......@@ -386,40 +386,40 @@ int Dar_ManSeqRehashOne( Dar_Man_t * p, Vec_Ptr_t * vNodes, Vec_Ptr_t * vUnreach
SeeAlso []
***********************************************************************/
void Dar_ManRemoveBuffers( Dar_Man_t * p )
void Aig_ManRemoveBuffers( Aig_Man_t * p )
{
Dar_Obj_t * pObj, * pObjNew, * pFanin0, * pFanin1;
Aig_Obj_t * pObj, * pObjNew, * pFanin0, * pFanin1;
int i;
if ( Dar_ManBufNum(p) == 0 )
if ( Aig_ManBufNum(p) == 0 )
return;
Dar_ManForEachObj( p, pObj, i )
Aig_ManForEachObj( p, pObj, i )
{
if ( Dar_ObjIsPo(pObj) )
if ( Aig_ObjIsPo(pObj) )
{
if ( !Dar_ObjIsBuf(Dar_ObjFanin0(pObj)) )
if ( !Aig_ObjIsBuf(Aig_ObjFanin0(pObj)) )
continue;
pFanin0 = Dar_ObjReal_rec( Dar_ObjChild0(pObj) );
Dar_ObjPatchFanin0( p, pObj, pFanin0 );
pFanin0 = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
Aig_ObjPatchFanin0( p, pObj, pFanin0 );
}
else if ( Dar_ObjIsLatch(pObj) )
else if ( Aig_ObjIsLatch(pObj) )
{
if ( !Dar_ObjIsBuf(Dar_ObjFanin0(pObj)) )
if ( !Aig_ObjIsBuf(Aig_ObjFanin0(pObj)) )
continue;
pFanin0 = Dar_ObjReal_rec( Dar_ObjChild0(pObj) );
pObjNew = Dar_Latch( p, pFanin0, 0 );
Dar_ObjReplace( p, pObj, pObjNew, 0 );
pFanin0 = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
pObjNew = Aig_Latch( p, pFanin0, 0 );
Aig_ObjReplace( p, pObj, pObjNew, 0 );
}
else if ( Dar_ObjIsAnd(pObj) )
else if ( Aig_ObjIsAnd(pObj) )
{
if ( !Dar_ObjIsBuf(Dar_ObjFanin0(pObj)) && !Dar_ObjIsBuf(Dar_ObjFanin1(pObj)) )
if ( !Aig_ObjIsBuf(Aig_ObjFanin0(pObj)) && !Aig_ObjIsBuf(Aig_ObjFanin1(pObj)) )
continue;
pFanin0 = Dar_ObjReal_rec( Dar_ObjChild0(pObj) );
pFanin1 = Dar_ObjReal_rec( Dar_ObjChild1(pObj) );
pObjNew = Dar_And( p, pFanin0, pFanin1 );
Dar_ObjReplace( p, pObj, pObjNew, 0 );
pFanin0 = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
pFanin1 = Aig_ObjReal_rec( Aig_ObjChild1(pObj) );
pObjNew = Aig_And( p, pFanin0, pFanin1 );
Aig_ObjReplace( p, pObj, pObjNew, 0 );
}
}
assert( Dar_ManBufNum(p) == 0 );
assert( Aig_ManBufNum(p) == 0 );
}
/**Function*************************************************************
......@@ -433,57 +433,57 @@ void Dar_ManRemoveBuffers( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
int Dar_ManSeqStrash( Dar_Man_t * p, int nLatches, int * pInits )
int Aig_ManSeqStrash( Aig_Man_t * p, int nLatches, int * pInits )
{
Vec_Ptr_t * vNodes, * vUnreach;
// Dar_Obj_t * pObj, * pFanin;
// Aig_Obj_t * pObj, * pFanin;
// int i;
int Iter, RetValue = 1;
// create latches out of the additional PI/PO pairs
Dar_ManSeqStrashConvert( p, nLatches, pInits );
Aig_ManSeqStrashConvert( p, nLatches, pInits );
// iteratively rehash the network
for ( Iter = 0; RetValue; Iter++ )
{
// Dar_ManPrintStats( p );
// Aig_ManPrintStats( p );
/*
Dar_ManForEachObj( p, pObj, i )
Aig_ManForEachObj( p, pObj, i )
{
assert( pObj->Type > 0 );
pFanin = Dar_ObjFanin0(pObj);
pFanin = Aig_ObjFanin0(pObj);
assert( pFanin == NULL || pFanin->Type > 0 );
pFanin = Dar_ObjFanin1(pObj);
pFanin = Aig_ObjFanin1(pObj);
assert( pFanin == NULL || pFanin->Type > 0 );
}
*/
// mark nodes unreachable from the PIs
vUnreach = Dar_ManDfsUnreach( p );
vUnreach = Aig_ManDfsUnreach( p );
if ( Iter == 0 && Vec_PtrSize(vUnreach) > 0 )
printf( "Unreachable objects = %d.\n", Vec_PtrSize(vUnreach) );
// collect nodes reachable from the POs
vNodes = Dar_ManDfsSeq( p );
vNodes = Aig_ManDfsSeq( p );
// remove nodes unreachable from the POs
if ( Iter == 0 )
Dar_ManRemoveUnmarked( p );
Aig_ManRemoveUnmarked( p );
// continue rehashing as long as there are changes
RetValue = Dar_ManSeqRehashOne( p, vNodes, vUnreach );
RetValue = Aig_ManSeqRehashOne( p, vNodes, vUnreach );
Vec_PtrFree( vNodes );
Vec_PtrFree( vUnreach );
}
// perform the final cleanup
Dar_ManIncrementTravId( p );
vNodes = Dar_ManDfsSeq( p );
Dar_ManRemoveUnmarked( p );
Aig_ManIncrementTravId( p );
vNodes = Aig_ManDfsSeq( p );
Aig_ManRemoveUnmarked( p );
Vec_PtrFree( vNodes );
// remove buffers if they are left
// Dar_ManRemoveBuffers( p );
// Aig_ManRemoveBuffers( p );
// clean up
if ( !Dar_ManCheck( p ) )
if ( !Aig_ManCheck( p ) )
{
printf( "Dar_ManSeqStrash: The network check has failed.\n" );
printf( "Aig_ManSeqStrash: The network check has failed.\n" );
return 0;
}
return 1;
......
/**CFile****************************************************************
FileName [darTable.c]
FileName [aigTable.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting.]
PackageName [AIG package.]
Synopsis [Structural hashing table.]
......@@ -14,48 +14,48 @@
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: darTable.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
Revision [$Id: aigTable.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#include "dar.h"
#include "aig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
// hashing the node
static unsigned long Dar_Hash( Dar_Obj_t * pObj, int TableSize )
static unsigned long Aig_Hash( Aig_Obj_t * pObj, int TableSize )
{
unsigned long Key = Dar_ObjIsExor(pObj) * 1699;
Key ^= (long)Dar_ObjFanin0(pObj) * 7937;
Key ^= (long)Dar_ObjFanin1(pObj) * 2971;
Key ^= Dar_ObjFaninC0(pObj) * 911;
Key ^= Dar_ObjFaninC1(pObj) * 353;
unsigned long Key = Aig_ObjIsExor(pObj) * 1699;
Key ^= (long)Aig_ObjFanin0(pObj) * 7937;
Key ^= (long)Aig_ObjFanin1(pObj) * 2971;
Key ^= Aig_ObjFaninC0(pObj) * 911;
Key ^= Aig_ObjFaninC1(pObj) * 353;
return Key % TableSize;
}
// returns the place where this node is stored (or should be stored)
static Dar_Obj_t ** Dar_TableFind( Dar_Man_t * p, Dar_Obj_t * pObj )
static Aig_Obj_t ** Aig_TableFind( Aig_Man_t * p, Aig_Obj_t * pObj )
{
Dar_Obj_t ** ppEntry;
if ( Dar_ObjIsLatch(pObj) )
Aig_Obj_t ** ppEntry;
if ( Aig_ObjIsLatch(pObj) )
{
assert( Dar_ObjChild0(pObj) && Dar_ObjChild1(pObj) == NULL );
assert( Aig_ObjChild0(pObj) && Aig_ObjChild1(pObj) == NULL );
}
else
{
assert( Dar_ObjChild0(pObj) && Dar_ObjChild1(pObj) );
assert( Dar_ObjFanin0(pObj)->Id < Dar_ObjFanin1(pObj)->Id );
assert( Aig_ObjChild0(pObj) && Aig_ObjChild1(pObj) );
assert( Aig_ObjFanin0(pObj)->Id < Aig_ObjFanin1(pObj)->Id );
}
for ( ppEntry = p->pTable + Dar_Hash(pObj, p->nTableSize); *ppEntry; ppEntry = &(*ppEntry)->pNext )
for ( ppEntry = p->pTable + Aig_Hash(pObj, p->nTableSize); *ppEntry; ppEntry = &(*ppEntry)->pNext )
if ( *ppEntry == pObj )
return ppEntry;
assert( *ppEntry == NULL );
return ppEntry;
}
static void Dar_TableResize( Dar_Man_t * p );
static void Aig_TableResize( Aig_Man_t * p );
static unsigned int Cudd_PrimeAig( unsigned int p );
////////////////////////////////////////////////////////////////////////
......@@ -73,29 +73,29 @@ static unsigned int Cudd_PrimeAig( unsigned int p );
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_TableLookup( Dar_Man_t * p, Dar_Obj_t * pGhost )
Aig_Obj_t * Aig_TableLookup( Aig_Man_t * p, Aig_Obj_t * pGhost )
{
Dar_Obj_t * pEntry;
assert( !Dar_IsComplement(pGhost) );
if ( pGhost->Type == DAR_AIG_LATCH )
Aig_Obj_t * pEntry;
assert( !Aig_IsComplement(pGhost) );
if ( pGhost->Type == AIG_OBJ_LATCH )
{
assert( Dar_ObjChild0(pGhost) && Dar_ObjChild1(pGhost) == NULL );
if ( !Dar_ObjRefs(Dar_ObjFanin0(pGhost)) )
assert( Aig_ObjChild0(pGhost) && Aig_ObjChild1(pGhost) == NULL );
if ( !Aig_ObjRefs(Aig_ObjFanin0(pGhost)) )
return NULL;
}
else
{
assert( pGhost->Type == DAR_AIG_AND );
assert( Dar_ObjChild0(pGhost) && Dar_ObjChild1(pGhost) );
assert( Dar_ObjFanin0(pGhost)->Id < Dar_ObjFanin1(pGhost)->Id );
if ( !Dar_ObjRefs(Dar_ObjFanin0(pGhost)) || !Dar_ObjRefs(Dar_ObjFanin1(pGhost)) )
assert( pGhost->Type == AIG_OBJ_AND );
assert( Aig_ObjChild0(pGhost) && Aig_ObjChild1(pGhost) );
assert( Aig_ObjFanin0(pGhost)->Id < Aig_ObjFanin1(pGhost)->Id );
if ( !Aig_ObjRefs(Aig_ObjFanin0(pGhost)) || !Aig_ObjRefs(Aig_ObjFanin1(pGhost)) )
return NULL;
}
for ( pEntry = p->pTable[Dar_Hash(pGhost, p->nTableSize)]; pEntry; pEntry = pEntry->pNext )
for ( pEntry = p->pTable[Aig_Hash(pGhost, p->nTableSize)]; pEntry; pEntry = pEntry->pNext )
{
if ( Dar_ObjChild0(pEntry) == Dar_ObjChild0(pGhost) &&
Dar_ObjChild1(pEntry) == Dar_ObjChild1(pGhost) &&
Dar_ObjType(pEntry) == Dar_ObjType(pGhost) )
if ( Aig_ObjChild0(pEntry) == Aig_ObjChild0(pGhost) &&
Aig_ObjChild1(pEntry) == Aig_ObjChild1(pGhost) &&
Aig_ObjType(pEntry) == Aig_ObjType(pGhost) )
return pEntry;
}
return NULL;
......@@ -112,14 +112,14 @@ Dar_Obj_t * Dar_TableLookup( Dar_Man_t * p, Dar_Obj_t * pGhost )
SeeAlso []
***********************************************************************/
void Dar_TableInsert( Dar_Man_t * p, Dar_Obj_t * pObj )
void Aig_TableInsert( Aig_Man_t * p, Aig_Obj_t * pObj )
{
Dar_Obj_t ** ppPlace;
assert( !Dar_IsComplement(pObj) );
assert( Dar_TableLookup(p, pObj) == NULL );
if ( (pObj->Id & 0xFF) == 0 && 2 * p->nTableSize < Dar_ManNodeNum(p) )
Dar_TableResize( p );
ppPlace = Dar_TableFind( p, pObj );
Aig_Obj_t ** ppPlace;
assert( !Aig_IsComplement(pObj) );
assert( Aig_TableLookup(p, pObj) == NULL );
if ( (pObj->Id & 0xFF) == 0 && 2 * p->nTableSize < Aig_ManNodeNum(p) )
Aig_TableResize( p );
ppPlace = Aig_TableFind( p, pObj );
assert( *ppPlace == NULL );
*ppPlace = pObj;
}
......@@ -135,11 +135,11 @@ void Dar_TableInsert( Dar_Man_t * p, Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Dar_TableDelete( Dar_Man_t * p, Dar_Obj_t * pObj )
void Aig_TableDelete( Aig_Man_t * p, Aig_Obj_t * pObj )
{
Dar_Obj_t ** ppPlace;
assert( !Dar_IsComplement(pObj) );
ppPlace = Dar_TableFind( p, pObj );
Aig_Obj_t ** ppPlace;
assert( !Aig_IsComplement(pObj) );
ppPlace = Aig_TableFind( p, pObj );
assert( *ppPlace == pObj ); // node should be in the table
// remove the node
*ppPlace = pObj->pNext;
......@@ -157,9 +157,9 @@ void Dar_TableDelete( Dar_Man_t * p, Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
int Dar_TableCountEntries( Dar_Man_t * p )
int Aig_TableCountEntries( Aig_Man_t * p )
{
Dar_Obj_t * pEntry;
Aig_Obj_t * pEntry;
int i, Counter = 0;
for ( i = 0; i < p->nTableSize; i++ )
for ( pEntry = p->pTable[i]; pEntry; pEntry = pEntry->pNext )
......@@ -178,33 +178,33 @@ int Dar_TableCountEntries( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
void Dar_TableResize( Dar_Man_t * p )
void Aig_TableResize( Aig_Man_t * p )
{
Dar_Obj_t * pEntry, * pNext;
Dar_Obj_t ** pTableOld, ** ppPlace;
Aig_Obj_t * pEntry, * pNext;
Aig_Obj_t ** pTableOld, ** ppPlace;
int nTableSizeOld, Counter, nEntries, i, clk;
clk = clock();
// save the old table
pTableOld = p->pTable;
nTableSizeOld = p->nTableSize;
// get the new table
p->nTableSize = Cudd_PrimeAig( 2 * Dar_ManNodeNum(p) );
p->pTable = ALLOC( Dar_Obj_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Dar_Obj_t *) * p->nTableSize );
p->nTableSize = Cudd_PrimeAig( 2 * Aig_ManNodeNum(p) );
p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
// rehash the entries from the old table
Counter = 0;
for ( i = 0; i < nTableSizeOld; i++ )
for ( pEntry = pTableOld[i], pNext = pEntry? pEntry->pNext : NULL; pEntry; pEntry = pNext, pNext = pEntry? pEntry->pNext : NULL )
{
// get the place where this entry goes in the table
ppPlace = Dar_TableFind( p, pEntry );
ppPlace = Aig_TableFind( p, pEntry );
assert( *ppPlace == NULL ); // should not be there
// add the entry to the list
*ppPlace = pEntry;
pEntry->pNext = NULL;
Counter++;
}
nEntries = Dar_ManNodeNum(p);
nEntries = Aig_ManNodeNum(p);
assert( Counter == nEntries );
printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize );
PRT( "Time", clock() - clk );
......@@ -223,9 +223,9 @@ clk = clock();
SeeAlso []
******************************************************************************/
void Dar_TableProfile( Dar_Man_t * p )
void Aig_TableProfile( Aig_Man_t * p )
{
Dar_Obj_t * pEntry;
Aig_Obj_t * pEntry;
int i, Counter;
for ( i = 0; i < p->nTableSize; i++ )
{
......
/**CFile****************************************************************
FileName [darUtil.c]
FileName [aigUtil.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting.]
PackageName [AIG package.]
Synopsis [Various procedures.]
......@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: darUtil.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
Revision [$Id: aigUtil.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#include "dar.h"
#include "aig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -28,24 +28,41 @@
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
/**Function********************************************************************
Synopsis [Returns the structure with default assignment of parameters.]
Synopsis [Returns the next prime >= p.]
Description []
SideEffects []
Description [Copied from CUDD, for stand-aloneness.]
SideEffects [None]
SeeAlso []
***********************************************************************/
Dar_Par_t * Dar_ManDefaultParams()
******************************************************************************/
unsigned int Aig_PrimeCudd( unsigned int p )
{
Dar_Par_t * p;
p = ALLOC( Dar_Par_t, 1 );
memset( p, 0, sizeof(Dar_Par_t) );
return p;
}
int i,pn;
p--;
do {
p++;
if (p&1) {
pn = 1;
i = 3;
while ((unsigned) (i * i) <= p) {
if (p % i == 0) {
pn = 0;
break;
}
i += 2;
}
} else {
pn = 0;
}
} while (!pn);
return(p);
} /* end of Cudd_Prime */
/**Function*************************************************************
......@@ -58,10 +75,10 @@ Dar_Par_t * Dar_ManDefaultParams()
SeeAlso []
***********************************************************************/
void Dar_ManIncrementTravId( Dar_Man_t * p )
void Aig_ManIncrementTravId( Aig_Man_t * p )
{
if ( p->nTravIds >= (1<<30)-1 )
Dar_ManCleanData( p );
Aig_ManCleanData( p );
p->nTravIds++;
}
......@@ -76,12 +93,12 @@ void Dar_ManIncrementTravId( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
int Dar_ManLevels( Dar_Man_t * p )
int Aig_ManLevels( Aig_Man_t * p )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i, LevelMax = 0;
Dar_ManForEachPo( p, pObj, i )
LevelMax = DAR_MAX( LevelMax, (int)Dar_ObjFanin0(pObj)->Level );
Aig_ManForEachPo( p, pObj, i )
LevelMax = AIG_MAX( LevelMax, (int)Aig_ObjFanin0(pObj)->Level );
return LevelMax;
}
......@@ -96,11 +113,11 @@ int Dar_ManLevels( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
void Dar_ManCleanData( Dar_Man_t * p )
void Aig_ManCleanData( Aig_Man_t * p )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
Dar_ManForEachObj( p, pObj, i )
Aig_ManForEachObj( p, pObj, i )
pObj->pData = NULL;
}
......@@ -115,14 +132,14 @@ void Dar_ManCleanData( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
void Dar_ObjCleanData_rec( Dar_Obj_t * pObj )
void Aig_ObjCleanData_rec( Aig_Obj_t * pObj )
{
assert( !Dar_IsComplement(pObj) );
assert( !Dar_ObjIsPo(pObj) );
if ( Dar_ObjIsAnd(pObj) )
assert( !Aig_IsComplement(pObj) );
assert( !Aig_ObjIsPo(pObj) );
if ( Aig_ObjIsAnd(pObj) )
{
Dar_ObjCleanData_rec( Dar_ObjFanin0(pObj) );
Dar_ObjCleanData_rec( Dar_ObjFanin1(pObj) );
Aig_ObjCleanData_rec( Aig_ObjFanin0(pObj) );
Aig_ObjCleanData_rec( Aig_ObjFanin1(pObj) );
}
pObj->pData = NULL;
}
......@@ -138,15 +155,15 @@ void Dar_ObjCleanData_rec( Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Dar_ObjCollectMulti_rec( Dar_Obj_t * pRoot, Dar_Obj_t * pObj, Vec_Ptr_t * vSuper )
void Aig_ObjCollectMulti_rec( Aig_Obj_t * pRoot, Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
{
if ( pRoot != pObj && (Dar_IsComplement(pObj) || Dar_ObjIsPi(pObj) || Dar_ObjType(pRoot) != Dar_ObjType(pObj)) )
if ( pRoot != pObj && (Aig_IsComplement(pObj) || Aig_ObjIsPi(pObj) || Aig_ObjType(pRoot) != Aig_ObjType(pObj)) )
{
Vec_PtrPushUnique(vSuper, pObj);
return;
}
Dar_ObjCollectMulti_rec( pRoot, Dar_ObjChild0(pObj), vSuper );
Dar_ObjCollectMulti_rec( pRoot, Dar_ObjChild1(pObj), vSuper );
Aig_ObjCollectMulti_rec( pRoot, Aig_ObjChild0(pObj), vSuper );
Aig_ObjCollectMulti_rec( pRoot, Aig_ObjChild1(pObj), vSuper );
}
/**Function*************************************************************
......@@ -160,11 +177,11 @@ void Dar_ObjCollectMulti_rec( Dar_Obj_t * pRoot, Dar_Obj_t * pObj, Vec_Ptr_t * v
SeeAlso []
***********************************************************************/
void Dar_ObjCollectMulti( Dar_Obj_t * pRoot, Vec_Ptr_t * vSuper )
void Aig_ObjCollectMulti( Aig_Obj_t * pRoot, Vec_Ptr_t * vSuper )
{
assert( !Dar_IsComplement(pRoot) );
assert( !Aig_IsComplement(pRoot) );
Vec_PtrClear( vSuper );
Dar_ObjCollectMulti_rec( pRoot, pRoot, vSuper );
Aig_ObjCollectMulti_rec( pRoot, pRoot, vSuper );
}
/**Function*************************************************************
......@@ -178,28 +195,28 @@ void Dar_ObjCollectMulti( Dar_Obj_t * pRoot, Vec_Ptr_t * vSuper )
SeeAlso []
***********************************************************************/
int Dar_ObjIsMuxType( Dar_Obj_t * pNode )
int Aig_ObjIsMuxType( Aig_Obj_t * pNode )
{
Dar_Obj_t * pNode0, * pNode1;
Aig_Obj_t * pNode0, * pNode1;
// check that the node is regular
assert( !Dar_IsComplement(pNode) );
assert( !Aig_IsComplement(pNode) );
// if the node is not AND, this is not MUX
if ( !Dar_ObjIsAnd(pNode) )
if ( !Aig_ObjIsAnd(pNode) )
return 0;
// if the children are not complemented, this is not MUX
if ( !Dar_ObjFaninC0(pNode) || !Dar_ObjFaninC1(pNode) )
if ( !Aig_ObjFaninC0(pNode) || !Aig_ObjFaninC1(pNode) )
return 0;
// get children
pNode0 = Dar_ObjFanin0(pNode);
pNode1 = Dar_ObjFanin1(pNode);
pNode0 = Aig_ObjFanin0(pNode);
pNode1 = Aig_ObjFanin1(pNode);
// if the children are not ANDs, this is not MUX
if ( !Dar_ObjIsAnd(pNode0) || !Dar_ObjIsAnd(pNode1) )
if ( !Aig_ObjIsAnd(pNode0) || !Aig_ObjIsAnd(pNode1) )
return 0;
// otherwise the node is MUX iff it has a pair of equal grandchildren
return (Dar_ObjFanin0(pNode0) == Dar_ObjFanin0(pNode1) && (Dar_ObjFaninC0(pNode0) ^ Dar_ObjFaninC0(pNode1))) ||
(Dar_ObjFanin0(pNode0) == Dar_ObjFanin1(pNode1) && (Dar_ObjFaninC0(pNode0) ^ Dar_ObjFaninC1(pNode1))) ||
(Dar_ObjFanin1(pNode0) == Dar_ObjFanin0(pNode1) && (Dar_ObjFaninC1(pNode0) ^ Dar_ObjFaninC0(pNode1))) ||
(Dar_ObjFanin1(pNode0) == Dar_ObjFanin1(pNode1) && (Dar_ObjFaninC1(pNode0) ^ Dar_ObjFaninC1(pNode1)));
return (Aig_ObjFanin0(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC0(pNode1))) ||
(Aig_ObjFanin0(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC1(pNode1))) ||
(Aig_ObjFanin1(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC0(pNode1))) ||
(Aig_ObjFanin1(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC1(pNode1)));
}
......@@ -214,33 +231,33 @@ int Dar_ObjIsMuxType( Dar_Obj_t * pNode )
SeeAlso []
***********************************************************************/
int Dar_ObjRecognizeExor( Dar_Obj_t * pObj, Dar_Obj_t ** ppFan0, Dar_Obj_t ** ppFan1 )
int Aig_ObjRecognizeExor( Aig_Obj_t * pObj, Aig_Obj_t ** ppFan0, Aig_Obj_t ** ppFan1 )
{
Dar_Obj_t * p0, * p1;
assert( !Dar_IsComplement(pObj) );
if ( !Dar_ObjIsNode(pObj) )
Aig_Obj_t * p0, * p1;
assert( !Aig_IsComplement(pObj) );
if ( !Aig_ObjIsNode(pObj) )
return 0;
if ( Dar_ObjIsExor(pObj) )
if ( Aig_ObjIsExor(pObj) )
{
*ppFan0 = Dar_ObjChild0(pObj);
*ppFan1 = Dar_ObjChild1(pObj);
*ppFan0 = Aig_ObjChild0(pObj);
*ppFan1 = Aig_ObjChild1(pObj);
return 1;
}
assert( Dar_ObjIsAnd(pObj) );
p0 = Dar_ObjChild0(pObj);
p1 = Dar_ObjChild1(pObj);
if ( !Dar_IsComplement(p0) || !Dar_IsComplement(p1) )
assert( Aig_ObjIsAnd(pObj) );
p0 = Aig_ObjChild0(pObj);
p1 = Aig_ObjChild1(pObj);
if ( !Aig_IsComplement(p0) || !Aig_IsComplement(p1) )
return 0;
p0 = Dar_Regular(p0);
p1 = Dar_Regular(p1);
if ( !Dar_ObjIsAnd(p0) || !Dar_ObjIsAnd(p1) )
p0 = Aig_Regular(p0);
p1 = Aig_Regular(p1);
if ( !Aig_ObjIsAnd(p0) || !Aig_ObjIsAnd(p1) )
return 0;
if ( Dar_ObjFanin0(p0) != Dar_ObjFanin0(p1) || Dar_ObjFanin1(p0) != Dar_ObjFanin1(p1) )
if ( Aig_ObjFanin0(p0) != Aig_ObjFanin0(p1) || Aig_ObjFanin1(p0) != Aig_ObjFanin1(p1) )
return 0;
if ( Dar_ObjFaninC0(p0) == Dar_ObjFaninC0(p1) || Dar_ObjFaninC1(p0) == Dar_ObjFaninC1(p1) )
if ( Aig_ObjFaninC0(p0) == Aig_ObjFaninC0(p1) || Aig_ObjFaninC1(p0) == Aig_ObjFaninC1(p1) )
return 0;
*ppFan0 = Dar_ObjChild0(p0);
*ppFan1 = Dar_ObjChild1(p0);
*ppFan0 = Aig_ObjChild0(p0);
*ppFan1 = Aig_ObjChild1(p0);
return 1;
}
......@@ -258,78 +275,78 @@ int Dar_ObjRecognizeExor( Dar_Obj_t * pObj, Dar_Obj_t ** ppFan0, Dar_Obj_t ** pp
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_ObjRecognizeMux( Dar_Obj_t * pNode, Dar_Obj_t ** ppNodeT, Dar_Obj_t ** ppNodeE )
Aig_Obj_t * Aig_ObjRecognizeMux( Aig_Obj_t * pNode, Aig_Obj_t ** ppNodeT, Aig_Obj_t ** ppNodeE )
{
Dar_Obj_t * pNode0, * pNode1;
assert( !Dar_IsComplement(pNode) );
assert( Dar_ObjIsMuxType(pNode) );
Aig_Obj_t * pNode0, * pNode1;
assert( !Aig_IsComplement(pNode) );
assert( Aig_ObjIsMuxType(pNode) );
// get children
pNode0 = Dar_ObjFanin0(pNode);
pNode1 = Dar_ObjFanin1(pNode);
pNode0 = Aig_ObjFanin0(pNode);
pNode1 = Aig_ObjFanin1(pNode);
// find the control variable
if ( Dar_ObjFanin1(pNode0) == Dar_ObjFanin1(pNode1) && (Dar_ObjFaninC1(pNode0) ^ Dar_ObjFaninC1(pNode1)) )
if ( Aig_ObjFanin1(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC1(pNode1)) )
{
// if ( Fraig_IsComplement(pNode1->p2) )
if ( Dar_ObjFaninC1(pNode0) )
if ( Aig_ObjFaninC1(pNode0) )
{ // pNode2->p2 is positive phase of C
*ppNodeT = Dar_Not(Dar_ObjChild0(pNode1));//pNode2->p1);
*ppNodeE = Dar_Not(Dar_ObjChild0(pNode0));//pNode1->p1);
return Dar_ObjChild1(pNode1);//pNode2->p2;
*ppNodeT = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
*ppNodeE = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
return Aig_ObjChild1(pNode1);//pNode2->p2;
}
else
{ // pNode1->p2 is positive phase of C
*ppNodeT = Dar_Not(Dar_ObjChild0(pNode0));//pNode1->p1);
*ppNodeE = Dar_Not(Dar_ObjChild0(pNode1));//pNode2->p1);
return Dar_ObjChild1(pNode0);//pNode1->p2;
*ppNodeT = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
*ppNodeE = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
return Aig_ObjChild1(pNode0);//pNode1->p2;
}
}
else if ( Dar_ObjFanin0(pNode0) == Dar_ObjFanin0(pNode1) && (Dar_ObjFaninC0(pNode0) ^ Dar_ObjFaninC0(pNode1)) )
else if ( Aig_ObjFanin0(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC0(pNode1)) )
{
// if ( Fraig_IsComplement(pNode1->p1) )
if ( Dar_ObjFaninC0(pNode0) )
if ( Aig_ObjFaninC0(pNode0) )
{ // pNode2->p1 is positive phase of C
*ppNodeT = Dar_Not(Dar_ObjChild1(pNode1));//pNode2->p2);
*ppNodeE = Dar_Not(Dar_ObjChild1(pNode0));//pNode1->p2);
return Dar_ObjChild0(pNode1);//pNode2->p1;
*ppNodeT = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
*ppNodeE = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
return Aig_ObjChild0(pNode1);//pNode2->p1;
}
else
{ // pNode1->p1 is positive phase of C
*ppNodeT = Dar_Not(Dar_ObjChild1(pNode0));//pNode1->p2);
*ppNodeE = Dar_Not(Dar_ObjChild1(pNode1));//pNode2->p2);
return Dar_ObjChild0(pNode0);//pNode1->p1;
*ppNodeT = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
*ppNodeE = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
return Aig_ObjChild0(pNode0);//pNode1->p1;
}
}
else if ( Dar_ObjFanin0(pNode0) == Dar_ObjFanin1(pNode1) && (Dar_ObjFaninC0(pNode0) ^ Dar_ObjFaninC1(pNode1)) )
else if ( Aig_ObjFanin0(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC1(pNode1)) )
{
// if ( Fraig_IsComplement(pNode1->p1) )
if ( Dar_ObjFaninC0(pNode0) )
if ( Aig_ObjFaninC0(pNode0) )
{ // pNode2->p2 is positive phase of C
*ppNodeT = Dar_Not(Dar_ObjChild0(pNode1));//pNode2->p1);
*ppNodeE = Dar_Not(Dar_ObjChild1(pNode0));//pNode1->p2);
return Dar_ObjChild1(pNode1);//pNode2->p2;
*ppNodeT = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
*ppNodeE = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
return Aig_ObjChild1(pNode1);//pNode2->p2;
}
else
{ // pNode1->p1 is positive phase of C
*ppNodeT = Dar_Not(Dar_ObjChild1(pNode0));//pNode1->p2);
*ppNodeE = Dar_Not(Dar_ObjChild0(pNode1));//pNode2->p1);
return Dar_ObjChild0(pNode0);//pNode1->p1;
*ppNodeT = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
*ppNodeE = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
return Aig_ObjChild0(pNode0);//pNode1->p1;
}
}
else if ( Dar_ObjFanin1(pNode0) == Dar_ObjFanin0(pNode1) && (Dar_ObjFaninC1(pNode0) ^ Dar_ObjFaninC0(pNode1)) )
else if ( Aig_ObjFanin1(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC0(pNode1)) )
{
// if ( Fraig_IsComplement(pNode1->p2) )
if ( Dar_ObjFaninC1(pNode0) )
if ( Aig_ObjFaninC1(pNode0) )
{ // pNode2->p1 is positive phase of C
*ppNodeT = Dar_Not(Dar_ObjChild1(pNode1));//pNode2->p2);
*ppNodeE = Dar_Not(Dar_ObjChild0(pNode0));//pNode1->p1);
return Dar_ObjChild0(pNode1);//pNode2->p1;
*ppNodeT = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
*ppNodeE = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
return Aig_ObjChild0(pNode1);//pNode2->p1;
}
else
{ // pNode1->p2 is positive phase of C
*ppNodeT = Dar_Not(Dar_ObjChild0(pNode0));//pNode1->p1);
*ppNodeE = Dar_Not(Dar_ObjChild1(pNode1));//pNode2->p2);
return Dar_ObjChild1(pNode0);//pNode1->p2;
*ppNodeT = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
*ppNodeE = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
return Aig_ObjChild1(pNode0);//pNode1->p2;
}
}
assert( 0 ); // this is not MUX
......@@ -347,13 +364,13 @@ Dar_Obj_t * Dar_ObjRecognizeMux( Dar_Obj_t * pNode, Dar_Obj_t ** ppNodeT, Dar_Ob
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_ObjReal_rec( Dar_Obj_t * pObj )
Aig_Obj_t * Aig_ObjReal_rec( Aig_Obj_t * pObj )
{
Dar_Obj_t * pObjNew, * pObjR = Dar_Regular(pObj);
if ( !Dar_ObjIsBuf(pObjR) )
Aig_Obj_t * pObjNew, * pObjR = Aig_Regular(pObj);
if ( !Aig_ObjIsBuf(pObjR) )
return pObj;
pObjNew = Dar_ObjReal_rec( Dar_ObjChild0(pObjR) );
return Dar_NotCond( pObjNew, Dar_IsComplement(pObj) );
pObjNew = Aig_ObjReal_rec( Aig_ObjChild0(pObjR) );
return Aig_NotCond( pObjNew, Aig_IsComplement(pObj) );
}
......@@ -369,22 +386,22 @@ Dar_Obj_t * Dar_ObjReal_rec( Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Dar_ObjPrintEqn( FILE * pFile, Dar_Obj_t * pObj, Vec_Vec_t * vLevels, int Level )
void Aig_ObjPrintEqn( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, int Level )
{
Vec_Ptr_t * vSuper;
Dar_Obj_t * pFanin;
Aig_Obj_t * pFanin;
int fCompl, i;
// store the complemented attribute
fCompl = Dar_IsComplement(pObj);
pObj = Dar_Regular(pObj);
fCompl = Aig_IsComplement(pObj);
pObj = Aig_Regular(pObj);
// constant case
if ( Dar_ObjIsConst1(pObj) )
if ( Aig_ObjIsConst1(pObj) )
{
fprintf( pFile, "%d", !fCompl );
return;
}
// PI case
if ( Dar_ObjIsPi(pObj) )
if ( Aig_ObjIsPi(pObj) )
{
fprintf( pFile, "%s%s", fCompl? "!" : "", pObj->pData );
return;
......@@ -392,11 +409,11 @@ void Dar_ObjPrintEqn( FILE * pFile, Dar_Obj_t * pObj, Vec_Vec_t * vLevels, int L
// AND case
Vec_VecExpand( vLevels, Level );
vSuper = Vec_VecEntry(vLevels, Level);
Dar_ObjCollectMulti( pObj, vSuper );
Aig_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
Vec_PtrForEachEntry( vSuper, pFanin, i )
{
Dar_ObjPrintEqn( pFile, Dar_NotCond(pFanin, fCompl), vLevels, Level+1 );
Aig_ObjPrintEqn( pFile, Aig_NotCond(pFanin, fCompl), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
fprintf( pFile, " %s ", fCompl? "+" : "*" );
}
......@@ -416,36 +433,36 @@ void Dar_ObjPrintEqn( FILE * pFile, Dar_Obj_t * pObj, Vec_Vec_t * vLevels, int L
SeeAlso []
***********************************************************************/
void Dar_ObjPrintVerilog( FILE * pFile, Dar_Obj_t * pObj, Vec_Vec_t * vLevels, int Level )
void Aig_ObjPrintVerilog( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, int Level )
{
Vec_Ptr_t * vSuper;
Dar_Obj_t * pFanin, * pFanin0, * pFanin1, * pFaninC;
Aig_Obj_t * pFanin, * pFanin0, * pFanin1, * pFaninC;
int fCompl, i;
// store the complemented attribute
fCompl = Dar_IsComplement(pObj);
pObj = Dar_Regular(pObj);
fCompl = Aig_IsComplement(pObj);
pObj = Aig_Regular(pObj);
// constant case
if ( Dar_ObjIsConst1(pObj) )
if ( Aig_ObjIsConst1(pObj) )
{
fprintf( pFile, "1\'b%d", !fCompl );
return;
}
// PI case
if ( Dar_ObjIsPi(pObj) )
if ( Aig_ObjIsPi(pObj) )
{
fprintf( pFile, "%s%s", fCompl? "~" : "", pObj->pData );
return;
}
// EXOR case
if ( Dar_ObjIsExor(pObj) )
if ( Aig_ObjIsExor(pObj) )
{
Vec_VecExpand( vLevels, Level );
vSuper = Vec_VecEntry( vLevels, Level );
Dar_ObjCollectMulti( pObj, vSuper );
Aig_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
Vec_PtrForEachEntry( vSuper, pFanin, i )
{
Dar_ObjPrintVerilog( pFile, Dar_NotCond(pFanin, (fCompl && i==0)), vLevels, Level+1 );
Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin, (fCompl && i==0)), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
fprintf( pFile, " ^ " );
}
......@@ -453,25 +470,25 @@ void Dar_ObjPrintVerilog( FILE * pFile, Dar_Obj_t * pObj, Vec_Vec_t * vLevels, i
return;
}
// MUX case
if ( Dar_ObjIsMuxType(pObj) )
if ( Aig_ObjIsMuxType(pObj) )
{
if ( Dar_ObjRecognizeExor( pObj, &pFanin0, &pFanin1 ) )
if ( Aig_ObjRecognizeExor( pObj, &pFanin0, &pFanin1 ) )
{
fprintf( pFile, "%s", (Level==0? "" : "(") );
Dar_ObjPrintVerilog( pFile, Dar_NotCond(pFanin0, fCompl), vLevels, Level+1 );
Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin0, fCompl), vLevels, Level+1 );
fprintf( pFile, " ^ " );
Dar_ObjPrintVerilog( pFile, pFanin1, vLevels, Level+1 );
Aig_ObjPrintVerilog( pFile, pFanin1, vLevels, Level+1 );
fprintf( pFile, "%s", (Level==0? "" : ")") );
}
else
{
pFaninC = Dar_ObjRecognizeMux( pObj, &pFanin1, &pFanin0 );
pFaninC = Aig_ObjRecognizeMux( pObj, &pFanin1, &pFanin0 );
fprintf( pFile, "%s", (Level==0? "" : "(") );
Dar_ObjPrintVerilog( pFile, pFaninC, vLevels, Level+1 );
Aig_ObjPrintVerilog( pFile, pFaninC, vLevels, Level+1 );
fprintf( pFile, " ? " );
Dar_ObjPrintVerilog( pFile, Dar_NotCond(pFanin1, fCompl), vLevels, Level+1 );
Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin1, fCompl), vLevels, Level+1 );
fprintf( pFile, " : " );
Dar_ObjPrintVerilog( pFile, Dar_NotCond(pFanin0, fCompl), vLevels, Level+1 );
Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin0, fCompl), vLevels, Level+1 );
fprintf( pFile, "%s", (Level==0? "" : ")") );
}
return;
......@@ -479,11 +496,11 @@ void Dar_ObjPrintVerilog( FILE * pFile, Dar_Obj_t * pObj, Vec_Vec_t * vLevels, i
// AND case
Vec_VecExpand( vLevels, Level );
vSuper = Vec_VecEntry(vLevels, Level);
Dar_ObjCollectMulti( pObj, vSuper );
Aig_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
Vec_PtrForEachEntry( vSuper, pFanin, i )
{
Dar_ObjPrintVerilog( pFile, Dar_NotCond(pFanin, fCompl), vLevels, Level+1 );
Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin, fCompl), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
fprintf( pFile, " %s ", fCompl? "|" : "&" );
}
......@@ -503,19 +520,19 @@ void Dar_ObjPrintVerilog( FILE * pFile, Dar_Obj_t * pObj, Vec_Vec_t * vLevels, i
SeeAlso []
***********************************************************************/
void Dar_ObjPrintVerbose( Dar_Obj_t * pObj, int fHaig )
void Aig_ObjPrintVerbose( Aig_Obj_t * pObj, int fHaig )
{
assert( !Dar_IsComplement(pObj) );
assert( !Aig_IsComplement(pObj) );
printf( "Node %p : ", pObj );
if ( Dar_ObjIsConst1(pObj) )
if ( Aig_ObjIsConst1(pObj) )
printf( "constant 1" );
else if ( Dar_ObjIsPi(pObj) )
else if ( Aig_ObjIsPi(pObj) )
printf( "PI" );
else
printf( "AND( %p%s, %p%s )",
Dar_ObjFanin0(pObj), (Dar_ObjFaninC0(pObj)? "\'" : " "),
Dar_ObjFanin1(pObj), (Dar_ObjFaninC1(pObj)? "\'" : " ") );
printf( " (refs = %3d)", Dar_ObjRefs(pObj) );
Aig_ObjFanin0(pObj), (Aig_ObjFaninC0(pObj)? "\'" : " "),
Aig_ObjFanin1(pObj), (Aig_ObjFaninC1(pObj)? "\'" : " ") );
printf( " (refs = %3d)", Aig_ObjRefs(pObj) );
}
/**Function*************************************************************
......@@ -529,18 +546,18 @@ void Dar_ObjPrintVerbose( Dar_Obj_t * pObj, int fHaig )
SeeAlso []
***********************************************************************/
void Dar_ManPrintVerbose( Dar_Man_t * p, int fHaig )
void Aig_ManPrintVerbose( Aig_Man_t * p, int fHaig )
{
Vec_Ptr_t * vNodes;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
printf( "PIs: " );
Dar_ManForEachPi( p, pObj, i )
Aig_ManForEachPi( p, pObj, i )
printf( " %p", pObj );
printf( "\n" );
vNodes = Dar_ManDfs( p );
vNodes = Aig_ManDfs( p );
Vec_PtrForEachEntry( vNodes, pObj, i )
Dar_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
Aig_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
printf( "\n" );
}
......@@ -555,61 +572,61 @@ void Dar_ManPrintVerbose( Dar_Man_t * p, int fHaig )
SeeAlso []
***********************************************************************/
void Dar_ManDumpBlif( Dar_Man_t * p, char * pFileName )
void Aig_ManDumpBlif( Aig_Man_t * p, char * pFileName )
{
FILE * pFile;
Vec_Ptr_t * vNodes;
Dar_Obj_t * pObj, * pConst1 = NULL;
Aig_Obj_t * pObj, * pConst1 = NULL;
int i, nDigits, Counter = 0;
if ( Dar_ManPoNum(p) == 0 )
if ( Aig_ManPoNum(p) == 0 )
{
printf( "Dar_ManDumpBlif(): AIG manager does not have POs.\n" );
printf( "Aig_ManDumpBlif(): AIG manager does not have POs.\n" );
return;
}
// collect nodes in the DFS order
vNodes = Dar_ManDfs( p );
vNodes = Aig_ManDfs( p );
// assign IDs to objects
Dar_ManConst1(p)->pData = (void *)Counter++;
Dar_ManForEachPi( p, pObj, i )
Aig_ManConst1(p)->pData = (void *)Counter++;
Aig_ManForEachPi( p, pObj, i )
pObj->pData = (void *)Counter++;
Dar_ManForEachPo( p, pObj, i )
Aig_ManForEachPo( p, pObj, i )
pObj->pData = (void *)Counter++;
Vec_PtrForEachEntry( vNodes, pObj, i )
pObj->pData = (void *)Counter++;
nDigits = Extra_Base10Log( Counter );
// write the file
pFile = fopen( pFileName, "w" );
fprintf( pFile, "# BLIF file written by procedure Dar_ManDumpBlif() in ABC\n" );
fprintf( pFile, "# BLIF file written by procedure Aig_ManDumpBlif() in ABC\n" );
fprintf( pFile, "# http://www.eecs.berkeley.edu/~alanmi/abc/\n" );
fprintf( pFile, ".model test\n" );
// write PIs
fprintf( pFile, ".inputs" );
Dar_ManForEachPi( p, pObj, i )
Aig_ManForEachPi( p, pObj, i )
fprintf( pFile, " n%0*d", nDigits, (int)pObj->pData );
fprintf( pFile, "\n" );
// write POs
fprintf( pFile, ".outputs" );
Dar_ManForEachPo( p, pObj, i )
Aig_ManForEachPo( p, pObj, i )
fprintf( pFile, " n%0*d", nDigits, (int)pObj->pData );
fprintf( pFile, "\n" );
// write nodes
Vec_PtrForEachEntry( vNodes, pObj, i )
{
fprintf( pFile, ".names n%0*d n%0*d n%0*d\n",
nDigits, (int)Dar_ObjFanin0(pObj)->pData,
nDigits, (int)Dar_ObjFanin1(pObj)->pData,
nDigits, (int)Aig_ObjFanin0(pObj)->pData,
nDigits, (int)Aig_ObjFanin1(pObj)->pData,
nDigits, (int)pObj->pData );
fprintf( pFile, "%d%d 1\n", !Dar_ObjFaninC0(pObj), !Dar_ObjFaninC1(pObj) );
fprintf( pFile, "%d%d 1\n", !Aig_ObjFaninC0(pObj), !Aig_ObjFaninC1(pObj) );
}
// write POs
Dar_ManForEachPo( p, pObj, i )
Aig_ManForEachPo( p, pObj, i )
{
fprintf( pFile, ".names n%0*d n%0*d\n",
nDigits, (int)Dar_ObjFanin0(pObj)->pData,
nDigits, (int)Aig_ObjFanin0(pObj)->pData,
nDigits, (int)pObj->pData );
fprintf( pFile, "%d 1\n", !Dar_ObjFaninC0(pObj) );
if ( Dar_ObjIsConst1(Dar_ObjFanin0(pObj)) )
pConst1 = Dar_ManConst1(p);
fprintf( pFile, "%d 1\n", !Aig_ObjFaninC0(pObj) );
if ( Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) )
pConst1 = Aig_ManConst1(p);
}
if ( pConst1 )
fprintf( pFile, ".names n%0*d\n 1\n", nDigits, (int)pConst1->pData );
......
/**CFile****************************************************************
FileName [aig_.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [AIG package.]
Synopsis []
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: aig_.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#include "aig.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
SRC += src/aig/aig/aigCheck.c \
src/aig/aig/aigDfs.c \
src/aig/aig/aigMan.c \
src/aig/aig/aigMem.c \
src/aig/aig/aigObj.c \
src/aig/aig/aigOper.c \
src/aig/aig/aigSeq.c \
src/aig/aig/aigTable.c \
src/aig/aig/aigUtil.c
SRC += src/aig/bdc/bdcCore.c \
src/aig/bdc/bdcDec.c \
src/aig/bdc/bdcTable.c
......@@ -36,7 +36,8 @@ extern "C" {
#include <time.h>
#include "vec.h"
#include "dar.h"
#include "aig.h"
#include "darInt.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
......@@ -53,7 +54,7 @@ typedef struct Cnf_Cut_t_ Cnf_Cut_t;
// the CNF asserting outputs of AIG to be 1
struct Cnf_Dat_t_
{
Dar_Man_t * pMan; // the AIG manager, for which CNF is computed
Aig_Man_t * pMan; // the AIG manager, for which CNF is computed
int nVars; // the number of variables
int nLiterals; // the number of CNF literals
int nClauses; // the number of CNF clauses
......@@ -74,11 +75,11 @@ struct Cnf_Cut_t_
// the CNF computation manager
struct Cnf_Man_t_
{
Dar_Man_t * pManAig; // the underlying AIG manager
Aig_Man_t * pManAig; // the underlying AIG manager
char * pSopSizes; // sizes of SOPs for 4-variable functions
char ** pSops; // the SOPs for 4-variable functions
int aArea; // the area of the mapping
Dar_MmFlex_t * pMemCuts; // memory manager for cuts
Aig_MmFlex_t * pMemCuts; // memory manager for cuts
int nMergeLimit; // the limit on the size of merged cut
unsigned * pTruths[4]; // temporary truth tables
Vec_Int_t * vMemory; // memory for intermediate ISOP representation
......@@ -88,8 +89,8 @@ static inline int Cnf_CutLeaveNum( Cnf_Cut_t * pCut ) { return pCut-
static inline int * Cnf_CutLeaves( Cnf_Cut_t * pCut ) { return pCut->pFanins; }
static inline unsigned * Cnf_CutTruth( Cnf_Cut_t * pCut ) { return (unsigned *)(pCut->pFanins + pCut->nFanins); }
static inline Cnf_Cut_t * Cnf_ObjBestCut( Dar_Obj_t * pObj ) { return pObj->pData; }
static inline void Cnf_ObjSetBestCut( Dar_Obj_t * pObj, Cnf_Cut_t * pCut ) { pObj->pData = pCut; }
static inline Cnf_Cut_t * Cnf_ObjBestCut( Aig_Obj_t * pObj ) { return pObj->pData; }
static inline void Cnf_ObjSetBestCut( Aig_Obj_t * pObj, Cnf_Cut_t * pCut ) { pObj->pData = pCut; }
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
......@@ -101,16 +102,16 @@ static inline void Cnf_ObjSetBestCut( Dar_Obj_t * pObj, Cnf_Cut_t * pCut
// iterator over leaves of the cut
#define Cnf_CutForEachLeaf( p, pCut, pLeaf, i ) \
for ( i = 0; (i < (int)(pCut)->nFanins) && ((pLeaf) = Dar_ManObj(p, (pCut)->pFanins[i])); i++ )
for ( i = 0; (i < (int)(pCut)->nFanins) && ((pLeaf) = Aig_ManObj(p, (pCut)->pFanins[i])); i++ )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== cnfCore.c ========================================================*/
extern Cnf_Dat_t * Cnf_Derive( Cnf_Man_t * p, Dar_Man_t * pAig );
extern Cnf_Dat_t * Cnf_Derive( Cnf_Man_t * p, Aig_Man_t * pAig );
/*=== cnfCut.c ========================================================*/
extern Cnf_Cut_t * Cnf_CutCreate( Cnf_Man_t * p, Dar_Obj_t * pObj );
extern Cnf_Cut_t * Cnf_CutCreate( Cnf_Man_t * p, Aig_Obj_t * pObj );
extern void Cnf_CutPrint( Cnf_Cut_t * pCut );
extern void Cnf_CutFree( Cnf_Cut_t * pCut );
extern void Cnf_CutUpdateRefs( Cnf_Man_t * p, Cnf_Cut_t * pCut, Cnf_Cut_t * pCutFan, Cnf_Cut_t * pCutRes );
......@@ -130,7 +131,7 @@ extern void Cnf_ManTransferCuts( Cnf_Man_t * p );
extern void Cnf_ManFreeCuts( Cnf_Man_t * p );
extern void Cnf_ManPostprocess( Cnf_Man_t * p );
/*=== cnfUtil.c ========================================================*/
extern Vec_Ptr_t * Dar_ManScanMapping( Cnf_Man_t * p, int fCollect );
extern Vec_Ptr_t * Aig_ManScanMapping( Cnf_Man_t * p, int fCollect );
extern Vec_Ptr_t * Cnf_ManScanMapping( Cnf_Man_t * p, int fCollect );
/*=== cnfWrite.c ========================================================*/
extern void Cnf_SopConvertToVector( char * pSop, int nCubes, Vec_Int_t * vCover );
......
......@@ -39,20 +39,20 @@
SeeAlso []
***********************************************************************/
Cnf_Dat_t * Cnf_Derive( Cnf_Man_t * p, Dar_Man_t * pAig )
Cnf_Dat_t * Cnf_Derive( Cnf_Man_t * p, Aig_Man_t * pAig )
{
Aig_MmFixed_t * pMemCuts;
Cnf_Dat_t * pCnf = NULL;
Vec_Ptr_t * vMapped;
int nIters = 2;
int clk;
// connect the managers
pAig->pManCnf = p;
p->pManAig = pAig;
// generate cuts for all nodes, assign cost, and find best cuts
clk = clock();
Dar_ManComputeCuts( pAig );
pMemCuts = Dar_ManComputeCuts( pAig );
PRT( "Cuts", clock() - clk );
/*
// iteratively improve area flow
......@@ -65,7 +65,7 @@ PRT( "iter ", clock() - clk );
}
*/
// write the file
vMapped = Dar_ManScanMapping( p, 1 );
vMapped = Aig_ManScanMapping( p, 1 );
Vec_PtrFree( vMapped );
clk = clock();
......@@ -91,6 +91,7 @@ PRT( "Ext ", clock() - clk );
Dar_ManCutsFree( pAig );
return pCnf;
*/
Aig_MmFixedStop( pMemCuts, 0 );
return NULL;
}
......
......@@ -43,10 +43,10 @@
Cnf_Cut_t * Cnf_CutAlloc( Cnf_Man_t * p, int nLeaves )
{
Cnf_Cut_t * pCut;
int nSize = sizeof(Cnf_Cut_t) + sizeof(int) * nLeaves + sizeof(unsigned) * Dar_TruthWordNum(nLeaves);
pCut = (Cnf_Cut_t *)Dar_MmFlexEntryFetch( p->pMemCuts, nSize );
int nSize = sizeof(Cnf_Cut_t) + sizeof(int) * nLeaves + sizeof(unsigned) * Aig_TruthWordNum(nLeaves);
pCut = (Cnf_Cut_t *)Aig_MmFlexEntryFetch( p->pMemCuts, nSize );
pCut->nFanins = nLeaves;
pCut->nWords = Dar_TruthWordNum(nLeaves);
pCut->nWords = Aig_TruthWordNum(nLeaves);
pCut->vIsop[0] = pCut->vIsop[1] = NULL;
return pCut;
}
......@@ -81,13 +81,14 @@ void Cnf_CutFree( Cnf_Cut_t * pCut )
SeeAlso []
***********************************************************************/
Cnf_Cut_t * Cnf_CutCreate( Cnf_Man_t * p, Dar_Obj_t * pObj )
Cnf_Cut_t * Cnf_CutCreate( Cnf_Man_t * p, Aig_Obj_t * pObj )
{
Dar_Cut_t * pCutBest;
Cnf_Cut_t * pCut;
unsigned * pTruth;
assert( Dar_ObjIsNode(pObj) );
pCutBest = Dar_ObjBestCut( pObj );
assert( Aig_ObjIsNode(pObj) );
// pCutBest = Aig_ObjBestCut( pObj );
pCutBest = NULL;
assert( pCutBest != NULL );
assert( pCutBest->nLeaves <= 4 );
pCut = Cnf_CutAlloc( p, pCutBest->nLeaves );
......@@ -131,7 +132,7 @@ void Cnf_CutPrint( Cnf_Cut_t * pCut )
***********************************************************************/
void Cnf_CutDeref( Cnf_Man_t * p, Cnf_Cut_t * pCut )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
Cnf_CutForEachLeaf( p->pManAig, pCut, pObj, i )
{
......@@ -153,7 +154,7 @@ void Cnf_CutDeref( Cnf_Man_t * p, Cnf_Cut_t * pCut )
***********************************************************************/
void Cnf_CutRef( Cnf_Man_t * p, Cnf_Cut_t * pCut )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
Cnf_CutForEachLeaf( p->pManAig, pCut, pObj, i )
{
......
......@@ -4614,7 +4614,7 @@ void Cnf_ReadMsops( char ** ppSopSizes, char *** ppSops )
SeeAlso []
***********************************************************************/
int Dar_ManDeriveCnfTest()
int Aig_ManDeriveCnfTest()
{
int i, k, Lit;
printf( "\n" );
......@@ -4644,7 +4644,7 @@ int Dar_ManDeriveCnfTest()
SeeAlso []
***********************************************************************/
int Dar_ManDeriveCnfTest2()
int Aig_ManDeriveCnfTest2()
{
char s_Data3[81] = "!#&()*+,-.0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz|";
......
......@@ -52,12 +52,12 @@ Cnf_Man_t * Cnf_ManStart()
// derive internal data structures
Cnf_ReadMsops( &p->pSopSizes, &p->pSops );
// allocate memory manager for cuts
p->pMemCuts = Dar_MmFlexStart();
p->pMemCuts = Aig_MmFlexStart();
p->nMergeLimit = 10;
// allocate temporary truth tables
p->pTruths[0] = ALLOC( unsigned, 4 * Dar_TruthWordNum(p->nMergeLimit) );
p->pTruths[0] = ALLOC( unsigned, 4 * Aig_TruthWordNum(p->nMergeLimit) );
for ( i = 1; i < 4; i++ )
p->pTruths[i] = p->pTruths[i-1] + Dar_TruthWordNum(p->nMergeLimit);
p->pTruths[i] = p->pTruths[i-1] + Aig_TruthWordNum(p->nMergeLimit);
p->vMemory = Vec_IntAlloc( 1 << 18 );
return p;
}
......@@ -77,7 +77,7 @@ void Cnf_ManStop( Cnf_Man_t * p )
{
Vec_IntFree( p->vMemory );
free( p->pTruths[0] );
Dar_MmFlexStop( p->pMemCuts, 0 );
Aig_MmFlexStop( p->pMemCuts, 0 );
free( p->pSopSizes );
free( p->pSops[1] );
free( p->pSops );
......
......@@ -28,6 +28,8 @@
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
#if 0
/**Function*************************************************************
Synopsis [Computes area of the first level.]
......@@ -39,16 +41,16 @@
SeeAlso []
***********************************************************************/
void Dar_CutDeref( Dar_Man_t * p, Dar_Cut_t * pCut )
void Aig_CutDeref( Aig_Man_t * p, Dar_Cut_t * pCut )
{
Dar_Obj_t * pLeaf;
Aig_Obj_t * pLeaf;
int i;
Dar_CutForEachLeaf( p, pCut, pLeaf, i )
{
assert( pLeaf->nRefs > 0 );
if ( --pLeaf->nRefs > 0 || !Dar_ObjIsAnd(pLeaf) )
if ( --pLeaf->nRefs > 0 || !Aig_ObjIsAnd(pLeaf) )
continue;
Dar_CutDeref( p, Dar_ObjBestCut(pLeaf) );
Aig_CutDeref( p, Aig_ObjBestCut(pLeaf) );
}
}
......@@ -63,16 +65,16 @@ void Dar_CutDeref( Dar_Man_t * p, Dar_Cut_t * pCut )
SeeAlso []
***********************************************************************/
int Dar_CutRef( Dar_Man_t * p, Dar_Cut_t * pCut )
int Aig_CutRef( Aig_Man_t * p, Dar_Cut_t * pCut )
{
Dar_Obj_t * pLeaf;
int i, Area = pCut->Cost;
Aig_Obj_t * pLeaf;
int i, Area = pCut->Value;
Dar_CutForEachLeaf( p, pCut, pLeaf, i )
{
assert( pLeaf->nRefs >= 0 );
if ( pLeaf->nRefs++ > 0 || !Dar_ObjIsAnd(pLeaf) )
if ( pLeaf->nRefs++ > 0 || !Aig_ObjIsAnd(pLeaf) )
continue;
Area += Dar_CutRef( p, Dar_ObjBestCut(pLeaf) );
Area += Aig_CutRef( p, Aig_ObjBestCut(pLeaf) );
}
return Area;
}
......@@ -88,11 +90,11 @@ int Dar_CutRef( Dar_Man_t * p, Dar_Cut_t * pCut )
SeeAlso []
***********************************************************************/
int Cnf_CutArea( Dar_Man_t * p, Dar_Cut_t * pCut )
int Cnf_CutArea( Aig_Man_t * p, Dar_Cut_t * pCut )
{
int Area;
Area = Dar_CutRef( p, pCut );
Dar_CutDeref( p, pCut );
Area = Aig_CutRef( p, pCut );
Aig_CutDeref( p, pCut );
return Area;
}
......@@ -136,7 +138,7 @@ static inline int Cnf_CutCompare( Dar_Cut_t * pC0, Dar_Cut_t * pC1 )
SeeAlso []
***********************************************************************/
Dar_Cut_t * Cnf_ObjFindBestCut( Dar_Obj_t * pObj )
Dar_Cut_t * Cnf_ObjFindBestCut( Aig_Obj_t * pObj )
{
Dar_Cut_t * pCut, * pCutBest;
int i;
......@@ -160,7 +162,7 @@ Dar_Cut_t * Cnf_ObjFindBestCut( Dar_Obj_t * pObj )
***********************************************************************/
void Cnf_CutAssignAreaFlow( Cnf_Man_t * p, Dar_Cut_t * pCut )
{
Dar_Obj_t * pLeaf;
Aig_Obj_t * pLeaf;
int i;
pCut->Cost = p->pSopSizes[pCut->uTruth] + p->pSopSizes[0xFFFF & ~pCut->uTruth];
pCut->Area = (float)pCut->Cost;
......@@ -168,16 +170,16 @@ void Cnf_CutAssignAreaFlow( Cnf_Man_t * p, Dar_Cut_t * pCut )
pCut->FanRefs = 0;
Dar_CutForEachLeaf( p->pManAig, pCut, pLeaf, i )
{
if ( !Dar_ObjIsNode(pLeaf) )
if ( !Aig_ObjIsNode(pLeaf) )
continue;
if ( pLeaf->nRefs == 0 )
{
pCut->Area += Dar_ObjBestCut(pLeaf)->Area;
pCut->Area += Aig_ObjBestCut(pLeaf)->Area;
pCut->NoRefs++;
}
else
{
pCut->Area += Dar_ObjBestCut(pLeaf)->Area / pLeaf->nRefs;
pCut->Area += Aig_ObjBestCut(pLeaf)->Area / pLeaf->nRefs;
if ( pCut->FanRefs + pLeaf->nRefs > 15 )
pCut->FanRefs = 15;
else
......@@ -199,18 +201,18 @@ void Cnf_CutAssignAreaFlow( Cnf_Man_t * p, Dar_Cut_t * pCut )
***********************************************************************/
void Cnf_CutAssignArea( Cnf_Man_t * p, Dar_Cut_t * pCut )
{
Dar_Obj_t * pLeaf;
Aig_Obj_t * pLeaf;
int i;
pCut->Area = (float)pCut->Cost;
pCut->NoRefs = 0;
pCut->FanRefs = 0;
Dar_CutForEachLeaf( p->pManAig, pCut, pLeaf, i )
{
if ( !Dar_ObjIsNode(pLeaf) )
if ( !Aig_ObjIsNode(pLeaf) )
continue;
if ( pLeaf->nRefs == 0 )
{
pCut->Area += Dar_ObjBestCut(pLeaf)->Cost;
pCut->Area += Aig_ObjBestCut(pLeaf)->Cost;
pCut->NoRefs++;
}
else
......@@ -236,18 +238,18 @@ void Cnf_CutAssignArea( Cnf_Man_t * p, Dar_Cut_t * pCut )
***********************************************************************/
int Cnf_ManMapForCnf( Cnf_Man_t * p )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
Dar_Cut_t * pCut, * pCutBest;
int i, k;
// visit the nodes in the topological order and update their best cuts
Dar_ManForEachNode( p->pManAig, pObj, i )
Aig_ManForEachNode( p->pManAig, pObj, i )
{
// find the old best cut
pCutBest = Dar_ObjBestCut(pObj);
pCutBest = Aig_ObjBestCut(pObj);
Dar_ObjClearBestCut(pCutBest);
// if the node is used, dereference its cut
if ( pObj->nRefs )
Dar_CutDeref( p->pManAig, pCutBest );
Aig_CutDeref( p->pManAig, pCutBest );
// evaluate the cuts of this node
Dar_ObjForEachCut( pObj, pCut, k )
......@@ -259,11 +261,13 @@ int Cnf_ManMapForCnf( Cnf_Man_t * p )
Dar_ObjSetBestCut( pCutBest );
// if the node is used, reference its cut
if ( pObj->nRefs )
Dar_CutRef( p->pManAig, pCutBest );
Aig_CutRef( p->pManAig, pCutBest );
}
return 1;
}
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -41,27 +41,30 @@
***********************************************************************/
void Cnf_ManPostprocess_old( Cnf_Man_t * p )
{
extern int Dar_ManLargeCutEval( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Cut_t * pCutR, Dar_Cut_t * pCutL, int Leaf );
// extern int Aig_ManLargeCutEval( Aig_Man_t * p, Aig_Obj_t * pRoot, Dar_Cut_t * pCutR, Dar_Cut_t * pCutL, int Leaf );
int nNew, Gain, nGain = 0, nVars = 0;
Dar_Obj_t * pObj, * pFan;
Aig_Obj_t * pObj, * pFan;
Dar_Cut_t * pCutBest, * pCut;
int i, k;//, a, b, Counter;
Dar_ManForEachObj( p->pManAig, pObj, i )
Aig_ManForEachObj( p->pManAig, pObj, i )
{
if ( !Dar_ObjIsNode(pObj) )
if ( !Aig_ObjIsNode(pObj) )
continue;
if ( pObj->nRefs == 0 )
continue;
pCutBest = Dar_ObjBestCut(pObj);
// pCutBest = Aig_ObjBestCut(pObj);
pCutBest = NULL;
Dar_CutForEachLeaf( p->pManAig, pCutBest, pFan, k )
{
if ( !Dar_ObjIsNode(pFan) )
if ( !Aig_ObjIsNode(pFan) )
continue;
assert( pFan->nRefs != 0 );
if ( pFan->nRefs != 1 )
continue;
pCut = Dar_ObjBestCut(pFan);
// pCut = Aig_ObjBestCut(pFan);
pCut = NULL;
/*
// find how many common variable they have
Counter = 0;
......@@ -77,11 +80,16 @@ void Cnf_ManPostprocess_old( Cnf_Man_t * p )
printf( "%d ", Counter );
*/
// find the new truth table after collapsing these two cuts
nNew = Dar_ManLargeCutEval( p->pManAig, pObj, pCutBest, pCut, pFan->Id );
// nNew = Aig_ManLargeCutEval( p->pManAig, pObj, pCutBest, pCut, pFan->Id );
nNew = 0;
// printf( "%d+%d=%d:%d(%d) ", pCutBest->Cost, pCut->Cost,
// pCutBest->Cost+pCut->Cost, nNew, pCutBest->Cost+pCut->Cost-nNew );
Gain = pCutBest->Cost+pCut->Cost-nNew;
Gain = pCutBest->Value + pCut->Value - nNew;
if ( Gain > 0 )
{
nGain += Gain;
......@@ -105,12 +113,12 @@ void Cnf_ManPostprocess_old( Cnf_Man_t * p )
***********************************************************************/
void Cnf_ManTransferCuts( Cnf_Man_t * p )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
Dar_MmFlexRestart( p->pMemCuts );
Dar_ManForEachObj( p->pManAig, pObj, i )
Aig_MmFlexRestart( p->pMemCuts );
Aig_ManForEachObj( p->pManAig, pObj, i )
{
if ( Dar_ObjIsNode(pObj) && pObj->nRefs > 0 )
if ( Aig_ObjIsNode(pObj) && pObj->nRefs > 0 )
pObj->pData = Cnf_CutCreate( p, pObj );
else
pObj->pData = NULL;
......@@ -130,9 +138,9 @@ void Cnf_ManTransferCuts( Cnf_Man_t * p )
***********************************************************************/
void Cnf_ManFreeCuts( Cnf_Man_t * p )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
Dar_ManForEachObj( p->pManAig, pObj, i )
Aig_ManForEachObj( p->pManAig, pObj, i )
if ( pObj->pData )
{
Cnf_CutFree( pObj->pData );
......@@ -154,10 +162,10 @@ void Cnf_ManFreeCuts( Cnf_Man_t * p )
void Cnf_ManPostprocess( Cnf_Man_t * p )
{
Cnf_Cut_t * pCut, * pCutFan, * pCutRes;
Dar_Obj_t * pObj, * pFan;
Aig_Obj_t * pObj, * pFan;
int Order[16], Costs[16];
int i, k, fChanges;
Dar_ManForEachNode( p->pManAig, pObj, i )
Aig_ManForEachNode( p->pManAig, pObj, i )
{
if ( pObj->nRefs == 0 )
continue;
......@@ -167,7 +175,7 @@ void Cnf_ManPostprocess( Cnf_Man_t * p )
Cnf_CutForEachLeaf( p->pManAig, pCut, pFan, k )
{
Order[k] = k;
Costs[k] = Dar_ObjIsNode(pFan)? Cnf_ObjBestCut(pFan)->Cost : 0;
Costs[k] = Aig_ObjIsNode(pFan)? Cnf_ObjBestCut(pFan)->Cost : 0;
}
// sort the cuts by Weight
do {
......@@ -186,9 +194,9 @@ void Cnf_ManPostprocess( Cnf_Man_t * p )
// Cnf_CutForEachLeaf( p->pManAig, pCut, pFan, k )
for ( k = 0; (k < (int)(pCut)->nFanins) && ((pFan) = Dar_ManObj(p->pManAig, (pCut)->pFanins[Order[k]])); k++ )
for ( k = 0; (k < (int)(pCut)->nFanins) && ((pFan) = Aig_ManObj(p->pManAig, (pCut)->pFanins[Order[k]])); k++ )
{
if ( !Dar_ObjIsNode(pFan) )
if ( !Aig_ObjIsNode(pFan) )
continue;
assert( pFan->nRefs != 0 );
if ( pFan->nRefs != 1 )
......
......@@ -39,22 +39,23 @@
SeeAlso []
***********************************************************************/
int Dar_ManScanMapping_rec( Cnf_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vMapped )
int Aig_ManScanMapping_rec( Cnf_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vMapped )
{
Dar_Obj_t * pLeaf;
Aig_Obj_t * pLeaf;
Dar_Cut_t * pCutBest;
int aArea, i;
if ( pObj->nRefs++ || Dar_ObjIsPi(pObj) || Dar_ObjIsConst1(pObj) )
if ( pObj->nRefs++ || Aig_ObjIsPi(pObj) || Aig_ObjIsConst1(pObj) )
return 0;
assert( Dar_ObjIsAnd(pObj) );
assert( Aig_ObjIsAnd(pObj) );
// collect the node first to derive pre-order
if ( vMapped )
Vec_PtrPush( vMapped, pObj );
// visit the transitive fanin of the selected cut
pCutBest = Dar_ObjBestCut(pObj);
aArea = pCutBest->Cost;
// pCutBest = Aig_ObjBestCut(pObj);
pCutBest = NULL;
aArea = pCutBest->Value;
Dar_CutForEachLeaf( p->pManAig, pCutBest, pLeaf, i )
aArea += Dar_ManScanMapping_rec( p, pLeaf, vMapped );
aArea += Aig_ManScanMapping_rec( p, pLeaf, vMapped );
return aArea;
}
......@@ -69,21 +70,21 @@ int Dar_ManScanMapping_rec( Cnf_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vMapped
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Dar_ManScanMapping( Cnf_Man_t * p, int fCollect )
Vec_Ptr_t * Aig_ManScanMapping( Cnf_Man_t * p, int fCollect )
{
Vec_Ptr_t * vMapped = NULL;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
// clean all references
Dar_ManForEachObj( p->pManAig, pObj, i )
Aig_ManForEachObj( p->pManAig, pObj, i )
pObj->nRefs = 0;
// allocate the array
if ( fCollect )
vMapped = Vec_PtrAlloc( 1000 );
// collect nodes reachable from POs in the DFS order through the best cuts
p->aArea = 0;
Dar_ManForEachPo( p->pManAig, pObj, i )
p->aArea += Dar_ManScanMapping_rec( p, Dar_ObjFanin0(pObj), vMapped );
Aig_ManForEachPo( p->pManAig, pObj, i )
p->aArea += Aig_ManScanMapping_rec( p, Aig_ObjFanin0(pObj), vMapped );
printf( "Variables = %6d. Clauses = %8d.\n", vMapped? Vec_PtrSize(vMapped) : 0, p->aArea );
return vMapped;
}
......@@ -99,14 +100,14 @@ Vec_Ptr_t * Dar_ManScanMapping( Cnf_Man_t * p, int fCollect )
SeeAlso []
***********************************************************************/
int Cnf_ManScanMapping_rec( Cnf_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vMapped )
int Cnf_ManScanMapping_rec( Cnf_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vMapped )
{
Dar_Obj_t * pLeaf;
Aig_Obj_t * pLeaf;
Cnf_Cut_t * pCutBest;
int aArea, i;
if ( pObj->nRefs++ || Dar_ObjIsPi(pObj) || Dar_ObjIsConst1(pObj) )
if ( pObj->nRefs++ || Aig_ObjIsPi(pObj) || Aig_ObjIsConst1(pObj) )
return 0;
assert( Dar_ObjIsAnd(pObj) );
assert( Aig_ObjIsAnd(pObj) );
assert( pObj->pData != NULL );
// visit the transitive fanin of the selected cut
pCutBest = pObj->pData;
......@@ -134,18 +135,18 @@ int Cnf_ManScanMapping_rec( Cnf_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vMapped
Vec_Ptr_t * Cnf_ManScanMapping( Cnf_Man_t * p, int fCollect )
{
Vec_Ptr_t * vMapped = NULL;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
// clean all references
Dar_ManForEachObj( p->pManAig, pObj, i )
Aig_ManForEachObj( p->pManAig, pObj, i )
pObj->nRefs = 0;
// allocate the array
if ( fCollect )
vMapped = Vec_PtrAlloc( 1000 );
// collect nodes reachable from POs in the DFS order through the best cuts
p->aArea = 0;
Dar_ManForEachPo( p->pManAig, pObj, i )
p->aArea += Cnf_ManScanMapping_rec( p, Dar_ObjFanin0(pObj), vMapped );
Aig_ManForEachPo( p->pManAig, pObj, i )
p->aArea += Cnf_ManScanMapping_rec( p, Aig_ObjFanin0(pObj), vMapped );
printf( "Variables = %6d. Clauses = %8d.\n", vMapped? Vec_PtrSize(vMapped) : 0, p->aArea );
return vMapped;
}
......
......@@ -183,7 +183,7 @@ int Cnf_IsopWriteCube( int Cube, int nVars, int * pVars, int fCompl, int * pLite
***********************************************************************/
Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
Cnf_Dat_t * pCnf;
Cnf_Cut_t * pCut;
int OutVar, pVars[32], * pLits, ** pClas;
......@@ -191,11 +191,11 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped )
int i, k, nLiterals, nClauses, nCubes, Cube, Number;
// count the number of literals and clauses
nLiterals = 1 + Dar_ManPoNum( p->pManAig );
nClauses = 1 + Dar_ManPoNum( p->pManAig );
nLiterals = 1 + Aig_ManPoNum( p->pManAig );
nClauses = 1 + Aig_ManPoNum( p->pManAig );
Vec_PtrForEachEntry( vMapped, pObj, i )
{
assert( Dar_ObjIsNode(pObj) );
assert( Aig_ObjIsNode(pObj) );
pCut = Cnf_ObjBestCut( pObj );
// positive polarity of the cut
......@@ -224,7 +224,7 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped )
nLiterals += Cnf_IsopCountLiterals( pCut->vIsop[0], pCut->nFanins ) + Vec_IntSize(pCut->vIsop[0]);
nClauses += Vec_IntSize(pCut->vIsop[0]);
}
//printf( "%d ", nClauses-(1 + Dar_ManPoNum( p->pManAig )) );
//printf( "%d ", nClauses-(1 + Aig_ManPoNum( p->pManAig )) );
}
//printf( "\n" );
......@@ -239,13 +239,13 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped )
// set variable numbers
Number = 0;
pCnf->pVarNums = ALLOC( int, 1+Dar_ManObjIdMax(p->pManAig) );
memset( pCnf->pVarNums, 0xff, sizeof(int) * (1+Dar_ManObjIdMax(p->pManAig)) );
pCnf->pVarNums = ALLOC( int, 1+Aig_ManObjIdMax(p->pManAig) );
memset( pCnf->pVarNums, 0xff, sizeof(int) * (1+Aig_ManObjIdMax(p->pManAig)) );
Vec_PtrForEachEntry( vMapped, pObj, i )
pCnf->pVarNums[pObj->Id] = Number++;
Dar_ManForEachPi( p->pManAig, pObj, i )
Aig_ManForEachPi( p->pManAig, pObj, i )
pCnf->pVarNums[pObj->Id] = Number++;
pCnf->pVarNums[Dar_ManConst1(p->pManAig)->Id] = Number++;
pCnf->pVarNums[Aig_ManConst1(p->pManAig)->Id] = Number++;
pCnf->nVars = Number;
// assign the clauses
......@@ -260,7 +260,7 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped )
for ( k = 0; k < (int)pCut->nFanins; k++ )
{
pVars[k] = pCnf->pVarNums[ pCut->pFanins[k] ];
assert( pVars[k] <= Dar_ManObjIdMax(p->pManAig) );
assert( pVars[k] <= Aig_ManObjIdMax(p->pManAig) );
}
// positive polarity of the cut
......@@ -310,17 +310,17 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped )
}
// write the constant literal
OutVar = pCnf->pVarNums[ Dar_ManConst1(p->pManAig)->Id ];
assert( OutVar <= Dar_ManObjIdMax(p->pManAig) );
OutVar = pCnf->pVarNums[ Aig_ManConst1(p->pManAig)->Id ];
assert( OutVar <= Aig_ManObjIdMax(p->pManAig) );
*pClas++ = pLits;
*pLits++ = 2 * OutVar;
// write the output literals
Dar_ManForEachPo( p->pManAig, pObj, i )
Aig_ManForEachPo( p->pManAig, pObj, i )
{
OutVar = pCnf->pVarNums[ Dar_ObjFanin0(pObj)->Id ];
OutVar = pCnf->pVarNums[ Aig_ObjFanin0(pObj)->Id ];
*pClas++ = pLits;
*pLits++ = 2 * OutVar + Dar_ObjFaninC0(pObj);
*pLits++ = 2 * OutVar + Aig_ObjFaninC0(pObj);
}
// verify that the correct number of literals and clauses was written
......
......@@ -51,7 +51,7 @@ extern "C" {
////////////////////////////////////////////////////////////////////////
/*=== cnfCore.c ========================================================*/
extern Dar_Man_t * Csw_Sweep( Dar_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose );
extern Aig_Man_t * Csw_Sweep( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose );
#ifdef __cplusplus
}
......
......@@ -39,34 +39,48 @@
SeeAlso []
***********************************************************************/
Dar_Man_t * Csw_Sweep( Dar_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose )
Aig_Man_t * Csw_Sweep( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose )
{
Csw_Man_t * p;
Dar_Man_t * pRes;
Dar_Obj_t * pObj, * pObjNew, * pObjRes;
int i;
Aig_Man_t * pRes;
Aig_Obj_t * pObj, * pObjNew, * pObjRes;
int i, clk;
clk = clock();
// start the manager
p = Csw_ManStart( pAig, nCutsMax, nLeafMax, fVerbose );
// set elementary cuts at the PIs
Dar_ManForEachPi( p->pManRes, pObj, i )
Aig_ManForEachPi( p->pManRes, pObj, i )
{
Csw_ObjPrepareCuts( p, pObj, 1 );
Csw_ObjAddRefs( p, pObj, Aig_ManPi(p->pManAig,i)->nRefs );
}
// process the nodes
Dar_ManForEachNode( pAig, pObj, i )
Aig_ManForEachNode( pAig, pObj, i )
{
// create the new node
pObjNew = Dar_And( p->pManRes, Csw_ObjChild0Equiv(p, pObj), Csw_ObjChild1Equiv(p, pObj) );
pObjNew = Aig_And( p->pManRes, Csw_ObjChild0Equiv(p, pObj), Csw_ObjChild1Equiv(p, pObj) );
// check if this node can be represented using another node
pObjRes = Csw_ObjSweep( p, Dar_Regular(pObjNew), pObj->nRefs > 1 );
pObjRes = Dar_NotCond( pObjRes, Dar_IsComplement(pObjNew) );
// set the resulting node
// pObjRes = Csw_ObjSweep( p, Aig_Regular(pObjNew), pObj->nRefs > 1 );
// pObjRes = Aig_NotCond( pObjRes, Aig_IsComplement(pObjNew) );
// try recursively if resubsitution is used
do {
pObjRes = Csw_ObjSweep( p, Aig_Regular(pObjNew), pObj->nRefs > 1 );
pObjRes = Aig_NotCond( pObjRes, Aig_IsComplement(pObjNew) );
pObjNew = pObjRes;
} while ( Csw_ObjCuts(p, Aig_Regular(pObjNew)) == NULL && !Aig_ObjIsConst1(Aig_Regular(pObjNew)) );
// save the resulting node
Csw_ObjSetEquiv( p, pObj, pObjRes );
// add to the reference counter
Csw_ObjAddRefs( p, Aig_Regular(pObjRes), pObj->nRefs );
}
// add the POs
Dar_ManForEachPo( pAig, pObj, i )
Dar_ObjCreatePo( p->pManRes, Csw_ObjChild0Equiv(p, pObj) );
Aig_ManForEachPo( pAig, pObj, i )
Aig_ObjCreatePo( p->pManRes, Csw_ObjChild0Equiv(p, pObj) );
// remove dangling nodes
Dar_ManCleanup( p->pManRes );
Aig_ManCleanup( p->pManRes );
// return the resulting manager
p->timeTotal = clock() - clk;
p->timeOther = p->timeTotal - p->timeCuts - p->timeHash;
pRes = p->pManRes;
Csw_ManStop( p );
return pRes;
......
......@@ -41,15 +41,43 @@
***********************************************************************/
static inline int Csw_CutFindCost( Csw_Man_t * p, Csw_Cut_t * pCut )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pLeaf;
int i, Cost = 0;
Csw_CutForEachLeaf( p->pManRes, pCut, pObj, i )
Cost += pObj->nRefs;
assert( pCut->nFanins > 0 );
Csw_CutForEachLeaf( p->pManRes, pCut, pLeaf, i )
{
// Cost += pLeaf->nRefs;
Cost += Csw_ObjRefs( p, pLeaf );
// printf( "%d ", pLeaf->nRefs );
}
//printf( "\n" );
return Cost * 100 / pCut->nFanins;
}
/**Function*************************************************************
Synopsis [Compute the cost of the cut.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline float Csw_CutFindCost2( Csw_Man_t * p, Csw_Cut_t * pCut )
{
Aig_Obj_t * pLeaf;
float Cost = 0.0;
int i;
assert( pCut->nFanins > 0 );
Csw_CutForEachLeaf( p->pManRes, pCut, pLeaf, i )
Cost += (float)1.0/pLeaf->nRefs;
return 1/Cost;
}
/**Function*************************************************************
Synopsis [Returns the next free cut to use.]
Description []
......@@ -59,7 +87,7 @@ static inline int Csw_CutFindCost( Csw_Man_t * p, Csw_Cut_t * pCut )
SeeAlso []
***********************************************************************/
static inline Csw_Cut_t * Csw_CutFindFree( Csw_Man_t * p, Dar_Obj_t * pObj )
static inline Csw_Cut_t * Csw_CutFindFree( Csw_Man_t * p, Aig_Obj_t * pObj )
{
Csw_Cut_t * pCut, * pCutMax;
int i;
......@@ -131,11 +159,126 @@ unsigned * Csw_CutComputeTruth( Csw_Man_t * p, Csw_Cut_t * pCut, Csw_Cut_t * pCu
Kit_TruthStretch( p->puTemp[3], p->puTemp[1], pCut1->nFanins, p->nLeafMax, Cut_TruthPhase(pCut, pCut1), 0 );
// produce the resulting table
Kit_TruthAnd( Csw_CutTruth(pCut), p->puTemp[2], p->puTemp[3], p->nLeafMax );
// assert( pCut->nFanins >= Kit_TruthSupportSize( Csw_CutTruth(pCut), p->nLeafMax ) );
return Csw_CutTruth(pCut);
}
/**Function*************************************************************
Synopsis [Performs support minimization for the truth table.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Csw_CutSupportMinimize( Csw_Man_t * p, Csw_Cut_t * pCut )
{
unsigned * pTruth;
int uSupp, nFansNew, i, k;
// get truth table
pTruth = Csw_CutTruth( pCut );
// get support
uSupp = Kit_TruthSupport( pTruth, p->nLeafMax );
// get the new support size
nFansNew = Kit_WordCountOnes( uSupp );
// check if there are redundant variables
if ( nFansNew == pCut->nFanins )
return nFansNew;
assert( nFansNew < pCut->nFanins );
// minimize support
Kit_TruthShrink( p->puTemp[0], pTruth, nFansNew, p->nLeafMax, uSupp, 1 );
for ( i = k = 0; i < pCut->nFanins; i++ )
if ( uSupp & (1 << i) )
pCut->pFanins[k++] = pCut->pFanins[i];
assert( k == nFansNew );
pCut->nFanins = nFansNew;
// assert( nFansNew == Kit_TruthSupportSize( pTruth, p->nLeafMax ) );
//Extra_PrintBinary( stdout, pTruth, (1<<p->nLeafMax) ); printf( "\n" );
return nFansNew;
}
/**Function*************************************************************
Synopsis [Returns 1 if pDom is contained in pCut.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Csw_CutCheckDominance( Csw_Cut_t * pDom, Csw_Cut_t * pCut )
{
int i, k;
for ( i = 0; i < (int)pDom->nFanins; i++ )
{
for ( k = 0; k < (int)pCut->nFanins; k++ )
if ( pDom->pFanins[i] == pCut->pFanins[k] )
break;
if ( k == (int)pCut->nFanins ) // node i in pDom is not contained in pCut
return 0;
}
// every node in pDom is contained in pCut
return 1;
}
/**Function*************************************************************
Synopsis [Returns 1 if the cut is contained.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Csw_CutFilter( Csw_Man_t * p, Aig_Obj_t * pObj, Csw_Cut_t * pCut )
{
Csw_Cut_t * pTemp;
int i;
// go through the cuts of the node
Csw_ObjForEachCut( p, pObj, pTemp, i )
{
if ( pTemp->nFanins < 2 )
continue;
if ( pTemp == pCut )
continue;
if ( pTemp->nFanins > pCut->nFanins )
{
// skip the non-contained cuts
if ( (pTemp->uSign & pCut->uSign) != pCut->uSign )
continue;
// check containment seriously
if ( Csw_CutCheckDominance( pCut, pTemp ) )
{
// remove contained cut
pTemp->nFanins = 0;
}
}
else
{
// skip the non-contained cuts
if ( (pTemp->uSign & pCut->uSign) != pTemp->uSign )
continue;
// check containment seriously
if ( Csw_CutCheckDominance( pTemp, pCut ) )
{
// remove the given
pCut->nFanins = 0;
return 1;
}
}
}
return 0;
}
/**Function*************************************************************
Synopsis [Merges two cuts.]
Description []
......@@ -251,6 +394,50 @@ int Csw_CutMerge( Csw_Man_t * p, Csw_Cut_t * pCut0, Csw_Cut_t * pCut1, Csw_Cut_t
/**Function*************************************************************
Synopsis [Consider cut with more than 2 fanins having 2 true variables.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Obj_t * Csw_ObjTwoVarCut( Csw_Man_t * p, Csw_Cut_t * pCut )
{
Aig_Obj_t * pRes, * pIn0, * pIn1;
int nVars, uTruth, fCompl = 0;
assert( pCut->nFanins > 2 );
// minimize support of this cut
nVars = Csw_CutSupportMinimize( p, pCut );
assert( nVars == 2 );
// get the fanins
pIn0 = Aig_ManObj( p->pManRes, pCut->pFanins[0] );
pIn1 = Aig_ManObj( p->pManRes, pCut->pFanins[1] );
// derive the truth table
uTruth = 0xF & *Csw_CutTruth(pCut);
if ( uTruth == 14 || uTruth == 13 || uTruth == 11 || uTruth == 7 )
{
uTruth = 0xF & ~uTruth;
fCompl = 1;
}
// compute the result
pRes = NULL;
if ( uTruth == 1 ) // 0001 // 1110 14
pRes = Aig_And( p->pManRes, Aig_Not(pIn0), Aig_Not(pIn1) );
if ( uTruth == 2 ) // 0010 // 1101 13
pRes = Aig_And( p->pManRes, pIn0 , Aig_Not(pIn1) );
if ( uTruth == 4 ) // 0100 // 1011 11
pRes = Aig_And( p->pManRes, Aig_Not(pIn0), pIn1 );
if ( uTruth == 8 ) // 1000 // 0111 7
pRes = Aig_And( p->pManRes, pIn0 , pIn1 );
if ( pRes )
pRes = Aig_NotCond( pRes, fCompl );
return pRes;
}
/**Function*************************************************************
Synopsis []
Description []
......@@ -260,17 +447,19 @@ int Csw_CutMerge( Csw_Man_t * p, Csw_Cut_t * pCut0, Csw_Cut_t * pCut1, Csw_Cut_t
SeeAlso []
***********************************************************************/
Csw_Cut_t * Csw_ObjPrepareCuts( Csw_Man_t * p, Dar_Obj_t * pObj, int fTriv )
Csw_Cut_t * Csw_ObjPrepareCuts( Csw_Man_t * p, Aig_Obj_t * pObj, int fTriv )
{
Csw_Cut_t * pCutSet, * pCut;
int i;
// create the cutset of the node
pCutSet = (Csw_Cut_t *)Dar_MmFixedEntryFetch( p->pMemCuts );
pCutSet = (Csw_Cut_t *)Aig_MmFixedEntryFetch( p->pMemCuts );
Csw_ObjSetCuts( p, pObj, pCutSet );
Csw_ObjForEachCut( p, pObj, pCut, i )
{
pCut->nFanins = 0;
pCut->iNode = pObj->Id;
pCut->nCutSize = p->nCutSize;
pCut->nLeafMax = p->nLeafMax;
}
// add unit cut if needed
if ( fTriv )
......@@ -280,7 +469,7 @@ Csw_Cut_t * Csw_ObjPrepareCuts( Csw_Man_t * p, Dar_Obj_t * pObj, int fTriv )
pCut->iNode = pObj->Id;
pCut->nFanins = 1;
pCut->pFanins[0] = pObj->Id;
pCut->uSign = Csw_ObjCutSign( pObj->Id );
pCut->uSign = Aig_ObjCutSign( pObj->Id );
memset( Csw_CutTruth(pCut), 0xAA, sizeof(unsigned) * p->nTruthWords );
}
return pCutSet;
......@@ -288,7 +477,7 @@ Csw_Cut_t * Csw_ObjPrepareCuts( Csw_Man_t * p, Dar_Obj_t * pObj, int fTriv )
/**Function*************************************************************
Synopsis []
Synopsis [Derives cuts for one node and sweeps this node.]
Description []
......@@ -297,23 +486,24 @@ Csw_Cut_t * Csw_ObjPrepareCuts( Csw_Man_t * p, Dar_Obj_t * pObj, int fTriv )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Csw_ObjSweep( Csw_Man_t * p, Dar_Obj_t * pObj, int fTriv )
Aig_Obj_t * Csw_ObjSweep( Csw_Man_t * p, Aig_Obj_t * pObj, int fTriv )
{
int fUseResub = 1;
Csw_Cut_t * pCut0, * pCut1, * pCut, * pCutSet;
Dar_Obj_t * pFanin0 = Dar_ObjFanin0(pObj);
Dar_Obj_t * pFanin1 = Dar_ObjFanin1(pObj);
Dar_Obj_t * pObjNew;
Aig_Obj_t * pFanin0 = Aig_ObjFanin0(pObj);
Aig_Obj_t * pFanin1 = Aig_ObjFanin1(pObj);
Aig_Obj_t * pObjNew;
unsigned * pTruth;
int i, k, nVars, iVar;
int i, k, nVars, nFanins, iVar, clk;
assert( !Dar_IsComplement(pObj) );
if ( !Dar_ObjIsNode(pObj) )
assert( !Aig_IsComplement(pObj) );
if ( !Aig_ObjIsNode(pObj) )
return pObj;
if ( Csw_ObjCuts(p, pObj) )
return pObj;
// the node is not processed yet
assert( Csw_ObjCuts(p, pObj) == NULL );
assert( Dar_ObjIsNode(pObj) );
assert( Aig_ObjIsNode(pObj) );
// set up the first cut
pCutSet = Csw_ObjPrepareCuts( p, pObj, fTriv );
......@@ -329,48 +519,77 @@ Dar_Obj_t * Csw_ObjSweep( Csw_Man_t * p, Dar_Obj_t * pObj, int fTriv )
continue;
// get the next cut of this node
pCut = Csw_CutFindFree( p, pObj );
clk = clock();
// assemble the new cut
if ( !Csw_CutMerge( p, pCut0, pCut1, pCut ) )
{
assert( pCut->nFanins == 0 );
continue;
}
/*
// check containment
if ( Csw_CutFilter( p, pCutSet, pCut ) )
if ( Csw_CutFilter( p, pObj, pCut ) )
{
pCut->nFanins = 0;
assert( pCut->nFanins == 0 );
continue;
}
*/
// create its truth table
pTruth = Csw_CutComputeTruth( p, pCut, pCut0, pCut1, Dar_ObjFaninC0(pObj), Dar_ObjFaninC1(pObj) );
// check for trivial truth table
pTruth = Csw_CutComputeTruth( p, pCut, pCut0, pCut1, Aig_ObjFaninC0(pObj), Aig_ObjFaninC1(pObj) );
// support minimize the truth table
nFanins = pCut->nFanins;
// nVars = Csw_CutSupportMinimize( p, pCut ); // leads to quality degradation
nVars = Kit_TruthSupportSize( pTruth, p->nLeafMax );
p->timeCuts += clock() - clk;
// check for trivial truth tables
if ( nVars == 0 )
return Dar_NotCond( Dar_ManConst1(p->pManRes), !(pTruth[0] & 1) );
{
p->nNodesTriv0++;
return Aig_NotCond( Aig_ManConst1(p->pManRes), !(pTruth[0] & 1) );
}
if ( nVars == 1 )
{
p->nNodesTriv1++;
iVar = Kit_WordFindFirstBit( Kit_TruthSupport(pTruth, p->nLeafMax) );
assert( iVar < pCut->nFanins );
return Dar_NotCond( Dar_ManObj(p->pManRes, pCut->pFanins[iVar]), (pTruth[0] & 1) );
return Aig_NotCond( Aig_ManObj(p->pManRes, pCut->pFanins[iVar]), (pTruth[0] & 1) );
}
if ( nVars == 2 && nFanins > 2 && fUseResub )
{
if ( pObjNew = Csw_ObjTwoVarCut( p, pCut ) )
{
p->nNodesTriv2++;
return pObjNew;
}
}
// check if an equivalent node with the same cut exists
if ( pObjNew = Csw_TableCutLookup( p, pCut ) )
clk = clock();
pObjNew = pCut->nFanins > 2 ? Csw_TableCutLookup( p, pCut ) : NULL;
p->timeHash += clock() - clk;
if ( pObjNew )
{
p->nNodesCuts++;
return pObjNew;
}
// assign the cost
pCut->Cost = Csw_CutFindCost( p, pCut );
assert( pCut->nFanins > 0 );
assert( pCut->Cost > 0 );
}
p->nNodesTried++;
// load the resulting cuts into the table
clk = clock();
Csw_ObjForEachCut( p, pObj, pCut, i )
{
if ( pCut->nFanins > 2 )
{
assert( pCut->Cost > 0 );
Csw_TableCutInsert( p, pCut );
}
}
p->timeHash += clock() - clk;
// return the node if could not replace it
return pObj;
......
......@@ -35,6 +35,7 @@ extern "C" {
#include <assert.h>
#include <time.h>
#include "aig.h"
#include "dar.h"
#include "kit.h"
#include "csw.h"
......@@ -55,9 +56,12 @@ struct Csw_Cut_t_
{
Csw_Cut_t * pNext; // the next cut in the table
int Cost; // the cost of the cut
// float Cost; // the cost of the cut
unsigned uSign; // cut signature
int iNode; // the node, for which it is the cut
int nFanins; // the number of words in truth table
short nCutSize; // the number of bytes in the cut
char nLeafMax; // the maximum number of fanins
char nFanins; // the current number of fanins
int pFanins[0]; // the fanins (followed by the truth table)
};
......@@ -65,10 +69,11 @@ struct Csw_Cut_t_
struct Csw_Man_t_
{
// AIG manager
Dar_Man_t * pManAig; // the input AIG manager
Dar_Man_t * pManRes; // the output AIG manager
Dar_Obj_t ** pEquiv; // the equivalent nodes in the resulting manager
Aig_Man_t * pManAig; // the input AIG manager
Aig_Man_t * pManRes; // the output AIG manager
Aig_Obj_t ** pEquiv; // the equivalent nodes in the resulting manager
Csw_Cut_t ** pCuts; // the cuts for each node in the output manager
int * pnRefs; // the number of references of each new node
// hash table for cuts
Csw_Cut_t ** pTable; // the table composed of cuts
int nTableSize; // the size of hash table
......@@ -79,25 +84,36 @@ struct Csw_Man_t_
// internal variables
int nCutSize; // the number of bytes needed to store one cut
int nTruthWords; // the number of truth table words
Dar_MmFixed_t * pMemCuts; // memory manager for cuts
Aig_MmFixed_t * pMemCuts; // memory manager for cuts
unsigned * puTemp[4]; // used for the truth table computation
// statistics
int nNodesTriv0; // the number of trivial nodes
int nNodesTriv1; // the number of trivial nodes
int nNodesTriv2; // the number of trivial nodes
int nNodesCuts; // the number of rewritten nodes
int nNodesTried; // the number of nodes tried
int timeCuts; // time to compute the cut and its truth table
int timeHash; // time for hashing cuts
int timeOther; // other time
int timeTotal; // total time
};
static inline unsigned Csw_ObjCutSign( unsigned ObjId ) { return (1 << (ObjId % 31)); }
static inline int Csw_CutLeaveNum( Csw_Cut_t * pCut ) { return pCut->nFanins; }
static inline int * Csw_CutLeaves( Csw_Cut_t * pCut ) { return pCut->pFanins; }
static inline unsigned * Csw_CutTruth( Csw_Cut_t * pCut ) { return (unsigned *)(pCut->pFanins + pCut->nLeafMax); }
static inline Csw_Cut_t * Csw_CutNext( Csw_Cut_t * pCut ) { return (Csw_Cut_t *)(((char *)pCut) + pCut->nCutSize); }
static inline int Csw_CutLeaveNum( Csw_Cut_t * pCut ) { return pCut->nFanins; }
static inline int * Csw_CutLeaves( Csw_Cut_t * pCut ) { return pCut->pFanins; }
static inline unsigned * Csw_CutTruth( Csw_Cut_t * pCut ) { return (unsigned *)(pCut->pFanins + pCut->nFanins); }
static inline Csw_Cut_t * Csw_CutNext( Csw_Man_t * p, Csw_Cut_t * pCut ) { return (Csw_Cut_t *)(((char *)pCut) + p->nCutSize); }
static inline int Csw_ObjRefs( Csw_Man_t * p, Aig_Obj_t * pObj ) { return p->pnRefs[pObj->Id]; }
static inline void Csw_ObjAddRefs( Csw_Man_t * p, Aig_Obj_t * pObj, int nRefs ) { p->pnRefs[pObj->Id] += nRefs; }
static inline Csw_Cut_t * Csw_ObjCuts( Csw_Man_t * p, Dar_Obj_t * pObj ) { return p->pCuts[pObj->Id]; }
static inline void Csw_ObjSetCuts( Csw_Man_t * p, Dar_Obj_t * pObj, Csw_Cut_t * pCuts ) { p->pCuts[pObj->Id] = pCuts; }
static inline Csw_Cut_t * Csw_ObjCuts( Csw_Man_t * p, Aig_Obj_t * pObj ) { return p->pCuts[pObj->Id]; }
static inline void Csw_ObjSetCuts( Csw_Man_t * p, Aig_Obj_t * pObj, Csw_Cut_t * pCuts ) { p->pCuts[pObj->Id] = pCuts; }
static inline Dar_Obj_t * Csw_ObjEquiv( Csw_Man_t * p, Dar_Obj_t * pObj ) { return p->pEquiv[pObj->Id]; }
static inline void Csw_ObjSetEquiv( Csw_Man_t * p, Dar_Obj_t * pObj, Dar_Obj_t * pEquiv ) { p->pEquiv[pObj->Id] = pEquiv; }
static inline Aig_Obj_t * Csw_ObjEquiv( Csw_Man_t * p, Aig_Obj_t * pObj ) { return p->pEquiv[pObj->Id]; }
static inline void Csw_ObjSetEquiv( Csw_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pEquiv ) { p->pEquiv[pObj->Id] = pEquiv; }
static inline Dar_Obj_t * Csw_ObjChild0Equiv( Csw_Man_t * p, Dar_Obj_t * pObj ) { assert( !Dar_IsComplement(pObj) ); return Dar_ObjFanin0(pObj)? Dar_NotCond(Csw_ObjEquiv(p, Dar_ObjFanin0(pObj)), Dar_ObjFaninC0(pObj)) : NULL; }
static inline Dar_Obj_t * Csw_ObjChild1Equiv( Csw_Man_t * p, Dar_Obj_t * pObj ) { assert( !Dar_IsComplement(pObj) ); return Dar_ObjFanin1(pObj)? Dar_NotCond(Csw_ObjEquiv(p, Dar_ObjFanin1(pObj)), Dar_ObjFaninC1(pObj)) : NULL; }
static inline Aig_Obj_t * Csw_ObjChild0Equiv( Csw_Man_t * p, Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond(Csw_ObjEquiv(p, Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj)) : NULL; }
static inline Aig_Obj_t * Csw_ObjChild1Equiv( Csw_Man_t * p, Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond(Csw_ObjEquiv(p, Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj)) : NULL; }
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
......@@ -109,25 +125,25 @@ static inline Dar_Obj_t * Csw_ObjChild1Equiv( Csw_Man_t * p, Dar_Obj_t * pObj )
// iterator over cuts of the node
#define Csw_ObjForEachCut( p, pObj, pCut, i ) \
for ( i = 0, pCut = Csw_ObjCuts(p, pObj); i < p->nCutsMax; i++, pCut = Csw_CutNext(p, pCut) )
for ( i = 0, pCut = Csw_ObjCuts(p, pObj); i < p->nCutsMax; i++, pCut = Csw_CutNext(pCut) )
// iterator over leaves of the cut
#define Csw_CutForEachLeaf( p, pCut, pLeaf, i ) \
for ( i = 0; (i < (int)(pCut)->nFanins) && ((pLeaf) = Dar_ManObj(p, (pCut)->pFanins[i])); i++ )
for ( i = 0; (i < (int)(pCut)->nFanins) && ((pLeaf) = Aig_ManObj(p, (pCut)->pFanins[i])); i++ )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== cnfCut.c ========================================================*/
extern Csw_Cut_t * Csw_ObjPrepareCuts( Csw_Man_t * p, Dar_Obj_t * pObj, int fTriv );
extern Dar_Obj_t * Csw_ObjSweep( Csw_Man_t * p, Dar_Obj_t * pObj, int fTriv );
extern Csw_Cut_t * Csw_ObjPrepareCuts( Csw_Man_t * p, Aig_Obj_t * pObj, int fTriv );
extern Aig_Obj_t * Csw_ObjSweep( Csw_Man_t * p, Aig_Obj_t * pObj, int fTriv );
/*=== cnfMan.c ========================================================*/
extern Csw_Man_t * Csw_ManStart( Dar_Man_t * pMan, int nCutsMax, int nLeafMax, int fVerbose );
extern Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVerbose );
extern void Csw_ManStop( Csw_Man_t * p );
/*=== cnfTable.c ========================================================*/
extern int Csw_TableCountCuts( Csw_Man_t * p );
extern void Csw_TableCutInsert( Csw_Man_t * p, Csw_Cut_t * pCut );
extern Dar_Obj_t * Csw_TableCutLookup( Csw_Man_t * p, Csw_Cut_t * pCut );
extern unsigned int Cudd_PrimeCws( unsigned int p );
extern Aig_Obj_t * Csw_TableCutLookup( Csw_Man_t * p, Csw_Cut_t * pCut );
#ifdef __cplusplus
}
......
......@@ -39,10 +39,10 @@
SeeAlso []
***********************************************************************/
Csw_Man_t * Csw_ManStart( Dar_Man_t * pMan, int nCutsMax, int nLeafMax, int fVerbose )
Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVerbose )
{
Csw_Man_t * p;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
assert( nCutsMax >= 2 );
assert( nLeafMax <= 16 );
......@@ -54,24 +54,26 @@ Csw_Man_t * Csw_ManStart( Dar_Man_t * pMan, int nCutsMax, int nLeafMax, int fVer
p->fVerbose = fVerbose;
p->pManAig = pMan;
// create the new manager
p->pManRes = Dar_ManStartFrom( pMan );
assert( Dar_ManPiNum(p->pManAig) == Dar_ManPiNum(p->pManRes) );
p->pManRes = Aig_ManStartFrom( pMan );
assert( Aig_ManPiNum(p->pManAig) == Aig_ManPiNum(p->pManRes) );
// allocate room for cuts and equivalent nodes
p->pEquiv = ALLOC( Dar_Obj_t *, Dar_ManObjIdMax(pMan) + 1 );
p->pCuts = ALLOC( Csw_Cut_t *, Dar_ManObjIdMax(pMan) + 1 );
memset( p->pCuts, 0, sizeof(Dar_Obj_t *) * (Dar_ManObjIdMax(pMan) + 1) );
p->pnRefs = ALLOC( int, Aig_ManObjIdMax(pMan) + 1 );
p->pEquiv = ALLOC( Aig_Obj_t *, Aig_ManObjIdMax(pMan) + 1 );
p->pCuts = ALLOC( Csw_Cut_t *, Aig_ManObjIdMax(pMan) + 1 );
memset( p->pCuts, 0, sizeof(Aig_Obj_t *) * (Aig_ManObjIdMax(pMan) + 1) );
memset( p->pnRefs, 0, sizeof(int) * (Aig_ManObjIdMax(pMan) + 1) );
// allocate memory manager
p->nTruthWords = Dar_TruthWordNum(nLeafMax);
p->nTruthWords = Aig_TruthWordNum(nLeafMax);
p->nCutSize = sizeof(Csw_Cut_t) + sizeof(int) * nLeafMax + sizeof(unsigned) * p->nTruthWords;
p->pMemCuts = Dar_MmFixedStart( p->nCutSize * p->nCutsMax, 512 );
p->pMemCuts = Aig_MmFixedStart( p->nCutSize * p->nCutsMax, 512 );
// allocate hash table for cuts
p->nTableSize = Cudd_PrimeCws( Dar_ManNodeNum(pMan) * p->nCutsMax / 2 );
p->nTableSize = Aig_PrimeCudd( Aig_ManNodeNum(pMan) * p->nCutsMax / 2 );
p->pTable = ALLOC( Csw_Cut_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Dar_Obj_t *) * p->nTableSize );
memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
// set the pointers to the available fraig nodes
Csw_ObjSetEquiv( p, Dar_ManConst1(p->pManAig), Dar_ManConst1(p->pManRes) );
Dar_ManForEachPi( p->pManAig, pObj, i )
Csw_ObjSetEquiv( p, pObj, Dar_ManPi(p->pManRes, i) );
Csw_ObjSetEquiv( p, Aig_ManConst1(p->pManAig), Aig_ManConst1(p->pManRes) );
Aig_ManForEachPi( p->pManAig, pObj, i )
Csw_ObjSetEquiv( p, pObj, Aig_ManPi(p->pManRes, i) );
// room for temporary truth tables
p->puTemp[0] = ALLOC( unsigned, 4 * p->nTruthWords );
p->puTemp[1] = p->puTemp[0] + p->nTruthWords;
......@@ -93,8 +95,23 @@ Csw_Man_t * Csw_ManStart( Dar_Man_t * pMan, int nCutsMax, int nLeafMax, int fVer
***********************************************************************/
void Csw_ManStop( Csw_Man_t * p )
{
if ( p->fVerbose )
{
int nNodesBeg = Aig_ManNodeNum(p->pManAig);
int nNodesEnd = Aig_ManNodeNum(p->pManRes);
printf( "Beg = %7d. End = %7d. (%6.2f %%) Try = %7d. Cuts = %8d.\n",
nNodesBeg, nNodesEnd, 100.0*(nNodesBeg-nNodesEnd)/nNodesBeg,
p->nNodesTried, Csw_TableCountCuts( p ) );
printf( "Triv0 = %6d. Triv1 = %6d. Triv2 = %6d. Cut-replace = %6d.\n",
p->nNodesTriv0, p->nNodesTriv1, p->nNodesTriv2, p->nNodesCuts );
PRTP( "Cuts ", p->timeCuts, p->timeTotal );
PRTP( "Hashing ", p->timeHash, p->timeTotal );
PRTP( "Other ", p->timeOther, p->timeTotal );
PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
}
free( p->puTemp[0] );
Dar_MmFixedStop( p->pMemCuts, 0 );
Aig_MmFixedStop( p->pMemCuts, 0 );
free( p->pnRefs );
free( p->pEquiv );
free( p->pCuts );
free( p->pTable );
......
......@@ -65,41 +65,26 @@ unsigned Csw_CutHash( Csw_Cut_t * pCut )
return uHash;
}
/**Function********************************************************************
Synopsis [Returns the next prime >= p.]
/**Function*************************************************************
Description [Copied from CUDD, for stand-aloneness.]
Synopsis [Returns the total number of cuts in the table.]
SideEffects [None]
Description []
SideEffects []
SeeAlso []
******************************************************************************/
unsigned int Cudd_PrimeCws( unsigned int p )
***********************************************************************/
int Csw_TableCountCuts( Csw_Man_t * p )
{
int i,pn;
p--;
do {
p++;
if (p&1) {
pn = 1;
i = 3;
while ((unsigned) (i * i) <= p) {
if (p % i == 0) {
pn = 0;
break;
}
i += 2;
}
} else {
pn = 0;
}
} while (!pn);
return(p);
} /* end of Cudd_Prime */
Csw_Cut_t * pEnt;
int i, Counter = 0;
for ( i = 0; i < p->nTableSize; i++ )
for ( pEnt = p->pTable[i]; pEnt; pEnt = pEnt->pNext )
Counter++;
return Counter;
}
/**Function*************************************************************
......@@ -130,9 +115,9 @@ void Csw_TableCutInsert( Csw_Man_t * p, Csw_Cut_t * pCut )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Csw_TableCutLookup( Csw_Man_t * p, Csw_Cut_t * pCut )
Aig_Obj_t * Csw_TableCutLookup( Csw_Man_t * p, Csw_Cut_t * pCut )
{
Dar_Obj_t * pRes = NULL;
Aig_Obj_t * pRes = NULL;
Csw_Cut_t * pEnt;
unsigned * pTruthNew, * pTruthOld;
int iEntry = Csw_CutHash(pCut) % p->nTableSize;
......@@ -150,8 +135,8 @@ Dar_Obj_t * Csw_TableCutLookup( Csw_Man_t * p, Csw_Cut_t * pCut )
{
if ( Kit_TruthIsEqual( pTruthOld, pTruthNew, pCut->nFanins ) )
{
pRes = Dar_ManObj( p->pManRes, pEnt->iNode );
assert( pRes->fPhase == Dar_ManObj( p->pManRes, pCut->iNode )->fPhase );
pRes = Aig_ManObj( p->pManRes, pEnt->iNode );
assert( pRes->fPhase == Aig_ManObj( p->pManRes, pCut->iNode )->fPhase );
break;
}
}
......@@ -159,8 +144,8 @@ Dar_Obj_t * Csw_TableCutLookup( Csw_Man_t * p, Csw_Cut_t * pCut )
{
if ( Kit_TruthIsOpposite( pTruthOld, pTruthNew, pCut->nFanins ) )
{
pRes = Dar_Not( Dar_ManObj( p->pManRes, pEnt->iNode ) );
assert( Dar_Regular(pRes)->fPhase != Dar_ManObj( p->pManRes, pCut->iNode )->fPhase );
pRes = Aig_Not( Aig_ManObj( p->pManRes, pEnt->iNode ) );
assert( Aig_Regular(pRes)->fPhase != Aig_ManObj( p->pManRes, pCut->iNode )->fPhase );
break;
}
}
......
......@@ -29,14 +29,6 @@ extern "C" {
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include "vec.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
......@@ -46,434 +38,34 @@ extern "C" {
////////////////////////////////////////////////////////////////////////
typedef struct Dar_Par_t_ Dar_Par_t;
typedef struct Dar_Man_t_ Dar_Man_t;
typedef struct Dar_Obj_t_ Dar_Obj_t;
typedef struct Dar_Cut_t_ Dar_Cut_t;
typedef struct Dar_Cnf_t_ Dar_Cnf_t;
typedef struct Dar_MmFixed_t_ Dar_MmFixed_t;
typedef struct Dar_MmFlex_t_ Dar_MmFlex_t;
typedef struct Dar_MmStep_t_ Dar_MmStep_t;
// the maximum number of cuts stored at a node
#define DAR_CUT_BASE 64
// object types
typedef enum {
DAR_AIG_NONE, // 0: non-existent object
DAR_AIG_CONST1, // 1: constant 1
DAR_AIG_PI, // 2: primary input
DAR_AIG_PO, // 3: primary output
DAR_AIG_BUF, // 4: buffer node
DAR_AIG_AND, // 5: AND node
DAR_AIG_EXOR, // 6: EXOR node
DAR_AIG_LATCH, // 7: latch
DAR_AIG_VOID // 8: unused object
} Dar_Type_t;
// the parameters
// the rewriting parameters
struct Dar_Par_t_
{
int fUpdateLevel;
int fUseZeros;
int fVerbose;
int fVeryVerbose;
};
// the AIG 4-cut
struct Dar_Cut_t_ // 8 words
{
unsigned uSign;
unsigned uTruth : 16; // the truth table of the cut function
unsigned Cost : 5; // the cost of the cut in terms of CNF clauses
unsigned FanRefs : 4; // the average number of fanin references
unsigned NoRefs : 3; // the average number of fanin references
unsigned nLeaves : 3; // the number of leaves
unsigned fBest : 1; // marks the best cut
int pLeaves[4]; // the array of leaves
// unsigned char pIndices[4];
float Area; // the area flow or exact area of the cut
};
// the AIG node
struct Dar_Obj_t_ // 8 words
{
void * pData; // misc (cuts, copy, etc)
Dar_Obj_t * pNext; // strashing table
Dar_Obj_t * pFanin0; // fanin
Dar_Obj_t * pFanin1; // fanin
unsigned long Type : 3; // object type
unsigned long fPhase : 1; // value under 000...0 pattern
unsigned long fMarkA : 1; // multipurpose mask
unsigned long fMarkB : 1; // multipurpose mask
unsigned long nRefs : 26; // reference count
unsigned Level : 24; // the level of this node
unsigned nCuts : 8; // the number of cuts
int TravId; // unique ID of last traversal involving the node
int Id; // unique ID of the node
};
// the AIG manager
struct Dar_Man_t_
{
// parameters governing rewriting
Dar_Par_t * pPars;
// AIG nodes
Vec_Ptr_t * vPis; // the array of PIs
Vec_Ptr_t * vPos; // the array of POs
Vec_Ptr_t * vObjs; // the array of all nodes (optional)
Dar_Obj_t * pConst1; // the constant 1 node
Dar_Obj_t Ghost; // the ghost node
// AIG node counters
int nObjs[DAR_AIG_VOID];// the number of objects by type
int nCreated; // the number of created objects
int nDeleted; // the number of deleted objects
// structural hash table
Dar_Obj_t ** pTable; // structural hash table
int nTableSize; // structural hash table size
// 4-input cuts of the nodes
Dar_Cut_t * pBaseCuts[DAR_CUT_BASE];
Dar_Cut_t BaseCuts[DAR_CUT_BASE];
int nBaseCuts;
int nCutsUsed;
int nCutsFiltered;
// current rewriting step
int nNodesInit; // the original number of nodes
Vec_Ptr_t * vLeavesBest; // the best set of leaves
int OutBest; // the best output (in the library)
int OutNumBest; // the best number of the output
int GainBest; // the best gain
int LevelBest; // the level of node with the best gain
int ClassBest; // the equivalence class of the best replacement
int nTotalSubgs; // the total number of subgraphs tried
int ClassTimes[222];// the runtimes for each class
int ClassGains[222];// the gains for each class
int ClassSubgs[222];// the graphs for each class
int nCutMemUsed; // memory used for cuts
// various data members
Dar_MmFixed_t * pMemObjs; // memory manager for objects
Dar_MmFlex_t * pMemCuts; // memory manager for cuts
Vec_Int_t * vRequired; // the required times
int nLevelMax; // maximum number of levels
void * pData; // the temporary data
int nTravIds; // the current traversal ID
int fCatchExor; // enables EXOR nodes
// CNF mapping
void * pManCnf; // CNF conversion manager
// rewriting statistics
int nCutsBad;
int nCutsGood;
// timing statistics
int timeCuts;
int timeEval;
int timeOther;
int timeTotal;
int time1;
int time2;
};
// the CNF asserting outputs of AIG to be 1
struct Dar_Cnf_t_
{
Dar_Man_t * pMan; // the AIG manager, for which CNF is computed
int nLiterals; // the number of CNF literals
int nClauses; // the number of CNF clauses
int ** pClauses; // the CNF clauses
int * pVarNums; // the number of CNF variable for each node ID (-1 if unused)
int nCutsMax; // the maximum number of cuts to try
int nSubgMax; // the maximum number of subgraphs to try
int fUpdateLevel; // update level
int fUseZeros; // performs zero-cost replacement
int fVerbose; // enables verbose output
int fVeryVerbose; // enables very verbose output
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
#define DAR_MIN(a,b) (((a) < (b))? (a) : (b))
#define DAR_MAX(a,b) (((a) > (b))? (a) : (b))
#define DAR_INFINITY (100000000)
#ifndef PRT
#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))
#endif
static inline int Dar_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); }
static inline int Dar_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
static inline int Dar_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
static inline void Dar_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); }
static inline void Dar_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); }
static inline Dar_Obj_t * Dar_Regular( Dar_Obj_t * p ) { return (Dar_Obj_t *)((unsigned long)(p) & ~01); }
static inline Dar_Obj_t * Dar_Not( Dar_Obj_t * p ) { return (Dar_Obj_t *)((unsigned long)(p) ^ 01); }
static inline Dar_Obj_t * Dar_NotCond( Dar_Obj_t * p, int c ) { return (Dar_Obj_t *)((unsigned long)(p) ^ (c)); }
static inline int Dar_IsComplement( Dar_Obj_t * p ) { return (int )(((unsigned long)p) & 01); }
static inline Dar_Obj_t * Dar_ManConst0( Dar_Man_t * p ) { return Dar_Not(p->pConst1); }
static inline Dar_Obj_t * Dar_ManConst1( Dar_Man_t * p ) { return p->pConst1; }
static inline Dar_Obj_t * Dar_ManGhost( Dar_Man_t * p ) { return &p->Ghost; }
static inline Dar_Obj_t * Dar_ManPi( Dar_Man_t * p, int i ) { return (Dar_Obj_t *)Vec_PtrEntry(p->vPis, i); }
static inline Dar_Obj_t * Dar_ManPo( Dar_Man_t * p, int i ) { return (Dar_Obj_t *)Vec_PtrEntry(p->vPos, i); }
static inline Dar_Obj_t * Dar_ManObj( Dar_Man_t * p, int i ) { return p->vObjs ? (Dar_Obj_t *)Vec_PtrEntry(p->vObjs, i) : NULL; }
static inline int Dar_ManPiNum( Dar_Man_t * p ) { return p->nObjs[DAR_AIG_PI]; }
static inline int Dar_ManPoNum( Dar_Man_t * p ) { return p->nObjs[DAR_AIG_PO]; }
static inline int Dar_ManBufNum( Dar_Man_t * p ) { return p->nObjs[DAR_AIG_BUF]; }
static inline int Dar_ManAndNum( Dar_Man_t * p ) { return p->nObjs[DAR_AIG_AND]; }
static inline int Dar_ManExorNum( Dar_Man_t * p ) { return p->nObjs[DAR_AIG_EXOR]; }
static inline int Dar_ManLatchNum( Dar_Man_t * p ) { return p->nObjs[DAR_AIG_LATCH]; }
static inline int Dar_ManNodeNum( Dar_Man_t * p ) { return p->nObjs[DAR_AIG_AND]+p->nObjs[DAR_AIG_EXOR]; }
static inline int Dar_ManGetCost( Dar_Man_t * p ) { return p->nObjs[DAR_AIG_AND]+3*p->nObjs[DAR_AIG_EXOR]; }
static inline int Dar_ManObjNum( Dar_Man_t * p ) { return p->nCreated - p->nDeleted; }
static inline int Dar_ManObjIdMax( Dar_Man_t * p ) { return Vec_PtrSize(p->vObjs); }
static inline Dar_Type_t Dar_ObjType( Dar_Obj_t * pObj ) { return (Dar_Type_t)pObj->Type; }
static inline int Dar_ObjIsNone( Dar_Obj_t * pObj ) { return pObj->Type == DAR_AIG_NONE; }
static inline int Dar_ObjIsConst1( Dar_Obj_t * pObj ) { assert(!Dar_IsComplement(pObj)); return pObj->Type == DAR_AIG_CONST1; }
static inline int Dar_ObjIsPi( Dar_Obj_t * pObj ) { return pObj->Type == DAR_AIG_PI; }
static inline int Dar_ObjIsPo( Dar_Obj_t * pObj ) { return pObj->Type == DAR_AIG_PO; }
static inline int Dar_ObjIsBuf( Dar_Obj_t * pObj ) { return pObj->Type == DAR_AIG_BUF; }
static inline int Dar_ObjIsAnd( Dar_Obj_t * pObj ) { return pObj->Type == DAR_AIG_AND; }
static inline int Dar_ObjIsExor( Dar_Obj_t * pObj ) { return pObj->Type == DAR_AIG_EXOR; }
static inline int Dar_ObjIsLatch( Dar_Obj_t * pObj ) { return pObj->Type == DAR_AIG_LATCH; }
static inline int Dar_ObjIsNode( Dar_Obj_t * pObj ) { return pObj->Type == DAR_AIG_AND || pObj->Type == DAR_AIG_EXOR; }
static inline int Dar_ObjIsTerm( Dar_Obj_t * pObj ) { return pObj->Type == DAR_AIG_PI || pObj->Type == DAR_AIG_PO || pObj->Type == DAR_AIG_CONST1; }
static inline int Dar_ObjIsHash( Dar_Obj_t * pObj ) { return pObj->Type == DAR_AIG_AND || pObj->Type == DAR_AIG_EXOR || pObj->Type == DAR_AIG_LATCH; }
static inline int Dar_ObjIsMarkA( Dar_Obj_t * pObj ) { return pObj->fMarkA; }
static inline void Dar_ObjSetMarkA( Dar_Obj_t * pObj ) { pObj->fMarkA = 1; }
static inline void Dar_ObjClearMarkA( Dar_Obj_t * pObj ) { pObj->fMarkA = 0; }
static inline void Dar_ObjSetTravId( Dar_Obj_t * pObj, int TravId ) { pObj->TravId = TravId; }
static inline void Dar_ObjSetTravIdCurrent( Dar_Man_t * p, Dar_Obj_t * pObj ) { pObj->TravId = p->nTravIds; }
static inline void Dar_ObjSetTravIdPrevious( Dar_Man_t * p, Dar_Obj_t * pObj ) { pObj->TravId = p->nTravIds - 1; }
static inline int Dar_ObjIsTravIdCurrent( Dar_Man_t * p, Dar_Obj_t * pObj ) { return (int)(pObj->TravId == p->nTravIds); }
static inline int Dar_ObjIsTravIdPrevious( Dar_Man_t * p, Dar_Obj_t * pObj ) { return (int)(pObj->TravId == p->nTravIds - 1); }
static inline int Dar_ObjTravId( Dar_Obj_t * pObj ) { return (int)pObj->pData; }
static inline int Dar_ObjPhase( Dar_Obj_t * pObj ) { return pObj->fPhase; }
static inline int Dar_ObjRefs( Dar_Obj_t * pObj ) { return pObj->nRefs; }
static inline void Dar_ObjRef( Dar_Obj_t * pObj ) { pObj->nRefs++; }
static inline void Dar_ObjDeref( Dar_Obj_t * pObj ) { assert( pObj->nRefs > 0 ); pObj->nRefs--; }
static inline void Dar_ObjClearRef( Dar_Obj_t * pObj ) { pObj->nRefs = 0; }
static inline int Dar_ObjFaninC0( Dar_Obj_t * pObj ) { return Dar_IsComplement(pObj->pFanin0); }
static inline int Dar_ObjFaninC1( Dar_Obj_t * pObj ) { return Dar_IsComplement(pObj->pFanin1); }
static inline Dar_Obj_t * Dar_ObjFanin0( Dar_Obj_t * pObj ) { return Dar_Regular(pObj->pFanin0); }
static inline Dar_Obj_t * Dar_ObjFanin1( Dar_Obj_t * pObj ) { return Dar_Regular(pObj->pFanin1); }
static inline Dar_Obj_t * Dar_ObjChild0( Dar_Obj_t * pObj ) { return pObj->pFanin0; }
static inline Dar_Obj_t * Dar_ObjChild1( Dar_Obj_t * pObj ) { return pObj->pFanin1; }
static inline Dar_Obj_t * Dar_ObjChild0Copy( Dar_Obj_t * pObj ) { assert( !Dar_IsComplement(pObj) ); return Dar_ObjFanin0(pObj)? Dar_NotCond((Dar_Obj_t *)Dar_ObjFanin0(pObj)->pData, Dar_ObjFaninC0(pObj)) : NULL; }
static inline Dar_Obj_t * Dar_ObjChild1Copy( Dar_Obj_t * pObj ) { assert( !Dar_IsComplement(pObj) ); return Dar_ObjFanin1(pObj)? Dar_NotCond((Dar_Obj_t *)Dar_ObjFanin1(pObj)->pData, Dar_ObjFaninC1(pObj)) : NULL; }
static inline int Dar_ObjLevel( Dar_Obj_t * pObj ) { return pObj->nRefs; }
static inline int Dar_ObjLevelNew( Dar_Obj_t * pObj ) { return 1 + Dar_ObjIsExor(pObj) + DAR_MAX(Dar_ObjFanin0(pObj)->Level, Dar_ObjFanin1(pObj)->Level); }
static inline int Dar_ObjFaninPhase( Dar_Obj_t * pObj ) { return Dar_Regular(pObj)->fPhase ^ Dar_IsComplement(pObj); }
static inline void Dar_ObjClean( Dar_Obj_t * pObj ) { memset( pObj, 0, sizeof(Dar_Obj_t) ); }
static inline int Dar_ObjWhatFanin( Dar_Obj_t * pObj, Dar_Obj_t * pFanin )
{
if ( Dar_ObjFanin0(pObj) == pFanin ) return 0;
if ( Dar_ObjFanin1(pObj) == pFanin ) return 1;
assert(0); return -1;
}
static inline int Dar_ObjFanoutC( Dar_Obj_t * pObj, Dar_Obj_t * pFanout )
{
if ( Dar_ObjFanin0(pFanout) == pObj ) return Dar_ObjFaninC0(pObj);
if ( Dar_ObjFanin1(pFanout) == pObj ) return Dar_ObjFaninC1(pObj);
assert(0); return -1;
}
static inline Dar_Cut_t * Dar_ObjBestCut( Dar_Obj_t * pObj )
{
Dar_Cut_t * pCut; int i;
for ( pCut = pObj->pData, i = 0; i < (int)pObj->nCuts; i++, pCut++ )
if ( pCut->fBest )
return pCut;
return NULL;
}
static inline void Dar_ObjSetBestCut( Dar_Cut_t * pCut ) { assert( !pCut->fBest ); pCut->fBest = 1; }
static inline void Dar_ObjClearBestCut( Dar_Cut_t * pCut ) { assert( pCut->fBest ); pCut->fBest = 0; }
// create the ghost of the new node
static inline Dar_Obj_t * Dar_ObjCreateGhost( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1, Dar_Type_t Type )
{
Dar_Obj_t * pGhost;
assert( Type != DAR_AIG_AND || !Dar_ObjIsConst1(Dar_Regular(p0)) );
assert( p1 == NULL || !Dar_ObjIsConst1(Dar_Regular(p1)) );
assert( Type == DAR_AIG_PI || Dar_Regular(p0) != Dar_Regular(p1) );
pGhost = Dar_ManGhost(p);
pGhost->Type = Type;
if ( p1 == NULL || Dar_Regular(p0)->Id < Dar_Regular(p1)->Id )
{
pGhost->pFanin0 = p0;
pGhost->pFanin1 = p1;
}
else
{
pGhost->pFanin0 = p1;
pGhost->pFanin1 = p0;
}
return pGhost;
}
// internal memory manager
static inline Dar_Obj_t * Dar_ManFetchMemory( Dar_Man_t * p )
{
extern char * Dar_MmFixedEntryFetch( Dar_MmFixed_t * p );
Dar_Obj_t * pTemp;
pTemp = (Dar_Obj_t *)Dar_MmFixedEntryFetch( p->pMemObjs );
memset( pTemp, 0, sizeof(Dar_Obj_t) );
Vec_PtrPush( p->vObjs, pTemp );
pTemp->Id = p->nCreated++;
return pTemp;
}
static inline void Dar_ManRecycleMemory( Dar_Man_t * p, Dar_Obj_t * pEntry )
{
extern void Dar_MmFixedEntryRecycle( Dar_MmFixed_t * p, char * pEntry );
assert( pEntry->nRefs == 0 );
pEntry->Type = DAR_AIG_NONE; // distinquishes a dead node from a live node
Dar_MmFixedEntryRecycle( p->pMemObjs, (char *)pEntry );
p->nDeleted++;
}
////////////////////////////////////////////////////////////////////////
/// ITERATORS ///
////////////////////////////////////////////////////////////////////////
// iterator over the primary inputs
#define Dar_ManForEachPi( p, pObj, i ) \
Vec_PtrForEachEntry( p->vPis, pObj, i )
// iterator over the primary outputs
#define Dar_ManForEachPo( p, pObj, i ) \
Vec_PtrForEachEntry( p->vPos, pObj, i )
// iterator over all objects, including those currently not used
#define Dar_ManForEachObj( p, pObj, i ) \
Vec_PtrForEachEntry( p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
// iterator over all nodes
#define Dar_ManForEachNode( p, pObj, i ) \
Vec_PtrForEachEntry( p->vObjs, pObj, i ) if ( (pObj) == NULL || !Dar_ObjIsNode(pObj) ) {} else
// iterator over all cuts of the node
#define Dar_ObjForEachCut( pObj, pCut, i ) \
for ( pCut = pObj->pData, i = 0; i < (int)pObj->nCuts; i++, pCut++ ) if ( i==0 ) {} else
// iterator over leaves of the cut
#define Dar_CutForEachLeaf( p, pCut, pLeaf, i ) \
for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = Dar_ManObj(p, (pCut)->pLeaves[i])); i++ )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== darBalance.c ========================================================*/
extern Dar_Man_t * Dar_ManBalance( Dar_Man_t * p, int fUpdateLevel );
extern Dar_Obj_t * Dar_NodeBalanceBuildSuper( Dar_Man_t * p, Vec_Ptr_t * vSuper, Dar_Type_t Type, int fUpdateLevel );
/*=== darCheck.c ========================================================*/
extern int Dar_ManCheck( Dar_Man_t * p );
/*=== darCnf.c ========================================================*/
extern Dar_Cnf_t * Dar_ManDeriveCnf( Dar_Man_t * p );
extern Dar_Cut_t * Dar_ObjFindBestCut( Dar_Obj_t * pObj );
extern void Dar_CutAssignAreaFlow( Dar_Man_t * p, Dar_Cut_t * pCut );
extern void Dar_CutAssignArea( Dar_Man_t * p, Dar_Cut_t * pCut );
extern void Dar_CnfFree( Dar_Cnf_t * pCnf );
/*=== darCore.c ========================================================*/
extern int Dar_ManRewrite( Dar_Man_t * p );
extern int Dar_ManComputeCuts( Dar_Man_t * p );
/*=== darCut.c ========================================================*/
extern void Dar_ManSetupPis( Dar_Man_t * p );
extern Dar_Cut_t * Dar_ObjComputeCuts_rec( Dar_Man_t * p, Dar_Obj_t * pObj );
extern Dar_Cut_t * Dar_ObjComputeCuts( Dar_Man_t * p, Dar_Obj_t * pObj );
extern void Dar_ManCutsFree( Dar_Man_t * p );
/*=== darData.c ========================================================*/
extern Vec_Int_t * Dar_LibReadNodes();
extern Vec_Int_t * Dar_LibReadOuts();
/*=== darData2.c ========================================================*/
extern void Dar_LibReadMsops( char ** ppSopSizes, char *** ppSops );
/*=== darDfs.c ==========================================================*/
extern Vec_Ptr_t * Dar_ManDfs( Dar_Man_t * p );
extern Vec_Ptr_t * Dar_ManDfsNodes( Dar_Man_t * p, Dar_Obj_t ** ppNodes, int nNodes );
extern int Dar_ManCountLevels( Dar_Man_t * p );
extern void Dar_ManCreateRefs( Dar_Man_t * p );
extern int Dar_DagSize( Dar_Obj_t * pObj );
extern void Dar_ConeUnmark_rec( Dar_Obj_t * pObj );
extern Dar_Obj_t * Dar_Transfer( Dar_Man_t * pSour, Dar_Man_t * pDest, Dar_Obj_t * pObj, int nVars );
extern Dar_Obj_t * Dar_Compose( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Obj_t * pFunc, int iVar );
/*=== darLib.c ==========================================================*/
extern void Dar_LibStart();
extern void Dar_LibStop();
extern void Dar_LibEval( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Cut_t * pCut, int Required );
extern Dar_Obj_t * Dar_LibBuildBest( Dar_Man_t * p );
/*=== darMan.c ==========================================================*/
extern Dar_Man_t * Dar_ManStart();
extern Dar_Man_t * Dar_ManStartFrom( Dar_Man_t * p );
extern Dar_Man_t * Dar_ManDup( Dar_Man_t * p );
extern void Dar_ManStop( Dar_Man_t * p );
extern int Dar_ManCleanup( Dar_Man_t * p );
extern void Dar_ManPrintStats( Dar_Man_t * p );
extern void Dar_ManPrintRuntime( Dar_Man_t * p );
/*=== darMem.c ==========================================================*/
extern void Dar_ManStartMemory( Dar_Man_t * p );
extern void Dar_ManStopMemory( Dar_Man_t * p );
/*=== darObj.c ==========================================================*/
extern Dar_Obj_t * Dar_ObjCreatePi( Dar_Man_t * p );
extern Dar_Obj_t * Dar_ObjCreatePo( Dar_Man_t * p, Dar_Obj_t * pDriver );
extern Dar_Obj_t * Dar_ObjCreate( Dar_Man_t * p, Dar_Obj_t * pGhost );
extern void Dar_ObjConnect( Dar_Man_t * p, Dar_Obj_t * pObj, Dar_Obj_t * pFan0, Dar_Obj_t * pFan1 );
extern void Dar_ObjDisconnect( Dar_Man_t * p, Dar_Obj_t * pObj );
extern void Dar_ObjDelete( Dar_Man_t * p, Dar_Obj_t * pObj );
extern void Dar_ObjDelete_rec( Dar_Man_t * p, Dar_Obj_t * pObj, int fFreeTop );
extern void Dar_ObjPatchFanin0( Dar_Man_t * p, Dar_Obj_t * pObj, Dar_Obj_t * pFaninNew );
extern void Dar_ObjReplace( Dar_Man_t * p, Dar_Obj_t * pObjOld, Dar_Obj_t * pObjNew, int fNodesOnly );
/*=== darOper.c =========================================================*/
extern Dar_Obj_t * Dar_IthVar( Dar_Man_t * p, int i );
extern Dar_Obj_t * Dar_Oper( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1, Dar_Type_t Type );
extern Dar_Obj_t * Dar_And( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1 );
extern Dar_Obj_t * Dar_Latch( Dar_Man_t * p, Dar_Obj_t * pObj, int fInitOne );
extern Dar_Obj_t * Dar_Or( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1 );
extern Dar_Obj_t * Dar_Exor( Dar_Man_t * p, Dar_Obj_t * p0, Dar_Obj_t * p1 );
extern Dar_Obj_t * Dar_Mux( Dar_Man_t * p, Dar_Obj_t * pC, Dar_Obj_t * p1, Dar_Obj_t * p0 );
extern Dar_Obj_t * Dar_Maj( Dar_Man_t * p, Dar_Obj_t * pA, Dar_Obj_t * pB, Dar_Obj_t * pC );
extern Dar_Obj_t * Dar_Miter( Dar_Man_t * p, Vec_Ptr_t * vPairs );
extern Dar_Obj_t * Dar_CreateAnd( Dar_Man_t * p, int nVars );
extern Dar_Obj_t * Dar_CreateOr( Dar_Man_t * p, int nVars );
extern Dar_Obj_t * Dar_CreateExor( Dar_Man_t * p, int nVars );
/*=== darSeq.c ========================================================*/
extern int Dar_ManSeqStrash( Dar_Man_t * p, int nLatches, int * pInits );
/*=== darTable.c ========================================================*/
extern Dar_Obj_t * Dar_TableLookup( Dar_Man_t * p, Dar_Obj_t * pGhost );
extern void Dar_TableInsert( Dar_Man_t * p, Dar_Obj_t * pObj );
extern void Dar_TableDelete( Dar_Man_t * p, Dar_Obj_t * pObj );
extern int Dar_TableCountEntries( Dar_Man_t * p );
extern void Dar_TableProfile( Dar_Man_t * p );
/*=== darUtil.c =========================================================*/
extern Dar_Par_t * Dar_ManDefaultParams();
extern void Dar_ManIncrementTravId( Dar_Man_t * p );
extern int Dar_ManLevels( Dar_Man_t * p );
extern void Dar_ManCleanData( Dar_Man_t * p );
extern void Dar_ObjCleanData_rec( Dar_Obj_t * pObj );
extern void Dar_ObjCollectMulti( Dar_Obj_t * pFunc, Vec_Ptr_t * vSuper );
extern int Dar_ObjIsMuxType( Dar_Obj_t * pObj );
extern int Dar_ObjRecognizeExor( Dar_Obj_t * pObj, Dar_Obj_t ** ppFan0, Dar_Obj_t ** ppFan1 );
extern Dar_Obj_t * Dar_ObjRecognizeMux( Dar_Obj_t * pObj, Dar_Obj_t ** ppObjT, Dar_Obj_t ** ppObjE );
extern Dar_Obj_t * Dar_ObjReal_rec( Dar_Obj_t * pObj );
extern void Dar_ObjPrintEqn( FILE * pFile, Dar_Obj_t * pObj, Vec_Vec_t * vLevels, int Level );
extern void Dar_ObjPrintVerilog( FILE * pFile, Dar_Obj_t * pObj, Vec_Vec_t * vLevels, int Level );
extern void Dar_ObjPrintVerbose( Dar_Obj_t * pObj, int fHaig );
extern void Dar_ManPrintVerbose( Dar_Man_t * p, int fHaig );
extern void Dar_ManDumpBlif( Dar_Man_t * p, char * pFileName );
/*=== darMem.c ===========================================================*/
// fixed-size-block memory manager
extern Dar_MmFixed_t * Dar_MmFixedStart( int nEntrySize, int nEntriesMax );
extern void Dar_MmFixedStop( Dar_MmFixed_t * p, int fVerbose );
extern char * Dar_MmFixedEntryFetch( Dar_MmFixed_t * p );
extern void Dar_MmFixedEntryRecycle( Dar_MmFixed_t * p, char * pEntry );
extern void Dar_MmFixedRestart( Dar_MmFixed_t * p );
extern int Dar_MmFixedReadMemUsage( Dar_MmFixed_t * p );
extern int Dar_MmFixedReadMaxEntriesUsed( Dar_MmFixed_t * p );
// flexible-size-block memory manager
extern Dar_MmFlex_t * Dar_MmFlexStart();
extern void Dar_MmFlexStop( Dar_MmFlex_t * p, int fVerbose );
extern char * Dar_MmFlexEntryFetch( Dar_MmFlex_t * p, int nBytes );
extern void Dar_MmFlexRestart( Dar_MmFlex_t * p );
extern int Dar_MmFlexReadMemUsage( Dar_MmFlex_t * p );
// hierarchical memory manager
extern Dar_MmStep_t * Dar_MmStepStart( int nSteps );
extern void Dar_MmStepStop( Dar_MmStep_t * p, int fVerbose );
extern char * Dar_MmStepEntryFetch( Dar_MmStep_t * p, int nBytes );
extern void Dar_MmStepEntryRecycle( Dar_MmStep_t * p, char * pEntry, int nBytes );
extern int Dar_MmStepReadMemUsage( Dar_MmStep_t * p );
extern void Dar_ManDefaultParams( Dar_Par_t * pPars );
extern int Dar_ManRewrite( Aig_Man_t * pAig, Dar_Par_t * pPars );
extern Aig_MmFixed_t * Dar_ManComputeCuts( Aig_Man_t * pAig );
#ifdef __cplusplus
}
......
......@@ -18,17 +18,18 @@
***********************************************************************/
#include "dar.h"
#include "darInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static Dar_Obj_t * Dar_NodeBalance_rec( Dar_Man_t * pNew, Dar_Obj_t * pObj, Vec_Vec_t * vStore, int Level, int fUpdateLevel );
static Vec_Ptr_t * Dar_NodeBalanceCone( Dar_Obj_t * pObj, Vec_Vec_t * vStore, int Level );
static int Dar_NodeBalanceFindLeft( Vec_Ptr_t * vSuper );
static void Dar_NodeBalancePermute( Dar_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor );
static void Dar_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Dar_Obj_t * pObj );
static Aig_Obj_t * Dar_Balance_rec( Aig_Man_t * pNew, Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level, int fUpdateLevel );
static Vec_Ptr_t * Dar_BalanceCone( Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level );
static int Dar_BalanceFindLeft( Vec_Ptr_t * vSuper );
static void Dar_BalancePermute( Aig_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor );
static void Dar_BalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Aig_Obj_t * pObj );
static Aig_Obj_t * Dar_BalanceBuildSuper( Aig_Man_t * p, Vec_Ptr_t * vSuper, Aig_Type_t Type, int fUpdateLevel );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
......@@ -45,33 +46,33 @@ static void Dar_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Da
SeeAlso []
***********************************************************************/
Dar_Man_t * Dar_ManBalance( Dar_Man_t * p, int fUpdateLevel )
Aig_Man_t * Dar_ManBalance( Aig_Man_t * p, int fUpdateLevel )
{
Dar_Man_t * pNew;
Dar_Obj_t * pObj, * pObjNew;
Aig_Man_t * pNew;
Aig_Obj_t * pObj, * pObjNew;
Vec_Vec_t * vStore;
int i;
// create the new manager
pNew = Dar_ManStart();
pNew = Aig_ManStart();
// map the PI nodes
Dar_ManCleanData( p );
Dar_ManConst1(p)->pData = Dar_ManConst1(pNew);
Dar_ManForEachPi( p, pObj, i )
pObj->pData = Dar_ObjCreatePi(pNew);
Aig_ManCleanData( p );
Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
Aig_ManForEachPi( p, pObj, i )
pObj->pData = Aig_ObjCreatePi(pNew);
// balance the AIG
vStore = Vec_VecAlloc( 50 );
Dar_ManForEachPo( p, pObj, i )
Aig_ManForEachPo( p, pObj, i )
{
pObjNew = Dar_NodeBalance_rec( pNew, Dar_ObjFanin0(pObj), vStore, 0, fUpdateLevel );
Dar_ObjCreatePo( pNew, Dar_NotCond( pObjNew, Dar_ObjFaninC0(pObj) ) );
pObjNew = Dar_Balance_rec( pNew, Aig_ObjFanin0(pObj), vStore, 0, fUpdateLevel );
Aig_ObjCreatePo( pNew, Aig_NotCond( pObjNew, Aig_ObjFaninC0(pObj) ) );
}
Vec_VecFree( vStore );
// remove dangling nodes
// Dar_ManCreateRefs( pNew );
// if ( i = Dar_ManCleanup( pNew ) )
// Aig_ManCreateRefs( pNew );
// if ( i = Aig_ManCleanup( pNew ) )
// printf( "Cleanup after balancing removed %d dangling nodes.\n", i );
// check the resulting AIG
if ( !Dar_ManCheck(pNew) )
if ( !Aig_ManCheck(pNew) )
printf( "Dar_ManBalance(): The check has failed.\n" );
return pNew;
}
......@@ -87,33 +88,33 @@ Dar_Man_t * Dar_ManBalance( Dar_Man_t * p, int fUpdateLevel )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_NodeBalance_rec( Dar_Man_t * pNew, Dar_Obj_t * pObjOld, Vec_Vec_t * vStore, int Level, int fUpdateLevel )
Aig_Obj_t * Dar_Balance_rec( Aig_Man_t * pNew, Aig_Obj_t * pObjOld, Vec_Vec_t * vStore, int Level, int fUpdateLevel )
{
Dar_Obj_t * pObjNew;
Aig_Obj_t * pObjNew;
Vec_Ptr_t * vSuper;
int i;
assert( !Dar_IsComplement(pObjOld) );
assert( !Aig_IsComplement(pObjOld) );
// return if the result is known
if ( pObjOld->pData )
return pObjOld->pData;
assert( Dar_ObjIsNode(pObjOld) );
assert( Aig_ObjIsNode(pObjOld) );
// get the implication supergate
vSuper = Dar_NodeBalanceCone( pObjOld, vStore, Level );
vSuper = Dar_BalanceCone( pObjOld, vStore, Level );
// check if supergate contains two nodes in the opposite polarity
if ( vSuper->nSize == 0 )
return pObjOld->pData = Dar_ManConst0(pNew);
return pObjOld->pData = Aig_ManConst0(pNew);
if ( Vec_PtrSize(vSuper) < 2 )
printf( "BUG!\n" );
// for each old node, derive the new well-balanced node
for ( i = 0; i < Vec_PtrSize(vSuper); i++ )
{
pObjNew = Dar_NodeBalance_rec( pNew, Dar_Regular(vSuper->pArray[i]), vStore, Level + 1, fUpdateLevel );
vSuper->pArray[i] = Dar_NotCond( pObjNew, Dar_IsComplement(vSuper->pArray[i]) );
pObjNew = Dar_Balance_rec( pNew, Aig_Regular(vSuper->pArray[i]), vStore, Level + 1, fUpdateLevel );
vSuper->pArray[i] = Aig_NotCond( pObjNew, Aig_IsComplement(vSuper->pArray[i]) );
}
// build the supergate
pObjNew = Dar_NodeBalanceBuildSuper( pNew, vSuper, Dar_ObjType(pObjOld), fUpdateLevel );
pObjNew = Dar_BalanceBuildSuper( pNew, vSuper, Aig_ObjType(pObjOld), fUpdateLevel );
// make sure the balanced node is not assigned
// assert( pObjOld->Level >= Dar_Regular(pObjNew)->Level );
// assert( pObjOld->Level >= Aig_Regular(pObjNew)->Level );
assert( pObjOld->pData == NULL );
return pObjOld->pData = pObjNew;
}
......@@ -129,11 +130,11 @@ Dar_Obj_t * Dar_NodeBalance_rec( Dar_Man_t * pNew, Dar_Obj_t * pObjOld, Vec_Vec_
SeeAlso []
***********************************************************************/
int Dar_NodeBalanceCone_rec( Dar_Obj_t * pRoot, Dar_Obj_t * pObj, Vec_Ptr_t * vSuper )
int Dar_BalanceCone_rec( Aig_Obj_t * pRoot, Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
{
int RetValue1, RetValue2, i;
// check if the node is visited
if ( Dar_Regular(pObj)->fMarkB )
if ( Aig_Regular(pObj)->fMarkB )
{
// check if the node occurs in the same polarity
for ( i = 0; i < vSuper->nSize; i++ )
......@@ -141,23 +142,23 @@ int Dar_NodeBalanceCone_rec( Dar_Obj_t * pRoot, Dar_Obj_t * pObj, Vec_Ptr_t * vS
return 1;
// check if the node is present in the opposite polarity
for ( i = 0; i < vSuper->nSize; i++ )
if ( vSuper->pArray[i] == Dar_Not(pObj) )
if ( vSuper->pArray[i] == Aig_Not(pObj) )
return -1;
assert( 0 );
return 0;
}
// if the new node is complemented or a PI, another gate begins
if ( pObj != pRoot && (Dar_IsComplement(pObj) || Dar_ObjType(pObj) != Dar_ObjType(pRoot) || Dar_ObjRefs(pObj) > 1) )
if ( pObj != pRoot && (Aig_IsComplement(pObj) || Aig_ObjType(pObj) != Aig_ObjType(pRoot) || Aig_ObjRefs(pObj) > 1) )
{
Vec_PtrPush( vSuper, pObj );
Dar_Regular(pObj)->fMarkB = 1;
Aig_Regular(pObj)->fMarkB = 1;
return 0;
}
assert( !Dar_IsComplement(pObj) );
assert( Dar_ObjIsNode(pObj) );
assert( !Aig_IsComplement(pObj) );
assert( Aig_ObjIsNode(pObj) );
// go through the branches
RetValue1 = Dar_NodeBalanceCone_rec( pRoot, Dar_ObjChild0(pObj), vSuper );
RetValue2 = Dar_NodeBalanceCone_rec( pRoot, Dar_ObjChild1(pObj), vSuper );
RetValue1 = Dar_BalanceCone_rec( pRoot, Aig_ObjChild0(pObj), vSuper );
RetValue2 = Dar_BalanceCone_rec( pRoot, Aig_ObjChild1(pObj), vSuper );
if ( RetValue1 == -1 || RetValue2 == -1 )
return -1;
// return 1 if at least one branch has a duplicate
......@@ -175,11 +176,11 @@ int Dar_NodeBalanceCone_rec( Dar_Obj_t * pRoot, Dar_Obj_t * pObj, Vec_Ptr_t * vS
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Dar_NodeBalanceCone( Dar_Obj_t * pObj, Vec_Vec_t * vStore, int Level )
Vec_Ptr_t * Dar_BalanceCone( Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level )
{
Vec_Ptr_t * vNodes;
int RetValue, i;
assert( !Dar_IsComplement(pObj) );
assert( !Aig_IsComplement(pObj) );
// extend the storage
if ( Vec_VecSize( vStore ) <= Level )
Vec_VecPush( vStore, Level, 0 );
......@@ -187,11 +188,11 @@ Vec_Ptr_t * Dar_NodeBalanceCone( Dar_Obj_t * pObj, Vec_Vec_t * vStore, int Level
vNodes = Vec_VecEntry( vStore, Level );
Vec_PtrClear( vNodes );
// collect the nodes in the implication supergate
RetValue = Dar_NodeBalanceCone_rec( pObj, pObj, vNodes );
RetValue = Dar_BalanceCone_rec( pObj, pObj, vNodes );
assert( vNodes->nSize > 1 );
// unmark the visited nodes
Vec_PtrForEachEntry( vNodes, pObj, i )
Dar_Regular(pObj)->fMarkB = 0;
Aig_Regular(pObj)->fMarkB = 0;
// if we found the node and its complement in the same implication supergate,
// return empty set of nodes (meaning that we should use constant-0 node)
if ( RetValue == -1 )
......@@ -210,9 +211,9 @@ Vec_Ptr_t * Dar_NodeBalanceCone( Dar_Obj_t * pObj, Vec_Vec_t * vStore, int Level
SeeAlso []
***********************************************************************/
int Dar_NodeCompareLevelsDecrease( Dar_Obj_t ** pp1, Dar_Obj_t ** pp2 )
int Aig_NodeCompareLevelsDecrease( Aig_Obj_t ** pp1, Aig_Obj_t ** pp2 )
{
int Diff = Dar_ObjLevel(Dar_Regular(*pp1)) - Dar_ObjLevel(Dar_Regular(*pp2));
int Diff = Aig_ObjLevel(Aig_Regular(*pp1)) - Aig_ObjLevel(Aig_Regular(*pp2));
if ( Diff > 0 )
return -1;
if ( Diff < 0 )
......@@ -231,24 +232,24 @@ int Dar_NodeCompareLevelsDecrease( Dar_Obj_t ** pp1, Dar_Obj_t ** pp2 )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_NodeBalanceBuildSuper( Dar_Man_t * p, Vec_Ptr_t * vSuper, Dar_Type_t Type, int fUpdateLevel )
Aig_Obj_t * Dar_BalanceBuildSuper( Aig_Man_t * p, Vec_Ptr_t * vSuper, Aig_Type_t Type, int fUpdateLevel )
{
Dar_Obj_t * pObj1, * pObj2;
Aig_Obj_t * pObj1, * pObj2;
int LeftBound;
assert( vSuper->nSize > 1 );
// sort the new nodes by level in the decreasing order
Vec_PtrSort( vSuper, Dar_NodeCompareLevelsDecrease );
Vec_PtrSort( vSuper, Aig_NodeCompareLevelsDecrease );
// balance the nodes
while ( vSuper->nSize > 1 )
{
// find the left bound on the node to be paired
LeftBound = (!fUpdateLevel)? 0 : Dar_NodeBalanceFindLeft( vSuper );
LeftBound = (!fUpdateLevel)? 0 : Dar_BalanceFindLeft( vSuper );
// find the node that can be shared (if no such node, randomize choice)
Dar_NodeBalancePermute( p, vSuper, LeftBound, Type == DAR_AIG_EXOR );
Dar_BalancePermute( p, vSuper, LeftBound, Type == AIG_OBJ_EXOR );
// pull out the last two nodes
pObj1 = Vec_PtrPop(vSuper);
pObj2 = Vec_PtrPop(vSuper);
Dar_NodeBalancePushUniqueOrderByLevel( vSuper, Dar_Oper(p, pObj1, pObj2, Type) );
Dar_BalancePushUniqueOrderByLevel( vSuper, Aig_Oper(p, pObj1, pObj2, Type) );
}
return Vec_PtrEntry(vSuper, 0);
}
......@@ -268,9 +269,9 @@ Dar_Obj_t * Dar_NodeBalanceBuildSuper( Dar_Man_t * p, Vec_Ptr_t * vSuper, Dar_Ty
SeeAlso []
***********************************************************************/
int Dar_NodeBalanceFindLeft( Vec_Ptr_t * vSuper )
int Dar_BalanceFindLeft( Vec_Ptr_t * vSuper )
{
Dar_Obj_t * pObjRight, * pObjLeft;
Aig_Obj_t * pObjRight, * pObjLeft;
int Current;
// if two or less nodes, pair with the first
if ( Vec_PtrSize(vSuper) < 3 )
......@@ -284,13 +285,13 @@ int Dar_NodeBalanceFindLeft( Vec_Ptr_t * vSuper )
// get the next node on the left
pObjLeft = Vec_PtrEntry( vSuper, Current );
// if the level of this node is different, quit the loop
if ( Dar_ObjLevel(Dar_Regular(pObjLeft)) != Dar_ObjLevel(Dar_Regular(pObjRight)) )
if ( Aig_ObjLevel(Aig_Regular(pObjLeft)) != Aig_ObjLevel(Aig_Regular(pObjRight)) )
break;
}
Current++;
// get the node, for which the equality holds
pObjLeft = Vec_PtrEntry( vSuper, Current );
assert( Dar_ObjLevel(Dar_Regular(pObjLeft)) == Dar_ObjLevel(Dar_Regular(pObjRight)) );
assert( Aig_ObjLevel(Aig_Regular(pObjLeft)) == Aig_ObjLevel(Aig_Regular(pObjRight)) );
return Current;
}
......@@ -306,9 +307,9 @@ int Dar_NodeBalanceFindLeft( Vec_Ptr_t * vSuper )
SeeAlso []
***********************************************************************/
void Dar_NodeBalancePermute( Dar_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor )
void Dar_BalancePermute( Aig_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor )
{
Dar_Obj_t * pObj1, * pObj2, * pObj3, * pGhost;
Aig_Obj_t * pObj1, * pObj2, * pObj3, * pGhost;
int RightBound, i;
// get the right bound
RightBound = Vec_PtrSize(vSuper) - 2;
......@@ -318,20 +319,20 @@ void Dar_NodeBalancePermute( Dar_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, i
// get the two last nodes
pObj1 = Vec_PtrEntry( vSuper, RightBound + 1 );
pObj2 = Vec_PtrEntry( vSuper, RightBound );
if ( Dar_Regular(pObj1) == p->pConst1 || Dar_Regular(pObj2) == p->pConst1 )
if ( Aig_Regular(pObj1) == p->pConst1 || Aig_Regular(pObj2) == p->pConst1 )
return;
// find the first node that can be shared
for ( i = RightBound; i >= LeftBound; i-- )
{
pObj3 = Vec_PtrEntry( vSuper, i );
if ( Dar_Regular(pObj3) == p->pConst1 )
if ( Aig_Regular(pObj3) == p->pConst1 )
{
Vec_PtrWriteEntry( vSuper, i, pObj2 );
Vec_PtrWriteEntry( vSuper, RightBound, pObj3 );
return;
}
pGhost = Dar_ObjCreateGhost( p, pObj1, pObj3, fExor? DAR_AIG_EXOR : DAR_AIG_AND );
if ( Dar_TableLookup( p, pGhost ) )
pGhost = Aig_ObjCreateGhost( p, pObj1, pObj3, fExor? AIG_OBJ_EXOR : AIG_OBJ_AND );
if ( Aig_TableLookup( p, pGhost ) )
{
if ( pObj3 == pObj2 )
return;
......@@ -364,9 +365,9 @@ void Dar_NodeBalancePermute( Dar_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, i
SeeAlso []
***********************************************************************/
void Dar_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Dar_Obj_t * pObj )
void Dar_BalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Aig_Obj_t * pObj )
{
Dar_Obj_t * pObj1, * pObj2;
Aig_Obj_t * pObj1, * pObj2;
int i;
if ( Vec_PtrPushUnique(vStore, pObj) )
return;
......@@ -375,7 +376,7 @@ void Dar_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Dar_Obj_t * pObj
{
pObj1 = vStore->pArray[i ];
pObj2 = vStore->pArray[i-1];
if ( Dar_ObjLevel(Dar_Regular(pObj1)) <= Dar_ObjLevel(Dar_Regular(pObj2)) )
if ( Aig_ObjLevel(Aig_Regular(pObj1)) <= Aig_ObjLevel(Aig_Regular(pObj2)) )
break;
vStore->pArray[i ] = pObj2;
vStore->pArray[i-1] = pObj1;
......
......@@ -18,7 +18,7 @@
***********************************************************************/
#include "dar.h"
#include "darInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -30,6 +30,28 @@
/**Function*************************************************************
Synopsis [Returns the structure with default assignment of parameters.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Dar_ManDefaultParams( Dar_Par_t * pPars )
{
memset( pPars, 0, sizeof(Dar_Par_t) );
pPars->nCutsMax = 8;
pPars->nSubgMax = 4;
pPars->fUpdateLevel = 0;
pPars->fUseZeros = 0;
pPars->fVerbose = 0;
pPars->fVeryVerbose = 0;
}
/**Function*************************************************************
Synopsis []
Description []
......@@ -39,89 +61,107 @@
SeeAlso []
***********************************************************************/
int Dar_ManRewrite( Dar_Man_t * p )
int Dar_ManRewrite( Aig_Man_t * pAig, Dar_Par_t * pPars )
{
Dar_Man_t * p;
ProgressBar * pProgress;
Dar_Cut_t * pCutSet;
Dar_Obj_t * pObj, * pObjNew;
Dar_Cut_t * pCut;
Aig_Obj_t * pObj, * pObjNew;
int i, k, nNodesOld, nNodeBefore, nNodeAfter, Required;
int clk = 0, clkStart;
// create rewriting manager
p = Dar_ManStart( pAig, pPars );
// remove dangling nodes
Dar_ManCleanup( p );
Aig_ManCleanup( pAig );
// set elementary cuts for the PIs
Dar_ManSetupPis( p );
// Dar_ManSetupPis( p );
Aig_ManCleanData( pAig );
Dar_ObjPrepareCuts( p, Aig_ManConst1(pAig) );
Aig_ManForEachPi( pAig, pObj, i )
Dar_ObjPrepareCuts( p, pObj );
// if ( p->pPars->fUpdateLevel )
// Dar_NtkStartReverseLevels( p );
// Aig_NtkStartReverseLevels( p );
// resynthesize each node once
clkStart = clock();
p->nNodesInit = Dar_ManNodeNum(p);
nNodesOld = Vec_PtrSize( p->vObjs );
p->nNodesInit = Aig_ManNodeNum(pAig);
nNodesOld = Vec_PtrSize( pAig->vObjs );
pProgress = Extra_ProgressBarStart( stdout, nNodesOld );
Dar_ManForEachObj( p, pObj, i )
Aig_ManForEachObj( pAig, pObj, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
if ( !Dar_ObjIsNode(pObj) )
if ( !Aig_ObjIsNode(pObj) )
continue;
if ( i > nNodesOld )
break;
// compute cuts for the node
clk = clock();
pCutSet = Dar_ObjComputeCuts_rec( p, pObj );
Dar_ObjComputeCuts_rec( p, pObj );
p->timeCuts += clock() - clk;
// go through the cuts of this node
Required = 1000000;
p->GainBest = -1;
for ( k = 1; k < (int)pObj->nCuts; k++ )
// check if there is a trivial cut
Dar_ObjForEachCut( pObj, pCut, k )
if ( pCut->nLeaves == 0 || (pCut->nLeaves == 1 && pCut->pLeaves[0] != pObj->Id) )
break;
if ( k < (int)pObj->nCuts )
{
/*
if ( pObj->Id == 654 )
assert( pCut->nLeaves < 2 );
if ( pCut->nLeaves == 0 ) // replace by constant
{
int m;
for ( m = 0; m < 4; m++ )
printf( "%d ", pCutSet[k].pLeaves[m] );
printf( "\n" );
assert( pCut->uTruth == 0 || pCut->uTruth == 0xFFFF );
pObjNew = Aig_NotCond( Aig_ManConst1(p->pAig), pCut->uTruth==0 );
}
*/
Dar_LibEval( p, pObj, pCutSet + k, Required );
else
{
assert( pCut->uTruth == 0xAAAA || pCut->uTruth == 0x5555 );
pObjNew = Aig_NotCond( Aig_ManObj(p->pAig, pCut->pLeaves[0]), pCut->uTruth==0x5555 );
}
// replace the node
Aig_ObjReplace( pAig, pObj, pObjNew, 1 );
// remove the old cuts
Dar_ObjSetCuts( pObj, NULL );
continue;
}
// evaluate the cuts
p->GainBest = -1;
Required = 1000000;
Dar_ObjForEachCut( pObj, pCut, k )
Dar_LibEval( p, pObj, pCut, Required );
// check the best gain
if ( !(p->GainBest > 0 || p->GainBest == 0 && p->pPars->fUseZeros) )
continue;
// if we end up here, a rewriting step is accepted
nNodeBefore = Dar_ManNodeNum( p );
nNodeBefore = Aig_ManNodeNum( pAig );
pObjNew = Dar_LibBuildBest( p );
pObjNew = Dar_NotCond( pObjNew, pObjNew->fPhase ^ pObj->fPhase );
assert( (int)Dar_Regular(pObjNew)->Level <= Required );
pObjNew = Aig_NotCond( pObjNew, pObjNew->fPhase ^ pObj->fPhase );
assert( (int)Aig_Regular(pObjNew)->Level <= Required );
// replace the node
Dar_ObjReplace( p, pObj, pObjNew, 1 );
Aig_ObjReplace( pAig, pObj, pObjNew, 1 );
// remove the old cuts
pObj->pData = NULL;
Dar_ObjSetCuts( pObj, NULL );
// compare the gains
nNodeAfter = Dar_ManNodeNum( p );
nNodeAfter = Aig_ManNodeNum( pAig );
assert( p->GainBest <= nNodeBefore - nNodeAfter );
// count gains of this class
p->ClassGains[p->ClassBest] += nNodeBefore - nNodeAfter;
// if ( p->ClassBest == 29 )
// printf( "%d ", p->OutNumBest );
}
p->timeTotal = clock() - clkStart;
p->timeOther = p->timeTotal - p->timeCuts - p->timeEval;
Extra_ProgressBarStop( pProgress );
p->nCutMemUsed = Dar_MmFlexReadMemUsage(p->pMemCuts)/(1<<20);
p->nCutMemUsed = Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20);
Dar_ManCutsFree( p );
// stop the rewriting manager
Dar_ManStop( p );
// put the nodes into the DFS order and reassign their IDs
// Dar_NtkReassignIds( p );
// Aig_NtkReassignIds( p );
// fix the levels
// if ( p->pPars->fUpdateLevel )
// Dar_NtkStopReverseLevels( p );
// Aig_NtkStopReverseLevels( p );
// check
if ( !Dar_ManCheck( p ) )
if ( !Aig_ManCheck( pAig ) )
{
printf( "Dar_ManRewrite: The network check has failed.\n" );
printf( "Aig_ManRewrite: The network check has failed.\n" );
return 0;
}
return 1;
......@@ -138,32 +178,37 @@ p->timeOther = p->timeTotal - p->timeCuts - p->timeEval;
SeeAlso []
***********************************************************************/
int Dar_ManComputeCuts( Dar_Man_t * p )
Aig_MmFixed_t * Dar_ManComputeCuts( Aig_Man_t * pAig )
{
Dar_Obj_t * pObj;
Dar_Man_t * p;
Aig_Obj_t * pObj;
Aig_MmFixed_t * pMemCuts;
int i, clk = 0, clkStart = clock();
int nCutsMax = 0, nCutsTotal = 0;
// create rewriting manager
p = Dar_ManStart( pAig, NULL );
// remove dangling nodes
Dar_ManCleanup( p );
Aig_ManCleanup( pAig );
// set elementary cuts for the PIs
Dar_ManSetupPis( p );
// Dar_ManSetupPis( p );
Aig_ManForEachPi( pAig, pObj, i )
Dar_ObjPrepareCuts( p, pObj );
// compute cuts for each nodes in the topological order
Dar_ManForEachObj( p, pObj, i )
Aig_ManForEachObj( pAig, pObj, i )
{
if ( !Dar_ObjIsNode(pObj) )
if ( !Aig_ObjIsNode(pObj) )
continue;
Dar_ObjComputeCuts( p, pObj );
nCutsTotal += pObj->nCuts - 1;
nCutsMax = DAR_MAX( nCutsMax, (int)pObj->nCuts - 1 );
nCutsMax = AIG_MAX( nCutsMax, (int)pObj->nCuts - 1 );
}
// print statistics on the number of non-trivial cuts
printf( "Node = %6d. Cut = %8d. Max = %3d. Ave = %.2f. Filter = %8d. Created = %8d.\n",
Dar_ManNodeNum(p), nCutsTotal, nCutsMax, (float)nCutsTotal/Dar_ManNodeNum(p),
p->nCutsFiltered, p->nCutsFiltered+nCutsTotal+Dar_ManNodeNum(p)+Dar_ManPiNum(p) );
PRT( "Time", clock() - clkStart );
// free the cuts
pMemCuts = p->pMemCuts;
p->pMemCuts = NULL;
// Dar_ManCutsFree( p );
return 1;
// stop the rewriting manager
Dar_ManStop( p );
return pMemCuts;
}
......
......@@ -18,7 +18,7 @@
***********************************************************************/
#include "dar.h"
#include "darInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -30,6 +30,97 @@
/**Function*************************************************************
Synopsis [Returns the number of 1s in the machine word.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Dar_WordCountOnes( unsigned uWord )
{
uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555);
uWord = (uWord & 0x33333333) + ((uWord>>2) & 0x33333333);
uWord = (uWord & 0x0F0F0F0F) + ((uWord>>4) & 0x0F0F0F0F);
uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF);
return (uWord & 0x0000FFFF) + (uWord>>16);
}
/**Function*************************************************************
Synopsis [Compute the cost of the cut.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Dar_CutFindValue( Dar_Man_t * p, Dar_Cut_t * pCut )
{
Aig_Obj_t * pLeaf;
int i, Value;
assert( pCut->fUsed );
if ( pCut->nLeaves < 2 )
return 1001;
Value = 0;
Dar_CutForEachLeaf( p->pAig, pCut, pLeaf, i )
{
if ( pLeaf == NULL )
return 0;
assert( pLeaf != NULL );
Value += pLeaf->nRefs;
}
if ( Value > 1000 )
Value = 1000;
return Value;
}
/**Function*************************************************************
Synopsis [Returns the next free cut to use.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline Dar_Cut_t * Dar_CutFindFree( Dar_Man_t * p, Aig_Obj_t * pObj )
{
Dar_Cut_t * pCut, * pCutMax;
int i;
pCutMax = NULL;
Dar_ObjForEachCutAll( pObj, pCut, i )
{
if ( pCut->fUsed == 0 )
return pCut;
if ( pCut->nLeaves < 3 )
continue;
if ( pCutMax == NULL || pCutMax->Value > pCut->Value )
pCutMax = pCut;
}
if ( pCutMax == NULL )
{
Dar_ObjForEachCutAll( pObj, pCut, i )
{
if ( pCut->nLeaves < 2 )
continue;
if ( pCutMax == NULL || pCutMax->Value > pCut->Value )
pCutMax = pCut;
}
}
assert( pCutMax != NULL );
pCutMax->fUsed = 0;
return pCutMax;
}
/**Function*************************************************************
Synopsis [Returns 1 if pDom is contained in pCut.]
Description []
......@@ -42,6 +133,7 @@
static inline int Dar_CutCheckDominance( Dar_Cut_t * pDom, Dar_Cut_t * pCut )
{
int i, k;
assert( pDom->fUsed && pCut->fUsed );
for ( i = 0; i < (int)pDom->nLeaves; i++ )
{
for ( k = 0; k < (int)pCut->nLeaves; k++ )
......@@ -65,14 +157,16 @@ static inline int Dar_CutCheckDominance( Dar_Cut_t * pDom, Dar_Cut_t * pCut )
SeeAlso []
***********************************************************************/
static inline int Dar_CutFilter( Dar_Man_t * p, Dar_Cut_t * pCut )
static inline int Dar_CutFilter( Aig_Obj_t * pObj, Dar_Cut_t * pCut )
{
Dar_Cut_t * pTemp;
int i, k;
assert( p->pBaseCuts[p->nCutsUsed] == pCut );
for ( i = 0; i < p->nCutsUsed; i++ )
int i;
assert( pCut->fUsed );
// go through the cuts of the node
Dar_ObjForEachCut( pObj, pTemp, i )
{
pTemp = p->pBaseCuts[i];
if ( pTemp == pCut )
continue;
if ( pTemp->nLeaves > pCut->nLeaves )
{
// skip the non-contained cuts
......@@ -81,17 +175,8 @@ static inline int Dar_CutFilter( Dar_Man_t * p, Dar_Cut_t * pCut )
// check containment seriously
if ( Dar_CutCheckDominance( pCut, pTemp ) )
{
// p->ppCuts[i] = p->ppCuts[p->nCuts-1];
// p->ppCuts[p->nCuts-1] = pTemp;
// p->nCuts--;
// i--;
// remove contained cut
for ( k = i; k < p->nCutsUsed; k++ )
p->pBaseCuts[k] = p->pBaseCuts[k+1];
p->pBaseCuts[p->nCutsUsed] = pTemp;
p->nCutsUsed--;
i--;
p->nCutsFiltered++;
pTemp->fUsed = 0;
}
}
else
......@@ -102,7 +187,8 @@ static inline int Dar_CutFilter( Dar_Man_t * p, Dar_Cut_t * pCut )
// check containment seriously
if ( Dar_CutCheckDominance( pTemp, pCut ) )
{
p->nCutsFiltered++;
// remove the given cut
pCut->fUsed = 0;
return 1;
}
}
......@@ -215,6 +301,7 @@ static inline int Dar_CutMergeOrdered( Dar_Cut_t * pC, Dar_Cut_t * pC0, Dar_Cut_
***********************************************************************/
static inline int Dar_CutMerge( Dar_Cut_t * pCut, Dar_Cut_t * pCut0, Dar_Cut_t * pCut1 )
{
assert( !pCut->fUsed );
// merge the nodes
if ( pCut0->nLeaves <= pCut1->nLeaves )
{
......@@ -227,6 +314,7 @@ static inline int Dar_CutMerge( Dar_Cut_t * pCut, Dar_Cut_t * pCut0, Dar_Cut_t *
return 0;
}
pCut->uSign = pCut0->uSign | pCut1->uSign;
pCut->fUsed = 1;
return 1;
}
......@@ -377,6 +465,8 @@ static inline int Dar_CutSuppMinimize( Dar_Cut_t * pCut )
};
unsigned uPhase = 0, uTruth = 0xFFFF & pCut->uTruth;
int i, k, nLeaves;
assert( pCut->fUsed );
assert( pCut->nLeaves > 0 );
// compute the truth support of the cut's function
nLeaves = pCut->nLeaves;
for ( i = 0; i < (int)pCut->nLeaves; i++ )
......@@ -395,10 +485,8 @@ static inline int Dar_CutSuppMinimize( Dar_Cut_t * pCut )
{
if ( !(uPhase & (1 << i)) )
continue;
pCut->pLeaves[k] = pCut->pLeaves[i];
// pCut->pIndices[k] = pCut->pIndices[i];
pCut->uSign |= (1 << (pCut->pLeaves[i] & 31));
k++;
pCut->pLeaves[k++] = pCut->pLeaves[i];
pCut->uSign |= Aig_ObjCutSign( pCut->pLeaves[i] );
}
assert( k == nLeaves );
pCut->nLeaves = nLeaves;
......@@ -416,16 +504,13 @@ static inline int Dar_CutSuppMinimize( Dar_Cut_t * pCut )
SeeAlso []
***********************************************************************/
void Dar_ObjSetupTrivial( Dar_Obj_t * pObj )
void Dar_ManCutsFree( Dar_Man_t * p )
{
Dar_Cut_t * pCut;
pCut = pObj->pData;
memset( pCut, 0, sizeof(Dar_Cut_t) );
pCut->nLeaves = 1;
pCut->pLeaves[0] = pObj->Id;
// pCut->pIndices[0] = 0;
pCut->uSign = (1 << (pObj->Id & 31));
pCut->uTruth = 0xAAAA;
if ( p->pMemCuts == NULL )
return;
Aig_MmFixedStop( p->pMemCuts, 0 );
p->pMemCuts = NULL;
// Aig_ManCleanData( p );
}
/**Function*************************************************************
......@@ -439,16 +524,35 @@ void Dar_ObjSetupTrivial( Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Dar_ManSetupPis( Dar_Man_t * p )
Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj )
{
Dar_Obj_t * pObj;
Dar_Cut_t * pCutSet, * pCut;
int i;
Dar_ManForEachPi( p, pObj, i )
assert( Dar_ObjCuts(pObj) == NULL );
pObj->nCuts = p->pPars->nCutsMax;
// create the cutset of the node
pCutSet = (Dar_Cut_t *)Aig_MmFixedEntryFetch( p->pMemCuts );
Dar_ObjSetCuts( pObj, pCutSet );
Dar_ObjForEachCut( pObj, pCut, i )
pCut->fUsed = 0;
// add unit cut if needed
pCut = pCutSet;
pCut->fUsed = 1;
if ( Aig_ObjIsConst1(pObj) )
{
pObj->nCuts = 1;
pObj->pData = (Dar_Cut_t *)Dar_MmFlexEntryFetch( p->pMemCuts, pObj->nCuts * sizeof(Dar_Cut_t) );
Dar_ObjSetupTrivial( pObj );
pCut->nLeaves = 0;
pCut->uSign = 0;
pCut->uTruth = 0xFFFF;
}
else
{
pCut->nLeaves = 1;
pCut->pLeaves[0] = pObj->Id;
pCut->uSign = Aig_ObjCutSign( pObj->Id );
pCut->uTruth = 0xAAAA;
}
pCut->Value = Dar_CutFindValue( p, pCut );
return pCutSet;
}
/**Function*************************************************************
......@@ -462,86 +566,75 @@ void Dar_ManSetupPis( Dar_Man_t * p )
SeeAlso []
***********************************************************************/
void Dar_ManCutsFree( Dar_Man_t * p )
{
// Dar_ManCleanData( p );
Dar_MmFlexStop( p->pMemCuts, 0 );
p->pMemCuts = NULL;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Dar_Cut_t * Dar_ObjComputeCuts( Dar_Man_t * p, Dar_Obj_t * pObj )
Dar_Cut_t * Dar_ObjComputeCuts( Dar_Man_t * p, Aig_Obj_t * pObj )
{
Dar_Obj_t * pFanin0 = Dar_ObjReal_rec( Dar_ObjChild0(pObj) );
Dar_Obj_t * pFanin1 = Dar_ObjReal_rec( Dar_ObjChild1(pObj) );
Dar_Cut_t * pStart0 = Dar_Regular(pFanin0)->pData;
Dar_Cut_t * pStart1 = Dar_Regular(pFanin1)->pData;
Dar_Cut_t * pStop0 = pStart0 + Dar_Regular(pFanin0)->nCuts;
Dar_Cut_t * pStop1 = pStart1 + Dar_Regular(pFanin1)->nCuts;
Dar_Cut_t * pCut0, * pCut1, * pCut;
int i;
assert( pObj->pData == NULL );
Aig_Obj_t * pFanin0 = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
Aig_Obj_t * pFanin1 = Aig_ObjReal_rec( Aig_ObjChild1(pObj) );
Aig_Obj_t * pFaninR0 = Aig_Regular(pFanin0);
Aig_Obj_t * pFaninR1 = Aig_Regular(pFanin1);
Dar_Cut_t * pCutSet, * pCut0, * pCut1, * pCut;
int i, k, RetValue;
assert( !Aig_IsComplement(pObj) );
assert( Aig_ObjIsNode(pObj) );
assert( Dar_ObjCuts(pObj) == NULL );
assert( Dar_ObjCuts(pFaninR0) != NULL );
assert( Dar_ObjCuts(pFaninR1) != NULL );
// set up the first cut
pCutSet = Dar_ObjPrepareCuts( p, pObj );
// make sure fanins cuts are computed
p->nCutsUsed = 0;
for ( pCut0 = pStart0; pCut0 < pStop0; pCut0++ )
for ( pCut1 = pStart1; pCut1 < pStop1; pCut1++ )
Dar_ObjForEachCut( pFaninR0, pCut0, i )
Dar_ObjForEachCut( pFaninR1, pCut1, k )
{
// get storage for the next cut
if ( p->nCutsUsed == p->nBaseCuts )
break;
pCut = p->pBaseCuts[p->nCutsUsed];
p->nCutsAll++;
// make sure K-feasible cut exists
if ( Dar_WordCountOnes(pCut0->uSign | pCut1->uSign) > 4 )
continue;
// get the next cut of this node
pCut = Dar_CutFindFree( p, pObj );
// create the new cut
if ( !Dar_CutMerge( pCut, pCut0, pCut1 ) )
{
assert( !pCut->fUsed );
continue;
}
p->nCutsTried++;
// check dominance
if ( Dar_CutFilter( p, pCut ) )
if ( Dar_CutFilter( pObj, pCut ) )
{
assert( !pCut->fUsed );
continue;
}
// compute truth table
pCut->uTruth = 0xFFFF & Dar_CutTruth( pCut, pCut0, pCut1, Dar_IsComplement(pFanin0), Dar_IsComplement(pFanin1) );
pCut->uTruth = 0xFFFF & Dar_CutTruth( pCut, pCut0, pCut1, Aig_IsComplement(pFanin0), Aig_IsComplement(pFanin1) );
// minimize support of the cut
if ( Dar_CutSuppMinimize( pCut ) )
{
if ( Dar_CutFilter( p, pCut ) )
continue;
// if a simple cut is found return immediately
if ( pCut->nLeaves < 2 )
return pCutSet;
// otherwise, filter the cuts again
RetValue = Dar_CutFilter( pObj, pCut );
assert( !RetValue );
}
// CNF mapping: assign the cut cost
if ( p->pManCnf )
// assign the value of the cut
pCut->Value = Dar_CutFindValue( p, pCut );
// if the cut contains removed node, do not use it
if ( pCut->Value == 0 )
{
extern void Cnf_CutAssignAreaFlow( void * pManCnf, Dar_Cut_t * pCut );
Cnf_CutAssignAreaFlow( p->pManCnf, pCut );
p->nCutsSkipped++;
pCut->fUsed = 0;
}
// increment the number of cuts
p->nCutsUsed++;
}
// get memory for the cuts of this node
pObj->nCuts = p->nCutsUsed + 1;
pObj->pData = pCut = (Dar_Cut_t *)Dar_MmFlexEntryFetch( p->pMemCuts, pObj->nCuts * sizeof(Dar_Cut_t) );
// create elementary cut
Dar_ObjSetupTrivial( pObj );
// copy non-elementary cuts
for ( i = 0; i < p->nCutsUsed; i++ )
*++pCut = *(p->pBaseCuts[i]);
// CNF mapping: assign the best cut
if ( p->pManCnf )
{
extern Dar_Cut_t * Cnf_ObjFindBestCut( Dar_Obj_t * pObj );
Dar_ObjSetBestCut( Cnf_ObjFindBestCut(pObj) );
}
return pObj->pData;
// count the number of nontrivial cuts cuts
Dar_ObjForEachCut( pObj, pCut, i )
p->nCutsUsed += pCut->fUsed;
// discount trivial cut
p->nCutsUsed--;
return pCutSet;
}
/**Function*************************************************************
......@@ -555,14 +648,14 @@ Dar_Cut_t * Dar_ObjComputeCuts( Dar_Man_t * p, Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
Dar_Cut_t * Dar_ObjComputeCuts_rec( Dar_Man_t * p, Dar_Obj_t * pObj )
Dar_Cut_t * Dar_ObjComputeCuts_rec( Dar_Man_t * p, Aig_Obj_t * pObj )
{
if ( pObj->pData )
return pObj->pData;
if ( Dar_ObjIsBuf(pObj) )
return Dar_ObjComputeCuts_rec( p, Dar_ObjFanin0(pObj) );
Dar_ObjComputeCuts_rec( p, Dar_ObjFanin0(pObj) );
Dar_ObjComputeCuts_rec( p, Dar_ObjFanin1(pObj) );
if ( Dar_ObjCuts(pObj) )
return Dar_ObjCuts(pObj);
if ( Aig_ObjIsBuf(pObj) )
return Dar_ObjComputeCuts_rec( p, Aig_ObjFanin0(pObj) );
Dar_ObjComputeCuts_rec( p, Aig_ObjFanin0(pObj) );
Dar_ObjComputeCuts_rec( p, Aig_ObjFanin1(pObj) );
return Dar_ObjComputeCuts( p, pObj );
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/**CFile****************************************************************
FileName [darInt.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware AIG rewriting.]
Synopsis [Internal declarations.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - April 28, 2007.]
Revision [$Id: darInt.h,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef __DAR_INT_H__
#define __DAR_INT_H__
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include "vec.h"
#include "aig.h"
#include "dar.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
typedef struct Dar_Man_t_ Dar_Man_t;
typedef struct Dar_Cut_t_ Dar_Cut_t;
// the AIG 4-cut
struct Dar_Cut_t_ // 6 words
{
unsigned uSign; // cut signature
unsigned uTruth : 16; // the truth table of the cut function
unsigned Value : 12; // the value of the cut
unsigned fUsed : 1; // marks the cut currently in use
unsigned nLeaves : 3; // the number of leaves
int pLeaves[4]; // the array of leaves
};
// the AIG manager
struct Dar_Man_t_
{
// input data;
Dar_Par_t * pPars; // rewriting parameters
Aig_Man_t * pAig; // AIG manager
// various data members
Aig_MmFixed_t * pMemCuts; // memory manager for cuts
void * pManCnf; // CNF managers
// current rewriting step
Vec_Ptr_t * vLeavesBest; // the best set of leaves
int OutBest; // the best output (in the library)
int OutNumBest; // the best number of the output
int GainBest; // the best gain
int LevelBest; // the level of node with the best gain
int ClassBest; // the equivalence class of the best replacement
// function statistics
int nTotalSubgs; // the total number of subgraphs tried
int ClassTimes[222];// the runtimes for each class
int ClassGains[222];// the gains for each class
int ClassSubgs[222];// the graphs for each class
int nCutMemUsed; // memory used for cuts
// rewriting statistics
int nNodesInit; // the original number of nodes
int nCutsAll; // all cut pairs
int nCutsTried; // computed cuts
int nCutsUsed; // used cuts
int nCutsBad; // bad cuts due to absent fanin
int nCutsGood; // good cuts
int nCutsSkipped; // skipped bad cuts
// timing statistics
int timeCuts;
int timeEval;
int timeOther;
int timeTotal;
int time1;
int time2;
};
static inline Dar_Cut_t * Dar_ObjCuts( Aig_Obj_t * pObj ) { return pObj->pData; }
static inline void Dar_ObjSetCuts( Aig_Obj_t * pObj, Dar_Cut_t * pCuts ) { pObj->pData = pCuts; }
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// ITERATORS ///
////////////////////////////////////////////////////////////////////////
// iterator over all cuts of the node
#define Dar_ObjForEachCutAll( pObj, pCut, i ) \
for ( (pCut) = Dar_ObjCuts(pObj), i = 0; i < (int)(pObj)->nCuts; i++, pCut++ )
#define Dar_ObjForEachCut( pObj, pCut, i ) \
for ( (pCut) = Dar_ObjCuts(pObj), i = 0; i < (int)(pObj)->nCuts; i++, pCut++ ) if ( (pCut)->fUsed==0 ) {} else
// iterator over leaves of the cut
#define Dar_CutForEachLeaf( p, pCut, pLeaf, i ) \
for ( i = 0; (i < (int)(pCut)->nLeaves) && (((pLeaf) = Aig_ManObj(p, (pCut)->pLeaves[i])), 1); i++ )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/*=== darBalance.c ========================================================*/
extern Aig_Man_t * Dar_ManBalance( Aig_Man_t * p, int fUpdateLevel );
/*=== darCore.c ========================================================*/
/*=== darCut.c ========================================================*/
extern Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj );
extern void Dar_ManCutsFree( Dar_Man_t * p );
extern Dar_Cut_t * Dar_ObjComputeCuts_rec( Dar_Man_t * p, Aig_Obj_t * pObj );
extern Dar_Cut_t * Dar_ObjComputeCuts( Dar_Man_t * p, Aig_Obj_t * pObj );
/*=== darData.c ========================================================*/
extern Vec_Int_t * Dar_LibReadNodes();
extern Vec_Int_t * Dar_LibReadOuts();
extern Vec_Int_t * Dar_LibReadPrios();
/*=== darLib.c ==========================================================*/
extern void Dar_LibStart();
extern void Dar_LibStop();
extern void Dar_LibEval( Dar_Man_t * p, Aig_Obj_t * pRoot, Dar_Cut_t * pCut, int Required );
extern Aig_Obj_t * Dar_LibBuildBest( Dar_Man_t * p );
/*=== darMan.c ==========================================================*/
extern Dar_Man_t * Dar_ManStart( Aig_Man_t * pAig, Dar_Par_t * pPars );
extern void Dar_ManStop( Dar_Man_t * p );
extern void Dar_ManPrintStats( Dar_Man_t * p );
#ifdef __cplusplus
}
#endif
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......@@ -18,7 +18,7 @@
***********************************************************************/
#include "dar.h"
#include "darInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -41,7 +41,7 @@ struct Dar_LibObj_t_ // library object (2 words)
struct Dar_LibDat_t_ // library object data
{
Dar_Obj_t * pFunc; // the corresponding AIG node if it exists
Aig_Obj_t * pFunc; // the corresponding AIG node if it exists
int Level; // level of this node after it is constructured
int TravId; // traversal ID of the library object data
unsigned char Area; // area of the node
......@@ -61,7 +61,16 @@ struct Dar_Lib_t_ // library
int nSubgr[222]; // the number of subgraphs by class
int * pSubgr[222]; // the subgraphs for each class
int * pSubgrMem; // memory for subgraph pointers
int pSubgrTotal; // the total number of subgraph
int nSubgrTotal; // the total number of subgraph
// structure priorities
int * pPriosMem; // memory for priority of structures
int * pPrios[222]; // pointers to the priority numbers
// structure places in the priorities
int * pPlaceMem; // memory for places of structures in the priority lists
int * pPlace[222]; // pointers to the places numbers
// structure scores
int * pScoreMem; // memory for scores of structures
int * pScore[222]; // pointers to the scores numbers
// nodes by class
int nNodes[222]; // the number of nodes by class
int * pNodes[222]; // the nodes for each class
......@@ -141,6 +150,9 @@ void Dar_LibFree( Dar_Lib_t * p )
free( p->pDatas );
free( p->pNodesMem );
free( p->pSubgrMem );
free( p->pPriosMem );
FREE( p->pPlaceMem );
FREE( p->pScoreMem );
free( p->pPerms4 );
free( p->puCanons );
free( p->pPhases );
......@@ -208,8 +220,9 @@ void Dar_LibSetup_rec( Dar_Lib_t * p, Dar_LibObj_t * pObj, int Class )
SeeAlso []
***********************************************************************/
void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts )
void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios )
{
int fTraining = 0;
Dar_LibObj_t * pObj;
int nNodesTotal, uTruth, Class, Out, i, k;
assert( p->iObj == p->nObjs );
......@@ -226,14 +239,14 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts )
}
// allocate memory for the roots of each class
p->pSubgrMem = ALLOC( int, Vec_IntSize(vOuts) );
p->pSubgrTotal = 0;
p->nSubgrTotal = 0;
for ( i = 0; i < 222; i++ )
{
p->pSubgr[i] = p->pSubgrMem + p->pSubgrTotal;
p->pSubgrTotal += p->nSubgr[i];
p->pSubgr[i] = p->pSubgrMem + p->nSubgrTotal;
p->nSubgrTotal += p->nSubgr[i];
p->nSubgr[i] = 0;
}
assert( p->pSubgrTotal == Vec_IntSize(vOuts) );
assert( p->nSubgrTotal == Vec_IntSize(vOuts) );
// add the outputs to storage
Vec_IntForEachEntry( vOuts, Out, i )
{
......@@ -243,6 +256,65 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts )
p->pSubgr[Class][ p->nSubgr[Class]++ ] = Out;
}
if ( fTraining )
{
// allocate memory for the priority of roots of each class
p->pPriosMem = ALLOC( int, Vec_IntSize(vOuts) );
p->nSubgrTotal = 0;
for ( i = 0; i < 222; i++ )
{
p->pPrios[i] = p->pPriosMem + p->nSubgrTotal;
p->nSubgrTotal += p->nSubgr[i];
for ( k = 0; k < p->nSubgr[i]; k++ )
p->pPrios[i][k] = k;
}
assert( p->nSubgrTotal == Vec_IntSize(vOuts) );
// allocate memory for the priority of roots of each class
p->pPlaceMem = ALLOC( int, Vec_IntSize(vOuts) );
p->nSubgrTotal = 0;
for ( i = 0; i < 222; i++ )
{
p->pPlace[i] = p->pPlaceMem + p->nSubgrTotal;
p->nSubgrTotal += p->nSubgr[i];
for ( k = 0; k < p->nSubgr[i]; k++ )
p->pPlace[i][k] = k;
}
assert( p->nSubgrTotal == Vec_IntSize(vOuts) );
// allocate memory for the priority of roots of each class
p->pScoreMem = ALLOC( int, Vec_IntSize(vOuts) );
p->nSubgrTotal = 0;
for ( i = 0; i < 222; i++ )
{
p->pScore[i] = p->pScoreMem + p->nSubgrTotal;
p->nSubgrTotal += p->nSubgr[i];
for ( k = 0; k < p->nSubgr[i]; k++ )
p->pScore[i][k] = 0;
}
assert( p->nSubgrTotal == Vec_IntSize(vOuts) );
}
else
{
int Counter = 0;
// allocate memory for the priority of roots of each class
p->pPriosMem = ALLOC( int, Vec_IntSize(vOuts) );
p->nSubgrTotal = 0;
for ( i = 0; i < 222; i++ )
{
p->pPrios[i] = p->pPriosMem + p->nSubgrTotal;
p->nSubgrTotal += p->nSubgr[i];
for ( k = 0; k < p->nSubgr[i]; k++ )
p->pPrios[i][k] = Vec_IntEntry(vPrios, Counter++);
}
assert( p->nSubgrTotal == Vec_IntSize(vOuts) );
assert( Counter == Vec_IntSize(vPrios) );
}
// create traversal IDs
for ( i = 0; i < p->iObj; i++ )
Dar_LibObj(p, i)->Num = 0xff;
......@@ -294,12 +366,13 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts )
***********************************************************************/
Dar_Lib_t * Dar_LibRead()
{
Vec_Int_t * vObjs, * vOuts;
Vec_Int_t * vObjs, * vOuts, * vPrios;
Dar_Lib_t * p;
int i;
// read nodes and outputs
vObjs = Dar_LibReadNodes();
vOuts = Dar_LibReadOuts();
vObjs = Dar_LibReadNodes();
vOuts = Dar_LibReadOuts();
vPrios = Dar_LibReadPrios();
// create library
p = Dar_LibAlloc( Vec_IntSize(vObjs)/2 + 4, 6000 );
// create nodes
......@@ -307,7 +380,7 @@ Dar_Lib_t * Dar_LibRead()
Dar_LibAddNode( p, vObjs->pArray[i] >> 1, vObjs->pArray[i+1] >> 1,
vObjs->pArray[i] & 1, vObjs->pArray[i+1] & 1 );
// create outputs
Dar_LibSetup( p, vOuts );
Dar_LibSetup( p, vOuts, vPrios );
Vec_IntFree( vObjs );
Vec_IntFree( vOuts );
return p;
......@@ -329,7 +402,7 @@ void Dar_LibStart()
int clk = clock();
assert( s_DarLib == NULL );
s_DarLib = Dar_LibRead();
printf( "The 4-input library started with %d nodes and %d subgraphs. ", s_DarLib->nObjs - 4, s_DarLib->pSubgrTotal );
printf( "The 4-input library started with %d nodes and %d subgraphs. ", s_DarLib->nObjs - 4, s_DarLib->nSubgrTotal );
PRT( "Time", clock() - clk );
}
......@@ -351,6 +424,77 @@ void Dar_LibStop()
s_DarLib = NULL;
}
/**Function*************************************************************
Synopsis [Updates the score of the class and adjusts the priority of this class.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Dar_LibIncrementScore( int Class, int Out, int Gain )
{
int * pPrios = s_DarLib->pPrios[Class]; // pPrios[i] = Out
int * pPlace = s_DarLib->pPlace[Class]; // pPlace[Out] = i
int * pScore = s_DarLib->pScore[Class]; // score of Out
int Out2;
assert( Class >= 0 && Class < 222 );
assert( Out >= 0 && Out < s_DarLib->nSubgr[Class] );
assert( pPlace[pPrios[Out]] == Out );
// increment the score
pScore[Out] += Gain;
// move the out in the order
while ( pPlace[Out] > 0 && pScore[Out] > pScore[ pPrios[pPlace[Out]-1] ] )
{
// get the previous output in the priority list
Out2 = pPrios[pPlace[Out]-1];
// swap Out and Out2
pPlace[Out]--;
pPlace[Out2]++;
pPrios[pPlace[Out]] = Out;
pPrios[pPlace[Out2]] = Out2;
}
}
/**Function*************************************************************
Synopsis [Prints out the priorities into the file.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Dar_LibDumpPriorities()
{
int i, k, Out, Out2, Counter = 0, Printed = 0;
printf( "\nOutput priorities (total = %d):\n", s_DarLib->nSubgrTotal );
for ( i = 0; i < 222; i++ )
{
// printf( "Class%d: ", i );
for ( k = 0; k < s_DarLib->nSubgr[i]; k++ )
{
Out = s_DarLib->pPrios[i][k];
Out2 = k == 0 ? Out : s_DarLib->pPrios[i][k-1];
assert( s_DarLib->pScore[i][Out2] >= s_DarLib->pScore[i][Out] );
// printf( "%d(%d), ", Out, s_DarLib->pScore[i][Out] );
printf( "%d, ", Out );
Printed++;
if ( ++Counter == 15 )
{
printf( "\n" );
Counter = 0;
}
}
}
printf( "\n" );
assert( Printed == s_DarLib->nSubgrTotal );
}
/**Function*************************************************************
......@@ -366,7 +510,7 @@ void Dar_LibStop()
***********************************************************************/
int Dar_LibCutMatch( Dar_Man_t * p, Dar_Cut_t * pCut )
{
Dar_Obj_t * pFanin;
Aig_Obj_t * pFanin;
unsigned uPhase;
char * pPerm;
int i;
......@@ -377,16 +521,15 @@ int Dar_LibCutMatch( Dar_Man_t * p, Dar_Cut_t * pCut )
// collect fanins with the corresponding permutation/phase
for ( i = 0; i < (int)pCut->nLeaves; i++ )
{
pFanin = Dar_ManObj( p, pCut->pLeaves[pPerm[i]] );
pFanin = Aig_ManObj( p->pAig, pCut->pLeaves[pPerm[i]] );
if ( pFanin == NULL )
{
p->nCutsBad++;
return 0;
}
pFanin = Dar_NotCond(pFanin, ((uPhase >> i) & 1) );
// Vec_PtrWriteEntry( p->vFaninsCur, i, pFanin );
pFanin = Aig_NotCond(pFanin, ((uPhase >> i) & 1) );
s_DarLib->pDatas[i].pFunc = pFanin;
s_DarLib->pDatas[i].Level = Dar_Regular(pFanin)->Level;
s_DarLib->pDatas[i].Level = Aig_Regular(pFanin)->Level;
}
p->nCutsGood++;
return 1;
......@@ -405,22 +548,22 @@ int Dar_LibCutMatch( Dar_Man_t * p, Dar_Cut_t * pCut )
SeeAlso []
***********************************************************************/
int Dar_NodeDeref_rec( Dar_Man_t * p, Dar_Obj_t * pNode )
int Aig_NodeDeref_rec( Aig_Man_t * p, Aig_Obj_t * pNode )
{
Dar_Obj_t * pFanin;
Aig_Obj_t * pFanin;
int Counter = 0;
if ( Dar_ObjIsPi(pNode) )
if ( Aig_ObjIsPi(pNode) )
return Counter;
pFanin = Dar_ObjFanin0( pNode );
pFanin = Aig_ObjFanin0( pNode );
assert( pFanin->nRefs > 0 );
if ( --pFanin->nRefs == 0 )
Counter += Dar_NodeDeref_rec( p, pFanin );
if ( Dar_ObjIsBuf(pNode) )
Counter += Aig_NodeDeref_rec( p, pFanin );
if ( Aig_ObjIsBuf(pNode) )
return Counter;
pFanin = Dar_ObjFanin1( pNode );
pFanin = Aig_ObjFanin1( pNode );
assert( pFanin->nRefs > 0 );
if ( --pFanin->nRefs == 0 )
Counter += Dar_NodeDeref_rec( p, pFanin );
Counter += Aig_NodeDeref_rec( p, pFanin );
return 1 + Counter;
}
......@@ -435,21 +578,21 @@ int Dar_NodeDeref_rec( Dar_Man_t * p, Dar_Obj_t * pNode )
SeeAlso []
***********************************************************************/
int Dar_NodeRef_rec( Dar_Man_t * p, Dar_Obj_t * pNode )
int Aig_NodeRef_rec( Aig_Man_t * p, Aig_Obj_t * pNode )
{
Dar_Obj_t * pFanin;
Aig_Obj_t * pFanin;
int Counter = 0;
if ( Dar_ObjIsPi(pNode) )
if ( Aig_ObjIsPi(pNode) )
return Counter;
Dar_ObjSetTravIdCurrent( p, pNode );
pFanin = Dar_ObjFanin0( pNode );
Aig_ObjSetTravIdCurrent( p, pNode );
pFanin = Aig_ObjFanin0( pNode );
if ( pFanin->nRefs++ == 0 )
Counter += Dar_NodeRef_rec( p, pFanin );
if ( Dar_ObjIsBuf(pNode) )
Counter += Aig_NodeRef_rec( p, pFanin );
if ( Aig_ObjIsBuf(pNode) )
return Counter;
pFanin = Dar_ObjFanin1( pNode );
pFanin = Aig_ObjFanin1( pNode );
if ( pFanin->nRefs++ == 0 )
Counter += Dar_NodeRef_rec( p, pFanin );
Counter += Aig_NodeRef_rec( p, pFanin );
return 1 + Counter;
}
......@@ -464,20 +607,20 @@ int Dar_NodeRef_rec( Dar_Man_t * p, Dar_Obj_t * pNode )
SeeAlso []
***********************************************************************/
int Dar_LibCutMarkMffc( Dar_Man_t * p, Dar_Obj_t * pRoot )
int Dar_LibCutMarkMffc( Aig_Man_t * p, Aig_Obj_t * pRoot, int nLeaves )
{
int i, nNodes1, nNodes2;
// mark the cut leaves
for ( i = 0; i < 4; i++ )
Dar_Regular(s_DarLib->pDatas[i].pFunc)->nRefs++;
for ( i = 0; i < nLeaves; i++ )
Aig_Regular(s_DarLib->pDatas[i].pFunc)->nRefs++;
// label MFFC with current ID
Dar_ManIncrementTravId( p );
nNodes1 = Dar_NodeDeref_rec( p, pRoot );
nNodes2 = Dar_NodeRef_rec( p, pRoot );
Aig_ManIncrementTravId( p );
nNodes1 = Aig_NodeDeref_rec( p, pRoot );
nNodes2 = Aig_NodeRef_rec( p, pRoot );
assert( nNodes1 == nNodes2 );
// unmark the cut leaves
for ( i = 0; i < 4; i++ )
Dar_Regular(s_DarLib->pDatas[i].pFunc)->nRefs--;
for ( i = 0; i < nLeaves; i++ )
Aig_Regular(s_DarLib->pDatas[i].pFunc)->nRefs--;
return nNodes1;
}
......@@ -525,7 +668,7 @@ void Dar_LibEvalAssignNums( Dar_Man_t * p, int Class )
{
Dar_LibObj_t * pObj;
Dar_LibDat_t * pData, * pData0, * pData1;
Dar_Obj_t * pGhost, * pFanin0, * pFanin1;
Aig_Obj_t * pGhost, * pFanin0, * pFanin1;
int i;
for ( i = 0; i < s_DarLib->nNodes[Class]; i++ )
{
......@@ -538,15 +681,29 @@ void Dar_LibEvalAssignNums( Dar_Man_t * p, int Class )
// explore the fanins
pData0 = s_DarLib->pDatas + Dar_LibObj(s_DarLib, pObj->Fan0)->Num;
pData1 = s_DarLib->pDatas + Dar_LibObj(s_DarLib, pObj->Fan1)->Num;
pData->Level = 1 + DAR_MAX(pData0->Level, pData1->Level);
pData->Level = 1 + AIG_MAX(pData0->Level, pData1->Level);
if ( pData0->pFunc == NULL || pData1->pFunc == NULL )
continue;
pFanin0 = Dar_NotCond( pData0->pFunc, pObj->fCompl0 );
pFanin1 = Dar_NotCond( pData1->pFunc, pObj->fCompl1 );
pGhost = Dar_ObjCreateGhost( p, pFanin0, pFanin1, DAR_AIG_AND );
pData->pFunc = Dar_TableLookup( p, pGhost );
pFanin0 = Aig_NotCond( pData0->pFunc, pObj->fCompl0 );
pFanin1 = Aig_NotCond( pData1->pFunc, pObj->fCompl1 );
// consider simple cases
if ( pFanin0 == pFanin1 )
pData->pFunc = pFanin0;
else if ( pFanin0 == Aig_Not(pFanin1) )
pData->pFunc = Aig_ManConst0(p->pAig);
else if ( Aig_Regular(pFanin0) == Aig_ManConst1(p->pAig) )
pData->pFunc = pFanin0 == Aig_ManConst1(p->pAig) ? pFanin1 : Aig_ManConst0(p->pAig);
else if ( Aig_Regular(pFanin1) == Aig_ManConst1(p->pAig) )
pData->pFunc = pFanin1 == Aig_ManConst1(p->pAig) ? pFanin0 : Aig_ManConst0(p->pAig);
else
{
pGhost = Aig_ObjCreateGhost( p->pAig, pFanin0, pFanin1, AIG_OBJ_AND );
pData->pFunc = Aig_TableLookup( p->pAig, pGhost );
}
// clear the node if it is part of MFFC
if ( pData->pFunc != NULL && Dar_ObjIsTravIdCurrent(p, pData->pFunc) )
if ( pData->pFunc != NULL && Aig_ObjIsTravIdCurrent(p->pAig, pData->pFunc) )
pData->pFunc = NULL;
//if ( Class == 7 )
//printf( "Evaling node %d at data %d\n", pData->pFunc? pData->pFunc->Id : -1, pObj->Num );
......@@ -599,44 +756,32 @@ int Dar_LibEval_rec( Dar_LibObj_t * pObj, int Out, int nNodesSaved, int Required
SeeAlso []
***********************************************************************/
void Dar_LibEval( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Cut_t * pCut, int Required )
void Dar_LibEval( Dar_Man_t * p, Aig_Obj_t * pRoot, Dar_Cut_t * pCut, int Required )
{
int fTraining = 0;
Dar_LibObj_t * pObj;
int i, k, Class, nNodesSaved, nNodesAdded, nNodesGained, clk;
int Out, k, Class, nNodesSaved, nNodesAdded, nNodesGained, clk;
clk = clock();
if ( pCut->nLeaves != 4 )
return;
// if ( s_DarLib->nSubgr[ s_DarLib->pMap[pCut->uTruth] ] > 100 )
// return;
clk = clock();
/*
for ( k = 0; k < 4; k++ )
if ( pCut->pLeaves[k] > 4 )
return;
*/
// check if the cut exits
// check if the cut exits and assigns leaves and their levels
if ( !Dar_LibCutMatch(p, pCut) )
return;
// mark MFFC of the node
nNodesSaved = Dar_LibCutMarkMffc( p, pRoot );
nNodesSaved = Dar_LibCutMarkMffc( p->pAig, pRoot, pCut->nLeaves );
// evaluate the cut
Class = s_DarLib->pMap[pCut->uTruth];
Dar_LibEvalAssignNums( p, Class );
//if ( pRoot->Id == 654 )
//printf( "\n" );
// profile outputs by their savings
p->nTotalSubgs += s_DarLib->nSubgr[Class];
p->ClassSubgs[Class] += s_DarLib->nSubgr[Class];
for ( i = 0; i < s_DarLib->nSubgr[Class]; i++ )
for ( Out = 0; Out < s_DarLib->nSubgr[Class]; Out++ )
{
pObj = Dar_LibObj(s_DarLib, s_DarLib->pSubgr[Class][i]);
if ( pRoot->Id == 654 )
{
// Dar_LibObjPrint_rec( pObj );
// printf( "\n" );
}
nNodesAdded = Dar_LibEval_rec( pObj, i, nNodesSaved, Required );
pObj = Dar_LibObj(s_DarLib, s_DarLib->pSubgr[Class][Out]);
nNodesAdded = Dar_LibEval_rec( pObj, Out, nNodesSaved, Required );
nNodesGained = nNodesSaved - nNodesAdded;
if ( fTraining && nNodesGained >= 0 )
Dar_LibIncrementScore( Class, Out, nNodesGained + 1 );
if ( nNodesGained <= 0 )
continue;
if ( nNodesGained < p->GainBest ||
......@@ -644,10 +789,10 @@ void Dar_LibEval( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Cut_t * pCut, int Requir
continue;
// remember this possibility
Vec_PtrClear( p->vLeavesBest );
for ( k = 0; k < 4; k++ )
for ( k = 0; k < (int)pCut->nLeaves; k++ )
Vec_PtrPush( p->vLeavesBest, s_DarLib->pDatas[k].pFunc );
p->OutBest = s_DarLib->pSubgr[Class][i];
p->OutNumBest = i;
p->OutBest = s_DarLib->pSubgr[Class][Out];
p->OutNumBest = Out;
p->LevelBest = s_DarLib->pDatas[pObj->Num].Level;
p->GainBest = nNodesGained;
p->ClassBest = Class;
......@@ -689,17 +834,17 @@ void Dar_LibBuildClear_rec( Dar_LibObj_t * pObj, int * pCounter )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_LibBuildBest_rec( Dar_Man_t * p, Dar_LibObj_t * pObj )
Aig_Obj_t * Dar_LibBuildBest_rec( Dar_Man_t * p, Dar_LibObj_t * pObj )
{
Dar_Obj_t * pFanin0, * pFanin1;
Aig_Obj_t * pFanin0, * pFanin1;
Dar_LibDat_t * pData = s_DarLib->pDatas + pObj->Num;
if ( pData->pFunc )
return pData->pFunc;
pFanin0 = Dar_LibBuildBest_rec( p, Dar_LibObj(s_DarLib, pObj->Fan0) );
pFanin1 = Dar_LibBuildBest_rec( p, Dar_LibObj(s_DarLib, pObj->Fan1) );
pFanin0 = Dar_NotCond( pFanin0, pObj->fCompl0 );
pFanin1 = Dar_NotCond( pFanin1, pObj->fCompl1 );
pData->pFunc = Dar_And( p, pFanin0, pFanin1 );
pFanin0 = Aig_NotCond( pFanin0, pObj->fCompl0 );
pFanin1 = Aig_NotCond( pFanin1, pObj->fCompl1 );
pData->pFunc = Aig_And( p->pAig, pFanin0, pFanin1 );
//printf( "Adding node %d for data %d\n", pData->pFunc->Id, pObj->Num );
return pData->pFunc;
}
......@@ -715,15 +860,16 @@ Dar_Obj_t * Dar_LibBuildBest_rec( Dar_Man_t * p, Dar_LibObj_t * pObj )
SeeAlso []
***********************************************************************/
Dar_Obj_t * Dar_LibBuildBest( Dar_Man_t * p )
Aig_Obj_t * Dar_LibBuildBest( Dar_Man_t * p )
{
int i, Counter = 4;
for ( i = 0; i < 4; i++ )
for ( i = 0; i < Vec_PtrSize(p->vLeavesBest); i++ )
s_DarLib->pDatas[i].pFunc = Vec_PtrEntry( p->vLeavesBest, i );
Dar_LibBuildClear_rec( Dar_LibObj(s_DarLib, p->OutBest), &Counter );
return Dar_LibBuildBest_rec( p, Dar_LibObj(s_DarLib, p->OutBest) );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -18,7 +18,7 @@
***********************************************************************/
#include "dar.h"
#include "darInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -30,48 +30,25 @@
/**Function*************************************************************
Synopsis [Starts the AIG manager.]
Synopsis [Starts the rewriting manager.]
Description [The argument of this procedure is a soft limit on the
the number of nodes, or 0 if the limit is unknown.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Dar_Man_t * Dar_ManStart( int nNodesMax )
Dar_Man_t * Dar_ManStart( Aig_Man_t * pAig, Dar_Par_t * pPars )
{
Dar_Man_t * p;
int i;
if ( nNodesMax <= 0 )
nNodesMax = 10007;
// start the manager
p = ALLOC( Dar_Man_t, 1 );
memset( p, 0, sizeof(Dar_Man_t) );
// perform initializations
p->nTravIds = 1;
p->fCatchExor = 0;
// allocate arrays for nodes
p->vPis = Vec_PtrAlloc( 100 );
p->vPos = Vec_PtrAlloc( 100 );
p->vObjs = Vec_PtrAlloc( 1000 );
p->pPars = pPars;
p->pAig = pAig;
// prepare the internal memory manager
p->pMemObjs = Dar_MmFixedStart( sizeof(Dar_Obj_t), nNodesMax );
p->pMemCuts = Dar_MmFlexStart();
// prepare storage for cuts
p->nBaseCuts = DAR_CUT_BASE;
for ( i = 0; i < p->nBaseCuts; i++ )
p->pBaseCuts[i] = p->BaseCuts + i;
// create the constant node
p->pConst1 = Dar_ManFetchMemory( p );
p->pConst1->Type = DAR_AIG_CONST1;
p->pConst1->fPhase = 1;
p->nObjs[DAR_AIG_CONST1]++;
// start the table
p->nTableSize = nNodesMax;
p->pTable = ALLOC( Dar_Obj_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Dar_Obj_t *) * p->nTableSize );
p->pMemCuts = Aig_MmFixedStart( p->pPars->nCutsMax * sizeof(Dar_Cut_t), 512 );
// other data
p->vLeavesBest = Vec_PtrAlloc( 4 );
return p;
......@@ -79,69 +56,7 @@ Dar_Man_t * Dar_ManStart( int nNodesMax )
/**Function*************************************************************
Synopsis [Duplicates the AIG manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Dar_Man_t * Dar_ManStartFrom( Dar_Man_t * p )
{
Dar_Man_t * pNew;
Dar_Obj_t * pObj;
int i;
// create the new manager
pNew = Dar_ManStart( Dar_ManObjIdMax(p) + 1 );
// create the PIs
Dar_ManConst1(p)->pData = Dar_ManConst1(pNew);
Dar_ManForEachPi( p, pObj, i )
pObj->pData = Dar_ObjCreatePi(pNew);
return pNew;
}
/**Function*************************************************************
Synopsis [Duplicates the AIG manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Dar_Man_t * Dar_ManDup( Dar_Man_t * p )
{
Dar_Man_t * pNew;
Dar_Obj_t * pObj;
int i;
// create the new manager
pNew = Dar_ManStart( Dar_ManObjIdMax(p) + 1 );
// create the PIs
Dar_ManConst1(p)->pData = Dar_ManConst1(pNew);
Dar_ManForEachPi( p, pObj, i )
pObj->pData = Dar_ObjCreatePi(pNew);
// duplicate internal nodes
Dar_ManForEachObj( p, pObj, i )
if ( Dar_ObjIsBuf(pObj) )
pObj->pData = Dar_ObjChild0Copy(pObj);
else if ( Dar_ObjIsNode(pObj) )
pObj->pData = Dar_And( pNew, Dar_ObjChild0Copy(pObj), Dar_ObjChild1Copy(pObj) );
// add the POs
Dar_ManForEachPo( p, pObj, i )
Dar_ObjCreatePo( pNew, Dar_ObjChild0Copy(pObj) );
// check the resulting network
if ( !Dar_ManCheck(pNew) )
printf( "Dar_ManDup(): The check has failed.\n" );
return pNew;
}
/**Function*************************************************************
Synopsis [Stops the AIG manager.]
Synopsis [Stops the rewriting manager.]
Description []
......@@ -152,57 +67,17 @@ Dar_Man_t * Dar_ManDup( Dar_Man_t * p )
***********************************************************************/
void Dar_ManStop( Dar_Man_t * p )
{
Dar_Obj_t * pObj;
int i;
// make sure the nodes have clean marks
Dar_ManForEachObj( p, pObj, i )
assert( !pObj->fMarkA && !pObj->fMarkB );
// print time
if ( p->time1 ) { PRT( "time1", p->time1 ); }
if ( p->time2 ) { PRT( "time2", p->time2 ); }
// Dar_TableProfile( p );
Dar_MmFixedStop( p->pMemObjs, 0 );
Dar_MmFlexStop( p->pMemCuts, 0 );
if ( p->vPis ) Vec_PtrFree( p->vPis );
if ( p->vPos ) Vec_PtrFree( p->vPos );
if ( p->vObjs ) Vec_PtrFree( p->vObjs );
if ( p->vRequired ) Vec_IntFree( p->vRequired );
if ( p->vLeavesBest ) Vec_PtrFree( p->vLeavesBest );
free( p->pTable );
if ( p->pPars->fVerbose )
Dar_ManPrintStats( p );
if ( p->pMemCuts )
Aig_MmFixedStop( p->pMemCuts, 0 );
if ( p->vLeavesBest )
Vec_PtrFree( p->vLeavesBest );
free( p );
}
/**Function*************************************************************
Synopsis [Returns the number of dangling nodes removed.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Dar_ManCleanup( Dar_Man_t * p )
{
Vec_Ptr_t * vObjs;
Dar_Obj_t * pNode;
int i, nNodesOld;
nNodesOld = Dar_ManNodeNum(p);
// collect roots of dangling nodes
vObjs = Vec_PtrAlloc( 100 );
Dar_ManForEachObj( p, pNode, i )
if ( Dar_ObjIsNode(pNode) && Dar_ObjRefs(pNode) == 0 )
Vec_PtrPush( vObjs, pNode );
// recursively remove dangling nodes
Vec_PtrForEachEntry( vObjs, pNode, i )
Dar_ObjDelete_rec( p, pNode, 1 );
Vec_PtrFree( vObjs );
return nNodesOld - Dar_ManNodeNum(p);
}
/**Function*************************************************************
Synopsis [Stops the AIG manager.]
Description []
......@@ -214,39 +89,18 @@ int Dar_ManCleanup( Dar_Man_t * p )
***********************************************************************/
void Dar_ManPrintStats( Dar_Man_t * p )
{
printf( "PI/PO/Lat = %5d/%5d/%5d ", Dar_ManPiNum(p), Dar_ManPoNum(p), Dar_ManLatchNum(p) );
printf( "A = %6d. ", Dar_ManAndNum(p) );
if ( Dar_ManExorNum(p) )
printf( "X = %5d. ", Dar_ManExorNum(p) );
if ( Dar_ManBufNum(p) )
printf( "B = %3d. ", Dar_ManBufNum(p) );
printf( "Cre = %6d. ", p->nCreated );
printf( "Del = %6d. ", p->nDeleted );
// printf( "Lev = %3d. ", Dar_ManCountLevels(p) );
printf( "\n" );
}
/**Function*************************************************************
Synopsis [Stops the AIG manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Dar_ManPrintRuntime( Dar_Man_t * p )
{
int i, Gain;
printf( "Good cuts = %d. Bad cuts = %d. Cut mem = %d Mb\n",
p->nCutsGood, p->nCutsBad, p->nCutMemUsed );
Gain = p->nNodesInit - Aig_ManNodeNum(p->pAig);
printf( "NodesBeg = %8d. NodesEnd = %8d. Gain = %6d. (%6.2f %%). Cut mem = %d Mb\n",
p->nNodesInit, Aig_ManNodeNum(p->pAig), Gain, 100.0*Gain/p->nNodesInit, p->nCutMemUsed );
printf( "Cuts = %8d. Tried = %8d. Used = %8d. Bad = %5d. Skipped = %5d. Ave = %.2f.\n",
p->nCutsAll, p->nCutsTried, p->nCutsUsed, p->nCutsBad, p->nCutsSkipped,
(float)p->nCutsUsed/Aig_ManNodeNum(p->pAig) );
PRT( "Cuts ", p->timeCuts );
PRT( "Eval ", p->timeEval );
PRT( "Other ", p->timeOther );
PRT( "TOTAL ", p->timeTotal );
Gain = p->nNodesInit - Dar_ManNodeNum(p);
/*
for ( i = 0; i < 222; i++ )
{
if ( p->ClassGains[i] == 0 && p->ClassTimes[i] == 0 )
......@@ -257,6 +111,7 @@ void Dar_ManPrintRuntime( Dar_Man_t * p )
printf( "R = %7d ", p->ClassGains[i]? p->ClassSubgs[i]/p->ClassGains[i] : 9999999 );
PRTP( "T", p->ClassTimes[i], p->timeEval );
}
*/
}
......
......@@ -18,7 +18,7 @@
***********************************************************************/
#include "dar.h"
#include "darInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -28,6 +28,8 @@
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
#if 0
/**Function*************************************************************
Synopsis [Computes truth table of the cut.]
......@@ -39,14 +41,14 @@
SeeAlso []
***********************************************************************/
void Dar_ManCollectCut_rec( Dar_Man_t * p, Dar_Obj_t * pNode, Vec_Int_t * vNodes )
void Aig_ManCollectCut_rec( Aig_Man_t * p, Aig_Obj_t * pNode, Vec_Int_t * vNodes )
{
if ( pNode->fMarkA )
return;
pNode->fMarkA = 1;
assert( Dar_ObjIsAnd(pNode) || Dar_ObjIsExor(pNode) );
Dar_ManCollectCut_rec( p, Dar_ObjFanin0(pNode), vNodes );
Dar_ManCollectCut_rec( p, Dar_ObjFanin1(pNode), vNodes );
assert( Aig_ObjIsAnd(pNode) || Aig_ObjIsExor(pNode) );
Aig_ManCollectCut_rec( p, Aig_ObjFanin0(pNode), vNodes );
Aig_ManCollectCut_rec( p, Aig_ObjFanin1(pNode), vNodes );
Vec_IntPush( vNodes, pNode->Id );
}
......@@ -62,7 +64,7 @@ void Dar_ManCollectCut_rec( Dar_Man_t * p, Dar_Obj_t * pNode, Vec_Int_t * vNodes
SeeAlso []
***********************************************************************/
void Dar_ManCollectCut( Dar_Man_t * p, Dar_Obj_t * pRoot, Vec_Int_t * vLeaves, Vec_Int_t * vNodes )
void Aig_ManCollectCut( Aig_Man_t * p, Aig_Obj_t * pRoot, Vec_Int_t * vLeaves, Vec_Int_t * vNodes )
{
int i, Leaf;
// collect and mark the leaves
......@@ -70,13 +72,13 @@ void Dar_ManCollectCut( Dar_Man_t * p, Dar_Obj_t * pRoot, Vec_Int_t * vLeaves, V
Vec_IntForEachEntry( vLeaves, Leaf, i )
{
Vec_IntPush( vNodes, Leaf );
Dar_ManObj(p, Leaf)->fMarkA = 1;
Aig_ManObj(p, Leaf)->fMarkA = 1;
}
// collect and mark the nodes
Dar_ManCollectCut_rec( p, pRoot, vNodes );
Aig_ManCollectCut_rec( p, pRoot, vNodes );
// clean the nodes
Vec_IntForEachEntry( vNodes, Leaf, i )
Dar_ManObj(p, Leaf)->fMarkA = 0;
Aig_ManObj(p, Leaf)->fMarkA = 0;
}
/**Function*************************************************************
......@@ -90,7 +92,7 @@ void Dar_ManCollectCut( Dar_Man_t * p, Dar_Obj_t * pRoot, Vec_Int_t * vLeaves, V
SeeAlso []
***********************************************************************/
unsigned * Dar_ObjGetTruthStore( int ObjNum, Vec_Int_t * vTruth )
unsigned * Aig_ObjGetTruthStore( int ObjNum, Vec_Int_t * vTruth )
{
return ((unsigned *)Vec_IntArray(vTruth)) + 8 * ObjNum;
}
......@@ -106,26 +108,26 @@ unsigned * Dar_ObjGetTruthStore( int ObjNum, Vec_Int_t * vTruth )
SeeAlso []
***********************************************************************/
void Dar_ManCutTruthOne( Dar_Man_t * p, Dar_Obj_t * pNode, Vec_Int_t * vTruth, int nWords )
void Aig_ManCutTruthOne( Aig_Man_t * p, Aig_Obj_t * pNode, Vec_Int_t * vTruth, int nWords )
{
unsigned * pTruth, * pTruth0, * pTruth1;
int i;
pTruth = Dar_ObjGetTruthStore( pNode->Level, vTruth );
pTruth0 = Dar_ObjGetTruthStore( Dar_ObjFanin0(pNode)->Level, vTruth );
pTruth1 = Dar_ObjGetTruthStore( Dar_ObjFanin1(pNode)->Level, vTruth );
if ( Dar_ObjIsExor(pNode) )
pTruth = Aig_ObjGetTruthStore( pNode->Level, vTruth );
pTruth0 = Aig_ObjGetTruthStore( Aig_ObjFanin0(pNode)->Level, vTruth );
pTruth1 = Aig_ObjGetTruthStore( Aig_ObjFanin1(pNode)->Level, vTruth );
if ( Aig_ObjIsExor(pNode) )
for ( i = 0; i < nWords; i++ )
pTruth[i] = pTruth0[i] ^ pTruth1[i];
else if ( !Dar_ObjFaninC0(pNode) && !Dar_ObjFaninC1(pNode) )
else if ( !Aig_ObjFaninC0(pNode) && !Aig_ObjFaninC1(pNode) )
for ( i = 0; i < nWords; i++ )
pTruth[i] = pTruth0[i] & pTruth1[i];
else if ( !Dar_ObjFaninC0(pNode) && Dar_ObjFaninC1(pNode) )
else if ( !Aig_ObjFaninC0(pNode) && Aig_ObjFaninC1(pNode) )
for ( i = 0; i < nWords; i++ )
pTruth[i] = pTruth0[i] & ~pTruth1[i];
else if ( Dar_ObjFaninC0(pNode) && !Dar_ObjFaninC1(pNode) )
else if ( Aig_ObjFaninC0(pNode) && !Aig_ObjFaninC1(pNode) )
for ( i = 0; i < nWords; i++ )
pTruth[i] = ~pTruth0[i] & pTruth1[i];
else // if ( Dar_ObjFaninC0(pNode) && Dar_ObjFaninC1(pNode) )
else // if ( Aig_ObjFaninC0(pNode) && Aig_ObjFaninC1(pNode) )
for ( i = 0; i < nWords; i++ )
pTruth[i] = ~pTruth0[i] & ~pTruth1[i];
}
......@@ -142,7 +144,7 @@ void Dar_ManCutTruthOne( Dar_Man_t * p, Dar_Obj_t * pNode, Vec_Int_t * vTruth, i
SeeAlso []
***********************************************************************/
unsigned * Dar_ManCutTruth( Dar_Man_t * p, Dar_Obj_t * pRoot, Vec_Int_t * vLeaves, Vec_Int_t * vNodes, Vec_Int_t * vTruth )
unsigned * Aig_ManCutTruth( Aig_Man_t * p, Aig_Obj_t * pRoot, Vec_Int_t * vLeaves, Vec_Int_t * vNodes, Vec_Int_t * vTruth )
{
static unsigned uTruths[8][8] = { // elementary truth tables
{ 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA },
......@@ -156,20 +158,20 @@ unsigned * Dar_ManCutTruth( Dar_Man_t * p, Dar_Obj_t * pRoot, Vec_Int_t * vLeave
};
int i, Leaf;
// collect the cut
// Dar_ManCollectCut( p, pRoot, vLeaves, vNodes );
// Aig_ManCollectCut( p, pRoot, vLeaves, vNodes );
// set the node numbers
Vec_IntForEachEntry( vNodes, Leaf, i )
Dar_ManObj(p, Leaf)->Level = i;
Aig_ManObj(p, Leaf)->Level = i;
// alloc enough memory
Vec_IntClear( vTruth );
Vec_IntGrow( vTruth, 8 * Vec_IntSize(vNodes) );
// set the elementary truth tables
Vec_IntForEachEntry( vLeaves, Leaf, i )
memcpy( Dar_ObjGetTruthStore(i, vTruth), uTruths[i], 8 * sizeof(unsigned) );
memcpy( Aig_ObjGetTruthStore(i, vTruth), uTruths[i], 8 * sizeof(unsigned) );
// compute truths for other nodes
Vec_IntForEachEntryStart( vNodes, Leaf, i, Vec_IntSize(vLeaves) )
Dar_ManCutTruthOne( p, Dar_ManObj(p, Leaf), vTruth, 8 );
return Dar_ObjGetTruthStore( pRoot->Level, vTruth );
Aig_ManCutTruthOne( p, Aig_ManObj(p, Leaf), vTruth, 8 );
return Aig_ObjGetTruthStore( pRoot->Level, vTruth );
}
static inline int Kit_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
......@@ -191,21 +193,21 @@ static inline void Kit_TruthNot( unsigned * pOut, unsigned * pIn, int nVars )
SeeAlso []
***********************************************************************/
int Dar_ManLargeCutEvalIsop( unsigned * pTruth, int nVars, Vec_Int_t * vMemory )
int Aig_ManLargeCutEvalIsop( unsigned * pTruth, int nVars, Vec_Int_t * vMemory )
{
extern int Kit_TruthIsop( unsigned * puTruth, int nVars, Vec_Int_t * vMemory, int fTryBoth );
int RetValue, nClauses;
// compute ISOP for the positive phase
RetValue = Kit_TruthIsop( pTruth, nVars, vMemory, 0 );
if ( RetValue == -1 )
return DAR_INFINITY;
return AIG_INFINITY;
assert( RetValue == 0 || RetValue == 1 );
nClauses = Vec_IntSize( vMemory );
// compute ISOP for the negative phase
Kit_TruthNot( pTruth, pTruth, nVars );
RetValue = Kit_TruthIsop( pTruth, nVars, vMemory, 0 );
if ( RetValue == -1 )
return DAR_INFINITY;
return AIG_INFINITY;
Kit_TruthNot( pTruth, pTruth, nVars );
assert( RetValue == 0 || RetValue == 1 );
nClauses += Vec_IntSize( vMemory );
......@@ -223,21 +225,21 @@ int Dar_ManLargeCutEvalIsop( unsigned * pTruth, int nVars, Vec_Int_t * vMemory )
SeeAlso []
***********************************************************************/
void Dar_ManLargeCutCollect_rec( Dar_Man_t * p, Dar_Obj_t * pNode, Vec_Int_t * vLeaves, Vec_Int_t * vNodes )
void Aig_ManLargeCutCollect_rec( Aig_Man_t * p, Aig_Obj_t * pNode, Vec_Int_t * vLeaves, Vec_Int_t * vNodes )
{
if ( Dar_ObjIsTravIdCurrent(p, pNode) )
if ( Aig_ObjIsTravIdCurrent(p, pNode) )
return;
if ( Dar_ObjIsTravIdPrevious(p, pNode) )
if ( Aig_ObjIsTravIdPrevious(p, pNode) )
{
Vec_IntPush( vLeaves, pNode->Id );
// Vec_IntPush( vNodes, pNode->Id );
Dar_ObjSetTravIdCurrent( p, pNode );
Aig_ObjSetTravIdCurrent( p, pNode );
return;
}
assert( Dar_ObjIsAnd(pNode) || Dar_ObjIsExor(pNode) );
Dar_ObjSetTravIdCurrent( p, pNode );
Dar_ManLargeCutCollect_rec( p, Dar_ObjFanin0(pNode), vLeaves, vNodes );
Dar_ManLargeCutCollect_rec( p, Dar_ObjFanin1(pNode), vLeaves, vNodes );
assert( Aig_ObjIsAnd(pNode) || Aig_ObjIsExor(pNode) );
Aig_ObjSetTravIdCurrent( p, pNode );
Aig_ManLargeCutCollect_rec( p, Aig_ObjFanin0(pNode), vLeaves, vNodes );
Aig_ManLargeCutCollect_rec( p, Aig_ObjFanin1(pNode), vLeaves, vNodes );
Vec_IntPush( vNodes, pNode->Id );
}
......@@ -252,24 +254,24 @@ void Dar_ManLargeCutCollect_rec( Dar_Man_t * p, Dar_Obj_t * pNode, Vec_Int_t * v
SeeAlso []
***********************************************************************/
void Dar_ManLargeCutCollect( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Cut_t * pCutR, Dar_Cut_t * pCutL, int Leaf,
void Aig_ManLargeCutCollect( Aig_Man_t * p, Aig_Obj_t * pRoot, Aig_Cut_t * pCutR, Aig_Cut_t * pCutL, int Leaf,
Vec_Int_t * vLeaves, Vec_Int_t * vNodes )
{
Vec_Int_t * vTemp;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int Node, i;
Dar_ManIncrementTravId( p );
Dar_CutForEachLeaf( p, pCutR, pObj, i )
Aig_ManIncrementTravId( p );
Aig_CutForEachLeaf( p, pCutR, pObj, i )
if ( pObj->Id != Leaf )
Dar_ObjSetTravIdCurrent( p, pObj );
Dar_CutForEachLeaf( p, pCutL, pObj, i )
Dar_ObjSetTravIdCurrent( p, pObj );
Aig_ObjSetTravIdCurrent( p, pObj );
Aig_CutForEachLeaf( p, pCutL, pObj, i )
Aig_ObjSetTravIdCurrent( p, pObj );
// collect the internal nodes and leaves
Dar_ManIncrementTravId( p );
Aig_ManIncrementTravId( p );
vTemp = Vec_IntAlloc( 100 );
Dar_ManLargeCutCollect_rec( p, pRoot, vLeaves, vTemp );
Aig_ManLargeCutCollect_rec( p, pRoot, vLeaves, vTemp );
Vec_IntForEachEntry( vLeaves, Node, i )
Vec_IntPush( vNodes, Node );
......@@ -291,22 +293,22 @@ void Dar_ManLargeCutCollect( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Cut_t * pCutR
SeeAlso []
***********************************************************************/
int Dar_ManLargeCutEval( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Cut_t * pCutR, Dar_Cut_t * pCutL, int Leaf )
int Aig_ManLargeCutEval( Aig_Man_t * p, Aig_Obj_t * pRoot, Aig_Cut_t * pCutR, Aig_Cut_t * pCutL, int Leaf )
{
Vec_Int_t * vLeaves, * vNodes, * vTruth, * vMemory;
unsigned * pTruth;
int RetValue;
// Dar_Obj_t * pObj;
// Aig_Obj_t * pObj;
vMemory = Vec_IntAlloc( 1 << 16 );
vTruth = Vec_IntAlloc( 1 << 16 );
vLeaves = Vec_IntAlloc( 100 );
vNodes = Vec_IntAlloc( 100 );
Dar_ManLargeCutCollect( p, pRoot, pCutR, pCutL, Leaf, vLeaves, vNodes );
Aig_ManLargeCutCollect( p, pRoot, pCutR, pCutL, Leaf, vLeaves, vNodes );
/*
// collect the nodes
Dar_CutForEachLeaf( p, pCutR, pObj, i )
Aig_CutForEachLeaf( p, pCutR, pObj, i )
{
if ( pObj->Id == Leaf )
continue;
......@@ -316,7 +318,7 @@ int Dar_ManLargeCutEval( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Cut_t * pCutR, Da
Vec_IntPush( vLeaves, pObj->Id );
Vec_IntPush( vNodes, pObj->Id );
}
Dar_CutForEachLeaf( p, pCutL, pObj, i )
Aig_CutForEachLeaf( p, pCutL, pObj, i )
{
if ( pObj->fMarkA )
continue;
......@@ -325,14 +327,14 @@ int Dar_ManLargeCutEval( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Cut_t * pCutR, Da
Vec_IntPush( vNodes, pObj->Id );
}
// collect and mark the nodes
Dar_ManCollectCut_rec( p, pRoot, vNodes );
Aig_ManCollectCut_rec( p, pRoot, vNodes );
// clean the nodes
Vec_IntForEachEntry( vNodes, Leaf, i )
Dar_ManObj(p, Leaf)->fMarkA = 0;
Aig_ManObj(p, Leaf)->fMarkA = 0;
*/
pTruth = Dar_ManCutTruth( p, pRoot, vLeaves, vNodes, vTruth );
RetValue = Dar_ManLargeCutEvalIsop( pTruth, Vec_IntSize(vLeaves), vMemory );
pTruth = Aig_ManCutTruth( p, pRoot, vLeaves, vNodes, vTruth );
RetValue = Aig_ManLargeCutEvalIsop( pTruth, Vec_IntSize(vLeaves), vMemory );
Vec_IntFree( vLeaves );
Vec_IntFree( vNodes );
......@@ -342,6 +344,7 @@ int Dar_ManLargeCutEval( Dar_Man_t * p, Dar_Obj_t * pRoot, Dar_Cut_t * pCutR, Da
return RetValue;
}
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
SRC += src/aig/dar/darBalance.c \
src/aig/dar/darCheck.c \
src/aig/dar/darCore.c \
src/aig/dar/darCut.c \
src/aig/dar/darData.c \
src/aig/dar/darDfs.c \
src/aig/dar/darLib.c \
src/aig/dar/darMan.c \
src/aig/dar/darMem.c \
src/aig/dar/darObj.c \
src/aig/dar/darOper.c \
src/aig/dar/darSeq.c \
src/aig/dar/darTable.c \
src/aig/dar/darTruth.c \
src/aig/dar/darUtil.c
src/aig/dar/darTruth.c
......@@ -36,6 +36,7 @@ extern "C" {
#include <time.h>
#include "vec.h"
#include "aig.h"
#include "dar.h"
#include "satSolver.h"
......@@ -73,8 +74,8 @@ struct Fra_Man_t_
// high-level data
Fra_Par_t * pPars; // parameters governing fraiging
// AIG managers
Dar_Man_t * pManAig; // the starting AIG manager
Dar_Man_t * pManFraig; // the final AIG manager
Aig_Man_t * pManAig; // the starting AIG manager
Aig_Man_t * pManFraig; // the final AIG manager
// simulation info
unsigned * pSimWords; // memory for simulation information
int nSimWords; // the number of simulation words
......@@ -86,8 +87,8 @@ struct Fra_Man_t_
Vec_Ptr_t * vClasses; // equivalence classes
Vec_Ptr_t * vClasses1; // equivalence class of Const1 node
Vec_Ptr_t * vClassesTemp; // temporary storage for new classes
Dar_Obj_t ** pMemClasses; // memory allocated for equivalence classes
Dar_Obj_t ** pMemClassesFree; // memory allocated for equivalence classes to be used
Aig_Obj_t ** pMemClasses; // memory allocated for equivalence classes
Aig_Obj_t ** pMemClassesFree; // memory allocated for equivalence classes to be used
Vec_Ptr_t * vClassOld; // old equivalence class after splitting
Vec_Ptr_t * vClassNew; // new equivalence class(es) after splitting
int nPairs; // the number of pairs of nodes
......@@ -98,8 +99,8 @@ struct Fra_Man_t_
sint64 nBTLimitGlobal; // resource limit
sint64 nInsLimitGlobal; // resource limit
// various data members
Dar_Obj_t ** pMemFraig; // memory allocated for points to the fraig nodes
Dar_Obj_t ** pMemRepr; // memory allocated for points to the node representatives
Aig_Obj_t ** pMemFraig; // memory allocated for points to the fraig nodes
Aig_Obj_t ** pMemRepr; // memory allocated for points to the node representatives
Vec_Ptr_t ** pMemFanins; // the arrays of fanins
int * pMemSatNums; // the array of SAT numbers
int nSizeAlloc; // allocated size of the arrays
......@@ -135,21 +136,21 @@ struct Fra_Man_t_
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
static inline unsigned * Fra_ObjSim( Dar_Obj_t * pObj ) { return ((Fra_Man_t *)pObj->pData)->pSimWords + ((Fra_Man_t *)pObj->pData)->nSimWords * pObj->Id; }
static inline unsigned * Fra_ObjSim( Aig_Obj_t * pObj ) { return ((Fra_Man_t *)pObj->pData)->pSimWords + ((Fra_Man_t *)pObj->pData)->nSimWords * pObj->Id; }
static inline unsigned Fra_ObjRandomSim() { return (rand() << 24) ^ (rand() << 12) ^ rand(); }
static inline Dar_Obj_t * Fra_ObjFraig( Dar_Obj_t * pObj ) { return ((Fra_Man_t *)pObj->pData)->pMemFraig[pObj->Id]; }
static inline Dar_Obj_t * Fra_ObjRepr( Dar_Obj_t * pObj ) { return ((Fra_Man_t *)pObj->pData)->pMemRepr[pObj->Id]; }
static inline Vec_Ptr_t * Fra_ObjFaninVec( Dar_Obj_t * pObj ) { return ((Fra_Man_t *)pObj->pData)->pMemFanins[pObj->Id]; }
static inline int Fra_ObjSatNum( Dar_Obj_t * pObj ) { return ((Fra_Man_t *)pObj->pData)->pMemSatNums[pObj->Id]; }
static inline Aig_Obj_t * Fra_ObjFraig( Aig_Obj_t * pObj ) { return ((Fra_Man_t *)pObj->pData)->pMemFraig[pObj->Id]; }
static inline Aig_Obj_t * Fra_ObjRepr( Aig_Obj_t * pObj ) { return ((Fra_Man_t *)pObj->pData)->pMemRepr[pObj->Id]; }
static inline Vec_Ptr_t * Fra_ObjFaninVec( Aig_Obj_t * pObj ) { return ((Fra_Man_t *)pObj->pData)->pMemFanins[pObj->Id]; }
static inline int Fra_ObjSatNum( Aig_Obj_t * pObj ) { return ((Fra_Man_t *)pObj->pData)->pMemSatNums[pObj->Id]; }
static inline void Fra_ObjSetFraig( Dar_Obj_t * pObj, Dar_Obj_t * pNode ) { ((Fra_Man_t *)pObj->pData)->pMemFraig[pObj->Id] = pNode; }
static inline void Fra_ObjSetRepr( Dar_Obj_t * pObj, Dar_Obj_t * pNode ) { ((Fra_Man_t *)pObj->pData)->pMemRepr[pObj->Id] = pNode; }
static inline void Fra_ObjSetFaninVec( Dar_Obj_t * pObj, Vec_Ptr_t * vFanins ) { ((Fra_Man_t *)pObj->pData)->pMemFanins[pObj->Id] = vFanins; }
static inline void Fra_ObjSetSatNum( Dar_Obj_t * pObj, int Num ) { ((Fra_Man_t *)pObj->pData)->pMemSatNums[pObj->Id] = Num; }
static inline void Fra_ObjSetFraig( Aig_Obj_t * pObj, Aig_Obj_t * pNode ) { ((Fra_Man_t *)pObj->pData)->pMemFraig[pObj->Id] = pNode; }
static inline void Fra_ObjSetRepr( Aig_Obj_t * pObj, Aig_Obj_t * pNode ) { ((Fra_Man_t *)pObj->pData)->pMemRepr[pObj->Id] = pNode; }
static inline void Fra_ObjSetFaninVec( Aig_Obj_t * pObj, Vec_Ptr_t * vFanins ) { ((Fra_Man_t *)pObj->pData)->pMemFanins[pObj->Id] = vFanins; }
static inline void Fra_ObjSetSatNum( Aig_Obj_t * pObj, int Num ) { ((Fra_Man_t *)pObj->pData)->pMemSatNums[pObj->Id] = Num; }
static inline Dar_Obj_t * Fra_ObjChild0Fra( Dar_Obj_t * pObj ) { assert( !Dar_IsComplement(pObj) ); return Dar_ObjFanin0(pObj)? Dar_NotCond(Fra_ObjFraig(Dar_ObjFanin0(pObj)), Dar_ObjFaninC0(pObj)) : NULL; }
static inline Dar_Obj_t * Fra_ObjChild1Fra( Dar_Obj_t * pObj ) { assert( !Dar_IsComplement(pObj) ); return Dar_ObjFanin1(pObj)? Dar_NotCond(Fra_ObjFraig(Dar_ObjFanin1(pObj)), Dar_ObjFaninC1(pObj)) : NULL; }
static inline Aig_Obj_t * Fra_ObjChild0Fra( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond(Fra_ObjFraig(Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj)) : NULL; }
static inline Aig_Obj_t * Fra_ObjChild1Fra( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond(Fra_ObjFraig(Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj)) : NULL; }
////////////////////////////////////////////////////////////////////////
/// ITERATORS ///
......@@ -167,21 +168,21 @@ extern void Fra_CreateClasses( Fra_Man_t * p );
extern int Fra_RefineClasses( Fra_Man_t * p );
extern int Fra_RefineClasses1( Fra_Man_t * p );
/*=== fraCnf.c ========================================================*/
extern void Fra_NodeAddToSolver( Fra_Man_t * p, Dar_Obj_t * pOld, Dar_Obj_t * pNew );
extern void Fra_NodeAddToSolver( Fra_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew );
/*=== fraCore.c ========================================================*/
extern Dar_Man_t * Fra_Perform( Dar_Man_t * pManAig, Fra_Par_t * pParams );
extern Aig_Man_t * Fra_Perform( Aig_Man_t * pManAig, Fra_Par_t * pParams );
/*=== fraMan.c ========================================================*/
extern void Fra_ParamsDefault( Fra_Par_t * pParams );
extern Fra_Man_t * Fra_ManStart( Dar_Man_t * pManAig, Fra_Par_t * pParams );
extern Fra_Man_t * Fra_ManStart( Aig_Man_t * pManAig, Fra_Par_t * pParams );
extern void Fra_ManPrepare( Fra_Man_t * p );
extern void Fra_ManStop( Fra_Man_t * p );
extern void Fra_ManPrint( Fra_Man_t * p );
/*=== fraSat.c ========================================================*/
extern int Fra_NodesAreEquiv( Fra_Man_t * p, Dar_Obj_t * pOld, Dar_Obj_t * pNew );
extern int Fra_NodeIsConst( Fra_Man_t * p, Dar_Obj_t * pNew );
extern int Fra_NodesAreEquiv( Fra_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew );
extern int Fra_NodeIsConst( Fra_Man_t * p, Aig_Obj_t * pNew );
/*=== fraSim.c ========================================================*/
extern int Fra_NodeHasZeroSim( Fra_Man_t * p, Dar_Obj_t * pObj );
extern int Fra_NodeCompareSims( Fra_Man_t * p, Dar_Obj_t * pObj0, Dar_Obj_t * pObj1 );
extern int Fra_NodeHasZeroSim( Fra_Man_t * p, Aig_Obj_t * pObj );
extern int Fra_NodeCompareSims( Fra_Man_t * p, Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 );
extern void Fra_SavePattern( Fra_Man_t * p );
extern void Fra_Simulate( Fra_Man_t * p );
extern void Fra_Resimulate( Fra_Man_t * p );
......
......@@ -40,48 +40,48 @@
SeeAlso []
***********************************************************************/
Dar_Obj_t * Fra_And( Fra_Man_t * p, Dar_Obj_t * pObjOld )
Aig_Obj_t * Fra_And( Fra_Man_t * p, Aig_Obj_t * pObjOld )
{
Dar_Obj_t * pObjOldRepr, * pObjFraig, * pFanin0Fraig, * pFanin1Fraig, * pObjOldReprFraig;
Aig_Obj_t * pObjOldRepr, * pObjFraig, * pFanin0Fraig, * pFanin1Fraig, * pObjOldReprFraig;
int RetValue;
assert( !Dar_IsComplement(pObjOld) );
assert( Dar_ObjIsNode(pObjOld) );
assert( !Aig_IsComplement(pObjOld) );
assert( Aig_ObjIsNode(pObjOld) );
// get the fraiged fanins
pFanin0Fraig = Fra_ObjChild0Fra(pObjOld);
pFanin1Fraig = Fra_ObjChild1Fra(pObjOld);
// get the fraiged node
pObjFraig = Dar_And( p->pManFraig, pFanin0Fraig, pFanin1Fraig );
if ( Dar_ObjIsConst1(Dar_Regular(pObjFraig)) )
pObjFraig = Aig_And( p->pManFraig, pFanin0Fraig, pFanin1Fraig );
if ( Aig_ObjIsConst1(Aig_Regular(pObjFraig)) )
return pObjFraig;
Dar_Regular(pObjFraig)->pData = p;
Aig_Regular(pObjFraig)->pData = p;
// get representative of this class
pObjOldRepr = Fra_ObjRepr(pObjOld);
if ( pObjOldRepr == NULL || // this is a unique node
(!p->pPars->fDoSparse && pObjOldRepr == Dar_ManConst1(p->pManAig)) ) // this is a sparse node
(!p->pPars->fDoSparse && pObjOldRepr == Aig_ManConst1(p->pManAig)) ) // this is a sparse node
{
assert( Dar_Regular(pFanin0Fraig) != Dar_Regular(pFanin1Fraig) );
assert( Dar_Regular(pObjFraig) != Dar_Regular(pFanin0Fraig) );
assert( Dar_Regular(pObjFraig) != Dar_Regular(pFanin1Fraig) );
assert( Aig_Regular(pFanin0Fraig) != Aig_Regular(pFanin1Fraig) );
assert( Aig_Regular(pObjFraig) != Aig_Regular(pFanin0Fraig) );
assert( Aig_Regular(pObjFraig) != Aig_Regular(pFanin1Fraig) );
return pObjFraig;
}
// get the fraiged representative
pObjOldReprFraig = Fra_ObjFraig(pObjOldRepr);
// if the fraiged nodes are the same, return
if ( Dar_Regular(pObjFraig) == Dar_Regular(pObjOldReprFraig) )
if ( Aig_Regular(pObjFraig) == Aig_Regular(pObjOldReprFraig) )
return pObjFraig;
assert( Dar_Regular(pObjFraig) != Dar_ManConst1(p->pManFraig) );
assert( Aig_Regular(pObjFraig) != Aig_ManConst1(p->pManFraig) );
// printf( "Node = %d. Repr = %d.\n", pObjOld->Id, pObjOldRepr->Id );
// if they are proved different, the c-ex will be in p->pPatWords
RetValue = Fra_NodesAreEquiv( p, Dar_Regular(pObjOldReprFraig), Dar_Regular(pObjFraig) );
RetValue = Fra_NodesAreEquiv( p, Aig_Regular(pObjOldReprFraig), Aig_Regular(pObjFraig) );
if ( RetValue == 1 ) // proved equivalent
{
// pObjOld->fMarkA = 1;
return Dar_NotCond( pObjOldReprFraig, pObjOld->fPhase ^ pObjOldRepr->fPhase );
return Aig_NotCond( pObjOldReprFraig, pObjOld->fPhase ^ pObjOldRepr->fPhase );
}
if ( RetValue == -1 ) // failed
{
Dar_Obj_t * ppNodes[2] = { Dar_Regular(pObjOldReprFraig), Dar_Regular(pObjFraig) };
Aig_Obj_t * ppNodes[2] = { Aig_Regular(pObjOldReprFraig), Aig_Regular(pObjFraig) };
Vec_Ptr_t * vNodes;
if ( !p->pPars->fSpeculate )
......@@ -90,11 +90,11 @@ Dar_Obj_t * Fra_And( Fra_Man_t * p, Dar_Obj_t * pObjOld )
// pObjOld->fMarkB = 1;
p->nSpeculs++;
vNodes = Dar_ManDfsNodes( p->pManFraig, ppNodes, 2 );
vNodes = Aig_ManDfsNodes( p->pManFraig, ppNodes, 2 );
printf( "%d ", Vec_PtrSize(vNodes) );
Vec_PtrFree( vNodes );
return Dar_NotCond( pObjOldReprFraig, pObjOld->fPhase ^ pObjOldRepr->fPhase );
return Aig_NotCond( pObjOldReprFraig, pObjOld->fPhase ^ pObjOldRepr->fPhase );
}
// printf( "Disproved %d and %d.\n", pObjOldRepr->Id, pObjOld->Id );
// simulate the counter-example and return the Fraig node
......@@ -118,18 +118,18 @@ Dar_Obj_t * Fra_And( Fra_Man_t * p, Dar_Obj_t * pObjOld )
***********************************************************************/
void Fra_Sweep( Fra_Man_t * p )
{
Dar_Obj_t * pObj, * pObjNew;
Aig_Obj_t * pObj, * pObjNew;
int i, k = 0;
p->nClassesZero = Vec_PtrSize(p->vClasses1);
p->nClassesBeg = Vec_PtrSize(p->vClasses) + (int)(Vec_PtrSize(p->vClasses1) > 0);
// duplicate internal nodes
// p->pProgress = Extra_ProgressBarStart( stdout, Dar_ManNodeNum(p->pManAig) );
Dar_ManForEachNode( p->pManAig, pObj, i )
// p->pProgress = Extra_ProgressBarStart( stdout, Aig_ManNodeNum(p->pManAig) );
Aig_ManForEachNode( p->pManAig, pObj, i )
{
// Extra_ProgressBarUpdate( p->pProgress, k++, NULL );
// default to simple strashing if simulation detected a counter-example for a PO
if ( p->pManFraig->pData )
pObjNew = Dar_And( p->pManFraig, Fra_ObjChild0Fra(pObj), Fra_ObjChild1Fra(pObj) );
pObjNew = Aig_And( p->pManFraig, Fra_ObjChild0Fra(pObj), Fra_ObjChild1Fra(pObj) );
else
pObjNew = Fra_And( p, pObj ); // pObjNew can be complemented
Fra_ObjSetFraig( pObj, pObjNew );
......@@ -138,15 +138,15 @@ p->nClassesBeg = Vec_PtrSize(p->vClasses) + (int)(Vec_PtrSize(p->vClasses1) > 0
// Extra_ProgressBarStop( p->pProgress );
p->nClassesEnd = Vec_PtrSize(p->vClasses) + (int)(Vec_PtrSize(p->vClasses1) > 0);
// try to prove the outputs of the miter
p->nNodesMiter = Dar_ManNodeNum(p->pManFraig);
p->nNodesMiter = Aig_ManNodeNum(p->pManFraig);
// Fra_MiterStatus( p->pManFraig );
// if ( p->pPars->fProve && p->pManFraig->pData == NULL )
// Fra_MiterProve( p );
// add the POs
Dar_ManForEachPo( p->pManAig, pObj, i )
Dar_ObjCreatePo( p->pManFraig, Fra_ObjChild0Fra(pObj) );
Aig_ManForEachPo( p->pManAig, pObj, i )
Aig_ObjCreatePo( p->pManFraig, Fra_ObjChild0Fra(pObj) );
// remove dangling nodes
Dar_ManCleanup( p->pManFraig );
Aig_ManCleanup( p->pManFraig );
}
////////////////////////////////////////////////////////////////////////
......
......@@ -36,8 +36,8 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static inline Dar_Obj_t * Fra_ObjNext( Dar_Obj_t ** ppNexts, Dar_Obj_t * pObj ) { return ppNexts[pObj->Id]; }
static inline void Fra_ObjSetNext( Dar_Obj_t ** ppNexts, Dar_Obj_t * pObj, Dar_Obj_t * pNext ) { ppNexts[pObj->Id] = pNext; }
static inline Aig_Obj_t * Fra_ObjNext( Aig_Obj_t ** ppNexts, Aig_Obj_t * pObj ) { return ppNexts[pObj->Id]; }
static inline void Fra_ObjSetNext( Aig_Obj_t ** ppNexts, Aig_Obj_t * pObj, Aig_Obj_t * pNext ) { ppNexts[pObj->Id] = pNext; }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
......@@ -54,9 +54,9 @@ static inline void Fra_ObjSetNext( Dar_Obj_t ** ppNexts, Dar_Obj_t * pOb
SeeAlso []
***********************************************************************/
void Fra_PrintClass( Dar_Obj_t ** pClass )
void Fra_PrintClass( Aig_Obj_t ** pClass )
{
Dar_Obj_t * pTemp;
Aig_Obj_t * pTemp;
int i;
printf( "{ " );
for ( i = 0; pTemp = pClass[i]; i++ )
......@@ -75,9 +75,9 @@ void Fra_PrintClass( Dar_Obj_t ** pClass )
SeeAlso []
***********************************************************************/
int Fra_CountClass( Dar_Obj_t ** pClass )
int Fra_CountClass( Aig_Obj_t ** pClass )
{
Dar_Obj_t * pTemp;
Aig_Obj_t * pTemp;
int i;
for ( i = 0; pTemp = pClass[i]; i++ );
return i;
......@@ -96,7 +96,7 @@ int Fra_CountClass( Dar_Obj_t ** pClass )
***********************************************************************/
int Fra_CountPairsClasses( Fra_Man_t * p )
{
Dar_Obj_t ** pClass;
Aig_Obj_t ** pClass;
int i, nNodes, nPairs = 0;
Vec_PtrForEachEntry( p->vClasses, pClass, i )
{
......@@ -120,7 +120,7 @@ int Fra_CountPairsClasses( Fra_Man_t * p )
***********************************************************************/
void Fra_PrintClasses( Fra_Man_t * p )
{
Dar_Obj_t ** pClass;
Aig_Obj_t ** pClass;
int i;
printf( "Total classes = %d. Total pairs = %d.\n", Vec_PtrSize(p->vClasses), Fra_CountPairsClasses(p) );
Vec_PtrForEachEntry( p->vClasses, pClass, i )
......@@ -142,7 +142,7 @@ void Fra_PrintClasses( Fra_Man_t * p )
SeeAlso []
***********************************************************************/
unsigned Fra_NodeHash( Fra_Man_t * p, Dar_Obj_t * pObj )
unsigned Fra_NodeHash( Fra_Man_t * p, Aig_Obj_t * pObj )
{
static int s_FPrimes[128] = {
1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
......@@ -220,21 +220,21 @@ unsigned int Cudd_PrimeFra( unsigned int p )
***********************************************************************/
void Fra_CreateClasses( Fra_Man_t * p )
{
Dar_Obj_t ** ppTable, ** ppNexts;
Dar_Obj_t * pObj, * pTemp;
Aig_Obj_t ** ppTable, ** ppNexts;
Aig_Obj_t * pObj, * pTemp;
int i, k, nTableSize, nEntries, nNodes, iEntry;
// allocate the hash table hashing simulation info into nodes
nTableSize = Cudd_PrimeFra( Dar_ManObjIdMax(p->pManAig) + 1 );
ppTable = ALLOC( Dar_Obj_t *, nTableSize );
ppNexts = ALLOC( Dar_Obj_t *, nTableSize );
memset( ppTable, 0, sizeof(Dar_Obj_t *) * nTableSize );
nTableSize = Cudd_PrimeFra( Aig_ManObjIdMax(p->pManAig) + 1 );
ppTable = ALLOC( Aig_Obj_t *, nTableSize );
ppNexts = ALLOC( Aig_Obj_t *, nTableSize );
memset( ppTable, 0, sizeof(Aig_Obj_t *) * nTableSize );
// add all the nodes to the hash table
Vec_PtrClear( p->vClasses1 );
Dar_ManForEachObj( p->pManAig, pObj, i )
Aig_ManForEachObj( p->pManAig, pObj, i )
{
if ( !Dar_ObjIsNode(pObj) && !Dar_ObjIsPi(pObj) )
if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsPi(pObj) )
continue;
// hash the node by its simulation info
iEntry = Fra_NodeHash( p, pObj ) % nTableSize;
......@@ -242,7 +242,7 @@ void Fra_CreateClasses( Fra_Man_t * p )
if ( iEntry == 0 && Fra_NodeHasZeroSim( p, pObj ) )
{
Vec_PtrPush( p->vClasses1, pObj );
Fra_ObjSetRepr( pObj, Dar_ManConst1(p->pManAig) );
Fra_ObjSetRepr( pObj, Aig_ManConst1(p->pManAig) );
continue;
}
// add the node to the class
......@@ -275,15 +275,15 @@ void Fra_CreateClasses( Fra_Man_t * p )
}
// allocate room for classes
p->pMemClasses = ALLOC( Dar_Obj_t *, 2*(nEntries + Vec_PtrSize(p->vClasses1)) );
p->pMemClasses = ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->vClasses1)) );
p->pMemClassesFree = p->pMemClasses + 2*nEntries;
// copy the entries into storage in the topological order
Vec_PtrClear( p->vClasses );
nEntries = 0;
Dar_ManForEachObj( p->pManAig, pObj, i )
Aig_ManForEachObj( p->pManAig, pObj, i )
{
if ( !Dar_ObjIsNode(pObj) && !Dar_ObjIsPi(pObj) )
if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsPi(pObj) )
continue;
// skip the nodes that are not representatives of non-trivial classes
if ( pObj->fMarkA == 0 )
......@@ -307,7 +307,7 @@ void Fra_CreateClasses( Fra_Man_t * p )
Fra_ObjSetRepr( pTemp, pObj );
}
// add as many empty entries
// memset( p->pMemClasses + 2*nEntries + nNodes, 0, sizeof(Dar_Obj_t *) * nNodes );
// memset( p->pMemClasses + 2*nEntries + nNodes, 0, sizeof(Aig_Obj_t *) * nNodes );
p->pMemClasses[2*nEntries + nNodes] = NULL;
// increment the number of entries
nEntries += k;
......@@ -329,9 +329,9 @@ void Fra_CreateClasses( Fra_Man_t * p )
SeeAlso []
***********************************************************************/
Dar_Obj_t ** Fra_RefineClassOne( Fra_Man_t * p, Dar_Obj_t ** ppClass )
Aig_Obj_t ** Fra_RefineClassOne( Fra_Man_t * p, Aig_Obj_t ** ppClass )
{
Dar_Obj_t * pObj, ** ppThis;
Aig_Obj_t * pObj, ** ppThis;
int i;
assert( ppClass[0] != NULL && ppClass[1] != NULL );
......@@ -390,7 +390,7 @@ Dar_Obj_t ** Fra_RefineClassOne( Fra_Man_t * p, Dar_Obj_t ** ppClass )
***********************************************************************/
int Fra_RefineClassLastIter( Fra_Man_t * p, Vec_Ptr_t * vClasses )
{
Dar_Obj_t ** pClass, ** pClass2;
Aig_Obj_t ** pClass, ** pClass2;
int nRefis;
pClass = Vec_PtrEntryLast( vClasses );
for ( nRefis = 0; pClass2 = Fra_RefineClassOne( p, pClass ); nRefis++ )
......@@ -426,7 +426,7 @@ int Fra_RefineClassLastIter( Fra_Man_t * p, Vec_Ptr_t * vClasses )
int Fra_RefineClasses( Fra_Man_t * p )
{
Vec_Ptr_t * vTemp;
Dar_Obj_t ** pClass;
Aig_Obj_t ** pClass;
int clk, i, nRefis;
// check if some outputs already became non-constant
// this is a special case when computation can be stopped!!!
......@@ -466,14 +466,14 @@ p->timeRef += clock() - clk;
***********************************************************************/
int Fra_RefineClasses1( Fra_Man_t * p )
{
Dar_Obj_t * pObj, ** ppClass;
Aig_Obj_t * pObj, ** ppClass;
int i, k, nRefis, clk;
// check if there is anything to refine
if ( Vec_PtrSize(p->vClasses1) == 0 )
return 0;
clk = clock();
// make sure constant 1 class contains only non-constant nodes
assert( Vec_PtrEntry(p->vClasses1,0) != Dar_ManConst1(p->pManAig) );
assert( Vec_PtrEntry(p->vClasses1,0) != Aig_ManConst1(p->pManAig) );
// collect all the nodes to be refined
k = 0;
Vec_PtrClear( p->vClassNew );
......
......@@ -40,23 +40,23 @@
SeeAlso []
***********************************************************************/
void Fra_AddClausesMux( Fra_Man_t * p, Dar_Obj_t * pNode )
void Fra_AddClausesMux( Fra_Man_t * p, Aig_Obj_t * pNode )
{
Dar_Obj_t * pNodeI, * pNodeT, * pNodeE;
Aig_Obj_t * pNodeI, * pNodeT, * pNodeE;
int pLits[4], RetValue, VarF, VarI, VarT, VarE, fCompT, fCompE;
assert( !Dar_IsComplement( pNode ) );
assert( Dar_ObjIsMuxType( pNode ) );
assert( !Aig_IsComplement( pNode ) );
assert( Aig_ObjIsMuxType( pNode ) );
// get nodes (I = if, T = then, E = else)
pNodeI = Dar_ObjRecognizeMux( pNode, &pNodeT, &pNodeE );
pNodeI = Aig_ObjRecognizeMux( pNode, &pNodeT, &pNodeE );
// get the variable numbers
VarF = Fra_ObjSatNum(pNode);
VarI = Fra_ObjSatNum(pNodeI);
VarT = Fra_ObjSatNum(Dar_Regular(pNodeT));
VarE = Fra_ObjSatNum(Dar_Regular(pNodeE));
VarT = Fra_ObjSatNum(Aig_Regular(pNodeT));
VarE = Fra_ObjSatNum(Aig_Regular(pNodeE));
// get the complementation flags
fCompT = Dar_IsComplement(pNodeT);
fCompE = Dar_IsComplement(pNodeE);
fCompT = Aig_IsComplement(pNodeT);
fCompE = Aig_IsComplement(pNodeE);
// f = ITE(i, t, e)
......@@ -123,12 +123,12 @@ void Fra_AddClausesMux( Fra_Man_t * p, Dar_Obj_t * pNode )
SeeAlso []
***********************************************************************/
void Fra_AddClausesSuper( Fra_Man_t * p, Dar_Obj_t * pNode, Vec_Ptr_t * vSuper )
void Fra_AddClausesSuper( Fra_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
{
Dar_Obj_t * pFanin;
Aig_Obj_t * pFanin;
int * pLits, nLits, RetValue, i;
assert( !Dar_IsComplement(pNode) );
assert( Dar_ObjIsNode( pNode ) );
assert( !Aig_IsComplement(pNode) );
assert( Aig_ObjIsNode( pNode ) );
// create storage for literals
nLits = Vec_PtrSize(vSuper) + 1;
pLits = ALLOC( int, nLits );
......@@ -136,14 +136,14 @@ void Fra_AddClausesSuper( Fra_Man_t * p, Dar_Obj_t * pNode, Vec_Ptr_t * vSuper )
// add !A => !C or A + !C
Vec_PtrForEachEntry( vSuper, pFanin, i )
{
pLits[0] = toLitCond(Fra_ObjSatNum(Dar_Regular(pFanin)), Dar_IsComplement(pFanin));
pLits[0] = toLitCond(Fra_ObjSatNum(Aig_Regular(pFanin)), Aig_IsComplement(pFanin));
pLits[1] = toLitCond(Fra_ObjSatNum(pNode), 1);
RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
assert( RetValue );
}
// add A & B => C or !A + !B + C
Vec_PtrForEachEntry( vSuper, pFanin, i )
pLits[i] = toLitCond(Fra_ObjSatNum(Dar_Regular(pFanin)), !Dar_IsComplement(pFanin));
pLits[i] = toLitCond(Fra_ObjSatNum(Aig_Regular(pFanin)), !Aig_IsComplement(pFanin));
pLits[nLits-1] = toLitCond(Fra_ObjSatNum(pNode), 0);
RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits );
assert( RetValue );
......@@ -161,18 +161,18 @@ void Fra_AddClausesSuper( Fra_Man_t * p, Dar_Obj_t * pNode, Vec_Ptr_t * vSuper )
SeeAlso []
***********************************************************************/
void Fra_CollectSuper_rec( Dar_Obj_t * pObj, Vec_Ptr_t * vSuper, int fFirst, int fUseMuxes )
void Fra_CollectSuper_rec( Aig_Obj_t * pObj, Vec_Ptr_t * vSuper, int fFirst, int fUseMuxes )
{
// if the new node is complemented or a PI, another gate begins
if ( Dar_IsComplement(pObj) || Dar_ObjIsPi(pObj) || (!fFirst && Dar_ObjRefs(pObj) > 1) ||
(fUseMuxes && Dar_ObjIsMuxType(pObj)) )
if ( Aig_IsComplement(pObj) || Aig_ObjIsPi(pObj) || (!fFirst && Aig_ObjRefs(pObj) > 1) ||
(fUseMuxes && Aig_ObjIsMuxType(pObj)) )
{
Vec_PtrPushUnique( vSuper, pObj );
return;
}
// go through the branches
Fra_CollectSuper_rec( Dar_ObjChild0(pObj), vSuper, 0, fUseMuxes );
Fra_CollectSuper_rec( Dar_ObjChild1(pObj), vSuper, 0, fUseMuxes );
Fra_CollectSuper_rec( Aig_ObjChild0(pObj), vSuper, 0, fUseMuxes );
Fra_CollectSuper_rec( Aig_ObjChild1(pObj), vSuper, 0, fUseMuxes );
}
/**Function*************************************************************
......@@ -186,11 +186,11 @@ void Fra_CollectSuper_rec( Dar_Obj_t * pObj, Vec_Ptr_t * vSuper, int fFirst, int
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Fra_CollectSuper( Dar_Obj_t * pObj, int fUseMuxes )
Vec_Ptr_t * Fra_CollectSuper( Aig_Obj_t * pObj, int fUseMuxes )
{
Vec_Ptr_t * vSuper;
assert( !Dar_IsComplement(pObj) );
assert( !Dar_ObjIsPi(pObj) );
assert( !Aig_IsComplement(pObj) );
assert( !Aig_ObjIsPi(pObj) );
vSuper = Vec_PtrAlloc( 4 );
Fra_CollectSuper_rec( pObj, vSuper, 1, fUseMuxes );
return vSuper;
......@@ -207,19 +207,19 @@ Vec_Ptr_t * Fra_CollectSuper( Dar_Obj_t * pObj, int fUseMuxes )
SeeAlso []
***********************************************************************/
void Fra_ObjAddToFrontier( Fra_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vFrontier )
void Fra_ObjAddToFrontier( Fra_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vFrontier )
{
Fra_Man_t * pTemp = pObj->pData;
assert( !Dar_IsComplement(pObj) );
assert( !Aig_IsComplement(pObj) );
if ( Fra_ObjSatNum(pObj) )
return;
assert( Fra_ObjSatNum(pObj) == 0 );
assert( Fra_ObjFaninVec(pObj) == NULL );
if ( Dar_ObjIsConst1(pObj) )
if ( Aig_ObjIsConst1(pObj) )
return;
//printf( "Assigning node %d number %d\n", pObj->Id, p->nSatVars );
Fra_ObjSetSatNum( pObj, p->nSatVars++ );
if ( Dar_ObjIsNode(pObj) )
if ( Aig_ObjIsNode(pObj) )
Vec_PtrPush( vFrontier, pObj );
}
......@@ -234,10 +234,10 @@ void Fra_ObjAddToFrontier( Fra_Man_t * p, Dar_Obj_t * pObj, Vec_Ptr_t * vFrontie
SeeAlso []
***********************************************************************/
void Fra_NodeAddToSolver( Fra_Man_t * p, Dar_Obj_t * pOld, Dar_Obj_t * pNew )
void Fra_NodeAddToSolver( Fra_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
{
Vec_Ptr_t * vFrontier, * vFanins;
Dar_Obj_t * pNode, * pFanin;
Aig_Obj_t * pNode, * pFanin;
int i, k, fUseMuxes = 1;
assert( pOld || pNew );
// quit if CNF is ready
......@@ -253,22 +253,22 @@ void Fra_NodeAddToSolver( Fra_Man_t * p, Dar_Obj_t * pOld, Dar_Obj_t * pNew )
// create the supergate
assert( Fra_ObjSatNum(pNode) );
assert( Fra_ObjFaninVec(pNode) == NULL );
if ( fUseMuxes && Dar_ObjIsMuxType(pNode) )
if ( fUseMuxes && Aig_ObjIsMuxType(pNode) )
{
vFanins = Vec_PtrAlloc( 4 );
Vec_PtrPushUnique( vFanins, Dar_ObjFanin0( Dar_ObjFanin0(pNode) ) );
Vec_PtrPushUnique( vFanins, Dar_ObjFanin0( Dar_ObjFanin1(pNode) ) );
Vec_PtrPushUnique( vFanins, Dar_ObjFanin1( Dar_ObjFanin0(pNode) ) );
Vec_PtrPushUnique( vFanins, Dar_ObjFanin1( Dar_ObjFanin1(pNode) ) );
Vec_PtrPushUnique( vFanins, Aig_ObjFanin0( Aig_ObjFanin0(pNode) ) );
Vec_PtrPushUnique( vFanins, Aig_ObjFanin0( Aig_ObjFanin1(pNode) ) );
Vec_PtrPushUnique( vFanins, Aig_ObjFanin1( Aig_ObjFanin0(pNode) ) );
Vec_PtrPushUnique( vFanins, Aig_ObjFanin1( Aig_ObjFanin1(pNode) ) );
Vec_PtrForEachEntry( vFanins, pFanin, k )
Fra_ObjAddToFrontier( p, Dar_Regular(pFanin), vFrontier );
Fra_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
Fra_AddClausesMux( p, pNode );
}
else
{
vFanins = Fra_CollectSuper( pNode, fUseMuxes );
Vec_PtrForEachEntry( vFanins, pFanin, k )
Fra_ObjAddToFrontier( p, Dar_Regular(pFanin), vFrontier );
Fra_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
Fra_AddClausesSuper( p, pNode, vFanins );
}
assert( Vec_PtrSize(vFanins) > 1 );
......
......@@ -39,15 +39,15 @@
SeeAlso []
***********************************************************************/
Dar_Man_t * Fra_Perform( Dar_Man_t * pManAig, Fra_Par_t * pPars )
Aig_Man_t * Fra_Perform( Aig_Man_t * pManAig, Fra_Par_t * pPars )
{
Fra_Man_t * p;
Dar_Man_t * pManAigNew;
Aig_Man_t * pManAigNew;
int clk;
if ( Dar_ManNodeNum(pManAig) == 0 )
return Dar_ManDup(pManAig);
if ( Aig_ManNodeNum(pManAig) == 0 )
return Aig_ManDup(pManAig);
clk = clock();
assert( Dar_ManLatchNum(pManAig) == 0 );
assert( Aig_ManLatchNum(pManAig) == 0 );
p = Fra_ManStart( pManAig, pPars );
Fra_Simulate( p );
Fra_Sweep( p );
......
......@@ -66,7 +66,7 @@ void Fra_ParamsDefault( Fra_Par_t * pPars )
SeeAlso []
***********************************************************************/
Fra_Man_t * Fra_ManStart( Dar_Man_t * pManAig, Fra_Par_t * pPars )
Fra_Man_t * Fra_ManStart( Aig_Man_t * pManAig, Fra_Par_t * pPars )
{
Fra_Man_t * p;
// allocate the fraiging manager
......@@ -74,15 +74,15 @@ Fra_Man_t * Fra_ManStart( Dar_Man_t * pManAig, Fra_Par_t * pPars )
memset( p, 0, sizeof(Fra_Man_t) );
p->pPars = pPars;
p->pManAig = pManAig;
p->pManFraig = Dar_ManStartFrom( pManAig );
assert( Dar_ManPiNum(p->pManAig) == Dar_ManPiNum(p->pManFraig) );
p->pManFraig = Aig_ManStartFrom( pManAig );
assert( Aig_ManPiNum(p->pManAig) == Aig_ManPiNum(p->pManFraig) );
// allocate simulation info
p->nSimWords = pPars->nSimWords;
p->pSimWords = ALLOC( unsigned, (Dar_ManObjIdMax(pManAig) + 1) * p->nSimWords );
p->pSimWords = ALLOC( unsigned, (Aig_ManObjIdMax(pManAig) + 1) * p->nSimWords );
// clean simulation info of the constant node
memset( p->pSimWords, 0, sizeof(unsigned) * ((Dar_ManPiNum(pManAig) + 1) * p->nSimWords) );
memset( p->pSimWords, 0, sizeof(unsigned) * ((Aig_ManPiNum(pManAig) + 1) * p->nSimWords) );
// allocate storage for sim pattern
p->nPatWords = Dar_BitWordNum( Dar_ManPiNum(pManAig) );
p->nPatWords = Aig_BitWordNum( Aig_ManPiNum(pManAig) );
p->pPatWords = ALLOC( unsigned, p->nPatWords );
p->pPatScores = ALLOC( int, 32 * p->nSimWords );
p->vPiVars = Vec_PtrAlloc( 100 );
......@@ -92,11 +92,11 @@ Fra_Man_t * Fra_ManStart( Dar_Man_t * pManAig, Fra_Par_t * pPars )
p->vClassNew = Vec_PtrAlloc( 100 );
p->vClassesTemp = Vec_PtrAlloc( 100 );
// allocate other members
p->nSizeAlloc = Dar_ManObjIdMax(pManAig) + 1;
p->pMemFraig = ALLOC( Dar_Obj_t *, p->nSizeAlloc );
memset( p->pMemFraig, 0, p->nSizeAlloc * sizeof(Dar_Obj_t *) );
p->pMemRepr = ALLOC( Dar_Obj_t *, p->nSizeAlloc );
memset( p->pMemRepr, 0, p->nSizeAlloc * sizeof(Dar_Obj_t *) );
p->nSizeAlloc = Aig_ManObjIdMax(pManAig) + 1;
p->pMemFraig = ALLOC( Aig_Obj_t *, p->nSizeAlloc );
memset( p->pMemFraig, 0, p->nSizeAlloc * sizeof(Aig_Obj_t *) );
p->pMemRepr = ALLOC( Aig_Obj_t *, p->nSizeAlloc );
memset( p->pMemRepr, 0, p->nSizeAlloc * sizeof(Aig_Obj_t *) );
p->pMemFanins = ALLOC( Vec_Ptr_t *, p->nSizeAlloc );
memset( p->pMemFanins, 0, p->nSizeAlloc * sizeof(Vec_Ptr_t *) );
p->pMemSatNums = ALLOC( int, p->nSizeAlloc );
......@@ -123,18 +123,18 @@ Fra_Man_t * Fra_ManStart( Dar_Man_t * pManAig, Fra_Par_t * pPars )
***********************************************************************/
void Fra_ManPrepare( Fra_Man_t * p )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
// set the pointers to the manager
Dar_ManForEachObj( p->pManFraig, pObj, i )
Aig_ManForEachObj( p->pManFraig, pObj, i )
pObj->pData = p;
// set the pointer to the manager
Dar_ManForEachObj( p->pManAig, pObj, i )
Aig_ManForEachObj( p->pManAig, pObj, i )
pObj->pData = p;
// set the pointers to the available fraig nodes
Fra_ObjSetFraig( Dar_ManConst1(p->pManAig), Dar_ManConst1(p->pManFraig) );
Dar_ManForEachPi( p->pManAig, pObj, i )
Fra_ObjSetFraig( pObj, Dar_ManPi(p->pManFraig, i) );
Fra_ObjSetFraig( Aig_ManConst1(p->pManAig), Aig_ManConst1(p->pManFraig) );
Aig_ManForEachPi( p->pManAig, pObj, i )
Fra_ObjSetFraig( pObj, Aig_ManPi(p->pManFraig, i) );
}
/**Function*************************************************************
......@@ -187,14 +187,14 @@ void Fra_ManStop( Fra_Man_t * p )
***********************************************************************/
void Fra_ManPrint( Fra_Man_t * p )
{
double nMemory = 1.0*Dar_ManObjIdMax(p->pManAig)*((p->nSimWords+2)*sizeof(unsigned)+6*sizeof(void*))/(1<<20);
double nMemory = 1.0*Aig_ManObjIdMax(p->pManAig)*((p->nSimWords+2)*sizeof(unsigned)+6*sizeof(void*))/(1<<20);
printf( "SimWords = %d. Rounds = %d. Mem = %0.2f Mb. ", p->nSimWords, p->nSimRounds, nMemory );
printf( "Classes: Beg = %d. End = %d.\n", p->nClassesBeg, p->nClassesEnd );
printf( "Limits: BTNode = %d. BTMiter = %d.\n", p->pPars->nBTLimitNode, p->pPars->nBTLimitMiter );
printf( "Proof = %d. Counter-example = %d. Fail = %d. FailReal = %d. Zero = %d.\n",
p->nSatProof, p->nSatCallsSat, p->nSatFails, p->nSatFailsReal, p->nClassesZero );
printf( "Final = %d. Miter = %d. Total = %d. Mux = %d. (Exor = %d.) SatVars = %d.\n",
Dar_ManNodeNum(p->pManFraig), p->nNodesMiter, Dar_ManNodeNum(p->pManAig), 0, 0, p->nSatVars );
Aig_ManNodeNum(p->pManFraig), p->nNodesMiter, Aig_ManNodeNum(p->pManAig), 0, 0, p->nSatVars );
if ( p->pSat ) Sat_SolverPrintStats( stdout, p->pSat );
PRT( "AIG simulation ", p->timeSim );
PRT( "AIG traversal ", p->timeTrav );
......
......@@ -24,7 +24,7 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static int Fra_SetActivityFactors( Fra_Man_t * p, Dar_Obj_t * pOld, Dar_Obj_t * pNew );
static int Fra_SetActivityFactors( Fra_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
......@@ -41,13 +41,13 @@ static int Fra_SetActivityFactors( Fra_Man_t * p, Dar_Obj_t * pOld, Dar_Obj_t *
SeeAlso []
***********************************************************************/
int Fra_NodesAreEquiv( Fra_Man_t * p, Dar_Obj_t * pOld, Dar_Obj_t * pNew )
int Fra_NodesAreEquiv( Fra_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
{
int pLits[4], RetValue, RetValue1, nBTLimit, clk, clk2 = clock();
// make sure the nodes are not complemented
assert( !Dar_IsComplement(pNew) );
assert( !Dar_IsComplement(pOld) );
assert( !Aig_IsComplement(pNew) );
assert( !Aig_IsComplement(pOld) );
assert( pNew != pOld );
// if at least one of the nodes is a failed node, perform adjustments:
......@@ -189,12 +189,12 @@ p->timeSatFail += clock() - clk;
SeeAlso []
***********************************************************************/
int Fra_NodeIsConst( Fra_Man_t * p, Dar_Obj_t * pNew )
int Fra_NodeIsConst( Fra_Man_t * p, Aig_Obj_t * pNew )
{
int pLits[2], RetValue1, RetValue, clk;
// make sure the nodes are not complemented
assert( !Dar_IsComplement(pNew) );
assert( !Aig_IsComplement(pNew) );
assert( pNew != p->pManFraig->pConst1 );
p->nSatCalls++;
......@@ -261,19 +261,19 @@ p->timeSatFail += clock() - clk;
SeeAlso []
***********************************************************************/
int Fra_SetActivityFactors_rec( Fra_Man_t * p, Dar_Obj_t * pObj, int LevelMin, int LevelMax )
int Fra_SetActivityFactors_rec( Fra_Man_t * p, Aig_Obj_t * pObj, int LevelMin, int LevelMax )
{
Vec_Ptr_t * vFanins;
Dar_Obj_t * pFanin;
Aig_Obj_t * pFanin;
int i, Counter = 0;
assert( !Dar_IsComplement(pObj) );
assert( !Aig_IsComplement(pObj) );
assert( Fra_ObjSatNum(pObj) );
// skip visited variables
if ( Dar_ObjIsTravIdCurrent(p->pManFraig, pObj) )
if ( Aig_ObjIsTravIdCurrent(p->pManFraig, pObj) )
return 0;
Dar_ObjSetTravIdCurrent(p->pManFraig, pObj);
Aig_ObjSetTravIdCurrent(p->pManFraig, pObj);
// add the PI to the list
if ( pObj->Level <= (unsigned)LevelMin || Dar_ObjIsPi(pObj) )
if ( pObj->Level <= (unsigned)LevelMin || Aig_ObjIsPi(pObj) )
return 0;
// set the factor of this variable
// (LevelMax-LevelMin) / (pObj->Level-LevelMin) = p->pPars->dActConeBumpMax / ThisBump
......@@ -282,7 +282,7 @@ int Fra_SetActivityFactors_rec( Fra_Man_t * p, Dar_Obj_t * pObj, int LevelMin, i
// explore the fanins
vFanins = Fra_ObjFaninVec( pObj );
Vec_PtrForEachEntry( vFanins, pFanin, i )
Counter += Fra_SetActivityFactors_rec( p, Dar_Regular(pFanin), LevelMin, LevelMax );
Counter += Fra_SetActivityFactors_rec( p, Aig_Regular(pFanin), LevelMin, LevelMax );
return 1 + Counter;
}
......@@ -297,7 +297,7 @@ int Fra_SetActivityFactors_rec( Fra_Man_t * p, Dar_Obj_t * pObj, int LevelMin, i
SeeAlso []
***********************************************************************/
int Fra_SetActivityFactors( Fra_Man_t * p, Dar_Obj_t * pOld, Dar_Obj_t * pNew )
int Fra_SetActivityFactors( Fra_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
{
int clk, LevelMin, LevelMax;
assert( pOld || pNew );
......@@ -305,15 +305,15 @@ clk = clock();
// reset the active variables
veci_resize(&p->pSat->act_vars, 0);
// prepare for traversal
Dar_ManIncrementTravId( p->pManFraig );
Aig_ManIncrementTravId( p->pManFraig );
// determine the min and max level to visit
assert( p->pPars->dActConeRatio > 0 && p->pPars->dActConeRatio < 1 );
LevelMax = DAR_MAX( (pNew ? pNew->Level : 0), (pOld ? pOld->Level : 0) );
LevelMax = AIG_MAX( (pNew ? pNew->Level : 0), (pOld ? pOld->Level : 0) );
LevelMin = (int)(LevelMax * (1.0 - p->pPars->dActConeRatio));
// traverse
if ( pOld && !Dar_ObjIsConst1(pOld) )
if ( pOld && !Aig_ObjIsConst1(pOld) )
Fra_SetActivityFactors_rec( p, pOld, LevelMin, LevelMax );
if ( pNew && !Dar_ObjIsConst1(pNew) )
if ( pNew && !Aig_ObjIsConst1(pNew) )
Fra_SetActivityFactors_rec( p, pNew, LevelMin, LevelMax );
//Fra_PrintActivity( p );
p->timeTrav += clock() - clk;
......
......@@ -39,11 +39,11 @@
SeeAlso []
***********************************************************************/
void Fra_NodeAssignRandom( Fra_Man_t * p, Dar_Obj_t * pObj )
void Fra_NodeAssignRandom( Fra_Man_t * p, Aig_Obj_t * pObj )
{
unsigned * pSims;
int i;
assert( Dar_ObjIsPi(pObj) );
assert( Aig_ObjIsPi(pObj) );
pSims = Fra_ObjSim(pObj);
for ( i = 0; i < p->nSimWords; i++ )
pSims[i] = Fra_ObjRandomSim();
......@@ -60,11 +60,11 @@ void Fra_NodeAssignRandom( Fra_Man_t * p, Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Fra_NodeAssignConst( Fra_Man_t * p, Dar_Obj_t * pObj, int fConst1 )
void Fra_NodeAssignConst( Fra_Man_t * p, Aig_Obj_t * pObj, int fConst1 )
{
unsigned * pSims;
int i;
assert( Dar_ObjIsPi(pObj) );
assert( Aig_ObjIsPi(pObj) );
pSims = Fra_ObjSim(pObj);
for ( i = 0; i < p->nSimWords; i++ )
pSims[i] = fConst1? ~(unsigned)0 : 0;
......@@ -83,9 +83,9 @@ void Fra_NodeAssignConst( Fra_Man_t * p, Dar_Obj_t * pObj, int fConst1 )
***********************************************************************/
void Fra_AssignRandom( Fra_Man_t * p )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
Dar_ManForEachPi( p->pManAig, pObj, i )
Aig_ManForEachPi( p->pManAig, pObj, i )
Fra_NodeAssignRandom( p, pObj );
}
......@@ -102,17 +102,17 @@ void Fra_AssignRandom( Fra_Man_t * p )
***********************************************************************/
void Fra_AssignDist1( Fra_Man_t * p, unsigned * pPat )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i, Limit;
Dar_ManForEachPi( p->pManAig, pObj, i )
Aig_ManForEachPi( p->pManAig, pObj, i )
{
Fra_NodeAssignConst( p, pObj, Dar_InfoHasBit(pPat, i) );
// printf( "%d", Dar_InfoHasBit(pPat, i) );
Fra_NodeAssignConst( p, pObj, Aig_InfoHasBit(pPat, i) );
// printf( "%d", Aig_InfoHasBit(pPat, i) );
}
// printf( "\n" );
Limit = DAR_MIN( Dar_ManPiNum(p->pManAig), p->nSimWords * 32 - 1 );
Limit = AIG_MIN( Aig_ManPiNum(p->pManAig), p->nSimWords * 32 - 1 );
for ( i = 0; i < Limit; i++ )
Dar_InfoXorBit( Fra_ObjSim( Dar_ManPi(p->pManAig,i) ), i+1 );
Aig_InfoXorBit( Fra_ObjSim( Aig_ManPi(p->pManAig,i) ), i+1 );
}
/**Function*************************************************************
......@@ -126,7 +126,7 @@ void Fra_AssignDist1( Fra_Man_t * p, unsigned * pPat )
SeeAlso []
***********************************************************************/
int Fra_NodeHasZeroSim( Fra_Man_t * p, Dar_Obj_t * pObj )
int Fra_NodeHasZeroSim( Fra_Man_t * p, Aig_Obj_t * pObj )
{
unsigned * pSims;
int i;
......@@ -148,7 +148,7 @@ int Fra_NodeHasZeroSim( Fra_Man_t * p, Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
void Fra_NodeComplementSim( Fra_Man_t * p, Dar_Obj_t * pObj )
void Fra_NodeComplementSim( Fra_Man_t * p, Aig_Obj_t * pObj )
{
unsigned * pSims;
int i;
......@@ -168,7 +168,7 @@ void Fra_NodeComplementSim( Fra_Man_t * p, Dar_Obj_t * pObj )
SeeAlso []
***********************************************************************/
int Fra_NodeCompareSims( Fra_Man_t * p, Dar_Obj_t * pObj0, Dar_Obj_t * pObj1 )
int Fra_NodeCompareSims( Fra_Man_t * p, Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
{
unsigned * pSims0, * pSims1;
int i;
......@@ -192,20 +192,20 @@ int Fra_NodeCompareSims( Fra_Man_t * p, Dar_Obj_t * pObj0, Dar_Obj_t * pObj1 )
SeeAlso []
***********************************************************************/
void Fra_NodeSimulate( Fra_Man_t * p, Dar_Obj_t * pObj )
void Fra_NodeSimulate( Fra_Man_t * p, Aig_Obj_t * pObj )
{
unsigned * pSims, * pSims0, * pSims1;
int fCompl, fCompl0, fCompl1, i;
assert( !Dar_IsComplement(pObj) );
assert( Dar_ObjIsNode(pObj) );
assert( !Aig_IsComplement(pObj) );
assert( Aig_ObjIsNode(pObj) );
// get hold of the simulation information
pSims = Fra_ObjSim(pObj);
pSims0 = Fra_ObjSim(Dar_ObjFanin0(pObj));
pSims1 = Fra_ObjSim(Dar_ObjFanin1(pObj));
pSims0 = Fra_ObjSim(Aig_ObjFanin0(pObj));
pSims1 = Fra_ObjSim(Aig_ObjFanin1(pObj));
// get complemented attributes of the children using their random info
fCompl = pObj->fPhase;
fCompl0 = Dar_ObjFaninPhase(Dar_ObjChild0(pObj));
fCompl1 = Dar_ObjFaninPhase(Dar_ObjChild1(pObj));
fCompl0 = Aig_ObjFaninPhase(Aig_ObjChild0(pObj));
fCompl1 = Aig_ObjFaninPhase(Aig_ObjChild1(pObj));
// simulate
if ( fCompl0 && fCompl1 )
{
......@@ -290,13 +290,13 @@ void Fra_SavePattern1( Fra_Man_t * p )
***********************************************************************/
void Fra_SavePattern( Fra_Man_t * p )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
memset( p->pPatWords, 0, sizeof(unsigned) * p->nPatWords );
Dar_ManForEachPi( p->pManFraig, pObj, i )
Aig_ManForEachPi( p->pManFraig, pObj, i )
// Vec_PtrForEachEntry( p->vPiVars, pObj, i )
if ( p->pSat->model.ptr[Fra_ObjSatNum(pObj)] == l_True )
Dar_InfoSetBit( p->pPatWords, i );
Aig_InfoSetBit( p->pPatWords, i );
// Ivy_InfoSetBit( p->pPatWords, pObj->Id - 1 );
}
......@@ -329,7 +329,7 @@ void Fra_CleanPatScores( Fra_Man_t * p )
SeeAlso []
***********************************************************************/
void Fra_AddToPatScores( Fra_Man_t * p, Dar_Obj_t * pClass, Dar_Obj_t * pClassNew )
void Fra_AddToPatScores( Fra_Man_t * p, Aig_Obj_t * pClass, Aig_Obj_t * pClassNew )
{
unsigned * pSims0, * pSims1;
unsigned uDiff;
......@@ -363,7 +363,7 @@ void Fra_AddToPatScores( Fra_Man_t * p, Dar_Obj_t * pClass, Dar_Obj_t * pClassNe
int Fra_SelectBestPat( Fra_Man_t * p )
{
unsigned * pSims;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i, nLimit = p->nSimWords * 32, MaxScore = 0, BestPat = -1;
for ( i = 1; i < nLimit; i++ )
{
......@@ -379,11 +379,11 @@ int Fra_SelectBestPat( Fra_Man_t * p )
// printf( "Max score is %3d. ", MaxScore );
// copy the best pattern into the selected pattern
memset( p->pPatWords, 0, sizeof(unsigned) * p->nPatWords );
Dar_ManForEachPi( p->pManAig, pObj, i )
Aig_ManForEachPi( p->pManAig, pObj, i )
{
pSims = Fra_ObjSim(pObj);
if ( Dar_InfoHasBit(pSims, BestPat) )
Dar_InfoSetBit(p->pPatWords, i);
if ( Aig_InfoHasBit(pSims, BestPat) )
Aig_InfoSetBit(p->pPatWords, i);
}
return MaxScore;
}
......@@ -401,17 +401,17 @@ int Fra_SelectBestPat( Fra_Man_t * p )
***********************************************************************/
void Fra_SimulateOne( Fra_Man_t * p )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i, clk;
clk = clock();
Dar_ManForEachNode( p->pManAig, pObj, i )
Aig_ManForEachNode( p->pManAig, pObj, i )
{
Fra_NodeSimulate( p, pObj );
/*
if ( Dar_ObjFraig(pObj) == NULL )
if ( Aig_ObjFraig(pObj) == NULL )
printf( "%3d --- -- %d : ", pObj->Id, pObj->fPhase );
else
printf( "%3d %3d %2d %d : ", pObj->Id, Dar_Regular(Dar_ObjFraig(pObj))->Id, Dar_ObjSatNum(Dar_Regular(Dar_ObjFraig(pObj))), pObj->fPhase );
printf( "%3d %3d %2d %d : ", pObj->Id, Aig_Regular(Aig_ObjFraig(pObj))->Id, Aig_ObjSatNum(Aig_Regular(Aig_ObjFraig(pObj))), pObj->fPhase );
Extra_PrintBinary( stdout, Fra_ObjSim(pObj), 30 );
printf( "\n" );
*/
......@@ -527,7 +527,7 @@ void Fra_Simulate( Fra_Man_t * p )
SeeAlso []
***********************************************************************/
void Fra_CheckOutputSimsSavePattern( Fra_Man_t * p, Dar_Obj_t * pObj )
void Fra_CheckOutputSimsSavePattern( Fra_Man_t * p, Aig_Obj_t * pObj )
{
unsigned * pSims;
int i, k, BestPat, * pModel;
......@@ -545,10 +545,10 @@ void Fra_CheckOutputSimsSavePattern( Fra_Man_t * p, Dar_Obj_t * pObj )
// determine the best pattern
BestPat = i * 32 + k;
// fill in the counter-example data
pModel = ALLOC( int, Dar_ManPiNum(p->pManFraig) );
Dar_ManForEachPi( p->pManAig, pObj, i )
pModel = ALLOC( int, Aig_ManPiNum(p->pManFraig) );
Aig_ManForEachPi( p->pManAig, pObj, i )
{
pModel[i] = Dar_InfoHasBit(Fra_ObjSim(pObj), BestPat);
pModel[i] = Aig_InfoHasBit(Fra_ObjSim(pObj), BestPat);
// printf( "%d", pModel[i] );
}
// printf( "\n" );
......@@ -571,26 +571,26 @@ void Fra_CheckOutputSimsSavePattern( Fra_Man_t * p, Dar_Obj_t * pObj )
***********************************************************************/
int Fra_CheckOutputSims( Fra_Man_t * p )
{
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
// make sure the reference simulation pattern does not detect the bug
pObj = Dar_ManPo( p->pManAig, 0 );
assert( Dar_ObjFanin0(pObj)->fPhase == (unsigned)Dar_ObjFaninC0(pObj) ); // Dar_ObjFaninPhase(Dar_ObjChild0(pObj)) == 0
Dar_ManForEachPo( p->pManAig, pObj, i )
pObj = Aig_ManPo( p->pManAig, 0 );
assert( Aig_ObjFanin0(pObj)->fPhase == (unsigned)Aig_ObjFaninC0(pObj) ); // Aig_ObjFaninPhase(Aig_ObjChild0(pObj)) == 0
Aig_ManForEachPo( p->pManAig, pObj, i )
{
// complement simulation info
// if ( Dar_ObjFanin0(pObj)->fPhase ^ Dar_ObjFaninC0(pObj) ) // Dar_ObjFaninPhase(Dar_ObjChild0(pObj))
// Fra_NodeComplementSim( p, Dar_ObjFanin0(pObj) );
// if ( Aig_ObjFanin0(pObj)->fPhase ^ Aig_ObjFaninC0(pObj) ) // Aig_ObjFaninPhase(Aig_ObjChild0(pObj))
// Fra_NodeComplementSim( p, Aig_ObjFanin0(pObj) );
// check
if ( !Fra_NodeHasZeroSim( p, Dar_ObjFanin0(pObj) ) )
if ( !Fra_NodeHasZeroSim( p, Aig_ObjFanin0(pObj) ) )
{
// create the counter-example from this pattern
Fra_CheckOutputSimsSavePattern( p, Dar_ObjFanin0(pObj) );
Fra_CheckOutputSimsSavePattern( p, Aig_ObjFanin0(pObj) );
return 1;
}
// complement simulation info
// if ( Dar_ObjFanin0(pObj)->fPhase ^ Dar_ObjFaninC0(pObj) )
// Fra_NodeComplementSim( p, Dar_ObjFanin0(pObj) );
// if ( Aig_ObjFanin0(pObj)->fPhase ^ Aig_ObjFaninC0(pObj) )
// Fra_NodeComplementSim( p, Aig_ObjFanin0(pObj) );
}
return 0;
}
......
SRC += src/aig/kit/kitBdd.c \
src/aig/kit/kitDsd.c \
src/aig/kit/kitFactor.c \
src/aig/kit/kitGraph.c \
src/aig/kit/kitHop.c \
src/aig/kit/kitIsop.c \
src/aig/kit/kitSop.c \
src/aig/kit/kitTruth.c
......@@ -27,6 +27,8 @@
#include "if.h"
#include "res.h"
#include "lpk.h"
#include "aig.h"
#include "dar.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -108,6 +110,7 @@ static int Abc_CommandQuaReach ( Abc_Frame_t * pAbc, int argc, char ** arg
static int Abc_CommandIStrash ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandICut ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIRewriteSeq ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIResyn ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandISat ( Abc_Frame_t * pAbc, int argc, char ** argv );
......@@ -265,6 +268,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "New AIG", "istrash", Abc_CommandIStrash, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "icut", Abc_CommandICut, 0 );
Cmd_CommandAdd( pAbc, "New AIG", "irw", Abc_CommandIRewrite, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "drw", Abc_CommandDRewrite, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "irws", Abc_CommandIRewriteSeq, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "iresyn", Abc_CommandIResyn, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "isat", Abc_CommandISat, 1 );
......@@ -337,7 +341,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
{
extern void Dar_LibStart();
// Dar_LibStart();
Dar_LibStart();
}
}
......@@ -354,13 +358,16 @@ void Abc_Init( Abc_Frame_t * pAbc )
***********************************************************************/
void Abc_End()
{
// Dar_LibDumpPriorities();
{
extern void Dar_LibStop();
// Dar_LibStop();
Dar_LibStop();
}
Abc_NtkFraigStoreClean();
// Rwt_Man4ExplorePrint();
}
/**Function*************************************************************
......@@ -6081,14 +6088,13 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
// Abc_Ntk4VarTable( pNtk );
// Dar_NtkGenerateArrays( pNtk );
// Dar_ManDeriveCnfTest2();
/*
if ( !Abc_NtkIsStrash(pNtk) )
{
fprintf( pErr, "Network should be strashed. Command has failed.\n" );
return 1;
}
*/
// pNtkRes = Abc_NtkDar( pNtk );
pNtkRes = Abc_NtkDar( pNtk );
// pNtkRes = Abc_NtkDarToCnf( pNtk, "any.cnf" );
pNtkRes = NULL;
if ( pNtkRes == NULL )
......@@ -6609,6 +6615,105 @@ usage:
SeeAlso []
***********************************************************************/
int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
Dar_Par_t Pars, * pPars = &Pars;
int c;
extern Abc_Ntk_t * Abc_NtkDRewrite( Abc_Ntk_t * pNtk, Dar_Par_t * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set defaults
Dar_ManDefaultParams( pPars );
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "CNlzvwh" ) ) != EOF )
{
switch ( c )
{
case 'C':
if ( globalUtilOptind >= argc )
{
fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nCutsMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->nCutsMax < 0 )
goto usage;
break;
case 'N':
if ( globalUtilOptind >= argc )
{
fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nSubgMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->nSubgMax < 0 )
goto usage;
break;
case 'l':
pPars->fUpdateLevel ^= 1;
break;
case 'z':
pPars->fUseZeros ^= 1;
break;
case 'v':
pPars->fVerbose ^= 1;
break;
case 'w':
pPars->fVeryVerbose ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pNtk == NULL )
{
fprintf( pErr, "Empty network.\n" );
return 1;
}
pNtkRes = Abc_NtkDRewrite( pNtk, pPars );
if ( pNtkRes == NULL )
{
fprintf( pErr, "Command has failed.\n" );
return 0;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
fprintf( pErr, "usage: drw [-C num] [-N num] [-lzvwh]\n" );
fprintf( pErr, "\t perform combinational AIG rewriting\n" );
fprintf( pErr, "\t-C num : limit on the number of cuts at a node [default = %d]\n", pPars->nCutsMax );
fprintf( pErr, "\t-N num : limit on the number of subgraphs tried [default = %d]\n", pPars->nSubgMax );
fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
fprintf( pErr, "\t-w : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandIRewriteSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr;
......@@ -7023,7 +7128,7 @@ int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults
nCutsMax = 8;
nLeafMax = 8;
nLeafMax = 6;
fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "CKvh" ) ) != EOF )
......@@ -7067,6 +7172,18 @@ int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
if ( nCutsMax < 2 )
{
fprintf( pErr, "The number of cuts cannot be less than 2.\n" );
return 1;
}
if ( nLeafMax < 3 || nLeafMax > 16 )
{
fprintf( pErr, "The number of leaves is infeasible.\n" );
return 1;
}
pNtkRes = Abc_NtkCSweep( pNtk, nCutsMax, nLeafMax, fVerbose );
if ( pNtkRes == NULL )
{
......@@ -7080,8 +7197,8 @@ int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
usage:
fprintf( pErr, "usage: csweep [-C num] [-K num] [-vh]\n" );
fprintf( pErr, "\t performs cut sweeping using a new method\n" );
fprintf( pErr, "\t-C num : limit on the number of cuts [default = %d]\n", nCutsMax );
fprintf( pErr, "\t-K num : limit on the cut size [default = %d]\n", nLeafMax );
fprintf( pErr, "\t-C num : limit on the number of cuts (C >= 2) [default = %d]\n", nCutsMax );
fprintf( pErr, "\t-K num : limit on the cut size (3 <= K <= 16) [default = %d]\n", nLeafMax );
fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
return 1;
......
......@@ -19,6 +19,7 @@
***********************************************************************/
#include "abc.h"
#include "aig.h"
#include "dar.h"
#include "cnf.h"
#include "fra.h"
......@@ -42,27 +43,33 @@
SeeAlso []
***********************************************************************/
Dar_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk )
Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk )
{
Dar_Man_t * pMan;
Aig_Man_t * pMan;
Abc_Obj_t * pObj;
int i;
// create the manager
pMan = Dar_ManStart( Abc_NtkNodeNum(pNtk) + 100 );
pMan = Aig_ManStart( Abc_NtkNodeNum(pNtk) + 100 );
// transfer the pointers to the basic nodes
Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)Dar_ManConst1(pMan);
Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)Aig_ManConst1(pMan);
Abc_NtkForEachCi( pNtk, pObj, i )
pObj->pCopy = (Abc_Obj_t *)Dar_ObjCreatePi(pMan);
pObj->pCopy = (Abc_Obj_t *)Aig_ObjCreatePi(pMan);
// perform the conversion of the internal nodes (assumes DFS ordering)
Abc_NtkForEachNode( pNtk, pObj, i )
{
pObj->pCopy = (Abc_Obj_t *)Dar_And( pMan, (Dar_Obj_t *)Abc_ObjChild0Copy(pObj), (Dar_Obj_t *)Abc_ObjChild1Copy(pObj) );
// printf( "%d->%d ", pObj->Id, ((Dar_Obj_t *)pObj->pCopy)->Id );
pObj->pCopy = (Abc_Obj_t *)Aig_And( pMan, (Aig_Obj_t *)Abc_ObjChild0Copy(pObj), (Aig_Obj_t *)Abc_ObjChild1Copy(pObj) );
// printf( "%d->%d ", pObj->Id, ((Aig_Obj_t *)pObj->pCopy)->Id );
}
// create the POs
Abc_NtkForEachCo( pNtk, pObj, i )
Dar_ObjCreatePo( pMan, (Dar_Obj_t *)Abc_ObjChild0Copy(pObj) );
Dar_ManCleanup( pMan );
Aig_ObjCreatePo( pMan, (Aig_Obj_t *)Abc_ObjChild0Copy(pObj) );
Aig_ManCleanup( pMan );
if ( !Aig_ManCheck( pMan ) )
{
printf( "Abc_NtkToDar: AIG check has failed.\n" );
Aig_ManStop( pMan );
return NULL;
}
return pMan;
}
......@@ -77,29 +84,29 @@ Dar_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkFromDar( Abc_Ntk_t * pNtkOld, Dar_Man_t * pMan )
Abc_Ntk_t * Abc_NtkFromDar( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
{
Vec_Ptr_t * vNodes;
Abc_Ntk_t * pNtkNew;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
// perform strashing
pNtkNew = Abc_NtkStartFrom( pNtkOld, ABC_NTK_STRASH, ABC_FUNC_AIG );
// transfer the pointers to the basic nodes
Dar_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew);
Dar_ManForEachPi( pMan, pObj, i )
Aig_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew);
Aig_ManForEachPi( pMan, pObj, i )
pObj->pData = Abc_NtkCi(pNtkNew, i);
// rebuild the AIG
vNodes = Dar_ManDfs( pMan );
vNodes = Aig_ManDfs( pMan );
Vec_PtrForEachEntry( vNodes, pObj, i )
if ( Dar_ObjIsBuf(pObj) )
pObj->pData = (Abc_Obj_t *)Dar_ObjChild0Copy(pObj);
if ( Aig_ObjIsBuf(pObj) )
pObj->pData = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj);
else
pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Dar_ObjChild0Copy(pObj), (Abc_Obj_t *)Dar_ObjChild1Copy(pObj) );
pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
Vec_PtrFree( vNodes );
// connect the PO nodes
Dar_ManForEachPo( pMan, pObj, i )
Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), (Abc_Obj_t *)Dar_ObjChild0Copy(pObj) );
Aig_ManForEachPo( pMan, pObj, i )
Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), (Abc_Obj_t *)Aig_ObjChild0Copy(pObj) );
if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkFromDar(): Network check has failed.\n" );
return pNtkNew;
......@@ -116,24 +123,24 @@ Abc_Ntk_t * Abc_NtkFromDar( Abc_Ntk_t * pNtkOld, Dar_Man_t * pMan )
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkFromDarSeq( Abc_Ntk_t * pNtkOld, Dar_Man_t * pMan )
Abc_Ntk_t * Abc_NtkFromDarSeq( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
{
Vec_Ptr_t * vNodes;
Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pObjNew, * pFaninNew, * pFaninNew0, * pFaninNew1;
Dar_Obj_t * pObj;
Aig_Obj_t * pObj;
int i;
// assert( Dar_ManLatchNum(pMan) > 0 );
// assert( Aig_ManLatchNum(pMan) > 0 );
// perform strashing
pNtkNew = Abc_NtkStartFromNoLatches( pNtkOld, ABC_NTK_STRASH, ABC_FUNC_AIG );
// transfer the pointers to the basic nodes
Dar_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew);
Dar_ManForEachPi( pMan, pObj, i )
Aig_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew);
Aig_ManForEachPi( pMan, pObj, i )
pObj->pData = Abc_NtkPi(pNtkNew, i);
// create latches of the new network
Dar_ManForEachObj( pMan, pObj, i )
Aig_ManForEachObj( pMan, pObj, i )
{
if ( !Dar_ObjIsLatch(pObj) )
if ( !Aig_ObjIsLatch(pObj) )
continue;
pObjNew = Abc_NtkCreateLatch( pNtkNew );
pFaninNew0 = Abc_NtkCreateBi( pNtkNew );
......@@ -145,34 +152,34 @@ Abc_Ntk_t * Abc_NtkFromDarSeq( Abc_Ntk_t * pNtkOld, Dar_Man_t * pMan )
}
Abc_NtkAddDummyBoxNames( pNtkNew );
// rebuild the AIG
vNodes = Dar_ManDfs( pMan );
vNodes = Aig_ManDfs( pMan );
Vec_PtrForEachEntry( vNodes, pObj, i )
{
// add the first fanin
pObj->pData = pFaninNew0 = (Abc_Obj_t *)Dar_ObjChild0Copy(pObj);
if ( Dar_ObjIsBuf(pObj) )
pObj->pData = pFaninNew0 = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj);
if ( Aig_ObjIsBuf(pObj) )
continue;
// add the second fanin
pFaninNew1 = (Abc_Obj_t *)Dar_ObjChild1Copy(pObj);
pFaninNew1 = (Abc_Obj_t *)Aig_ObjChild1Copy(pObj);
// create the new node
if ( Dar_ObjIsExor(pObj) )
if ( Aig_ObjIsExor(pObj) )
pObj->pData = pObjNew = Abc_AigXor( pNtkNew->pManFunc, pFaninNew0, pFaninNew1 );
else
pObj->pData = pObjNew = Abc_AigAnd( pNtkNew->pManFunc, pFaninNew0, pFaninNew1 );
}
Vec_PtrFree( vNodes );
// connect the PO nodes
Dar_ManForEachPo( pMan, pObj, i )
Aig_ManForEachPo( pMan, pObj, i )
{
pFaninNew = (Abc_Obj_t *)Dar_ObjChild0Copy( pObj );
pFaninNew = (Abc_Obj_t *)Aig_ObjChild0Copy( pObj );
Abc_ObjAddFanin( Abc_NtkPo(pNtkNew, i), pFaninNew );
}
// connect the latches
Dar_ManForEachObj( pMan, pObj, i )
Aig_ManForEachObj( pMan, pObj, i )
{
if ( !Dar_ObjIsLatch(pObj) )
if ( !Aig_ObjIsLatch(pObj) )
continue;
pFaninNew = (Abc_Obj_t *)Dar_ObjChild0Copy( pObj );
pFaninNew = (Abc_Obj_t *)Aig_ObjChild0Copy( pObj );
Abc_ObjAddFanin( Abc_ObjFanin0(Abc_ObjFanin0(pObj->pData)), pFaninNew );
}
if ( !Abc_NtkCheck( pNtkNew ) )
......@@ -215,7 +222,7 @@ int * Abc_NtkGetLatchValues( Abc_Ntk_t * pNtk )
void Abc_NtkSecRetime( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
{
int fRemove1, fRemove2;
Dar_Man_t * pMan1, * pMan2;
Aig_Man_t * pMan1, * pMan2;
int * pArray;
fRemove1 = (!Abc_NtkIsStrash(pNtk1)) && (pNtk1 = Abc_NtkStrash(pNtk1, 0, 0, 0));
......@@ -225,22 +232,22 @@ void Abc_NtkSecRetime( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
pMan1 = Abc_NtkToDar( pNtk1 );
pMan2 = Abc_NtkToDar( pNtk2 );
Dar_ManPrintStats( pMan1 );
Dar_ManPrintStats( pMan2 );
Aig_ManPrintStats( pMan1 );
Aig_ManPrintStats( pMan2 );
pArray = Abc_NtkGetLatchValues(pNtk1);
Dar_ManSeqStrash( pMan1, Abc_NtkLatchNum(pNtk1), pArray );
Aig_ManSeqStrash( pMan1, Abc_NtkLatchNum(pNtk1), pArray );
free( pArray );
pArray = Abc_NtkGetLatchValues(pNtk2);
Dar_ManSeqStrash( pMan2, Abc_NtkLatchNum(pNtk2), pArray );
Aig_ManSeqStrash( pMan2, Abc_NtkLatchNum(pNtk2), pArray );
free( pArray );
Dar_ManPrintStats( pMan1 );
Dar_ManPrintStats( pMan2 );
Aig_ManPrintStats( pMan1 );
Aig_ManPrintStats( pMan2 );
Dar_ManStop( pMan1 );
Dar_ManStop( pMan2 );
Aig_ManStop( pMan1 );
Aig_ManStop( pMan2 );
if ( fRemove1 ) Abc_NtkDelete( pNtk1 );
......@@ -261,7 +268,7 @@ void Abc_NtkSecRetime( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
Abc_Ntk_t * Abc_NtkDar( Abc_Ntk_t * pNtk )
{
Abc_Ntk_t * pNtkAig;
Dar_Man_t * pMan;//, * pTemp;
Aig_Man_t * pMan;//, * pTemp;
// int * pArray;
assert( Abc_NtkIsStrash(pNtk) );
......@@ -269,45 +276,44 @@ Abc_Ntk_t * Abc_NtkDar( Abc_Ntk_t * pNtk )
pMan = Abc_NtkToDar( pNtk );
if ( pMan == NULL )
return NULL;
if ( !Dar_ManCheck( pMan ) )
if ( !Aig_ManCheck( pMan ) )
{
printf( "Abc_NtkDar: AIG check has failed.\n" );
Dar_ManStop( pMan );
Aig_ManStop( pMan );
return NULL;
}
// perform balance
Dar_ManPrintStats( pMan );
Aig_ManPrintStats( pMan );
/*
pArray = Abc_NtkGetLatchValues(pNtk);
Dar_ManSeqStrash( pMan, Abc_NtkLatchNum(pNtk), pArray );
Aig_ManSeqStrash( pMan, Abc_NtkLatchNum(pNtk), pArray );
free( pArray );
*/
// Dar_ManDumpBlif( pMan, "aig_temp.blif" );
// Aig_ManDumpBlif( pMan, "aig_temp.blif" );
// pMan->pPars = Dar_ManDefaultParams();
Dar_ManRewrite( pMan );
Dar_ManPrintStats( pMan );
Dar_ManPrintRuntime( pMan );
Dar_ManRewrite( pMan, NULL );
Aig_ManPrintStats( pMan );
// Dar_ManComputeCuts( pMan );
/*
{
extern Dar_Cnf_t * Dar_ManDeriveCnf( Dar_Man_t * p );
extern void Dar_CnfFree( Dar_Cnf_t * pCnf );
Dar_Cnf_t * pCnf;
pCnf = Dar_ManDeriveCnf( pMan );
Dar_CnfFree( pCnf );
extern Aig_Cnf_t * Aig_ManDeriveCnf( Aig_Man_t * p );
extern void Aig_CnfFree( Aig_Cnf_t * pCnf );
Aig_Cnf_t * pCnf;
pCnf = Aig_ManDeriveCnf( pMan );
Aig_CnfFree( pCnf );
}
*/
// convert from the AIG manager
if ( Dar_ManLatchNum(pMan) )
if ( Aig_ManLatchNum(pMan) )
pNtkAig = Abc_NtkFromDarSeq( pNtk, pMan );
else
pNtkAig = Abc_NtkFromDar( pNtk, pMan );
if ( pNtkAig == NULL )
return NULL;
Dar_ManStop( pMan );
Aig_ManStop( pMan );
// make sure everything is okay
if ( !Abc_NtkCheck( pNtkAig ) )
{
......@@ -334,7 +340,7 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t
{
Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pNode, * pNodeNew;
Dar_Obj_t * pObj, * pLeaf;
Aig_Obj_t * pObj, * pLeaf;
Cnf_Cut_t * pCut;
Vec_Int_t * vCover;
unsigned uTruth;
......@@ -342,9 +348,9 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t
// create the new network
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
// make the mapper point to the new network
Dar_ManConst1(p->pManAig)->pData = Abc_NtkCreateNodeConst1(pNtkNew);
Aig_ManConst1(p->pManAig)->pData = Abc_NtkCreateNodeConst1(pNtkNew);
Abc_NtkForEachCi( pNtk, pNode, i )
Dar_ManPi(p->pManAig, i)->pData = pNode->pCopy;
Aig_ManPi(p->pManAig, i)->pData = pNode->pCopy;
// process the nodes in topological order
vCover = Vec_IntAlloc( 1 << 16 );
Vec_PtrForEachEntry( vMapped, pObj, i )
......@@ -371,13 +377,13 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t
// add the CO drivers
Abc_NtkForEachCo( pNtk, pNode, i )
{
pObj = Dar_ManPo(p->pManAig, i);
pNodeNew = Abc_ObjNotCond( Dar_ObjFanin0(pObj)->pData, Dar_ObjFaninC0(pObj) );
pObj = Aig_ManPo(p->pManAig, i);
pNodeNew = Abc_ObjNotCond( Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
}
// remove the constant node if not used
pNodeNew = (Abc_Obj_t *)Dar_ManConst1(p->pManAig)->pData;
pNodeNew = (Abc_Obj_t *)Aig_ManConst1(p->pManAig)->pData;
if ( Abc_ObjFanoutNum(pNodeNew) == 0 )
Abc_NtkDeleteObj( pNodeNew );
// minimize the node
......@@ -406,21 +412,21 @@ Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName )
{
Abc_Ntk_t * pNtkNew = NULL;
Cnf_Man_t * pCnf;
Dar_Man_t * pMan;
Aig_Man_t * pMan;
Cnf_Dat_t * pData;
assert( Abc_NtkIsStrash(pNtk) );
// convert to the AIG manager
pMan = Abc_NtkToDar( pNtk );
if ( pMan == NULL )
return NULL;
if ( !Dar_ManCheck( pMan ) )
if ( !Aig_ManCheck( pMan ) )
{
printf( "Abc_NtkDarToCnf: AIG check has failed.\n" );
Dar_ManStop( pMan );
Aig_ManStop( pMan );
return NULL;
}
// perform balance
Dar_ManPrintStats( pMan );
Aig_ManPrintStats( pMan );
// derive CNF
pCnf = Cnf_ManStart();
......@@ -433,7 +439,7 @@ Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName )
Vec_PtrFree( vMapped );
}
Dar_ManStop( pMan );
Aig_ManStop( pMan );
Cnf_ManStop( pCnf );
// write CNF into a file
......@@ -459,7 +465,7 @@ Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, in
{
Fra_Par_t Params, * pParams = &Params;
Abc_Ntk_t * pNtkAig;
Dar_Man_t * pMan, * pTemp;
Aig_Man_t * pMan, * pTemp;
pMan = Abc_NtkToDar( pNtk );
if ( pMan == NULL )
return NULL;
......@@ -471,8 +477,8 @@ Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, in
pParams->fSpeculate = fSpeculate;
pMan = Fra_Perform( pTemp = pMan, pParams );
pNtkAig = Abc_NtkFromDar( pNtk, pMan );
Dar_ManStop( pTemp );
Dar_ManStop( pMan );
Aig_ManStop( pTemp );
Aig_ManStop( pMan );
return pNtkAig;
}
......@@ -489,16 +495,43 @@ Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, in
***********************************************************************/
Abc_Ntk_t * Abc_NtkCSweep( Abc_Ntk_t * pNtk, int nCutsMax, int nLeafMax, int fVerbose )
{
extern Dar_Man_t * Csw_Sweep( Dar_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose );
extern Aig_Man_t * Csw_Sweep( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose );
Abc_Ntk_t * pNtkAig;
Dar_Man_t * pMan, * pTemp;
Aig_Man_t * pMan, * pTemp;
pMan = Abc_NtkToDar( pNtk );
if ( pMan == NULL )
return NULL;
pMan = Csw_Sweep( pTemp = pMan, nCutsMax, nLeafMax, fVerbose );
pNtkAig = Abc_NtkFromDar( pNtk, pMan );
Dar_ManStop( pTemp );
Dar_ManStop( pMan );
Aig_ManStop( pTemp );
Aig_ManStop( pMan );
return pNtkAig;
}
/**Function*************************************************************
Synopsis [Gives the current ABC network to AIG manager for processing.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkDRewrite( Abc_Ntk_t * pNtk, Dar_Par_t * pPars )
{
Aig_Man_t * pMan;
Abc_Ntk_t * pNtkAig;
assert( Abc_NtkIsStrash(pNtk) );
pMan = Abc_NtkToDar( pNtk );
if ( pMan == NULL )
return NULL;
// Aig_ManPrintStats( pMan );
Dar_ManRewrite( pMan, pPars );
// Aig_ManPrintStats( pMan );
pNtkAig = Abc_NtkFromDar( pNtk, pMan );
Aig_ManStop( pMan );
return pNtkAig;
}
......
......@@ -76,6 +76,7 @@ static inline int If_CutCheckEquality( If_Cut_t * pDom, If_Cut_t * pCut )
return 0;
return 1;
}
/**Function*************************************************************
Synopsis [Returns 1 if the cut is contained.]
......
SRC += src/opt/res/resCore.c \
src/opt/res/resDivs.c \
src/opt/res/resFilter.c \
src/opt/res/resSat.c \
src/opt/res/resSim.c \
src/opt/res/resStrash.c \
src/opt/res/resUpdate.c \
src/opt/res/resWin.c
SRC += src/opt/kit/kitBdd.c \
src/opt/kit/kitDsd.c \
src/opt/kit/kitFactor.c \
src/opt/kit/kitGraph.c \
src/opt/kit/kitHop.c \
src/opt/kit/kitIsop.c \
src/opt/kit/kitSop.c \
src/opt/kit/kitTruth.c
......@@ -56,13 +56,13 @@ int Rwr_NodeRewrite( Rwr_Man_t * p, Cut_Man_t * pManCut, Abc_Obj_t * pNode, int
{
int fVeryVerbose = 0;
Dec_Graph_t * pGraph;
Cut_Cut_t * pCut;
Cut_Cut_t * pCut;//, * pTemp;
Abc_Obj_t * pFanin;
unsigned uPhase, uTruthBest, uTruth;
char * pPerm;
int Required, nNodesSaved, nNodesSaveCur;
int i, GainCur, GainBest = -1;
int clk, clk2;
int clk, clk2;//, Counter;
p->nNodesConsidered++;
// get the required times
......@@ -75,7 +75,12 @@ clk = clock();
p->timeCut += clock() - clk;
//printf( " %d", Rwr_CutCountNumNodes(pNode, pCut) );
/*
Counter = 0;
for ( pTemp = pCut->pNext; pTemp; pTemp = pTemp->pNext )
Counter++;
printf( "%d ", Counter );
*/
// go through the cuts
clk = clock();
for ( pCut = pCut->pNext; pCut; pCut = pCut->pNext )
......
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