summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2007-07-12 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2007-07-12 08:01:00 -0700
commitc5277d3334e3dbca556fbf82bbe1c0cacdc85cb1 (patch)
treec6ea67f6b0a823cc097de6b61c9195ffafdb08b1
parent066726076deedaf6d5b38ee4ed27eeb4a2b0061a (diff)
downloadabc-c5277d3334e3dbca556fbf82bbe1c0cacdc85cb1.tar.gz
abc-c5277d3334e3dbca556fbf82bbe1c0cacdc85cb1.tar.bz2
abc-c5277d3334e3dbca556fbf82bbe1c0cacdc85cb1.zip
Version abc70712
-rw-r--r--Makefile6
-rw-r--r--abc.dsp868
-rw-r--r--abc.rc4
-rw-r--r--src/aig/aig/aig.h373
-rw-r--r--src/aig/aig/aigCheck.c (renamed from src/aig/dar/darCheck.c)62
-rw-r--r--src/aig/aig/aigDfs.c (renamed from src/aig/dar/darDfs.c)216
-rw-r--r--src/aig/aig/aigMan.c224
-rw-r--r--src/aig/aig/aigMem.c (renamed from src/aig/dar/darMem.c)86
-rw-r--r--src/aig/aig/aigObj.c (renamed from src/aig/dar/darObj.c)164
-rw-r--r--src/aig/aig/aigOper.c (renamed from src/aig/dar/darOper.c)224
-rw-r--r--src/aig/aig/aigSeq.c (renamed from src/aig/dar/darSeq.c)282
-rw-r--r--src/aig/aig/aigTable.c (renamed from src/aig/dar/darTable.c)110
-rw-r--r--src/aig/aig/aigUtil.c (renamed from src/aig/dar/darUtil.c)355
-rw-r--r--src/aig/aig/aig_.c48
-rw-r--r--src/aig/aig/module.make9
-rw-r--r--src/aig/bdc/bdc.h (renamed from src/opt/bdc/bdc.h)0
-rw-r--r--src/aig/bdc/bdcCore.c (renamed from src/opt/bdc/bdcCore.c)0
-rw-r--r--src/aig/bdc/bdcDec.c (renamed from src/opt/bdc/bdcDec.c)0
-rw-r--r--src/aig/bdc/bdcInt.h (renamed from src/opt/bdc/bdcInt.h)0
-rw-r--r--src/aig/bdc/bdcTable.c (renamed from src/opt/bdc/bdcTable.c)0
-rw-r--r--src/aig/bdc/bdc_.c (renamed from src/opt/bdc/bdc_.c)0
-rw-r--r--src/aig/bdc/module.make4
-rw-r--r--src/aig/cnf/cnf.h21
-rw-r--r--src/aig/cnf/cnfCore.c9
-rw-r--r--src/aig/cnf/cnfCut.c17
-rw-r--r--src/aig/cnf/cnfData.c4
-rw-r--r--src/aig/cnf/cnfMan.c8
-rw-r--r--src/aig/cnf/cnfMap.c54
-rw-r--r--src/aig/cnf/cnfPost.c48
-rw-r--r--src/aig/cnf/cnfUtil.c41
-rw-r--r--src/aig/cnf/cnfWrite.c30
-rw-r--r--src/aig/csw/csw.h2
-rw-r--r--src/aig/csw/cswCore.c40
-rw-r--r--src/aig/csw/cswCut.c269
-rw-r--r--src/aig/csw/cswInt.h62
-rw-r--r--src/aig/csw/cswMan.c47
-rw-r--r--src/aig/csw/cswTable.c55
-rw-r--r--src/aig/dar/dar.h428
-rw-r--r--src/aig/dar/darBalance.c129
-rw-r--r--src/aig/dar/darCore.c151
-rw-r--r--src/aig/dar/darCut.c303
-rw-r--r--src/aig/dar/darData.c1684
-rw-r--r--src/aig/dar/darInt.h158
-rw-r--r--src/aig/dar/darLib.c312
-rw-r--r--src/aig/dar/darMan.c189
-rw-r--r--src/aig/dar/darTruth.c111
-rw-r--r--src/aig/dar/module.make10
-rw-r--r--src/aig/fra/fra.h49
-rw-r--r--src/aig/fra/fraAnd.c52
-rw-r--r--src/aig/fra/fraClass.c56
-rw-r--r--src/aig/fra/fraCnf.c72
-rw-r--r--src/aig/fra/fraCore.c10
-rw-r--r--src/aig/fra/fraMan.c38
-rw-r--r--src/aig/fra/fraSat.c36
-rw-r--r--src/aig/fra/fraSim.c96
-rw-r--r--src/aig/kit/kit.h (renamed from src/opt/kit/kit.h)0
-rw-r--r--src/aig/kit/kitBdd.c (renamed from src/opt/kit/kitBdd.c)0
-rw-r--r--src/aig/kit/kitDsd.c (renamed from src/opt/kit/kitDsd.c)0
-rw-r--r--src/aig/kit/kitFactor.c (renamed from src/opt/kit/kitFactor.c)0
-rw-r--r--src/aig/kit/kitGraph.c (renamed from src/opt/kit/kitGraph.c)0
-rw-r--r--src/aig/kit/kitHop.c (renamed from src/opt/kit/kitHop.c)0
-rw-r--r--src/aig/kit/kitIsop.c (renamed from src/opt/kit/kitIsop.c)0
-rw-r--r--src/aig/kit/kitSop.c (renamed from src/opt/kit/kitSop.c)0
-rw-r--r--src/aig/kit/kitTruth.c (renamed from src/opt/kit/kitTruth.c)0
-rw-r--r--src/aig/kit/kit_.c (renamed from src/opt/kit/kit_.c)0
-rw-r--r--src/aig/kit/module.make8
-rw-r--r--src/base/abci/abc.c133
-rw-r--r--src/base/abci/abcDar.c191
-rw-r--r--src/map/if/ifCut.c1
-rw-r--r--src/opt/bdc/module.make8
-rw-r--r--src/opt/kit/module.make8
-rw-r--r--src/opt/rwr/rwrEva.c11
72 files changed, 5328 insertions, 2658 deletions
diff --git a/Makefile b/Makefile
index 3375bc42..a6ec2b0a 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/abc.dsp b/abc.dsp
index 067aaaa5..095c8ebd 100644
--- a/abc.dsp
+++ b/abc.dsp
@@ -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,366 +614,6 @@ SOURCE=.\src\base\ver\verStream.c
# PROP Default_Filter ""
# End Group
# End Group
-# Begin Group "aig"
-
-# PROP Default_Filter ""
-# Begin Group "hop"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\aig\hop\hop.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\hop\hopBalance.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\hop\hopCheck.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\hop\hopDfs.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\hop\hopMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\hop\hopMem.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\hop\hopObj.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\hop\hopOper.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\hop\hopTable.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\hop\hopUtil.c
-# End Source File
-# End Group
-# Begin Group "ivy"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivy.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyBalance.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyCanon.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyCheck.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyCut.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyCutTrav.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyDfs.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyDsd.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyFanout.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyFastMap.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyFraig.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyHaig.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyMem.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyMulti.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyObj.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyOper.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyResyn.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyRwr.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivySeq.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyShow.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyTable.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\ivy\ivyUtil.c
-# End Source File
-# End Group
-# Begin Group "rwt"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\aig\rwt\rwt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\rwt\rwtDec.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\rwt\rwtMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\rwt\rwtUtil.c
-# End Source File
-# End Group
-# Begin Group "deco"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\aig\deco\deco.h
-# End Source File
-# End Group
-# Begin Group "mem"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\aig\mem\mem.c
-# End Source File
-# Begin Source File
-
-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\aig\dar\dar.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darBalance.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darCheck.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darCore.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darCut.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darData.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darDfs.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darLib.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darMem.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darObj.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darOper.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darSeq.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darTable.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darTruth.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\dar\darUtil.c
-# End Source File
-# End Group
-# Begin Group "fra"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\aig\fra\fra.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\fra\fraAnd.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\fra\fraClass.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\fra\fraCnf.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\fra\fraCore.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\fra\fraMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\fra\fraSat.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\fra\fraSim.c
-# End Source File
-# End Group
-# Begin Group "cnf"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\aig\cnf\cnf.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\cnf\cnfCore.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\cnf\cnfCut.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\cnf\cnfData.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\cnf\cnfMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\cnf\cnfMap.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\cnf\cnfPost.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\cnf\cnfUtil.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\cnf\cnfWrite.c
-# End Source File
-# End Group
-# Begin Group "csw"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\aig\csw\csw.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\csw\cswCore.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\csw\cswCut.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\csw\cswInt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\csw\cswMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\aig\csw\cswTable.c
-# End Source File
-# End Group
-# End Group
# Begin Group "bdd"
# PROP Default_Filter ""
@@ -1853,46 +1493,6 @@ SOURCE=.\src\opt\ret\retInt.h
SOURCE=.\src\opt\ret\retLvalue.c
# End Source File
# End Group
-# Begin Group "kit"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\opt\kit\kit.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\kit\kitBdd.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\kit\kitDsd.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\kit\kitFactor.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\kit\kitGraph.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\kit\kitHop.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\kit\kitIsop.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\kit\kitSop.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\kit\kitTruth.c
-# End Source File
-# End Group
# Begin Group "res"
# PROP Default_Filter ""
@@ -1933,30 +1533,6 @@ SOURCE=.\src\opt\res\resStrash.c
SOURCE=.\src\opt\res\resWin.c
# End Source File
# End Group
-# Begin Group "bdc"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\opt\bdc\bdc.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\bdc\bdcCore.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\bdc\bdcDec.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\bdc\bdcInt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\opt\bdc\bdcTable.c
-# End Source File
-# End Group
# Begin Group "lpk"
# PROP Default_Filter ""
@@ -2734,6 +2310,446 @@ 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\aig\hop\hop.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\hop\hopBalance.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\hop\hopCheck.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\hop\hopDfs.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\hop\hopMan.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\hop\hopMem.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\hop\hopObj.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\hop\hopOper.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\hop\hopTable.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\hop\hopUtil.c
+# End Source File
+# End Group
+# Begin Group "ivy"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivy.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyBalance.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyCanon.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyCheck.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyCut.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyCutTrav.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyDfs.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyDsd.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyFanout.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyFastMap.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyFraig.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyHaig.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyMan.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyMem.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyMulti.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyObj.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyOper.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyResyn.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyRwr.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivySeq.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyShow.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyTable.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\ivy\ivyUtil.c
+# End Source File
+# End Group
+# Begin Group "rwt"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\aig\rwt\rwt.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\rwt\rwtDec.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\rwt\rwtMan.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\rwt\rwtUtil.c
+# End Source File
+# End Group
+# Begin Group "deco"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\aig\deco\deco.h
+# End Source File
+# End Group
+# Begin Group "mem"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\aig\mem\mem.c
+# End Source File
+# Begin Source File
+
+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\aig\dar\dar.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\dar\darBalance.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\dar\darCore.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\dar\darCut.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\dar\darData.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\dar\darInt.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\dar\darLib.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\dar\darMan.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\dar\darTruth.c
+# End Source File
+# End Group
+# Begin Group "fra"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\aig\fra\fra.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\fra\fraAnd.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\fra\fraClass.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\fra\fraCnf.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\fra\fraCore.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\fra\fraMan.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\fra\fraSat.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\fra\fraSim.c
+# End Source File
+# End Group
+# Begin Group "cnf"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\aig\cnf\cnf.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\cnf\cnfCore.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\cnf\cnfCut.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\cnf\cnfData.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\cnf\cnfMan.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\cnf\cnfMap.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\cnf\cnfPost.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\cnf\cnfUtil.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\cnf\cnfWrite.c
+# End Source File
+# End Group
+# Begin Group "csw"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\aig\csw\csw.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\csw\cswCore.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\csw\cswCut.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\csw\cswInt.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\csw\cswMan.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\csw\cswTable.c
+# End Source File
+# End Group
+# Begin Group "kit"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\aig\kit\kit.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\kit\kitBdd.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\kit\kitDsd.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\kit\kitFactor.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\kit\kitGraph.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\kit\kitHop.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\kit\kitIsop.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\kit\kitSop.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\kit\kitTruth.c
+# End Source File
+# End Group
+# Begin Group "bdc"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\aig\bdc\bdc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\bdc\bdcCore.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\bdc\bdcDec.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\bdc\bdcInt.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\bdc\bdcTable.c
+# End Source File
+# End Group
+# Begin Group "aig"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\aig\aig\aig.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\aig\aigCheck.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\aig\aigDfs.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\aig\aigMan.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\aig\aigMem.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\aig\aigObj.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\aig\aigOper.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\aig\aigSeq.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\aig\aigTable.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\aig\aigUtil.c
+# End Source File
+# End Group
+# End Group
# End Group
# Begin Group "Header Files"
diff --git a/abc.rc b/abc.rc
index 4b253b07..71f16fb5 100644
--- a/abc.rc
+++ b/abc.rc
@@ -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"
diff --git a/src/aig/aig/aig.h b/src/aig/aig/aig.h
new file mode 100644
index 00000000..4d9f9819
--- /dev/null
+++ b/src/aig/aig/aig.h
@@ -0,0 +1,373 @@
+/**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 ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/aig/dar/darCheck.c b/src/aig/aig/aigCheck.c
index 5c7a2390..1a8f108e 100644
--- a/src/aig/dar/darCheck.c
+++ b/src/aig/aig/aigCheck.c
@@ -1,10 +1,10 @@
/**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;
}
diff --git a/src/aig/dar/darDfs.c b/src/aig/aig/aigDfs.c
index 116f428c..0f2d9401 100644
--- a/src/aig/dar/darDfs.c
+++ b/src/aig/aig/aigDfs.c
@@ -1,10 +1,10 @@
/**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) );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/aig/aigMan.c b/src/aig/aig/aigMan.c
new file mode 100644
index 00000000..1b0ea548
--- /dev/null
+++ b/src/aig/aig/aigMan.c
@@ -0,0 +1,224 @@
+/**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 ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/dar/darMem.c b/src/aig/aig/aigMem.c
index c2626bb1..20663e6f 100644
--- a/src/aig/dar/darMem.c
+++ b/src/aig/aig/aigMem.c
@@ -1,10 +1,10 @@
/**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++ )
diff --git a/src/aig/dar/darObj.c b/src/aig/aig/aigObj.c
index 85b142e6..a261ab40 100644
--- a/src/aig/dar/darObj.c
+++ b/src/aig/aig/aigObj.c
@@ -1,10 +1,10 @@
/**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]++;
}
diff --git a/src/aig/dar/darOper.c b/src/aig/aig/aigOper.c
index cfb89e31..55ab5862 100644
--- a/src/aig/dar/darOper.c
+++ b/src/aig/aig/aigOper.c
@@ -1,10 +1,10 @@
/**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;
}
diff --git a/src/aig/dar/darSeq.c b/src/aig/aig/aigSeq.c
index 33f11f31..98b7d195 100644
--- a/src/aig/dar/darSeq.c
+++ b/src/aig/aig/aigSeq.c
@@ -1,12 +1,12 @@
/**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;
diff --git a/src/aig/dar/darTable.c b/src/aig/aig/aigTable.c
index af9956ec..e8cfb480 100644
--- a/src/aig/dar/darTable.c
+++ b/src/aig/aig/aigTable.c
@@ -1,10 +1,10 @@
/**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++ )
{
diff --git a/src/aig/dar/darUtil.c b/src/aig/aig/aigUtil.c
index 052fad60..1e45bca1 100644
--- a/src/aig/dar/darUtil.c
+++ b/src/aig/aig/aigUtil.c
@@ -1,10 +1,10 @@
/**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 );
diff --git a/src/aig/aig/aig_.c b/src/aig/aig/aig_.c
new file mode 100644
index 00000000..b2313d35
--- /dev/null
+++ b/src/aig/aig/aig_.c
@@ -0,0 +1,48 @@
+/**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 ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/aig/module.make b/src/aig/aig/module.make
new file mode 100644
index 00000000..f1e83fe6
--- /dev/null
+++ b/src/aig/aig/module.make
@@ -0,0 +1,9 @@
+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
diff --git a/src/opt/bdc/bdc.h b/src/aig/bdc/bdc.h
index 71875edb..71875edb 100644
--- a/src/opt/bdc/bdc.h
+++ b/src/aig/bdc/bdc.h
diff --git a/src/opt/bdc/bdcCore.c b/src/aig/bdc/bdcCore.c
index 157927b1..157927b1 100644
--- a/src/opt/bdc/bdcCore.c
+++ b/src/aig/bdc/bdcCore.c
diff --git a/src/opt/bdc/bdcDec.c b/src/aig/bdc/bdcDec.c
index 747fcb14..747fcb14 100644
--- a/src/opt/bdc/bdcDec.c
+++ b/src/aig/bdc/bdcDec.c
diff --git a/src/opt/bdc/bdcInt.h b/src/aig/bdc/bdcInt.h
index 65ab9d27..65ab9d27 100644
--- a/src/opt/bdc/bdcInt.h
+++ b/src/aig/bdc/bdcInt.h
diff --git a/src/opt/bdc/bdcTable.c b/src/aig/bdc/bdcTable.c
index d86a938d..d86a938d 100644
--- a/src/opt/bdc/bdcTable.c
+++ b/src/aig/bdc/bdcTable.c
diff --git a/src/opt/bdc/bdc_.c b/src/aig/bdc/bdc_.c
index 9d0a9462..9d0a9462 100644
--- a/src/opt/bdc/bdc_.c
+++ b/src/aig/bdc/bdc_.c
diff --git a/src/aig/bdc/module.make b/src/aig/bdc/module.make
new file mode 100644
index 00000000..8697c998
--- /dev/null
+++ b/src/aig/bdc/module.make
@@ -0,0 +1,4 @@
+SRC += src/aig/bdc/bdcCore.c \
+ src/aig/bdc/bdcDec.c \
+ src/aig/bdc/bdcTable.c
+
diff --git a/src/aig/cnf/cnf.h b/src/aig/cnf/cnf.h
index 8c27b62d..c758867c 100644
--- a/src/aig/cnf/cnf.h
+++ b/src/aig/cnf/cnf.h
@@ -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 );
diff --git a/src/aig/cnf/cnfCore.c b/src/aig/cnf/cnfCore.c
index b09f0bdc..a3a7efaa 100644
--- a/src/aig/cnf/cnfCore.c
+++ b/src/aig/cnf/cnfCore.c
@@ -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;
}
diff --git a/src/aig/cnf/cnfCut.c b/src/aig/cnf/cnfCut.c
index feeef1f2..afe5920a 100644
--- a/src/aig/cnf/cnfCut.c
+++ b/src/aig/cnf/cnfCut.c
@@ -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 )
{
diff --git a/src/aig/cnf/cnfData.c b/src/aig/cnf/cnfData.c
index 57ce9392..7b8be51e 100644
--- a/src/aig/cnf/cnfData.c
+++ b/src/aig/cnf/cnfData.c
@@ -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|";
diff --git a/src/aig/cnf/cnfMan.c b/src/aig/cnf/cnfMan.c
index d1d1fc21..e978e322 100644
--- a/src/aig/cnf/cnfMan.c
+++ b/src/aig/cnf/cnfMan.c
@@ -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 );
diff --git a/src/aig/cnf/cnfMap.c b/src/aig/cnf/cnfMap.c
index 09be7701..a9ba41a0 100644
--- a/src/aig/cnf/cnfMap.c
+++ b/src/aig/cnf/cnfMap.c
@@ -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 ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/cnf/cnfPost.c b/src/aig/cnf/cnfPost.c
index 2f6a6424..988275b2 100644
--- a/src/aig/cnf/cnfPost.c
+++ b/src/aig/cnf/cnfPost.c
@@ -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 )
diff --git a/src/aig/cnf/cnfUtil.c b/src/aig/cnf/cnfUtil.c
index 249f43fb..da5edef2 100644
--- a/src/aig/cnf/cnfUtil.c
+++ b/src/aig/cnf/cnfUtil.c
@@ -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;
}
diff --git a/src/aig/cnf/cnfWrite.c b/src/aig/cnf/cnfWrite.c
index 2637d115..22c4240a 100644
--- a/src/aig/cnf/cnfWrite.c
+++ b/src/aig/cnf/cnfWrite.c
@@ -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
diff --git a/src/aig/csw/csw.h b/src/aig/csw/csw.h
index 4a326414..1443f4d9 100644
--- a/src/aig/csw/csw.h
+++ b/src/aig/csw/csw.h
@@ -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
}
diff --git a/src/aig/csw/cswCore.c b/src/aig/csw/cswCore.c
index ddf37035..20893058 100644
--- a/src/aig/csw/cswCore.c
+++ b/src/aig/csw/cswCore.c
@@ -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;
diff --git a/src/aig/csw/cswCut.c b/src/aig/csw/cswCut.c
index f1cb1fde..b3b7152b 100644
--- a/src/aig/csw/cswCut.c
+++ b/src/aig/csw/cswCut.c
@@ -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;
diff --git a/src/aig/csw/cswInt.h b/src/aig/csw/cswInt.h
index 74fa417b..37efe9b4 100644
--- a/src/aig/csw/cswInt.h
+++ b/src/aig/csw/cswInt.h
@@ -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
}
diff --git a/src/aig/csw/cswMan.c b/src/aig/csw/cswMan.c
index 180fecef..2af1a844 100644
--- a/src/aig/csw/cswMan.c
+++ b/src/aig/csw/cswMan.c
@@ -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 );
diff --git a/src/aig/csw/cswTable.c b/src/aig/csw/cswTable.c
index 82f09d01..87e36ae1 100644
--- a/src/aig/csw/cswTable.c
+++ b/src/aig/csw/cswTable.c
@@ -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;
}
}
diff --git a/src/aig/dar/dar.h b/src/aig/dar/dar.h
index 8e82cdf4..cff2785b 100644
--- a/src/aig/dar/dar.h
+++ b/src/aig/dar/dar.h
@@ -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
}
diff --git a/src/aig/dar/darBalance.c b/src/aig/dar/darBalance.c
index 2d9a48d4..a1502382 100644
--- a/src/aig/dar/darBalance.c
+++ b/src/aig/dar/darBalance.c
@@ -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;
diff --git a/src/aig/dar/darCore.c b/src/aig/dar/darCore.c
index 23563766..a617f5d6 100644
--- a/src/aig/dar/darCore.c
+++ b/src/aig/dar/darCore.c
@@ -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;
}
diff --git a/src/aig/dar/darCut.c b/src/aig/dar/darCut.c
index 48f4dc6c..af9d1227 100644
--- a/src/aig/dar/darCut.c
+++ b/src/aig/dar/darCut.c
@@ -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 );
}
diff --git a/src/aig/dar/darData.c b/src/aig/dar/darData.c
index 60fab63e..abf1d378 100644
--- a/src/aig/dar/darData.c
+++ b/src/aig/dar/darData.c
@@ -18,7 +18,7 @@
***********************************************************************/
-#include "dar.h"
+#include "darInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -9419,6 +9419,1665 @@ unsigned int s_Data2[24772] = {
15235,15234,27897,27488
};
+
+const int s_nDataSize3 = 24772;
+unsigned int s_Data3[24772] = {
+//Output priorities (total = 24772):
+10, 9, 12, 6, 11, 14, 4, 1, 7, 5, 2, 3, 13, 8, 0,
+0, 1, 2, 219, 218, 76, 217, 216, 77, 1, 0, 74, 78, 79, 75,
+70, 71, 72, 68, 73, 69, 310, 299, 296, 331, 297, 332, 114, 26, 298,
+340, 330, 336, 338, 339, 62, 112, 328, 334, 329, 335, 113, 337, 327, 333,
+115, 60, 27, 61, 63, 273, 215, 36, 213, 31, 35, 39, 319, 312, 320,
+323, 324, 343, 157, 345, 28, 178, 32, 59, 269, 58, 309, 305, 275, 271,
+308, 304, 34, 117, 181, 129, 154, 211, 30, 38, 177, 193, 55, 130, 268,
+33, 303, 174, 29, 37, 119, 212, 143, 188, 66, 270, 141, 183, 194, 179,
+126, 261, 190, 267, 344, 346, 272, 189, 173, 274, 51, 322, 321, 342, 315,
+214, 311, 14, 57, 223, 348, 125, 176, 192, 317, 280, 314, 165, 160, 175,
+326, 127, 17, 247, 172, 262, 5, 231, 99, 138, 124, 54, 301, 325, 167,
+15, 43, 205, 47, 122, 147, 292, 295, 83, 106, 86, 87, 220, 131, 347,
+293, 150, 209, 233, 67, 116, 148, 156, 171, 180, 191, 256, 195, 341, 128,
+277, 291, 281, 289, 294, 313, 102, 46, 103, 207, 229, 236, 240, 224, 227,
+249, 170, 49, 251, 258, 318, 133, 197, 278, 2, 56, 252, 265, 254, 20,
+142, 151, 316, 164, 121, 162, 41, 107, 139, 203, 288, 302, 48, 52, 110,
+53, 64, 4, 16, 284, 135, 307, 3, 40, 155, 202, 23, 93, 22, 92,
+290, 65, 210, 50, 98, 208, 94, 123, 137, 187, 225, 7, 10, 120, 109,
+263, 287, 186, 108, 152, 264, 90, 253, 96, 97, 136, 200, 118, 140, 300,
+306, 185, 6, 11, 89, 259, 85, 101, 132, 196, 24, 45, 260, 244, 91,
+18, 104, 232, 19, 44, 105, 184, 21, 84, 226, 250, 283, 279, 286, 158,
+248, 257, 255, 80, 169, 13, 100, 81, 168, 199, 238, 9, 12, 82, 182,
+201, 266, 146, 204, 230, 239, 241, 159, 221, 285, 134, 88, 242, 246, 8,
+144, 222, 149, 161, 228, 237, 276, 95, 206, 282, 163, 198, 243, 235, 245,
+42, 166, 25, 111, 145, 153, 234, 13, 0, 1, 8, 3, 11, 7, 9,
+2, 12, 4, 6, 5, 10, 0, 61, 62, 0, 2, 3, 5, 6, 8,
+15, 17, 1, 4, 7, 9, 10, 11, 12, 13, 14, 16, 18, 19, 20,
+21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
+51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 63, 64, 65, 66, 67,
+68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 4, 5,
+2, 0, 1, 3, 7, 10, 8, 11, 6, 9, 97, 100, 22, 123, 124,
+125, 98, 101, 40, 39, 66, 72, 75, 69, 68, 74, 21, 41, 67, 73,
+77, 30, 71, 23, 106, 36, 54, 55, 63, 96, 32, 99, 58, 59, 65,
+38, 107, 27, 17, 56, 57, 64, 70, 76, 29, 15, 31, 122, 102, 25,
+48, 49, 50, 51, 52, 53, 26, 28, 103, 37, 127, 104, 120, 121, 24,
+33, 46, 47, 62, 112, 113, 116, 105, 20, 13, 126, 128, 35, 34, 19,
+42, 43, 44, 45, 60, 61, 18, 79, 84, 91, 16, 14, 82, 89, 94,
+85, 119, 83, 88, 95, 118, 78, 90, 81, 86, 93, 12, 80, 87, 92,
+108, 109, 110, 111, 114, 115, 117, 148, 542, 149, 147, 303, 531, 555, 573,
+574, 532, 556, 150, 153, 155, 578, 304, 560, 536, 151, 154, 157, 534, 558,
+576, 533, 538, 557, 575, 547, 551, 570, 305, 568, 306, 540, 541, 544, 546,
+550, 553, 562, 564, 565, 571, 552, 554, 572, 535, 559, 577, 537, 561, 569,
+539, 543, 545, 548, 549, 563, 566, 567, 308, 307, 152, 156, 158, 382, 144,
+128, 145, 438, 446, 450, 458, 462, 470, 474, 482, 492, 500, 504, 510, 516,
+522, 530, 204, 394, 528, 381, 397, 480, 498, 396, 400, 436, 444, 448, 456,
+460, 468, 472, 490, 502, 508, 514, 520, 286, 388, 393, 294, 403, 273, 384,
+385, 387, 391, 399, 408, 313, 317, 347, 354, 414, 419, 426, 25, 88, 127,
+130, 198, 275, 336, 483, 126, 281, 283, 341, 432, 299, 325, 390, 402, 415,
+416, 417, 418, 427, 428, 116, 124, 134, 142, 221, 229, 298, 479, 486, 497,
+527, 24, 87, 227, 311, 315, 329, 353, 506, 512, 518, 30, 34, 41, 196,
+300, 484, 48, 104, 186, 191, 264, 335, 343, 363, 234, 276, 441, 443, 453,
+455, 465, 467, 477, 495, 525, 222, 269, 476, 494, 524, 395, 89, 140, 413,
+420, 425, 481, 499, 505, 511, 517, 529, 200, 257, 327, 398, 401, 440, 445,
+452, 457, 464, 469, 32, 36, 42, 47, 345, 365, 435, 442, 447, 454, 459,
+466, 471, 478, 489, 496, 501, 507, 513, 519, 526, 202, 323, 146, 170, 177,
+179, 248, 255, 368, 380, 206, 122, 132, 258, 279, 288, 296, 349, 375, 434,
+46, 114, 165, 180, 201, 219, 243, 250, 297, 405, 429, 33, 38, 43, 172,
+203, 208, 346, 392, 404, 410, 485, 488, 183, 216, 261, 348, 386, 430, 20,
+26, 65, 100, 131, 162, 167, 174, 182, 188, 189, 194, 210, 218, 240, 252,
+260, 266, 272, 284, 360, 372, 383, 423, 12, 17, 57, 92, 99, 129, 213,
+215, 230, 231, 278, 291, 293, 339, 389, 406, 411, 422, 15, 60, 62, 97,
+117, 119, 135, 199, 224, 225, 236, 245, 267, 302, 321, 326, 377, 407, 102,
+137, 175, 274, 431, 412, 421, 424, 173, 238, 246, 251, 253, 262, 270, 282,
+366, 370, 378, 437, 439, 449, 451, 461, 463, 473, 475, 491, 493, 503, 509,
+515, 521, 523, 0, 1, 81, 82, 106, 160, 168, 184, 185, 192, 193, 263,
+271, 277, 322, 358, 22, 28, 31, 40, 67, 98, 103, 105, 138, 254, 316,
+319, 355, 328, 10, 14, 49, 52, 59, 70, 73, 90, 112, 133, 220, 228,
+232, 233, 301, 309, 314, 331, 333, 337, 344, 351, 35, 37, 44, 163, 342,
+409, 433, 487, 259, 27, 29, 39, 50, 161, 164, 176, 178, 181, 187, 190,
+197, 205, 239, 241, 242, 324, 332, 359, 361, 362, 371, 373, 374, 6, 7,
+45, 55, 56, 75, 77, 79, 80, 108, 109, 159, 166, 169, 171, 195, 217,
+237, 247, 249, 256, 265, 268, 280, 334, 340, 350, 357, 367, 369, 379, 2,
+3, 9, 18, 19, 21, 23, 53, 63, 64, 66, 68, 72, 76, 83, 84,
+93, 95, 96, 101, 107, 111, 120, 121, 123, 125, 139, 141, 143, 212, 244,
+290, 295, 310, 312, 318, 320, 330, 338, 352, 356, 4, 5, 8, 11, 13,
+51, 54, 58, 61, 69, 71, 74, 78, 85, 86, 94, 110, 113, 115, 136,
+207, 209, 211, 214, 223, 226, 235, 285, 287, 289, 292, 364, 376, 16, 91,
+118, 0, 3, 19, 149, 96, 20, 150, 5, 1, 6, 4, 2, 147, 93,
+91, 145, 148, 95, 146, 85, 55, 66, 76, 59, 73, 81, 51, 61, 64,
+54, 58, 92, 94, 63, 173, 62, 86, 65, 75, 60, 74, 82, 56, 52,
+53, 57, 171, 167, 160, 159, 170, 72, 141, 162, 172, 28, 68, 29, 140,
+168, 27, 70, 126, 139, 69, 163, 89, 137, 166, 71, 169, 129, 142, 164,
+116, 135, 143, 90, 67, 113, 121, 165, 161, 131, 123, 125, 133, 30, 7,
+138, 10, 117, 119, 11, 120, 127, 134, 130, 132, 115, 124, 114, 136, 9,
+118, 33, 77, 157, 158, 8, 12, 88, 155, 156, 34, 78, 99, 97, 128,
+36, 44, 87, 35, 43, 15, 13, 17, 122, 21, 23, 25, 144, 37, 45,
+47, 103, 32, 42, 80, 39, 49, 83, 108, 40, 50, 84, 38, 46, 48,
+31, 41, 79, 18, 98, 22, 24, 26, 14, 16, 105, 107, 100, 152, 111,
+109, 104, 101, 110, 112, 106, 153, 102, 151, 154, 0, 1, 3, 4, 2,
+12, 13, 10, 11, 14, 9, 6, 5, 7, 8, 21, 24, 23, 22, 20,
+19, 15, 16, 17, 18, 0, 1, 3, 2, 108, 109, 139, 153, 122, 96,
+178, 97, 126, 95, 101, 100, 94, 174, 140, 172, 175, 173, 5, 36, 154,
+88, 83, 80, 35, 161, 151, 19, 11, 6, 147, 143, 34, 176, 123, 37,
+169, 170, 171, 163, 164, 165, 166, 167, 168, 155, 156, 157, 158, 159, 160,
+82, 162, 177, 152, 81, 111, 7, 12, 20, 128, 4, 93, 21, 64, 13,
+148, 60, 62, 118, 10, 18, 33, 144, 30, 48, 135, 149, 86, 114, 99,
+124, 129, 130, 131, 61, 63, 65, 8, 14, 16, 22, 24, 26, 28, 73,
+75, 77, 90, 56, 72, 74, 76, 78, 51, 53, 55, 57, 59, 67, 69,
+71, 79, 89, 91, 50, 52, 54, 58, 66, 68, 70, 92, 107, 39, 41,
+43, 45, 47, 110, 103, 105, 120, 145, 127, 38, 40, 42, 44, 46, 137,
+102, 104, 106, 31, 32, 49, 9, 15, 17, 23, 29, 87, 25, 27, 150,
+141, 142, 84, 85, 146, 98, 116, 119, 133, 115, 121, 136, 132, 125, 117,
+112, 113, 138, 134, 2, 0, 1, 3, 8, 6, 7, 4, 5, 9, 10,
+0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+15, 16, 2, 1, 4, 8, 7, 9, 6, 0, 5, 3, 10, 109, 107,
+108, 97, 105, 28, 30, 21, 81, 26, 32, 106, 20, 24, 35, 22, 34,
+96, 104, 62, 27, 111, 11, 18, 23, 36, 83, 37, 12, 95, 17, 46,
+56, 25, 40, 42, 87, 89, 14, 16, 13, 29, 103, 82, 110, 15, 19,
+31, 33, 102, 38, 66, 67, 68, 69, 70, 71, 72, 85, 41, 115, 117,
+91, 93, 94, 99, 101, 43, 73, 86, 88, 114, 116, 50, 52, 74, 76,
+77, 78, 79, 39, 113, 44, 45, 47, 48, 49, 51, 53, 54, 55, 57,
+58, 59, 60, 61, 63, 64, 65, 75, 80, 84, 90, 92, 98, 100, 112,
+0, 1, 20, 17, 18, 12, 19, 16, 21, 15, 23, 14, 22, 13, 0,
+6, 5, 11, 3, 9, 2, 8, 1, 7, 4, 10, 3, 4, 11, 14,
+17, 32, 0, 1, 2, 5, 6, 7, 8, 9, 10, 12, 13, 15, 16,
+18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 33,
+34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 2, 3, 0, 1,
+15, 13, 17, 21, 77, 76, 33, 30, 34, 110, 105, 114, 118, 31, 32,
+35, 101, 100, 16, 131, 12, 14, 130, 135, 132, 112, 120, 116, 111, 115,
+119, 79, 117, 113, 121, 20, 133, 80, 134, 78, 81, 44, 109, 49, 47,
+124, 46, 28, 48, 126, 26, 87, 89, 90, 88, 6, 5, 7, 9, 11,
+19, 36, 38, 40, 42, 86, 91, 18, 4, 10, 39, 8, 37, 41, 43,
+45, 60, 127, 27, 61, 106, 129, 59, 108, 128, 53, 54, 57, 58, 62,
+50, 29, 56, 63, 52, 55, 107, 122, 123, 125, 51, 64, 65, 66, 67,
+68, 69, 70, 71, 72, 73, 74, 75, 82, 83, 84, 85, 92, 93, 94,
+95, 96, 97, 98, 99, 102, 103, 104, 23, 25, 24, 22, 175, 174, 176,
+162, 158, 165, 124, 166, 15, 155, 126, 160, 120, 121, 122, 123, 125, 127,
+128, 129, 153, 157, 171, 152, 163, 170, 96, 97, 108, 0, 3, 6, 9,
+12, 66, 69, 72, 75, 78, 81, 130, 131, 150, 151, 156, 159, 161, 168,
+169, 173, 177, 154, 164, 167, 172, 1, 2, 4, 5, 7, 8, 10, 11,
+13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
+29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
+44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
+59, 60, 61, 62, 63, 64, 65, 67, 68, 70, 71, 73, 74, 76, 77,
+79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
+95, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 109, 110, 111, 112,
+113, 114, 115, 116, 117, 118, 119, 132, 133, 134, 135, 136, 137, 138, 139,
+140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 178, 179, 0, 1, 2,
+8, 6, 7, 3, 5, 4, 0, 1305, 1308, 540, 545, 558, 563, 564, 569,
+570, 575, 576, 581, 582, 587, 588, 593, 594, 599, 600, 605, 606, 611, 612,
+617, 618, 623, 624, 629, 630, 635, 636, 641, 642, 647, 648, 653, 654, 657,
+662, 663, 668, 669, 672, 677, 678, 681, 684, 687, 690, 0, 1, 2, 3,
+4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
+34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
+79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
+94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
+109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
+124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
+139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
+154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
+169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
+184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198,
+199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
+214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
+229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243,
+244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258,
+259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
+274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
+289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303,
+304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318,
+319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333,
+334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348,
+349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363,
+364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378,
+379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393,
+394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408,
+409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423,
+424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438,
+439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453,
+454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468,
+469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483,
+484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498,
+499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513,
+514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528,
+529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 541, 542, 543, 544,
+546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 559, 560, 561,
+562, 565, 566, 567, 568, 571, 572, 573, 574, 577, 578, 579, 580, 583, 584,
+585, 586, 589, 590, 591, 592, 595, 596, 597, 598, 601, 602, 603, 604, 607,
+608, 609, 610, 613, 614, 615, 616, 619, 620, 621, 622, 625, 626, 627, 628,
+631, 632, 633, 634, 637, 638, 639, 640, 643, 644, 645, 646, 649, 650, 651,
+652, 655, 656, 658, 659, 660, 661, 664, 665, 666, 667, 670, 671, 673, 674,
+675, 676, 679, 680, 682, 683, 685, 686, 688, 689, 691, 692, 693, 694, 695,
+696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710,
+711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725,
+726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740,
+741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755,
+756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770,
+771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785,
+786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800,
+801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815,
+816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830,
+831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845,
+846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860,
+861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875,
+876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890,
+891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905,
+906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920,
+921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935,
+936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950,
+951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965,
+966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980,
+981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995,
+996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010,
+1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025,
+1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040,
+1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055,
+1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070,
+1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085,
+1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100,
+1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115,
+1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130,
+1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145,
+1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160,
+1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175,
+1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190,
+1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205,
+1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220,
+1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235,
+1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250,
+1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265,
+1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280,
+1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295,
+1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1306, 1307, 1309, 1310, 158, 161,
+164, 167, 170, 173, 74, 77, 86, 89, 0, 3, 12, 15, 24, 27, 36,
+39, 48, 51, 60, 63, 110, 113, 122, 125, 134, 137, 146, 149, 76, 88,
+156, 160, 162, 165, 169, 171, 2, 132, 175, 26, 38, 50, 62, 72, 83,
+84, 95, 108, 120, 78, 90, 96, 104, 174, 14, 144, 176, 9, 21, 33,
+45, 57, 69, 79, 81, 91, 93, 98, 106, 119, 131, 143, 155, 59, 71,
+157, 159, 163, 166, 168, 172, 99, 101, 103, 105, 11, 35, 47, 73, 75,
+80, 82, 85, 87, 92, 94, 97, 100, 102, 107, 117, 129, 141, 8, 20,
+23, 32, 44, 56, 68, 114, 126, 138, 150, 153, 179, 186, 191, 198, 180,
+192, 1, 4, 5, 6, 7, 10, 13, 16, 17, 18, 19, 22, 25, 28,
+29, 30, 31, 34, 37, 40, 41, 42, 43, 46, 49, 52, 53, 54, 55,
+58, 61, 64, 65, 66, 67, 70, 109, 111, 112, 115, 116, 118, 121, 123,
+124, 127, 128, 130, 133, 135, 136, 139, 140, 142, 145, 147, 148, 151, 152,
+154, 213, 214, 215, 216, 177, 189, 184, 196, 221, 222, 223, 224, 178, 181,
+182, 183, 185, 187, 188, 190, 193, 194, 195, 197, 199, 200, 201, 202, 203,
+204, 205, 206, 207, 208, 209, 210, 211, 212, 217, 218, 219, 220, 2, 4,
+6, 8, 10, 12, 32, 34, 36, 46, 48, 52, 54, 56, 58, 60, 62,
+64, 86, 87, 88, 105, 106, 107, 108, 109, 112, 113, 115, 117, 121, 1,
+3, 5, 7, 9, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23,
+25, 26, 27, 28, 29, 30, 31, 33, 35, 37, 38, 39, 40, 41, 42,
+43, 44, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 66, 67,
+68, 71, 73, 75, 76, 78, 79, 80, 82, 83, 84, 92, 93, 94, 96,
+97, 98, 99, 100, 101, 102, 103, 104, 110, 111, 114, 116, 118, 119, 120,
+122, 124, 126, 127, 129, 131, 141, 143, 145, 146, 148, 150, 152, 153, 156,
+166, 167, 170, 173, 174, 176, 180, 182, 184, 186, 0, 22, 24, 50, 69,
+70, 72, 74, 77, 81, 85, 89, 90, 91, 95, 123, 125, 128, 130, 132,
+133, 134, 135, 136, 137, 138, 139, 140, 142, 144, 147, 149, 151, 154, 155,
+157, 158, 159, 160, 161, 162, 163, 164, 165, 168, 169, 171, 172, 175, 177,
+178, 179, 181, 183, 185, 122, 85, 89, 92, 106, 118, 136, 148, 156, 164,
+27, 35, 37, 38, 52, 57, 62, 67, 71, 83, 55, 65, 68, 121, 26,
+53, 63, 66, 80, 82, 105, 114, 119, 123, 137, 143, 14, 25, 30, 31,
+100, 28, 117, 108, 134, 3, 12, 34, 36, 39, 40, 45, 46, 51, 59,
+60, 61, 73, 74, 75, 76, 77, 78, 84, 86, 87, 88, 90, 91, 93,
+94, 95, 110, 112, 115, 116, 120, 127, 128, 130, 132, 141, 142, 152, 175,
+58, 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 16,
+17, 18, 19, 20, 21, 22, 23, 24, 29, 32, 33, 41, 42, 43, 44,
+47, 48, 49, 50, 54, 56, 64, 69, 70, 72, 79, 81, 96, 97, 98,
+99, 101, 102, 103, 104, 107, 109, 111, 113, 124, 125, 126, 129, 131, 133,
+135, 138, 139, 140, 144, 145, 146, 147, 149, 150, 151, 153, 154, 155, 157,
+158, 159, 160, 161, 162, 163, 165, 166, 167, 168, 169, 170, 171, 172, 173,
+174, 176, 177, 23, 29, 5, 24, 25, 26, 27, 28, 30, 31, 0, 1,
+2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
+18, 19, 20, 21, 22, 32, 83, 84, 96, 99, 100, 16, 85, 98, 18,
+26, 27, 37, 40, 49, 52, 17, 51, 55, 57, 97, 8, 3, 19, 9,
+50, 56, 58, 10, 53, 72, 82, 87, 89, 91, 14, 118, 129, 12, 81,
+86, 88, 90, 130, 11, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31,
+32, 33, 34, 35, 36, 43, 67, 68, 69, 93, 95, 41, 45, 47, 4,
+5, 6, 13, 38, 117, 128, 71, 0, 1, 2, 15, 39, 92, 94, 65,
+70, 122, 123, 127, 7, 42, 44, 46, 48, 54, 59, 60, 61, 62, 63,
+64, 66, 105, 106, 109, 110, 111, 112, 113, 114, 121, 124, 126, 73, 74,
+75, 76, 77, 78, 79, 80, 101, 102, 103, 104, 107, 108, 115, 116, 119,
+120, 125, 18, 24, 5, 7, 9, 13, 0, 1, 2, 3, 4, 6, 8,
+10, 11, 12, 14, 15, 16, 17, 19, 20, 21, 22, 23, 25, 26, 27,
+28, 29, 30, 38, 37, 3, 2, 39, 4, 40, 5, 109, 110, 111, 99,
+107, 97, 105, 140, 141, 142, 0, 98, 106, 1, 100, 108, 34, 35, 36,
+10, 11, 42, 46, 50, 54, 58, 62, 66, 70, 13, 17, 21, 30, 6,
+88, 90, 96, 102, 113, 115, 121, 123, 125, 135, 137, 139, 9, 14, 18,
+22, 33, 44, 48, 52, 56, 60, 64, 68, 72, 116, 126, 130, 43, 47,
+51, 55, 59, 63, 67, 71, 85, 91, 93, 103, 80, 82, 83, 73, 75,
+76, 119, 129, 133, 12, 16, 20, 31, 7, 41, 45, 49, 53, 57, 61,
+65, 69, 117, 127, 131, 87, 89, 95, 101, 112, 114, 120, 122, 124, 134,
+136, 138, 86, 92, 94, 104, 118, 128, 132, 79, 81, 84, 74, 77, 78,
+8, 15, 19, 23, 32, 24, 25, 28, 26, 27, 29, 0, 1, 2, 3,
+4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
+34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
+79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
+94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
+109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
+124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
+139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
+154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 34, 5, 6, 7,
+8, 9, 10, 11, 12, 33, 47, 2, 4, 19, 20, 21, 36, 37, 38,
+40, 41, 0, 1, 3, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25,
+26, 27, 28, 29, 30, 31, 32, 35, 39, 42, 43, 44, 45, 46, 48,
+49, 50, 144, 145, 0, 141, 142, 143, 155, 154, 139, 140, 146, 147, 150,
+151, 76, 82, 83, 84, 85, 86, 87, 158, 131, 77, 132, 159, 23, 24,
+25, 26, 27, 28, 32, 33, 73, 79, 91, 95, 1, 3, 5, 12, 13,
+14, 15, 16, 17, 18, 19, 20, 21, 22, 29, 30, 31, 34, 102, 104,
+106, 108, 112, 113, 114, 115, 116, 117, 118, 119, 138, 37, 39, 41, 43,
+48, 50, 52, 54, 2, 4, 6, 7, 8, 9, 10, 11, 36, 38, 40,
+42, 44, 45, 46, 47, 56, 57, 58, 59, 60, 62, 64, 66, 68, 70,
+72, 74, 75, 78, 80, 81, 88, 89, 90, 92, 93, 94, 96, 97, 98,
+100, 103, 105, 107, 109, 137, 160, 161, 162, 35, 49, 51, 53, 55, 61,
+63, 65, 67, 69, 71, 99, 101, 110, 111, 120, 121, 122, 123, 124, 125,
+126, 127, 128, 129, 130, 133, 134, 135, 136, 148, 149, 152, 153, 156, 157,
+4, 11, 5, 6, 7, 8, 10, 9, 12, 17, 18, 19, 21, 2, 3,
+0, 1, 13, 14, 15, 16, 20, 28, 32, 34, 38, 40, 22, 23, 24,
+25, 26, 27, 29, 30, 31, 33, 35, 36, 37, 39, 41, 73, 69, 95,
+11, 72, 14, 12, 13, 93, 71, 74, 94, 87, 81, 86, 79, 60, 96,
+98, 88, 59, 82, 97, 44, 46, 54, 68, 92, 100, 45, 53, 67, 43,
+91, 99, 80, 89, 77, 1, 3, 9, 5, 6, 7, 8, 70, 28, 83,
+22, 34, 42, 49, 51, 57, 17, 23, 29, 37, 63, 19, 25, 31, 39,
+48, 50, 52, 56, 58, 62, 64, 66, 84, 76, 90, 78, 75, 85, 4,
+0, 2, 10, 20, 26, 32, 36, 40, 15, 61, 16, 18, 24, 30, 35,
+38, 47, 55, 65, 21, 27, 33, 41, 0, 1, 2, 3, 4, 5, 6,
+7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+22, 23, 24, 25, 26, 40, 42, 3, 1, 51, 5, 49, 48, 22, 24,
+4, 2, 52, 50, 76, 78, 80, 94, 96, 98, 23, 47, 26, 27, 63,
+64, 65, 70, 71, 21, 77, 79, 81, 17, 20, 33, 37, 41, 43, 57,
+55, 56, 58, 59, 60, 61, 62, 18, 19, 25, 32, 36, 95, 97, 99,
+0, 38, 39, 54, 67, 69, 73, 75, 85, 87, 91, 93, 53, 66, 84,
+86, 90, 89, 6, 7, 11, 12, 13, 82, 83, 68, 72, 74, 92, 8,
+9, 10, 14, 15, 16, 28, 29, 30, 31, 34, 35, 44, 45, 46, 88,
+0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
+90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
+105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+120, 121, 122, 123, 124, 125, 0, 1, 2, 3, 4, 5, 6, 7, 8,
+9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
+69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
+84, 85, 86, 87, 88, 89, 90, 91, 92, 0, 1, 2, 3, 4, 5,
+6, 7, 8, 1, 3, 43, 0, 2, 4, 5, 6, 7, 8, 9, 10,
+11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+41, 42, 44, 45, 46, 89, 90, 0, 1, 2, 3, 4, 5, 6, 7,
+8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
+23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
+53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
+68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
+83, 84, 85, 86, 87, 88, 91, 92, 93, 94, 95, 96, 97, 98, 99,
+100, 101, 102, 103, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+26, 27, 28, 29, 30, 31, 0, 1, 2, 3, 4, 5, 6, 7, 8,
+9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
+69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 186, 189, 174,
+185, 179, 180, 177, 181, 188, 191, 60, 63, 175, 183, 176, 184, 64, 61,
+62, 65, 178, 182, 187, 190, 130, 142, 154, 166, 104, 110, 116, 13, 24,
+36, 78, 122, 136, 148, 160, 172, 7, 18, 30, 84, 102, 108, 114, 105,
+111, 117, 120, 123, 74, 86, 98, 107, 113, 119, 125, 1, 9, 20, 32,
+44, 45, 55, 75, 99, 103, 109, 115, 0, 6, 19, 31, 42, 43, 54,
+72, 73, 85, 96, 97, 137, 149, 161, 173, 2, 46, 47, 56, 76, 77,
+100, 101, 127, 133, 139, 145, 151, 157, 163, 169, 8, 21, 33, 87, 106,
+112, 118, 121, 124, 128, 129, 140, 141, 152, 153, 3, 4, 15, 26, 38,
+48, 49, 50, 51, 57, 58, 66, 67, 68, 69, 80, 90, 91, 92, 93,
+126, 131, 134, 138, 143, 146, 150, 155, 158, 162, 167, 170, 10, 11, 22,
+23, 34, 35, 88, 89, 135, 147, 159, 171, 5, 12, 14, 16, 17, 25,
+27, 28, 29, 37, 39, 40, 41, 52, 53, 59, 70, 71, 79, 81, 82,
+83, 94, 95, 132, 144, 156, 164, 165, 168, 756, 759, 761, 104, 105, 640,
+647, 700, 107, 757, 760, 102, 222, 224, 310, 420, 431, 441, 460, 468, 491,
+494, 501, 558, 571, 654, 666, 683, 722, 7, 10, 31, 34, 60, 65, 162,
+165, 178, 434, 467, 477, 480, 550, 569, 657, 671, 682, 718, 751, 13, 37,
+54, 175, 181, 262, 265, 313, 385, 465, 551, 563, 641, 645, 701, 719, 253,
+316, 333, 339, 364, 365, 369, 371, 436, 439, 461, 496, 499, 505, 514, 520,
+522, 577, 585, 588, 598, 601, 608, 617, 622, 685, 727, 733, 223, 240, 191,
+709, 92, 115, 144, 199, 248, 252, 290, 307, 338, 372, 382, 410, 475, 508,
+513, 515, 527, 547, 566, 567, 572, 580, 587, 590, 595, 604, 606, 615, 619,
+688, 716, 725, 730, 735, 739, 747, 11, 16, 22, 23, 35, 40, 46, 47,
+52, 53, 59, 64, 88, 89, 94, 103, 118, 121, 124, 138, 143, 149, 163,
+164, 179, 184, 190, 202, 205, 208, 225, 244, 245, 250, 259, 268, 280, 281,
+284, 285, 291, 322, 328, 332, 340, 373, 379, 388, 400, 401, 404, 405, 411,
+421, 426, 428, 429, 437, 442, 450, 455, 457, 469, 478, 481, 488, 497, 502,
+529, 530, 536, 537, 540, 553, 564, 570, 625, 626, 630, 635, 637, 643, 655,
+656, 668, 670, 678, 681, 691, 692, 699, 703, 704, 724, 738, 749, 750, 753,
+560, 574, 723, 85, 331, 470, 101, 217, 633, 642, 697, 742, 745, 754, 19,
+43, 48, 187, 324, 97, 218, 296, 416, 130, 137, 166, 226, 241, 271, 279,
+319, 327, 391, 399, 440, 482, 142, 283, 325, 403, 443, 453, 485, 758, 0,
+24, 67, 298, 336, 346, 464, 489, 504, 507, 510, 516, 518, 521, 523, 524,
+535, 552, 559, 573, 576, 579, 582, 583, 591, 592, 594, 599, 602, 603, 607,
+611, 614, 616, 620, 623, 632, 644, 649, 651, 661, 663, 667, 669, 684, 687,
+696, 708, 720, 726, 729, 732, 736, 1, 2, 3, 4, 5, 6, 8, 9,
+12, 14, 15, 17, 18, 20, 21, 25, 26, 27, 28, 29, 30, 32, 33,
+36, 38, 39, 41, 42, 44, 45, 49, 50, 51, 55, 56, 57, 58, 61,
+62, 63, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+80, 81, 82, 83, 84, 86, 87, 90, 91, 93, 95, 96, 98, 99, 100,
+106, 108, 109, 110, 111, 112, 113, 114, 116, 117, 119, 120, 122, 123, 125,
+126, 127, 128, 129, 131, 132, 133, 134, 135, 136, 139, 140, 141, 145, 146,
+147, 148, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 167,
+168, 169, 170, 171, 172, 173, 174, 176, 177, 180, 182, 183, 185, 186, 188,
+189, 192, 193, 194, 195, 196, 197, 198, 200, 201, 203, 204, 206, 207, 209,
+210, 211, 212, 213, 214, 215, 216, 219, 220, 221, 227, 228, 229, 230, 231,
+232, 233, 234, 235, 236, 237, 238, 239, 242, 243, 246, 247, 249, 251, 254,
+255, 256, 257, 258, 260, 261, 263, 264, 266, 267, 269, 270, 272, 273, 274,
+275, 276, 277, 278, 282, 286, 287, 288, 289, 292, 293, 294, 295, 297, 299,
+300, 301, 302, 303, 304, 305, 306, 308, 309, 311, 312, 314, 315, 317, 318,
+320, 321, 323, 326, 329, 330, 334, 335, 337, 341, 342, 343, 344, 345, 347,
+348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362,
+363, 366, 367, 368, 370, 374, 375, 376, 377, 378, 380, 381, 383, 384, 386,
+387, 389, 390, 392, 393, 394, 395, 396, 397, 398, 402, 406, 407, 408, 409,
+412, 413, 414, 415, 417, 418, 419, 422, 423, 424, 425, 427, 430, 432, 433,
+435, 438, 444, 445, 446, 447, 448, 449, 451, 452, 454, 456, 458, 459, 462,
+463, 466, 471, 472, 473, 474, 476, 479, 483, 484, 486, 487, 490, 492, 493,
+495, 498, 500, 503, 506, 509, 511, 512, 517, 519, 525, 526, 528, 531, 532,
+533, 534, 538, 539, 541, 542, 543, 544, 545, 546, 548, 549, 554, 555, 556,
+557, 561, 562, 565, 568, 575, 578, 581, 584, 586, 589, 593, 596, 597, 600,
+605, 609, 610, 612, 613, 618, 621, 624, 627, 628, 629, 631, 634, 636, 638,
+639, 646, 648, 650, 652, 653, 658, 659, 660, 662, 664, 665, 672, 673, 674,
+675, 676, 677, 679, 680, 686, 689, 690, 693, 694, 695, 698, 702, 705, 706,
+707, 710, 711, 712, 713, 714, 715, 717, 721, 728, 731, 734, 737, 740, 741,
+743, 744, 746, 748, 752, 755, 325, 326, 324, 15, 258, 103, 123, 3, 9,
+124, 331, 14, 259, 16, 2, 8, 337, 102, 335, 340, 4, 10, 17, 120,
+246, 247, 276, 333, 334, 33, 72, 128, 338, 5, 11, 76, 105, 127, 0,
+13, 74, 73, 122, 1, 75, 7, 300, 336, 364, 6, 12, 228, 235, 263,
+265, 270, 280, 291, 106, 297, 77, 135, 162, 169, 192, 199, 201, 214, 216,
+225, 260, 262, 104, 306, 316, 339, 170, 200, 223, 341, 137, 160, 190, 203,
+215, 218, 141, 150, 157, 171, 180, 187, 312, 313, 317, 39, 125, 143, 148,
+158, 173, 178, 188, 308, 318, 107, 322, 362, 35, 91, 97, 109, 299, 230,
+272, 293, 244, 256, 289, 323, 367, 38, 121, 302, 303, 311, 327, 245, 257,
+261, 290, 305, 234, 264, 279, 34, 36, 79, 85, 115, 126, 298, 307, 309,
+319, 328, 57, 63, 69, 198, 229, 271, 292, 82, 88, 90, 96, 108, 118,
+304, 320, 329, 37, 41, 80, 86, 116, 301, 332, 139, 159, 164, 168, 189,
+194, 205, 213, 217, 220, 222, 40, 136, 145, 167, 177, 197, 202, 212, 227,
+18, 27, 48, 363, 237, 267, 282, 196, 240, 241, 252, 253, 285, 286, 142,
+147, 152, 155, 156, 172, 175, 182, 185, 186, 310, 321, 330, 346, 347, 348,
+355, 138, 163, 165, 193, 195, 204, 210, 219, 226, 131, 132, 208, 250, 251,
+278, 314, 315, 357, 365, 140, 146, 179, 206, 211, 20, 29, 50, 161, 166,
+191, 221, 224, 269, 368, 26, 44, 47, 58, 64, 70, 81, 87, 117, 144,
+151, 153, 174, 181, 183, 93, 99, 111, 232, 274, 295, 59, 65, 71, 133,
+134, 149, 154, 176, 184, 209, 350, 361, 239, 242, 254, 284, 287, 268, 56,
+62, 68, 78, 84, 94, 100, 112, 114, 92, 98, 110, 238, 283, 55, 61,
+67, 349, 236, 243, 255, 266, 281, 288, 19, 24, 28, 42, 45, 49, 129,
+130, 207, 248, 249, 277, 354, 359, 360, 233, 275, 296, 352, 353, 22, 31,
+52, 54, 60, 66, 83, 89, 95, 101, 113, 119, 342, 345, 366, 231, 273,
+294, 25, 43, 46, 23, 32, 53, 343, 351, 358, 21, 30, 51, 344, 356,
+0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
+90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
+105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
+135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
+165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
+195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
+210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
+225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
+255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
+270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
+285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
+300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
+315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329,
+330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
+345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359,
+360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
+375, 376, 377, 19, 29, 33, 45, 86, 88, 90, 92, 18, 27, 31, 47,
+82, 103, 37, 41, 55, 87, 11, 35, 39, 43, 49, 51, 53, 57, 61,
+63, 89, 91, 105, 109, 114, 20, 9, 13, 107, 28, 30, 32, 34, 46,
+48, 78, 84, 133, 135, 93, 112, 134, 136, 36, 40, 62, 66, 80, 38,
+42, 44, 50, 52, 54, 56, 58, 64, 127, 131, 137, 1, 15, 16, 21,
+22, 102, 111, 113, 128, 132, 138, 23, 25, 59, 68, 70, 94, 69, 3,
+4, 6, 7, 10, 104, 106, 108, 110, 121, 123, 67, 24, 26, 60, 122,
+124, 72, 76, 81, 96, 85, 74, 98, 129, 83, 125, 0, 2, 5, 8,
+12, 14, 17, 71, 73, 75, 77, 79, 95, 97, 99, 100, 126, 65, 130,
+101, 118, 116, 120, 115, 117, 119, 219, 220, 221, 127, 131, 135, 139, 228,
+229, 230, 231, 232, 233, 234, 235, 222, 223, 224, 225, 226, 227, 236, 237,
+238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252,
+253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 275,
+276, 277, 278, 9, 13, 17, 21, 25, 29, 36, 40, 44, 48, 49, 56,
+60, 64, 68, 72, 76, 80, 84, 171, 176, 180, 184, 0, 1, 2, 3,
+4, 5, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20, 22,
+23, 24, 26, 27, 28, 30, 31, 32, 33, 34, 35, 37, 38, 39, 41,
+42, 43, 45, 46, 47, 50, 51, 52, 53, 54, 55, 57, 58, 59, 61,
+62, 63, 65, 66, 67, 69, 70, 71, 73, 74, 75, 77, 78, 79, 81,
+82, 83, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
+98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
+113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 128,
+129, 130, 132, 133, 134, 136, 137, 138, 140, 141, 142, 143, 144, 145, 146,
+147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
+162, 163, 164, 165, 166, 167, 168, 169, 170, 172, 173, 174, 175, 177, 178,
+179, 181, 182, 183, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
+196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
+211, 212, 213, 214, 215, 216, 217, 218, 267, 268, 269, 270, 271, 272, 273,
+274, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 1, 2,
+3, 4, 0, 8, 12, 11, 102, 127, 6, 5, 101, 7, 128, 4, 3,
+10, 1, 2, 0, 9, 92, 90, 97, 114, 94, 95, 99, 112, 111, 123,
+116, 118, 120, 121, 125, 98, 89, 91, 96, 93, 100, 113, 24, 34, 16,
+36, 14, 22, 13, 21, 33, 18, 26, 30, 115, 117, 124, 119, 122, 126,
+17, 25, 29, 104, 19, 27, 31, 106, 28, 20, 32, 15, 23, 35, 54,
+56, 110, 51, 72, 88, 38, 40, 49, 58, 60, 64, 66, 74, 81, 105,
+107, 37, 39, 50, 52, 57, 59, 63, 65, 71, 73, 82, 87, 42, 43,
+45, 48, 61, 67, 70, 76, 77, 79, 83, 86, 53, 55, 41, 44, 46,
+47, 62, 68, 69, 75, 78, 80, 84, 85, 109, 103, 108, 7, 8, 6,
+9, 17, 10, 28, 26, 24, 50, 68, 4, 34, 5, 0, 23, 46, 2,
+18, 33, 1, 85, 19, 58, 62, 70, 29, 31, 35, 3, 25, 27, 47,
+48, 49, 51, 11, 90, 30, 32, 36, 40, 41, 42, 43, 44, 45, 12,
+13, 14, 15, 16, 20, 21, 22, 37, 38, 39, 52, 53, 54, 55, 56,
+57, 59, 60, 61, 63, 64, 65, 66, 67, 69, 71, 72, 73, 74, 75,
+76, 77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, 89, 88, 125,
+101, 103, 124, 127, 134, 135, 25, 29, 37, 45, 165, 177, 163, 180, 138,
+142, 113, 24, 28, 36, 40, 41, 44, 48, 49, 58, 59, 60, 61, 66,
+67, 68, 69, 70, 71, 72, 73, 89, 92, 93, 145, 148, 149, 94, 105,
+109, 151, 154, 161, 173, 96, 99, 100, 102, 104, 107, 108, 111, 114, 115,
+116, 118, 119, 120, 122, 123, 126, 132, 133, 136, 137, 140, 141, 155, 156,
+159, 160, 164, 169, 171, 172, 175, 176, 179, 181, 182, 183, 0, 1, 2,
+3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
+18, 19, 20, 21, 22, 23, 26, 27, 30, 31, 32, 33, 34, 35, 38,
+39, 42, 43, 46, 47, 50, 51, 52, 53, 54, 55, 56, 57, 62, 63,
+64, 65, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
+87, 90, 91, 95, 97, 98, 106, 110, 112, 117, 121, 128, 129, 130, 131,
+139, 143, 144, 146, 147, 150, 152, 153, 157, 158, 162, 166, 167, 168, 170,
+174, 178, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 0, 1, 2, 3,
+4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
+34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
+79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
+94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
+109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
+124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
+139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
+154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
+169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183,
+184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198,
+199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
+214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
+229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243,
+244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258,
+259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
+274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
+289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303,
+304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318,
+319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333,
+334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348,
+349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363,
+364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378,
+379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393,
+394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408,
+409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423,
+424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438,
+439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453,
+454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468,
+469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483,
+484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498,
+499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513,
+514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528,
+529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543,
+544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558,
+559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573,
+574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588,
+589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603,
+604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618,
+619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633,
+634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648,
+649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663,
+664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678,
+679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693,
+694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708,
+709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723,
+724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738,
+739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753,
+754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768,
+769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783,
+784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798,
+799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813,
+814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828,
+829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843,
+844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858,
+859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873,
+874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888,
+889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903,
+904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918,
+919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933,
+934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948,
+949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963,
+964, 965, 966, 967, 968, 969, 970, 971, 306, 146, 158, 174, 216, 233, 27,
+29, 121, 123, 125, 127, 144, 150, 152, 173, 188, 218, 295, 299, 307, 0,
+1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 30, 31, 32,
+33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
+63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
+78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
+93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 122, 124,
+126, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141,
+142, 143, 145, 147, 148, 149, 151, 153, 154, 155, 156, 157, 159, 160, 161,
+162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 175, 176, 177, 178,
+179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 193, 194,
+195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
+210, 211, 212, 213, 214, 215, 217, 219, 220, 221, 222, 223, 224, 225, 226,
+227, 228, 229, 230, 231, 232, 234, 235, 236, 237, 238, 239, 240, 241, 242,
+243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257,
+258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
+273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
+288, 289, 290, 291, 292, 293, 294, 296, 297, 298, 300, 301, 302, 303, 304,
+305, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321,
+322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336,
+337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351,
+352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366,
+367, 368, 369, 370, 371, 372, 373, 374, 76, 106, 77, 107, 125, 115, 126,
+60, 61, 71, 59, 96, 99, 110, 89, 70, 58, 25, 27, 33, 35, 86,
+87, 72, 75, 79, 94, 112, 95, 100, 73, 74, 78, 101, 102, 105, 109,
+88, 26, 32, 34, 103, 104, 108, 24, 97, 98, 113, 114, 44, 64, 69,
+36, 38, 41, 43, 47, 54, 57, 63, 66, 111, 37, 39, 40, 42, 45,
+46, 55, 56, 62, 65, 67, 68, 90, 92, 5, 11, 9, 84, 8, 4,
+10, 2, 48, 50, 52, 81, 82, 0, 6, 12, 14, 85, 80, 83, 49,
+51, 53, 91, 93, 118, 121, 124, 3, 17, 18, 21, 22, 29, 30, 1,
+7, 13, 15, 116, 119, 122, 129, 16, 19, 20, 23, 28, 31, 117, 120,
+123, 127, 128, 130, 3, 4, 5, 6, 25, 26, 27, 28, 29, 33, 41,
+54, 61, 62, 99, 101, 105, 106, 107, 108, 133, 134, 0, 7, 30, 83,
+86, 87, 88, 90, 91, 92, 93, 135, 136, 137, 1, 2, 31, 32, 34,
+100, 102, 103, 104, 119, 132, 138, 139, 140, 16, 21, 22, 23, 24, 44,
+51, 64, 65, 66, 67, 69, 71, 72, 73, 74, 75, 76, 8, 9, 10,
+11, 12, 13, 14, 15, 35, 36, 42, 43, 46, 48, 49, 50, 52, 60,
+63, 77, 78, 79, 80, 81, 82, 85, 89, 94, 95, 96, 97, 98, 109,
+110, 111, 112, 113, 114, 115, 120, 121, 17, 18, 19, 20, 37, 38, 39,
+40, 45, 47, 53, 55, 56, 57, 58, 59, 68, 70, 84, 116, 117, 118,
+122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 141, 142, 143, 144, 145,
+146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
+161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
+176, 177, 178, 179, 180, 181, 182, 49, 18, 16, 17, 42, 45, 15, 8,
+46, 39, 6, 48, 7, 9, 10, 41, 44, 5, 40, 43, 30, 47, 51,
+52, 25, 19, 20, 21, 22, 23, 24, 3, 4, 29, 31, 32, 33, 34,
+35, 36, 37, 38, 71, 73, 11, 12, 13, 14, 50, 70, 0, 1, 2,
+26, 27, 28, 60, 62, 69, 61, 63, 64, 65, 72, 75, 76, 54, 55,
+56, 57, 58, 59, 66, 68, 81, 82, 83, 84, 86, 74, 53, 67, 77,
+78, 79, 80, 85, 87, 88, 0, 1, 2, 3, 4, 5, 6, 7, 8,
+9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
+69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
+84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
+99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
+114, 115, 116, 117, 118, 119, 120, 121, 122, 0, 1, 2, 3, 4, 5,
+6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+21, 100, 31, 35, 41, 33, 30, 34, 40, 82, 81, 103, 47, 32, 15,
+99, 46, 9, 21, 8, 69, 65, 67, 14, 62, 57, 58, 60, 80, 56,
+20, 11, 97, 10, 85, 86, 1, 22, 26, 36, 16, 17, 78, 79, 105,
+108, 5, 24, 28, 38, 44, 45, 59, 61, 63, 70, 109, 111, 0, 4,
+25, 29, 39, 50, 51, 54, 55, 71, 72, 73, 74, 75, 76, 77, 95,
+96, 101, 102, 104, 110, 98, 18, 19, 83, 84, 89, 23, 27, 37, 42,
+43, 48, 113, 2, 3, 6, 7, 12, 13, 49, 52, 53, 87, 88, 90,
+91, 92, 93, 94, 106, 107, 112, 64, 66, 68, 5, 4, 0, 39, 48,
+17, 8, 6, 7, 77, 78, 75, 76, 79, 80, 16, 15, 73, 56, 55,
+74, 40, 41, 42, 60, 9, 10, 11, 12, 13, 14, 59, 43, 62, 1,
+2, 3, 44, 61, 58, 68, 22, 23, 28, 35, 36, 45, 46, 47, 57,
+67, 69, 70, 71, 19, 18, 20, 21, 24, 25, 26, 27, 29, 30, 31,
+32, 33, 34, 37, 38, 49, 50, 51, 52, 53, 54, 63, 64, 65, 66,
+72, 81, 82, 83, 84, 34, 44, 71, 32, 43, 30, 35, 72, 33, 11,
+10, 39, 37, 13, 38, 42, 36, 12, 41, 31, 8, 9, 40, 50, 69,
+55, 20, 24, 28, 135, 1, 5, 15, 136, 70, 46, 51, 114, 115, 45,
+3, 7, 17, 113, 116, 54, 128, 129, 134, 138, 0, 4, 14, 26, 19,
+23, 27, 48, 62, 63, 68, 123, 124, 125, 126, 131, 132, 29, 49, 59,
+60, 66, 127, 130, 133, 86, 110, 119, 57, 58, 65, 83, 87, 103, 111,
+122, 18, 22, 82, 102, 61, 64, 67, 21, 25, 52, 2, 6, 16, 75,
+76, 85, 90, 95, 99, 100, 109, 120, 56, 73, 74, 77, 78, 79, 80,
+81, 84, 88, 89, 91, 92, 93, 94, 96, 97, 98, 101, 104, 105, 106,
+107, 108, 112, 117, 118, 121, 137, 47, 53, 4, 5, 0, 1, 2, 3,
+7, 8, 6, 9, 10, 20, 25, 27, 18, 19, 21, 23, 24, 26, 28,
+0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+15, 16, 17, 22, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+40, 41, 76, 96, 112, 109, 110, 94, 95, 49, 73, 56, 61, 65, 68,
+102, 30, 37, 38, 40, 41, 44, 45, 47, 48, 55, 57, 59, 60, 79,
+82, 88, 89, 90, 91, 92, 98, 100, 105, 108, 111, 0, 1, 2, 3,
+4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34,
+35, 36, 39, 42, 43, 46, 50, 51, 52, 53, 54, 58, 62, 63, 64,
+66, 67, 69, 70, 71, 72, 74, 75, 77, 78, 80, 81, 83, 84, 85,
+86, 87, 93, 97, 99, 101, 103, 104, 106, 107, 113, 91, 42, 46, 77,
+26, 8, 78, 41, 43, 44, 47, 68, 5, 30, 45, 89, 90, 48, 49,
+50, 51, 25, 76, 93, 14, 70, 88, 4, 23, 24, 29, 59, 63, 75,
+79, 92, 97, 0, 1, 2, 6, 7, 15, 16, 17, 20, 21, 27, 31,
+32, 33, 34, 35, 36, 62, 64, 67, 72, 61, 66, 71, 86, 94, 12,
+74, 55, 58, 60, 81, 83, 3, 9, 10, 11, 13, 18, 19, 22, 28,
+37, 38, 39, 40, 53, 56, 65, 69, 73, 82, 84, 85, 52, 54, 57,
+80, 87, 95, 96, 1, 8, 10, 13, 12, 6, 2, 0, 11, 9, 5,
+25, 7, 19, 43, 44, 45, 32, 33, 34, 50, 51, 52, 26, 22, 23,
+3, 4, 28, 15, 36, 37, 49, 30, 31, 29, 14, 20, 21, 24, 27,
+17, 39, 46, 16, 35, 53, 38, 40, 41, 42, 18, 47, 48, 0, 1,
+2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
+47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
+77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
+107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
+122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
+0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 49, 310, 312,
+314, 269, 271, 273, 275, 277, 279, 281, 297, 299, 0, 1, 2, 3, 4,
+5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50,
+51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
+66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
+111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
+126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
+141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
+156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170,
+171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
+186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
+201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
+216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230,
+231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245,
+246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260,
+261, 262, 263, 264, 265, 266, 267, 268, 270, 272, 274, 276, 278, 280, 282,
+283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 298,
+300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 311, 313, 315, 316, 317,
+318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332,
+333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
+348, 349, 350, 351, 352, 353, 354, 355, 179, 200, 161, 175, 243, 100, 104,
+196, 198, 223, 227, 176, 203, 212, 215, 162, 163, 247, 160, 174, 216, 218,
+158, 172, 96, 157, 166, 170, 197, 199, 217, 219, 159, 173, 178, 201, 99,
+101, 103, 105, 177, 202, 213, 214, 98, 102, 92, 108, 112, 116, 120, 124,
+128, 132, 184, 192, 208, 180, 188, 204, 239, 249, 221, 225, 154, 165, 169,
+51, 53, 55, 57, 59, 63, 67, 71, 75, 79, 83, 87, 95, 119, 123,
+127, 131, 138, 142, 146, 150, 183, 191, 207, 236, 241, 245, 250, 61, 65,
+69, 73, 77, 81, 85, 89, 93, 109, 113, 117, 140, 144, 148, 152, 8,
+9, 14, 15, 20, 21, 50, 52, 54, 56, 91, 107, 111, 115, 121, 125,
+129, 133, 134, 135, 136, 137, 141, 145, 149, 153, 155, 164, 168, 181, 187,
+189, 195, 205, 211, 58, 62, 66, 70, 74, 78, 82, 86, 118, 122, 126,
+130, 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 16, 17,
+18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+60, 64, 68, 72, 76, 80, 84, 88, 139, 143, 147, 151, 186, 194, 210,
+222, 226, 238, 242, 246, 248, 94, 97, 156, 167, 171, 228, 230, 90, 106,
+110, 114, 220, 224, 237, 240, 244, 251, 182, 185, 190, 193, 206, 209, 229,
+231, 232, 233, 234, 235, 24, 51, 54, 111, 25, 52, 55, 112, 13, 31,
+34, 37, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 26, 27, 28, 29, 30,
+32, 33, 35, 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+49, 50, 53, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
+68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
+83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
+98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 113, 114,
+115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
+130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 0,
+1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+16, 17, 8, 16, 18, 7, 26, 30, 34, 104, 14, 15, 17, 19, 22,
+48, 68, 73, 75, 79, 11, 1, 6, 20, 28, 32, 36, 38, 40, 44,
+98, 102, 103, 105, 106, 115, 2, 13, 21, 23, 49, 53, 54, 55, 56,
+57, 58, 60, 61, 64, 66, 67, 69, 76, 83, 85, 95, 100, 10, 0,
+3, 4, 5, 9, 12, 24, 25, 27, 29, 31, 33, 35, 37, 39, 41,
+42, 43, 45, 46, 47, 50, 51, 52, 59, 62, 63, 65, 70, 71, 72,
+74, 77, 78, 80, 81, 82, 84, 86, 87, 88, 89, 90, 91, 92, 93,
+94, 96, 97, 99, 101, 107, 108, 109, 110, 111, 112, 113, 114, 116, 117,
+118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 121, 120, 103, 101, 102,
+86, 111, 124, 27, 44, 100, 10, 13, 82, 92, 98, 78, 88, 94, 42,
+40, 9, 11, 12, 14, 80, 84, 90, 96, 45, 119, 122, 46, 48, 50,
+52, 104, 106, 109, 110, 1, 4, 18, 25, 29, 32, 19, 34, 22, 5,
+8, 38, 107, 39, 16, 17, 21, 26, 30, 33, 43, 87, 125, 41, 83,
+93, 99, 2, 24, 28, 31, 35, 53, 55, 81, 91, 97, 105, 0, 3,
+7, 6, 15, 20, 23, 36, 37, 47, 49, 51, 54, 56, 57, 58, 59,
+60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+75, 76, 77, 79, 85, 89, 95, 108, 112, 113, 114, 115, 116, 117, 118,
+123, 161, 57, 60, 95, 169, 165, 171, 0, 160, 40, 168, 164, 39, 58,
+59, 96, 1, 2, 50, 55, 64, 75, 85, 92, 97, 71, 77, 81, 87,
+6, 16, 30, 44, 181, 170, 49, 56, 63, 76, 86, 91, 98, 174, 180,
+5, 15, 29, 43, 72, 78, 82, 88, 113, 126, 194, 195, 198, 158, 159,
+162, 163, 114, 125, 144, 145, 166, 167, 192, 193, 156, 47, 48, 51, 52,
+53, 54, 61, 62, 65, 66, 83, 84, 89, 90, 93, 94, 99, 100, 101,
+102, 103, 104, 130, 131, 132, 133, 134, 135, 152, 175, 176, 177, 67, 69,
+73, 79, 105, 3, 4, 7, 8, 13, 14, 17, 18, 19, 20, 25, 26,
+27, 28, 31, 32, 33, 34, 37, 38, 41, 42, 45, 46, 68, 70, 74,
+80, 106, 117, 118, 142, 143, 178, 179, 138, 9, 140, 147, 148, 107, 109,
+111, 139, 141, 146, 149, 182, 183, 184, 185, 190, 191, 115, 119, 121, 123,
+137, 155, 157, 187, 189, 197, 10, 11, 12, 21, 22, 23, 24, 35, 36,
+108, 110, 112, 116, 120, 122, 124, 127, 128, 129, 136, 150, 151, 153, 154,
+173, 186, 188, 196, 172, 37, 36, 33, 32, 35, 34, 4, 2, 6, 0,
+44, 45, 47, 46, 42, 43, 39, 41, 40, 38, 5, 7, 3, 1, 51,
+17, 11, 15, 19, 9, 13, 10, 14, 18, 16, 23, 24, 27, 28, 31,
+8, 12, 20, 22, 21, 25, 26, 29, 30, 49, 48, 50, 179, 176, 165,
+178, 171, 175, 174, 177, 162, 168, 190, 188, 202, 200, 33, 75, 93, 51,
+81, 87, 173, 164, 157, 114, 3, 6, 156, 15, 21, 27, 170, 167, 123,
+63, 69, 39, 45, 57, 199, 211, 172, 208, 205, 214, 181, 184, 203, 196,
+169, 198, 201, 160, 161, 137, 163, 125, 209, 119, 183, 215, 166, 207, 204,
+213, 197, 191, 206, 210, 182, 212, 187, 185, 53, 83, 89, 192, 186, 193,
+136, 180, 194, 130, 142, 154, 155, 148, 149, 131, 143, 116, 32, 74, 92,
+122, 101, 107, 110, 113, 98, 104, 71, 65, 41, 47, 59, 2, 11, 14,
+20, 26, 195, 189, 147, 150, 151, 145, 133, 127, 139, 126, 138, 132, 144,
+117, 159, 52, 82, 88, 158, 120, 96, 102, 108, 99, 105, 111, 30, 72,
+90, 8, 5, 9, 0, 124, 97, 103, 109, 12, 18, 24, 48, 78, 84,
+66, 60, 70, 62, 35, 77, 95, 68, 42, 50, 80, 86, 17, 23, 29,
+36, 54, 38, 44, 56, 152, 153, 64, 40, 58, 46, 128, 140, 129, 134,
+135, 141, 146, 106, 100, 112, 121, 7, 4, 115, 118, 34, 61, 76, 94,
+16, 22, 28, 37, 43, 55, 49, 79, 85, 67, 1, 13, 19, 25, 31,
+73, 91, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
+27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
+42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
+72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
+87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
+102, 103, 104, 105, 106, 107, 108, 109, 110, 2, 5, 8, 11, 14, 17,
+20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62,
+65, 68, 0, 1, 3, 4, 6, 7, 9, 10, 12, 13, 15, 16, 18,
+19, 21, 22, 24, 25, 27, 28, 30, 31, 33, 34, 36, 37, 39, 40,
+42, 43, 45, 46, 48, 49, 51, 52, 54, 55, 57, 58, 60, 61, 63,
+64, 66, 67, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+53, 52, 72, 71, 73, 70, 97, 98, 96, 99, 68, 80, 82, 74, 77,
+78, 5, 22, 25, 41, 49, 1, 9, 17, 95, 103, 102, 104, 75, 76,
+79, 66, 69, 93, 67, 94, 81, 83, 84, 85, 86, 87, 88, 89, 90,
+91, 106, 107, 92, 100, 101, 105, 32, 34, 38, 12, 15, 54, 58, 62,
+39, 14, 36, 57, 61, 65, 31, 35, 47, 29, 45, 42, 28, 44, 30,
+46, 18, 16, 55, 59, 63, 40, 21, 26, 50, 3, 7, 11, 19, 0,
+4, 8, 33, 37, 20, 23, 24, 27, 43, 48, 51, 2, 6, 10, 13,
+56, 60, 64, 0, 2, 1, 11, 5, 6, 12, 3, 4, 9, 10, 14,
+7, 8, 13, 21, 36, 18, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+32, 33, 34, 35, 37, 15, 16, 22, 17, 19, 20, 0, 1, 0, 1,
+2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 48, 5, 34, 63,
+4, 62, 50, 47, 49, 33, 35, 36, 29, 3, 6, 61, 64, 54, 58,
+45, 32, 51, 56, 60, 70, 57, 40, 46, 11, 55, 59, 44, 53, 65,
+72, 14, 15, 17, 20, 22, 27, 66, 68, 69, 71, 26, 19, 67, 1,
+9, 12, 7, 25, 24, 28, 30, 31, 10, 8, 16, 18, 21, 23, 52,
+0, 2, 41, 42, 43, 13, 37, 38, 39, 107, 15, 97, 100, 101, 105,
+99, 33, 81, 79, 80, 34, 92, 95, 86, 48, 118, 41, 43, 119, 35,
+36, 37, 75, 102, 103, 104, 23, 24, 25, 26, 31, 4, 17, 19, 21,
+22, 27, 38, 39, 52, 56, 58, 64, 70, 72, 82, 47, 87, 51, 55,
+57, 77, 78, 98, 116, 117, 28, 29, 30, 32, 40, 42, 5, 7, 9,
+93, 96, 1, 2, 3, 6, 8, 10, 12, 54, 59, 65, 66, 68, 69,
+71, 73, 74, 76, 83, 84, 89, 90, 106, 109, 111, 112, 114, 44, 45,
+46, 49, 50, 11, 53, 16, 18, 20, 0, 13, 14, 60, 61, 62, 63,
+67, 85, 88, 91, 94, 108, 110, 113, 115, 13, 4, 46, 47, 2, 6,
+37, 38, 43, 51, 54, 55, 58, 67, 69, 0, 1, 3, 5, 7, 8,
+9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 39, 40, 41,
+42, 44, 45, 48, 49, 50, 52, 53, 56, 57, 59, 60, 61, 62, 63,
+64, 65, 66, 68, 70, 71, 72, 73, 74, 75, 7, 4, 6, 5, 2,
+3, 9, 8, 0, 1, 23, 22, 24, 25, 14, 26, 30, 34, 10, 11,
+12, 13, 15, 16, 17, 18, 19, 20, 21, 27, 28, 29, 31, 32, 33,
+35, 36, 37, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+25, 26, 27, 28, 29, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
+55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
+70, 71, 72, 73, 0, 1, 2, 3, 4, 4, 0, 1, 2, 3, 5,
+6, 7, 8, 0, 1, 2, 3, 4, 5, 323, 139, 149, 165, 207, 234,
+320, 296, 300, 20, 44, 45, 52, 138, 147, 189, 191, 192, 193, 210, 213,
+215, 217, 226, 232, 236, 238, 293, 322, 325, 74, 122, 306, 150, 264, 4,
+5, 197, 201, 117, 172, 188, 195, 203, 222, 244, 245, 265, 271, 291, 292,
+332, 2, 18, 19, 22, 34, 46, 57, 82, 84, 85, 88, 89, 120, 130,
+133, 134, 136, 137, 140, 142, 143, 145, 146, 148, 153, 159, 160, 161, 162,
+166, 169, 173, 184, 185, 209, 211, 219, 228, 229, 231, 237, 240, 242, 243,
+246, 247, 248, 251, 253, 254, 257, 286, 294, 298, 324, 335, 33, 98, 118,
+200, 204, 303, 305, 327, 100, 196, 205, 275, 123, 126, 282, 0, 1, 3,
+6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 21, 23, 24,
+25, 26, 27, 28, 29, 30, 31, 32, 35, 36, 37, 38, 39, 40, 41,
+42, 43, 47, 48, 49, 50, 51, 53, 54, 55, 56, 58, 59, 60, 61,
+62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77,
+78, 79, 80, 81, 83, 86, 87, 90, 91, 92, 93, 94, 95, 96, 97,
+99, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
+115, 116, 119, 121, 124, 125, 127, 128, 129, 131, 132, 135, 141, 144, 151,
+152, 154, 155, 156, 157, 158, 163, 164, 167, 168, 170, 171, 174, 175, 176,
+177, 178, 179, 180, 181, 182, 183, 186, 187, 190, 194, 198, 199, 202, 206,
+208, 212, 214, 216, 218, 220, 221, 223, 224, 225, 227, 230, 233, 235, 239,
+241, 249, 250, 252, 255, 256, 258, 259, 260, 261, 262, 263, 266, 267, 268,
+269, 270, 272, 273, 274, 276, 277, 278, 279, 280, 281, 283, 284, 285, 287,
+288, 289, 290, 295, 297, 299, 301, 302, 304, 307, 308, 309, 310, 311, 312,
+313, 314, 315, 316, 317, 318, 319, 321, 326, 328, 329, 330, 331, 333, 334,
+336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350,
+351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 0, 1,
+2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
+47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
+77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
+107, 108, 109, 4, 5, 18, 20, 0, 1, 2, 3, 6, 7, 8, 9,
+10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 22, 23, 24, 25, 26,
+0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
+55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
+70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
+85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
+100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
+115, 116, 117, 118, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
+71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
+86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
+101, 102, 103, 104, 105, 106, 107, 38, 40, 39, 65, 63, 66, 26, 28,
+11, 20, 24, 32, 108, 8, 47, 45, 48, 49, 105, 109, 139, 75, 124,
+18, 22, 30, 34, 111, 102, 114, 118, 77, 123, 133, 1, 5, 17, 46,
+69, 73, 81, 29, 78, 101, 37, 50, 64, 9, 51, 55, 61, 76, 68,
+72, 84, 2, 6, 14, 19, 23, 35, 67, 71, 79, 83, 107, 113, 115,
+117, 137, 147, 36, 10, 27, 53, 57, 59, 135, 13, 103, 104, 126, 3,
+7, 15, 41, 44, 54, 58, 60, 70, 74, 80, 82, 0, 4, 12, 16,
+21, 25, 31, 33, 42, 43, 52, 56, 62, 85, 88, 91, 94, 106, 110,
+112, 116, 119, 120, 121, 122, 125, 127, 128, 129, 130, 131, 132, 134, 136,
+138, 140, 141, 142, 143, 144, 145, 146, 148, 89, 86, 87, 90, 92, 93,
+95, 96, 97, 98, 99, 100, 0, 1, 2, 3, 4, 5, 6, 7, 8,
+9, 10, 11, 12, 1, 2, 4, 32, 36, 38, 3, 34, 28, 31, 35,
+37, 6, 12, 14, 19, 20, 22, 33, 39, 43, 53, 54, 55, 56, 57,
+61, 67, 69, 70, 71, 30, 0, 5, 7, 8, 9, 10, 11, 13, 15,
+16, 17, 18, 21, 23, 24, 25, 26, 27, 29, 40, 41, 42, 44, 45,
+46, 47, 48, 49, 50, 51, 52, 58, 59, 60, 62, 63, 64, 65, 66,
+68, 72, 16, 28, 34, 38, 42, 2, 14, 15, 18, 19, 26, 29, 30,
+31, 32, 33, 40, 43, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10,
+11, 12, 13, 17, 20, 21, 22, 23, 24, 25, 27, 35, 36, 37, 39,
+41, 2, 0, 7, 1, 86, 5, 74, 21, 89, 85, 88, 3, 4, 6,
+51, 23, 111, 70, 56, 90, 98, 27, 78, 53, 68, 80, 87, 116, 12,
+25, 109, 114, 103, 108, 110, 9, 57, 62, 65, 91, 96, 99, 69, 71,
+72, 73, 81, 49, 50, 52, 93, 101, 36, 55, 64, 125, 19, 20, 22,
+106, 41, 8, 11, 13, 29, 34, 37, 54, 102, 107, 118, 123, 126, 14,
+15, 16, 18, 82, 83, 84, 92, 97, 100, 104, 112, 17, 32, 121, 94,
+24, 113, 76, 77, 79, 10, 61, 95, 26, 28, 30, 31, 35, 38, 39,
+40, 46, 58, 59, 60, 63, 66, 67, 75, 105, 115, 117, 119, 120, 124,
+127, 128, 33, 42, 43, 44, 45, 47, 48, 122, 0, 1, 2, 3, 4,
+5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 2, 0, 1, 3, 4,
+5, 6, 7, 8, 82, 11, 26, 19, 75, 6, 9, 47, 54, 66, 73,
+80, 87, 0, 3, 4, 5, 18, 23, 24, 25, 44, 53, 62, 63, 65,
+67, 68, 69, 70, 72, 76, 77, 86, 88, 89, 90, 91, 92, 93, 22,
+10, 15, 21, 49, 58, 50, 59, 83, 1, 2, 7, 8, 12, 13, 14,
+16, 17, 20, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+39, 40, 41, 42, 43, 45, 46, 48, 51, 52, 55, 56, 57, 60, 61,
+64, 71, 74, 78, 79, 81, 84, 85, 0, 1, 0, 1, 34, 2, 12,
+13, 32, 37, 76, 3, 10, 11, 19, 20, 21, 22, 23, 27, 28, 29,
+30, 35, 53, 55, 78, 4, 16, 17, 5, 6, 7, 8, 9, 14, 15,
+18, 24, 25, 26, 31, 33, 36, 38, 39, 40, 41, 42, 43, 44, 45,
+46, 47, 48, 49, 50, 51, 52, 54, 56, 57, 58, 59, 60, 61, 62,
+63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 77, 79,
+80, 81, 82, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+12, 13, 14, 15, 5, 30, 31, 0, 1, 2, 3, 4, 6, 7, 8,
+9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+24, 25, 26, 27, 28, 29, 32, 33, 34, 35, 36, 37, 59, 0, 1,
+2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+32, 33, 34, 35, 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 61, 62, 63,
+64, 65, 36, 61, 20, 1, 19, 126, 127, 60, 56, 33, 34, 35, 21,
+22, 52, 59, 67, 71, 72, 63, 65, 66, 32, 45, 57, 84, 91, 114,
+125, 64, 0, 2, 3, 68, 70, 73, 26, 46, 53, 54, 55, 58, 115,
+131, 74, 12, 96, 97, 99, 41, 42, 44, 49, 50, 75, 80, 83, 85,
+103, 106, 107, 108, 109, 110, 111, 112, 113, 116, 117, 118, 119, 120, 124,
+13, 62, 76, 77, 78, 86, 128, 129, 94, 23, 24, 25, 27, 28, 29,
+30, 31, 37, 38, 39, 40, 43, 47, 48, 51, 4, 5, 6, 7, 8,
+9, 10, 11, 14, 15, 16, 17, 18, 69, 79, 81, 82, 87, 88, 89,
+90, 92, 93, 95, 98, 100, 101, 102, 104, 105, 121, 122, 123, 130, 132,
+3, 2, 10, 11, 1, 4, 6, 8, 5, 7, 9, 0, 31, 30, 15,
+43, 49, 53, 57, 45, 12, 13, 16, 18, 32, 34, 36, 14, 33, 35,
+37, 21, 23, 17, 19, 20, 22, 24, 25, 26, 27, 28, 29, 42, 48,
+52, 56, 38, 41, 44, 46, 50, 54, 39, 40, 47, 51, 55, 35, 36,
+3, 5, 7, 9, 11, 2, 17, 30, 34, 14, 20, 23, 4, 6, 13,
+16, 18, 19, 22, 24, 25, 31, 32, 33, 8, 10, 12, 15, 21, 0,
+1, 26, 27, 28, 29, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+40, 41, 42, 43, 44, 45, 46, 47, 5, 4, 6, 21, 0, 3, 18,
+16, 15, 17, 9, 12, 20, 7, 14, 19, 8, 10, 11, 13, 1, 2,
+167, 168, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
+43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
+58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
+73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
+88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
+103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
+118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
+133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
+148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
+163, 164, 165, 166, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1,
+2, 3, 7, 6, 8, 9, 16, 2, 18, 19, 28, 27, 24, 25, 26,
+17, 3, 20, 22, 21, 23, 13, 0, 4, 14, 1, 5, 12, 10, 11,
+15, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 12, 13,
+14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8,
+9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
+69, 70, 71, 72, 73, 18, 22, 28, 35, 53, 54, 57, 59, 0, 1,
+2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+17, 19, 20, 21, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34,
+36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
+51, 52, 55, 56, 58, 9, 13, 4, 6, 11, 15, 8, 12, 5, 7,
+10, 14, 2, 3, 0, 1, 0, 3, 4, 7, 1, 2, 5, 6, 8,
+9, 10, 0, 1, 2, 65, 64, 66, 52, 46, 49, 53, 59, 44, 48,
+45, 57, 34, 25, 26, 27, 36, 56, 24, 43, 47, 0, 1, 2, 3,
+4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+19, 20, 21, 22, 23, 28, 29, 30, 31, 32, 33, 35, 37, 38, 39,
+40, 41, 42, 50, 51, 54, 55, 58, 60, 61, 62, 63, 0, 1, 2,
+3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
+18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
+63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
+78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
+93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+108, 109, 110, 111, 112, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+40, 41, 42, 43, 44, 45, 46, 47, 48, 0, 1, 2, 3, 4, 5,
+6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8,
+9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
+69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
+84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
+99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
+114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
+129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
+159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
+174, 175, 84, 86, 5, 16, 18, 21, 81, 82, 3, 6, 10, 12, 14,
+22, 24, 26, 29, 39, 41, 42, 54, 56, 58, 60, 62, 75, 0, 1,
+2, 4, 7, 8, 9, 11, 13, 15, 17, 19, 20, 23, 25, 27, 28,
+30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 43, 44, 45, 46, 47,
+48, 49, 50, 51, 52, 53, 55, 57, 59, 61, 63, 64, 65, 66, 67,
+68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, 83, 85, 0,
+2, 4, 6, 14, 16, 18, 20, 8, 31, 10, 11, 24, 25, 28, 29,
+32, 33, 36, 38, 40, 41, 44, 45, 9, 30, 1, 3, 5, 7, 12,
+13, 15, 17, 19, 21, 22, 23, 26, 27, 34, 35, 37, 39, 42, 43,
+46, 47, 27, 28, 35, 36, 45, 46, 13, 14, 59, 60, 0, 1, 2,
+3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15, 16, 17, 18, 19,
+20, 21, 22, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 37, 38,
+39, 40, 41, 42, 43, 44, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+56, 57, 58, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
+73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
+88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
+103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
+118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
+133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
+148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
+163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
+178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
+193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
+208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222,
+223, 224, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+13, 14, 15, 16, 17, 0, 4, 1, 2, 3, 7, 5, 9, 6, 8,
+0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+30, 31, 32, 33, 34, 35, 36, 37, 8, 11, 9, 10, 0, 1, 4,
+5, 2, 3, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+10, 11, 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
+27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
+42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
+72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
+87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
+102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
+117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
+132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
+147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
+162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
+177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206,
+207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221,
+222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236,
+237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
+252, 253, 254, 255, 256, 257, 0, 1, 2, 3, 4, 5, 6, 7, 8,
+9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+35, 1, 2, 20, 29, 32, 33, 34, 0, 3, 4, 5, 6, 7, 8,
+9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,
+25, 26, 27, 28, 30, 31, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+45, 46, 47, 48, 49, 50, 51, 52, 53, 0, 1, 2, 3, 4, 5,
+6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+36, 37, 38, 39, 40, 0, 1, 0, 1, 2, 3, 4, 5, 0, 1,
+2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
+47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
+77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
+107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
+122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
+137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
+152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
+167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181,
+182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196,
+197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211,
+212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226,
+227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
+242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256,
+257, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
+14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
+29, 0, 1, 4, 27, 19, 21, 5, 18, 6, 8, 10, 11, 12, 14,
+15, 16, 17, 20, 0, 1, 2, 3, 7, 9, 13, 22, 23, 24, 25,
+26, 28, 29, 30, 31, 32, 33, 34, 35, 0, 1, 2, 3, 4, 0,
+1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+16, 17, 18, 19, 112, 110, 113, 111, 29, 37, 18, 93, 96, 97, 99,
+98, 92, 100, 104, 105, 108, 101, 61, 62, 69, 77, 86, 70, 78, 85,
+68, 76, 87, 60, 54, 55, 59, 30, 38, 73, 81, 90, 94, 19, 14,
+16, 71, 79, 84, 50, 51, 57, 0, 2, 4, 6, 8, 10, 12, 20,
+26, 34, 44, 64, 72, 80, 91, 40, 63, 13, 5, 7, 9, 11, 15,
+1, 3, 39, 21, 48, 49, 56, 95, 74, 82, 89, 31, 25, 33, 45,
+65, 43, 103, 106, 107, 109, 17, 52, 53, 58, 28, 36, 41, 23, 27,
+35, 47, 42, 66, 22, 24, 32, 46, 67, 75, 83, 88, 102, 6, 7,
+0, 1, 3, 5, 2, 4, 50, 48, 52, 54, 56, 2, 6, 14, 18,
+22, 26, 30, 34, 49, 53, 55, 57, 58, 59, 60, 0, 1, 3, 4,
+5, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 19, 20, 21, 23,
+24, 25, 27, 28, 29, 31, 32, 33, 35, 36, 37, 38, 39, 40, 41,
+42, 43, 44, 45, 46, 47, 51, 23, 24, 25, 26, 16, 18, 20, 22,
+15, 17, 19, 21, 6, 8, 10, 12, 14, 0, 2, 1, 3, 4, 5,
+11, 7, 9, 13, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
+71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
+86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
+101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
+116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
+131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 1, 0,
+2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1,
+2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
+47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 1, 2, 3, 4, 5,
+6, 7, 8, 9, 10, 11, 12, 0, 1, 2, 112, 114, 19, 61, 70,
+18, 111, 3, 5, 6, 66, 82, 109, 110, 113, 58, 102, 104, 31, 35,
+36, 37, 38, 71, 77, 86, 93, 95, 96, 108, 47, 25, 45, 46, 53,
+55, 75, 40, 41, 42, 52, 60, 83, 84, 24, 26, 11, 12, 22, 23,
+28, 30, 57, 63, 65, 69, 81, 90, 106, 32, 33, 34, 49, 50, 51,
+72, 73, 78, 79, 87, 88, 94, 4, 7, 8, 9, 10, 20, 21, 29,
+39, 43, 44, 48, 54, 56, 59, 62, 64, 67, 68, 74, 76, 80, 89,
+91, 92, 100, 101, 115, 116, 16, 99, 13, 14, 15, 17, 27, 85, 97,
+98, 103, 105, 107, 117, 7, 10, 19, 0, 1, 2, 3, 4, 5, 6,
+8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 0, 1, 2, 3, 4,
+5, 7, 17, 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12,
+13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 0, 1, 0, 7, 11,
+5, 6, 10, 3, 4, 1, 2, 8, 9, 12, 0, 1, 2, 3, 4,
+0, 1, 2, 3, 4, 1, 3, 0, 2, 4, 5, 6, 7, 8, 9,
+10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4,
+5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+35, 36, 0, 1, 75, 78, 76, 15, 79, 77, 8, 85, 14, 0, 4,
+10, 81, 83, 84, 87, 12, 80, 82, 11, 9, 2, 6, 86, 36, 38,
+37, 13, 1, 5, 3, 7, 49, 22, 24, 28, 32, 50, 58, 63, 66,
+71, 23, 25, 29, 33, 47, 48, 51, 52, 53, 54, 46, 17, 19, 16,
+20, 21, 26, 27, 30, 31, 34, 35, 39, 40, 41, 42, 43, 44, 45,
+55, 56, 57, 59, 60, 61, 62, 64, 65, 67, 68, 69, 70, 72, 73,
+74, 18, 11, 22, 1, 3, 5, 7, 9, 10, 13, 15, 16, 18, 20,
+26, 28, 0, 2, 4, 6, 8, 12, 14, 17, 19, 21, 23, 24, 25,
+27, 29, 47, 45, 43, 48, 42, 44, 49, 46, 33, 11, 27, 31, 37,
+38, 63, 17, 18, 21, 23, 25, 29, 32, 35, 77, 83, 97, 0, 5,
+9, 15, 16, 19, 39, 41, 53, 69, 20, 22, 24, 26, 28, 30, 34,
+36, 76, 82, 96, 102, 103, 1, 3, 7, 13, 40, 51, 57, 61, 67,
+71, 73, 75, 81, 87, 95, 101, 106, 107, 70, 2, 4, 6, 8, 10,
+12, 14, 50, 52, 54, 55, 56, 58, 59, 60, 62, 64, 65, 66, 68,
+72, 74, 78, 79, 80, 84, 85, 86, 88, 89, 90, 91, 92, 93, 94,
+98, 99, 100, 104, 105, 108, 109, 0, 1, 46, 43, 47, 42, 3, 44,
+5, 20, 4, 18, 24, 26, 30, 38, 34, 36, 7, 9, 22, 2, 45,
+21, 40, 19, 35, 37, 39, 32, 12, 14, 28, 10, 16, 41, 25, 27,
+31, 6, 8, 23, 33, 11, 17, 13, 15, 29, 52, 50, 53, 48, 49,
+51, 0, 1, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
+6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
+51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
+66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
+111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
+126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
+141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
+156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170,
+171, 172, 173, 174, 175, 176, 177, 178, 179, 0, 1, 2, 3, 4, 5,
+6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
+51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
+66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
+111, 112, 113, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
+27, 28, 29, 30, 31, 32, 33, 34, 35, 5, 15, 19, 27, 31, 35,
+39, 43, 96, 104, 120, 121, 131, 0, 1, 2, 10, 12, 24, 25, 46,
+47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 76, 77, 78, 79, 80,
+81, 82, 83, 84, 85, 86, 87, 88, 90, 91, 93, 95, 97, 99, 101,
+103, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
+119, 122, 123, 124, 125, 126, 127, 128, 129, 130, 132, 133, 134, 135, 136,
+137, 138, 140, 144, 148, 152, 156, 160, 164, 3, 4, 6, 7, 8, 9,
+11, 13, 14, 16, 17, 18, 20, 21, 22, 23, 26, 28, 29, 30, 32,
+33, 34, 36, 37, 38, 40, 41, 42, 44, 45, 57, 58, 59, 60, 61,
+62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 89,
+92, 94, 98, 100, 102, 139, 141, 142, 143, 145, 146, 147, 149, 150, 151,
+153, 154, 155, 157, 158, 159, 161, 162, 163, 165, 166, 36, 57, 60, 65,
+68, 114, 135, 156, 161, 162, 165, 170, 176, 179, 182, 183, 188, 191, 194,
+197, 198, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43,
+44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 58, 59,
+61, 62, 63, 64, 66, 67, 69, 70, 71, 72, 73, 74, 75, 76, 77,
+78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
+93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+108, 109, 110, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 122, 123,
+124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 136, 137, 138, 139,
+140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
+155, 157, 158, 159, 160, 163, 164, 166, 167, 168, 169, 171, 172, 173, 174,
+175, 177, 178, 180, 181, 184, 185, 186, 187, 189, 190, 192, 193, 195, 196,
+199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
+214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228,
+229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243,
+244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258,
+259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
+274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
+289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303,
+304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318,
+319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333,
+334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348,
+349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363,
+364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378,
+379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393,
+394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408,
+409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423,
+424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438,
+439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453,
+454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468,
+469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483,
+484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498,
+499, 500, 501, 502, 503, 504, 505, 506, 0, 1, 2, 3, 4, 5, 6,
+7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
+55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
+70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
+85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
+100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
+115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
+130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
+145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
+175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
+190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
+205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
+220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234,
+235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
+250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
+280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
+295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309,
+310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
+325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339,
+340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
+355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369,
+370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
+385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399,
+400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414,
+415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429,
+430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444,
+445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459,
+460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474,
+475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489,
+490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504,
+505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519,
+520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534,
+535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549,
+550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564,
+565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579,
+580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594,
+595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609,
+610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624,
+625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639,
+640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654,
+655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669,
+0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+15, 16, 17, 18, 19, 20, 21, 0, 1, 2, 3, 4, 5, 6, 7,
+8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
+23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
+53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
+68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
+83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
+98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
+113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
+128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
+143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
+158, 159, 160, 161, 162, 163, 164, 165, 166, 0, 1, 2, 3, 4, 5,
+6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5,
+0, 3, 5, 10, 16, 18, 94, 4, 6, 7, 8, 17, 37, 44, 48,
+51, 56, 66, 69, 75, 79, 82, 84, 88, 98, 99, 102, 1, 2, 9,
+11, 12, 13, 14, 15, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
+29, 30, 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 42, 43, 45,
+46, 47, 49, 50, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63,
+64, 65, 67, 68, 70, 71, 72, 73, 74, 76, 77, 78, 80, 81, 83,
+85, 86, 87, 89, 90, 91, 92, 93, 95, 96, 97, 100, 101, 103, 104,
+105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
+135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
+165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
+81, 18, 24, 33, 69, 83, 19, 25, 35, 71, 0, 1, 2, 3, 4,
+5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21,
+22, 23, 26, 27, 28, 29, 30, 31, 32, 34, 36, 37, 38, 39, 40,
+41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 72,
+73, 74, 75, 76, 77, 78, 79, 80, 82, 84, 85, 86, 87, 88, 89,
+90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
+105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
+135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
+165, 166, 167, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+12, 13, 14, 15, 16, 17, 4, 5, 6, 31, 32, 39, 40, 41, 0,
+1, 2, 3, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 33, 34, 35,
+36, 37, 38, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
+69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
+84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
+99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
+114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
+129, 130, 131, 132, 133, 134, 135, 136, 0, 1, 3, 22, 23, 26, 34,
+0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+16, 17, 18, 19, 20, 21, 24, 25, 27, 28, 29, 30, 31, 32, 33,
+35, 36, 37, 38, 39, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0,
+1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
+31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
+46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
+61, 62, 63, 64, 65, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+25, 26, 27, 28, 29, 30, 31, 32, 33, 51, 0, 1, 2, 3, 4,
+5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+50, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
+66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 0, 1, 2,
+3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
+18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 0, 1,
+2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
+47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
+77, 74, 75, 92, 93, 116, 143, 144, 149, 14, 15, 34, 35, 36, 37,
+68, 69, 98, 99, 104, 105, 110, 111, 154, 155, 156, 157, 166, 167, 168,
+169, 178, 179, 180, 181, 4, 5, 6, 7, 22, 23, 24, 25, 46, 47,
+50, 51, 56, 57, 60, 61, 80, 82, 85, 87, 121, 122, 123, 124, 133,
+134, 135, 136, 190, 191, 194, 197, 202, 203, 206, 207, 212, 213, 216, 217,
+0, 1, 2, 3, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20,
+21, 26, 27, 28, 29, 30, 31, 32, 33, 38, 39, 40, 41, 42, 43,
+44, 45, 48, 49, 52, 53, 54, 55, 58, 59, 62, 63, 64, 65, 66,
+67, 70, 71, 72, 73, 76, 77, 78, 79, 81, 83, 84, 86, 88, 89,
+90, 91, 94, 95, 96, 97, 100, 101, 102, 103, 106, 107, 108, 109, 112,
+113, 114, 115, 117, 118, 119, 120, 125, 126, 127, 128, 129, 130, 131, 132,
+137, 138, 139, 140, 141, 142, 145, 146, 147, 148, 150, 151, 152, 153, 158,
+159, 160, 161, 162, 163, 164, 165, 170, 171, 172, 173, 174, 175, 176, 177,
+182, 183, 184, 185, 186, 187, 188, 189, 192, 193, 195, 196, 198, 199, 200,
+201, 204, 205, 208, 209, 210, 211, 214, 215, 218, 219, 220, 221, 0, 1,
+2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 1, 2,
+3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
+18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
+63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
+78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
+93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
+123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
+138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152,
+153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
+168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
+183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
+198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
+213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
+228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
+243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257,
+258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
+273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
+288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302,
+303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317,
+318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332,
+333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
+348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362,
+363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377,
+0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 1, 2, 3,
+4, 5, 6, 7, 0, 1, 14, 15, 16, 17, 2, 3, 4, 5, 8,
+9, 10, 11, 12, 13, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+28, 29, 30, 31, 32, 33, 11, 2, 5, 10, 8, 4, 9, 1, 7,
+3, 0, 6, 42, 45, 36, 39, 12, 16, 18, 22, 38, 41, 44, 47,
+37, 40, 43, 46, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+11, 13, 14, 15, 17, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29,
+30, 31, 32, 33, 34, 35, 0, 1, 2, 3, 4, 5, 6, 7, 8,
+9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
+39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
+69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
+84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
+99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
+114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
+129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
+159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
+174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
+189, 190, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
+43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
+58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
+73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
+88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
+103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 4, 5,
+6, 8, 1, 3, 0, 2, 7, 9, 0, 1, 2, 3, 4, 5, 6,
+7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
+37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
+67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
+82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
+97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
+127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141,
+142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156,
+157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
+172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
+187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201,
+202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216,
+217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231,
+232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246,
+247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261,
+262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
+277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
+292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306,
+307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321,
+322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336,
+337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351,
+352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366,
+367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381,
+382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396,
+397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411,
+412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426,
+427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441,
+442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456,
+457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471,
+472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486,
+487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501,
+502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516,
+517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531,
+532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546,
+547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561,
+562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576,
+577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591,
+592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606,
+607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621,
+622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636,
+637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651,
+652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666,
+667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681,
+682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696,
+697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711,
+712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726,
+727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741,
+742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756,
+757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771,
+772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786,
+787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801,
+802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816,
+817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831,
+832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846,
+847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861,
+862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876,
+877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891,
+892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906,
+907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921,
+922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936,
+937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951,
+952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966,
+967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981,
+982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996,
+997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011,
+1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026,
+1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041,
+1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056,
+1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071,
+1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086,
+1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101,
+1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116,
+1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131,
+1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146,
+1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161,
+1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176,
+1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191,
+1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206,
+1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221,
+1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236,
+1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251,
+1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266,
+1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281,
+1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296,
+1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311,
+1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326,
+1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341,
+1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356,
+1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371,
+1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386,
+1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401,
+1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415, 1416,
+1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431,
+1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446,
+1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461,
+1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476,
+1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491,
+1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506,
+1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521,
+1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536,
+1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551,
+1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566,
+1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581,
+1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596,
+1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611,
+1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626,
+1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641,
+1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656,
+1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671,
+1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686,
+1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1700, 1701,
+1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713, 1714, 1715, 1716,
+1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, 1730, 1731,
+1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1746,
+1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761,
+1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776,
+1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791,
+1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806,
+1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821,
+1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836,
+1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851,
+1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866,
+1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881,
+1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896,
+1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911,
+1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926,
+1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941,
+1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956,
+1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971,
+1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986,
+1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016,
+2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031,
+2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, 2046,
+2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061,
+2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, 2076,
+2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091,
+2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106,
+2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121,
+2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, 2136,
+2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151,
+2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159, 2160, 2161, 2162, 2163, 2164, 2165, 2166,
+2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2179, 2180, 2181,
+2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193, 2194, 2195, 2196,
+2197, 2198, 2199, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211,
+2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2225, 2226,
+2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238, 2239, 2240, 2241,
+2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253, 2254, 2255, 2256,
+2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271,
+2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286,
+2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2296, 2297, 2298, 2299, 2300, 2301,
+2302, 2303, 2304, 2305, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 2316,
+2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, 2329, 2330, 2331,
+2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2343, 2344, 2345, 2346,
+2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, 2360, 2361,
+2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373, 2374, 2375, 2376,
+2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391,
+2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406,
+2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421,
+2422, 2423, 2424, 2425, 2426, 2427, 2428, 2429, 2430, 2431, 2432, 2433, 2434, 2435, 2436,
+2437, 2438, 2439, 2440, 2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448, 2449, 2450, 2451,
+2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466,
+2467, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481,
+2482, 2483, 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2494, 2495, 2496,
+2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511,
+2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523, 2524, 2525, 2526,
+2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537, 2538, 2539, 2540, 2541,
+2542, 2543, 2544, 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556,
+2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568, 2569, 2570, 2571,
+2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586,
+2587, 2588, 2589, 2590, 2591, 2592, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601,
+2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2612, 2613, 2614, 2615, 2616,
+2617, 2618, 2619, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627, 2628, 2629, 2630, 2631,
+2632, 2633, 2634, 2635, 2636, 2637, 2638, 2639, 2640, 2641, 2642, 2643, 2644, 2645, 2646,
+2647, 2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2658, 2659, 2660, 2661,
+2662, 2663, 2664, 2665, 2666, 2667, 2668, 2669, 2670, 2671, 2672, 2673, 2674, 2675, 2676,
+2677, 2678, 2679, 2680, 2681, 2682, 2683, 2684, 2685, 2686, 2687, 2688, 2689, 2690, 2691,
+2692, 2693, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706,
+2707, 2708, 2709, 2710, 2711, 2712, 2713, 2714, 2715, 2716, 2717, 2718, 2719, 2720, 2721,
+2722, 2723, 2724, 2725, 2726, 2727, 2728, 2729, 2730, 2731, 2732, 2733, 2734, 2735, 2736,
+2737, 2738, 2739, 2740, 2741, 2742, 2743, 2744, 2745, 2746, 2747, 2748, 2749, 2750, 2751,
+2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760, 2761, 2762, 2763, 2764, 2765, 2766,
+2767, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778, 2779, 2780, 2781,
+2782, 2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2792, 2793, 2794, 2795, 2796,
+2797, 2798, 2799, 2800, 2801, 2802, 2803, 2804, 2805, 2806, 2807, 2808, 2809, 2810, 2811,
+2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823, 2824, 2825, 2826,
+2827, 2828, 2829, 2830, 2831, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2840, 2841,
+2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856,
+2857, 2858, 2859, 2860, 2861, 2862, 2863, 9, 11, 6, 7, 8, 10, 4, 5,
+0, 1, 2, 3, 0, 2, 10, 3, 6, 1, 9, 11, 4, 8, 7,
+5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
+14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
+29, 30, 31, 32, 33, 34, 35, 68, 116, 22, 10, 97, 117, 52, 110,
+7, 19, 111, 115, 6, 18, 0, 74, 88, 12, 48, 108, 99, 109, 38,
+104, 4, 16, 24, 96, 15, 3, 50, 84, 71, 85, 36, 102, 103, 119,
+54, 86, 100, 30, 25, 105, 113, 69, 53, 63, 98, 87, 93, 89, 95,
+9, 21, 62, 114, 5, 17, 26, 55, 2, 14, 65, 8, 20, 64, 92,
+42, 106, 11, 23, 46, 66, 34, 101, 107, 56, 35, 47, 57, 67, 76,
+118, 75, 83, 82, 94, 37, 77, 29, 51, 1, 13, 27, 49, 58, 112,
+39, 59, 28, 70, 44, 73, 80, 81, 32, 72, 31, 43, 33, 40, 41,
+45, 60, 61, 78, 79, 90, 91
+};
+
+
/**Function*************************************************************
Synopsis [Reads library from array.]
@@ -9461,6 +11120,27 @@ Vec_Int_t * Dar_LibReadOuts()
return vResult;
}
+/**Function*************************************************************
+
+ Synopsis [Reads library from array.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Dar_LibReadPrios()
+{
+ Vec_Int_t * vResult;
+ int i;
+ vResult = Vec_IntAlloc( s_nDataSize3 );
+ for ( i = 0; i < s_nDataSize3; i++ )
+ Vec_IntPush( vResult, s_Data3[i] );
+ return vResult;
+}
+
//#if 0
#include "abc.h"
@@ -9476,7 +11156,7 @@ Vec_Int_t * Dar_LibReadOuts()
SeeAlso []
***********************************************************************/
-void Dar_NtkGenerateArrays( Abc_Ntk_t * pNtk )
+void Aig_NtkGenerateArrays( Abc_Ntk_t * pNtk )
{
extern int Io_WriteAigerEncode( char * pBuffer, int Pos, unsigned x );
diff --git a/src/aig/dar/darInt.h b/src/aig/dar/darInt.h
new file mode 100644
index 00000000..0eb8f9fe
--- /dev/null
+++ b/src/aig/dar/darInt.h
@@ -0,0 +1,158 @@
+/**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 ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/aig/dar/darLib.c b/src/aig/dar/darLib.c
index 89ce2f0b..fce6155b 100644
--- a/src/aig/dar/darLib.c
+++ b/src/aig/dar/darLib.c
@@ -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 ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/dar/darMan.c b/src/aig/dar/darMan.c
index 52df8890..a209503a 100644
--- a/src/aig/dar/darMan.c
+++ b/src/aig/dar/darMan.c
@@ -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 );
}
+*/
}
diff --git a/src/aig/dar/darTruth.c b/src/aig/dar/darTruth.c
index 16b9f62a..7fd47787 100644
--- a/src/aig/dar/darTruth.c
+++ b/src/aig/dar/darTruth.c
@@ -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 ///
diff --git a/src/aig/dar/module.make b/src/aig/dar/module.make
index 4bf473d4..bcf9a2e6 100644
--- a/src/aig/dar/module.make
+++ b/src/aig/dar/module.make
@@ -1,15 +1,7 @@
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
diff --git a/src/aig/fra/fra.h b/src/aig/fra/fra.h
index 29195d19..7f2df105 100644
--- a/src/aig/fra/fra.h
+++ b/src/aig/fra/fra.h
@@ -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 );
diff --git a/src/aig/fra/fraAnd.c b/src/aig/fra/fraAnd.c
index a360ce9b..36b4ccc3 100644
--- a/src/aig/fra/fraAnd.c
+++ b/src/aig/fra/fraAnd.c
@@ -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 );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/fra/fraClass.c b/src/aig/fra/fraClass.c
index 33421423..3de54453 100644
--- a/src/aig/fra/fraClass.c
+++ b/src/aig/fra/fraClass.c
@@ -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 );
diff --git a/src/aig/fra/fraCnf.c b/src/aig/fra/fraCnf.c
index a662ade2..7df55d93 100644
--- a/src/aig/fra/fraCnf.c
+++ b/src/aig/fra/fraCnf.c
@@ -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 );
diff --git a/src/aig/fra/fraCore.c b/src/aig/fra/fraCore.c
index 7fdd1b83..5338d662 100644
--- a/src/aig/fra/fraCore.c
+++ b/src/aig/fra/fraCore.c
@@ -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 );
diff --git a/src/aig/fra/fraMan.c b/src/aig/fra/fraMan.c
index 19ed6c03..78246a8c 100644
--- a/src/aig/fra/fraMan.c
+++ b/src/aig/fra/fraMan.c
@@ -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 );
diff --git a/src/aig/fra/fraSat.c b/src/aig/fra/fraSat.c
index 1c72c807..66b1ba5a 100644
--- a/src/aig/fra/fraSat.c
+++ b/src/aig/fra/fraSat.c
@@ -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;
diff --git a/src/aig/fra/fraSim.c b/src/aig/fra/fraSim.c
index 7207cfa2..beaa79fd 100644
--- a/src/aig/fra/fraSim.c
+++ b/src/aig/fra/fraSim.c
@@ -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;
}
diff --git a/src/opt/kit/kit.h b/src/aig/kit/kit.h
index e9a389e0..e9a389e0 100644
--- a/src/opt/kit/kit.h
+++ b/src/aig/kit/kit.h
diff --git a/src/opt/kit/kitBdd.c b/src/aig/kit/kitBdd.c
index 9c8d4f7a..9c8d4f7a 100644
--- a/src/opt/kit/kitBdd.c
+++ b/src/aig/kit/kitBdd.c
diff --git a/src/opt/kit/kitDsd.c b/src/aig/kit/kitDsd.c
index 06377cba..06377cba 100644
--- a/src/opt/kit/kitDsd.c
+++ b/src/aig/kit/kitDsd.c
diff --git a/src/opt/kit/kitFactor.c b/src/aig/kit/kitFactor.c
index 4ef3fd94..4ef3fd94 100644
--- a/src/opt/kit/kitFactor.c
+++ b/src/aig/kit/kitFactor.c
diff --git a/src/opt/kit/kitGraph.c b/src/aig/kit/kitGraph.c
index 8bc7ca91..8bc7ca91 100644
--- a/src/opt/kit/kitGraph.c
+++ b/src/aig/kit/kitGraph.c
diff --git a/src/opt/kit/kitHop.c b/src/aig/kit/kitHop.c
index 95461c4e..95461c4e 100644
--- a/src/opt/kit/kitHop.c
+++ b/src/aig/kit/kitHop.c
diff --git a/src/opt/kit/kitIsop.c b/src/aig/kit/kitIsop.c
index cc61a6bd..cc61a6bd 100644
--- a/src/opt/kit/kitIsop.c
+++ b/src/aig/kit/kitIsop.c
diff --git a/src/opt/kit/kitSop.c b/src/aig/kit/kitSop.c
index 3fa81351..3fa81351 100644
--- a/src/opt/kit/kitSop.c
+++ b/src/aig/kit/kitSop.c
diff --git a/src/opt/kit/kitTruth.c b/src/aig/kit/kitTruth.c
index d41e5d4e..d41e5d4e 100644
--- a/src/opt/kit/kitTruth.c
+++ b/src/aig/kit/kitTruth.c
diff --git a/src/opt/kit/kit_.c b/src/aig/kit/kit_.c
index 5c68ee3c..5c68ee3c 100644
--- a/src/opt/kit/kit_.c
+++ b/src/aig/kit/kit_.c
diff --git a/src/aig/kit/module.make b/src/aig/kit/module.make
new file mode 100644
index 00000000..a01690d0
--- /dev/null
+++ b/src/aig/kit/module.make
@@ -0,0 +1,8 @@
+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
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 9c2c0153..6b305033 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.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;
diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c
index ed6fa77e..c4020127 100644
--- a/src/base/abci/abcDar.c
+++ b/src/base/abci/abcDar.c
@@ -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;
}
diff --git a/src/map/if/ifCut.c b/src/map/if/ifCut.c
index 57dd2c41..1a7ecc2c 100644
--- a/src/map/if/ifCut.c
+++ b/src/map/if/ifCut.c
@@ -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.]
diff --git a/src/opt/bdc/module.make b/src/opt/bdc/module.make
deleted file mode 100644
index 85936f5b..00000000
--- a/src/opt/bdc/module.make
+++ /dev/null
@@ -1,8 +0,0 @@
-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
diff --git a/src/opt/kit/module.make b/src/opt/kit/module.make
deleted file mode 100644
index d1363ee2..00000000
--- a/src/opt/kit/module.make
+++ /dev/null
@@ -1,8 +0,0 @@
-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
diff --git a/src/opt/rwr/rwrEva.c b/src/opt/rwr/rwrEva.c
index 9696b027..f46c16c0 100644
--- a/src/opt/rwr/rwrEva.c
+++ b/src/opt/rwr/rwrEva.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 )