summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2006-11-22 08:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2006-11-22 08:01:00 -0800
commit6ad22b4d3b0446652919d95b15fefb374bddfac0 (patch)
treeeb525005c9827e844464c4e787c5907c7edc1d5c
parentda5e0785dfb98335bd49a13bf9e86e736fb931be (diff)
downloadabc-6ad22b4d3b0446652919d95b15fefb374bddfac0.tar.gz
abc-6ad22b4d3b0446652919d95b15fefb374bddfac0.tar.bz2
abc-6ad22b4d3b0446652919d95b15fefb374bddfac0.zip
Version abc61122
-rw-r--r--Makefile8
-rw-r--r--abc.dsp506
-rw-r--r--abc.rc3
-rw-r--r--src/aig/aig-alan.tar.gzbin0 -> 27265 bytes
-rw-r--r--src/aig/deco/deco.h (renamed from src/temp/deco/deco.h)0
-rw-r--r--src/aig/deco/module.make (renamed from src/temp/deco/module.make)0
-rw-r--r--src/aig/ec/module.make1
-rw-r--r--src/aig/hop/cudd2.c (renamed from src/temp/aig/cudd2.c)2
-rw-r--r--src/aig/hop/cudd2.h (renamed from src/temp/aig/cudd2.h)0
-rw-r--r--src/aig/hop/hop.h321
-rw-r--r--src/aig/hop/hopBalance.c (renamed from src/temp/aig/aigBalance.c)134
-rw-r--r--src/aig/hop/hopCheck.c (renamed from src/temp/aig_free/aigCheck.c)50
-rw-r--r--src/aig/hop/hopDfs.c (renamed from src/temp/aig/aigDfs.c)218
-rw-r--r--src/aig/hop/hopMan.c (renamed from src/temp/aig/aigMan.c)62
-rw-r--r--src/aig/hop/hopMem.c (renamed from src/temp/aig_free/aigMem.c)24
-rw-r--r--src/aig/hop/hopObj.c (renamed from src/temp/aig/aigObj.c)100
-rw-r--r--src/aig/hop/hopOper.c (renamed from src/temp/aig_free/aigOper.c)178
-rw-r--r--src/aig/hop/hopTable.c (renamed from src/temp/aig/aigTable.c)88
-rw-r--r--src/aig/hop/hopUtil.c (renamed from src/temp/aig/aigUtil.c)272
-rw-r--r--src/aig/hop/hop_.c (renamed from src/temp/aig/aig_.c)0
-rw-r--r--src/aig/hop/module.make9
-rw-r--r--src/aig/ivy/attr.h414
-rw-r--r--src/aig/ivy/ivy.h (renamed from src/temp/ivy/ivy.h)8
-rw-r--r--src/aig/ivy/ivyBalance.c (renamed from src/temp/ivy/ivyBalance.c)0
-rw-r--r--src/aig/ivy/ivyCanon.c (renamed from src/temp/ivy/ivyCanon.c)0
-rw-r--r--src/aig/ivy/ivyCheck.c (renamed from src/temp/ivy/ivyCheck.c)0
-rw-r--r--src/aig/ivy/ivyCut.c (renamed from src/temp/ivy/ivyCut.c)0
-rw-r--r--src/aig/ivy/ivyCutTrav.c (renamed from src/temp/ivy/ivyCutTrav.c)0
-rw-r--r--src/aig/ivy/ivyDfs.c (renamed from src/temp/ivy/ivyDfs.c)0
-rw-r--r--src/aig/ivy/ivyDsd.c (renamed from src/temp/ivy/ivyDsd.c)0
-rw-r--r--src/aig/ivy/ivyFanout.c (renamed from src/temp/ivy/ivyFanout.c)0
-rw-r--r--src/aig/ivy/ivyFastMap.c (renamed from src/temp/ivy/ivyFastMap.c)0
-rw-r--r--src/aig/ivy/ivyFpga.c378
-rw-r--r--src/aig/ivy/ivyFraig.c (renamed from src/temp/ivy/ivyFraig.c)222
-rw-r--r--src/aig/ivy/ivyHaig.c (renamed from src/temp/ivy/ivyHaig.c)0
-rw-r--r--src/aig/ivy/ivyIsop.c (renamed from src/temp/ivy/ivyIsop.c)0
-rw-r--r--src/aig/ivy/ivyMan.c (renamed from src/temp/ivy/ivyMan.c)4
-rw-r--r--src/aig/ivy/ivyMem.c (renamed from src/temp/ivy/ivyMem.c)0
-rw-r--r--src/aig/ivy/ivyMulti.c (renamed from src/temp/ivy/ivyMulti.c)0
-rw-r--r--src/aig/ivy/ivyMulti8.c (renamed from src/temp/ivy/ivyMulti8.c)0
-rw-r--r--src/aig/ivy/ivyObj.c (renamed from src/temp/ivy/ivyObj.c)0
-rw-r--r--src/aig/ivy/ivyOper.c (renamed from src/temp/ivy/ivyOper.c)0
-rw-r--r--src/aig/ivy/ivyResyn.c (renamed from src/temp/ivy/ivyResyn.c)0
-rw-r--r--src/aig/ivy/ivyRwr.c (renamed from src/temp/ivy/ivyRwr.c)0
-rw-r--r--src/aig/ivy/ivyRwrAlg.c (renamed from src/temp/ivy/ivyRwrAlg.c)0
-rw-r--r--src/aig/ivy/ivySeq.c (renamed from src/temp/ivy/ivySeq.c)2
-rw-r--r--src/aig/ivy/ivyShow.c (renamed from src/temp/ivy/ivyShow.c)0
-rw-r--r--src/aig/ivy/ivyTable.c (renamed from src/temp/ivy/ivyTable.c)0
-rw-r--r--src/aig/ivy/ivyUtil.c (renamed from src/temp/ivy/ivyUtil.c)0
-rw-r--r--src/aig/ivy/ivy_.c (renamed from src/temp/ivy/ivy_.c)0
-rw-r--r--src/aig/ivy/module.make23
-rw-r--r--src/aig/mem/mem.c (renamed from src/temp/mem/mem.c)0
-rw-r--r--src/aig/mem/mem.h (renamed from src/temp/mem/mem.h)0
-rw-r--r--src/aig/mem/module.make1
-rw-r--r--src/aig/rwt/module.make3
-rw-r--r--src/aig/rwt/rwt.h (renamed from src/temp/rwt/rwt.h)0
-rw-r--r--src/aig/rwt/rwtDec.c (renamed from src/temp/rwt/rwtDec.c)0
-rw-r--r--src/aig/rwt/rwtMan.c (renamed from src/temp/rwt/rwtMan.c)0
-rw-r--r--src/aig/rwt/rwtUtil.c (renamed from src/temp/rwt/rwtUtil.c)0
-rw-r--r--src/base/abc/abc.h37
-rw-r--r--src/base/abc/abcAig.c2
-rw-r--r--src/base/abc/abcCheck.c23
-rw-r--r--src/base/abc/abcDfs.c215
-rw-r--r--src/base/abc/abcFanio.c4
-rw-r--r--src/base/abc/abcFunc.c82
-rw-r--r--src/base/abc/abcLatch.c4
-rw-r--r--src/base/abc/abcLib.c4
-rw-r--r--src/base/abc/abcNetlist.c22
-rw-r--r--src/base/abc/abcNtk.c50
-rw-r--r--src/base/abc/abcObj.c30
-rw-r--r--src/base/abc/abcShow.c126
-rw-r--r--src/base/abc/abcSop.c5
-rw-r--r--src/base/abc/abcUtil.c29
-rw-r--r--src/base/abci/abc.c556
-rw-r--r--src/base/abci/abcAuto.c22
-rw-r--r--src/base/abci/abcClpBdd.c30
-rw-r--r--src/base/abci/abcCut.c3
-rw-r--r--src/base/abci/abcDebug.c20
-rw-r--r--src/base/abci/abcDsd.c41
-rw-r--r--src/base/abci/abcFpgaFast.c6
-rw-r--r--src/base/abci/abcIf.c287
-rw-r--r--src/base/abci/abcIvy.c21
-rw-r--r--src/base/abci/abcLut.c2
-rw-r--r--src/base/abci/abcMini.c54
-rw-r--r--src/base/abci/abcNtbdd.c137
-rw-r--r--src/base/abci/abcPrint.c80
-rw-r--r--src/base/abci/abcProve.c2
-rw-r--r--src/base/abci/abcRefactor.c2
-rw-r--r--src/base/abci/abcRestruct.c2
-rw-r--r--src/base/abci/abcResub.c2
-rw-r--r--src/base/abci/abcRewrite.c2
-rw-r--r--src/base/abci/abcRr.c6
-rw-r--r--src/base/abci/abcSat.c2
-rw-r--r--src/base/abci/abcStrash.c55
-rw-r--r--src/base/abci/abcSweep.c38
-rw-r--r--src/base/abci/abcSymm.c12
-rw-r--r--src/base/abci/abcTiming.c4
-rw-r--r--src/base/abci/abcUnate.c23
-rw-r--r--src/base/abci/abcUnreach.c10
-rw-r--r--src/base/abci/module.make2
-rw-r--r--src/base/io/io.c14
-rw-r--r--src/base/io/io.h4
-rw-r--r--src/base/io/ioUtil.c2
-rw-r--r--src/base/io/ioWriteDot.c260
-rw-r--r--src/base/io/ioWritePla.c2
-rw-r--r--src/base/io/ioWriteVer.c8
-rw-r--r--src/base/main/libSupport.c4
-rw-r--r--src/base/ver/module.make4
-rw-r--r--src/base/ver/ver.h (renamed from src/temp/ver/ver.h)0
-rw-r--r--src/base/ver/verCore.c (renamed from src/temp/ver/verCore.c)14
-rw-r--r--src/base/ver/verFormula.c (renamed from src/temp/ver/verFormula.c)36
-rw-r--r--src/base/ver/verParse.c (renamed from src/temp/ver/verParse.c)0
-rw-r--r--src/base/ver/verStream.c (renamed from src/temp/ver/verStream.c)0
-rw-r--r--src/base/ver/verWords.c (renamed from src/temp/ver/verWords.c)0
-rw-r--r--src/base/ver/ver_.c (renamed from src/temp/ver/ver_.c)0
-rw-r--r--src/map/fpga/fpga.h2
-rw-r--r--src/map/fpga/fpgaCut.c3
-rw-r--r--src/map/if/if.h255
-rw-r--r--src/map/if/ifCore.c47
-rw-r--r--src/map/if/ifCut.c47
-rw-r--r--src/map/if/ifMan.c250
-rw-r--r--src/map/if/ifMap.c391
-rw-r--r--src/map/if/ifUtil.c229
-rw-r--r--src/map/if/if_.c47
-rw-r--r--src/map/if/module.make4
-rw-r--r--src/map/pga/module.make4
-rw-r--r--src/map/pga/pga.h80
-rw-r--r--src/map/pga/pgaCore.c152
-rw-r--r--src/map/pga/pgaInt.h132
-rw-r--r--src/map/pga/pgaMan.c180
-rw-r--r--src/map/pga/pgaMatch.c378
-rw-r--r--src/map/pga/pgaUtil.c320
-rw-r--r--src/misc/vec/vec.h1
-rw-r--r--src/misc/vec/vecAtt.h392
-rw-r--r--src/opt/cut/abcCut.c2
-rw-r--r--src/opt/dec/decAbc.c22
-rw-r--r--src/opt/ret/module.make3
-rw-r--r--src/opt/ret/retArea.c331
-rw-r--r--src/opt/ret/retCore.c26
-rw-r--r--src/opt/ret/retDelay.c24
-rw-r--r--src/opt/ret/retFlow.c370
-rw-r--r--src/opt/ret/retIncrem.c44
-rw-r--r--src/opt/ret/retInit.c1
-rw-r--r--src/opt/ret/retInt.h6
-rw-r--r--src/opt/ret/retLvalue.c419
-rw-r--r--src/sat/bsat/satSolver.c4
-rw-r--r--src/sat/fraig/fraigMan.c1
-rw-r--r--src/temp/aig/aig.h321
-rw-r--r--src/temp/aig/aigCheck.c110
-rw-r--r--src/temp/aig/aigMem.c115
-rw-r--r--src/temp/aig/aigOper.c373
-rw-r--r--src/temp/aig/module.make9
-rw-r--r--src/temp/aig_free/aig.h321
-rw-r--r--src/temp/aig_free/aigBalance.c391
-rw-r--r--src/temp/aig_free/aigDfs.c399
-rw-r--r--src/temp/aig_free/aigMan.c162
-rw-r--r--src/temp/aig_free/aigObj.c228
-rw-r--r--src/temp/aig_free/aigTable.c266
-rw-r--r--src/temp/aig_free/aigUtil.c513
-rw-r--r--src/temp/aig_free/cudd2.c375
-rw-r--r--src/temp/aig_free/cudd2.h83
-rw-r--r--src/temp/aig_free/st.c626
-rw-r--r--src/temp/aig_free/st.h96
-rw-r--r--src/temp/aig_free/subdir.mk87
-rw-r--r--src/temp/aig_free/vec.h82
-rw-r--r--src/temp/aig_free/vecFlt.h667
-rw-r--r--src/temp/aig_free/vecInt.h781
-rw-r--r--src/temp/aig_free/vecPtr.h587
-rw-r--r--src/temp/aig_free/vecStr.h510
-rw-r--r--src/temp/aig_free/vecVec.h289
-rw-r--r--src/temp/ivy/module.make23
-rw-r--r--src/temp/mem/module.make1
-rw-r--r--src/temp/rwt/module.make3
-rw-r--r--src/temp/ver/module.make4
174 files changed, 6080 insertions, 10942 deletions
diff --git a/Makefile b/Makefile
index cf5e864f..3b37b2e6 100644
--- a/Makefile
+++ b/Makefile
@@ -6,13 +6,13 @@ CP := cp
PROG := abc
-MODULES := src/base/abc src/base/abci src/base/cmd src/base/io src/base/main \
+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/mem/deco src/aig/ec \
src/bdd/cudd src/bdd/dsd src/bdd/epd src/bdd/mtr src/bdd/parse src/bdd/reo \
- src/map/fpga src/map/pga src/map/mapper src/map/mio src/map/super \
+ src/map/fpga src/map/pga src/map/mapper src/map/mio src/map/super src/map/if \
src/misc/extra src/misc/mvc src/misc/st src/misc/util 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/sat/asat src/sat/bsat src/sat/csat src/sat/msat src/sat/fraig \
- src/temp/ivy src/temp/aig src/temp/rwt src/temp/deco src/temp/mem src/temp/ver
+ src/sat/asat src/sat/bsat src/sat/csat src/sat/msat src/sat/fraig
default: $(PROG)
diff --git a/abc.dsp b/abc.dsp
index f37efc65..c94c0e6d 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\map\fpga" /I "src\map\pga" /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\temp\ivy" /I "src\temp\esop" /I "src\temp\rwt" /I "src\temp\deco" /I "src\temp\mem" /I "src\temp\aig" /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\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\temp\esop" /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\map\fpga" /I "src\map\pga" /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\temp\ivy" /I "src\temp\esop" /I "src\temp\rwt" /I "src\temp\deco" /I "src\temp\mem" /I "src\temp\aig" /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\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\temp\esop" /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"
@@ -238,6 +238,10 @@ SOURCE=.\src\base\abci\abcGen.c
# End Source File
# Begin Source File
+SOURCE=.\src\base\abci\abcIf.c
+# End Source File
+# Begin Source File
+
SOURCE=.\src\base\abci\abcIvy.c
# End Source File
# Begin Source File
@@ -270,10 +274,6 @@ SOURCE=.\src\base\abci\abcOrder.c
# End Source File
# Begin Source File
-SOURCE=.\src\base\abci\abcPga.c
-# End Source File
-# Begin Source File
-
SOURCE=.\src\base\abci\abcPrint.c
# End Source File
# Begin Source File
@@ -505,6 +505,226 @@ SOURCE=.\src\base\main\mainInt.h
SOURCE=.\src\base\main\mainUtils.c
# End Source File
# End Group
+# Begin Group "ver"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\base\ver\ver.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\ver\verCore.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\ver\verFormula.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\ver\verParse.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\ver\verStream.c
+# End Source File
+# 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\ivyFpga.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\ivyIsop.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
# End Group
# Begin Group "bdd"
@@ -1364,6 +1584,10 @@ SOURCE=.\src\opt\ret\retInit.c
SOURCE=.\src\opt\ret\retInt.h
# End Source File
+# Begin Source File
+
+SOURCE=.\src\opt\ret\retLvalue.c
+# End Source File
# End Group
# End Group
# Begin Group "map"
@@ -1577,32 +1801,32 @@ SOURCE=.\src\map\super\superInt.h
SOURCE=.\src\map\super\superWrite.c
# End Source File
# End Group
-# Begin Group "pga"
+# Begin Group "if"
# PROP Default_Filter ""
# Begin Source File
-SOURCE=.\src\map\pga\pga.h
+SOURCE=.\src\map\if\if.h
# End Source File
# Begin Source File
-SOURCE=.\src\map\pga\pgaCore.c
+SOURCE=.\src\map\if\ifCore.c
# End Source File
# Begin Source File
-SOURCE=.\src\map\pga\pgaInt.h
+SOURCE=.\src\map\if\ifCut.c
# End Source File
# Begin Source File
-SOURCE=.\src\map\pga\pgaMan.c
+SOURCE=.\src\map\if\ifMan.c
# End Source File
# Begin Source File
-SOURCE=.\src\map\pga\pgaMatch.c
+SOURCE=.\src\map\if\ifMap.c
# End Source File
# Begin Source File
-SOURCE=.\src\map\pga\pgaUtil.c
+SOURCE=.\src\map\if\ifUtil.c
# End Source File
# End Group
# End Group
@@ -1774,6 +1998,10 @@ SOURCE=.\src\misc\vec\vec.h
# End Source File
# Begin Source File
+SOURCE=.\src\misc\vec\vecAtt.h
+# End Source File
+# Begin Source File
+
SOURCE=.\src\misc\vec\vecFlt.h
# End Source File
# Begin Source File
@@ -2025,258 +2253,6 @@ SOURCE=.\src\misc\hash\hashPtr.h
# Begin Group "temp"
# PROP Default_Filter ""
-# Begin Group "ivy"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivy.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyBalance.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyCanon.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyCheck.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyCut.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyCutTrav.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyDfs.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyDsd.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyFanout.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyFastMap.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyFraig.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyHaig.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyIsop.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyMem.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyMulti.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyObj.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyOper.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyResyn.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyRwr.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivySeq.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyShow.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyTable.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ivy\ivyUtil.c
-# End Source File
-# End Group
-# Begin Group "player"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\temp\player\player.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\player\playerCore.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\player\playerMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\player\playerToAbc.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\player\playerUtil.c
-# End Source File
-# End Group
-# Begin Group "esop"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\temp\esop\esop.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\esop\esopMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\esop\esopMin.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\esop\esopUtil.c
-# End Source File
-# End Group
-# Begin Group "rwt"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\temp\rwt\rwt.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\rwt\rwtDec.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\rwt\rwtMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\rwt\rwtUtil.c
-# End Source File
-# End Group
-# Begin Group "deco"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\temp\deco\deco.h
-# End Source File
-# End Group
-# Begin Group "mem"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\temp\mem\mem.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\mem\mem.h
-# End Source File
-# End Group
-# Begin Group "ver"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\temp\ver\ver.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ver\verCore.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ver\verFormula.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ver\verParse.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\ver\verStream.c
-# End Source File
-# End Group
-# Begin Group "aig"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\src\temp\aig\aig.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\aig\aigBalance.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\aig\aigCheck.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\aig\aigDfs.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\aig\aigMan.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\aig\aigMem.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\aig\aigObj.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\aig\aigOper.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\aig\aigTable.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\src\temp\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 abde3836..e4902714 100644
--- a/abc.rc
+++ b/abc.rc
@@ -43,6 +43,9 @@ alias psy print_symm
alias pun print_unate
alias q quit
alias r read
+alias r3 retime -M 3
+alias r3f retime -M 3 -f
+alias r3b retime -M 3 -b
alias ren renode
alias rl read_blif
alias rb read_bench
diff --git a/src/aig/aig-alan.tar.gz b/src/aig/aig-alan.tar.gz
new file mode 100644
index 00000000..b61827ad
--- /dev/null
+++ b/src/aig/aig-alan.tar.gz
Binary files differ
diff --git a/src/temp/deco/deco.h b/src/aig/deco/deco.h
index 67126902..67126902 100644
--- a/src/temp/deco/deco.h
+++ b/src/aig/deco/deco.h
diff --git a/src/temp/deco/module.make b/src/aig/deco/module.make
index d6d908e7..d6d908e7 100644
--- a/src/temp/deco/module.make
+++ b/src/aig/deco/module.make
diff --git a/src/aig/ec/module.make b/src/aig/ec/module.make
new file mode 100644
index 00000000..d6d908e7
--- /dev/null
+++ b/src/aig/ec/module.make
@@ -0,0 +1 @@
+SRC +=
diff --git a/src/temp/aig/cudd2.c b/src/aig/hop/cudd2.c
index 3cc38260..28d13ce0 100644
--- a/src/temp/aig/cudd2.c
+++ b/src/aig/hop/cudd2.c
@@ -18,7 +18,7 @@
***********************************************************************/
-#include "aig.h"
+#include "hop.h"
#include "st.h"
////////////////////////////////////////////////////////////////////////
diff --git a/src/temp/aig/cudd2.h b/src/aig/hop/cudd2.h
index 69711c11..69711c11 100644
--- a/src/temp/aig/cudd2.h
+++ b/src/aig/hop/cudd2.h
diff --git a/src/aig/hop/hop.h b/src/aig/hop/hop.h
new file mode 100644
index 00000000..a5d6e2e5
--- /dev/null
+++ b/src/aig/hop/hop.h
@@ -0,0 +1,321 @@
+/**CFile****************************************************************
+
+ FileName [hop.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Minimalistic And-Inverter Graph package.]
+
+ Synopsis [External declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - May 11, 2006.]
+
+ Revision [$Id: hop.h,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __HOP_H__
+#define __HOP_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 Hop_Man_t_ Hop_Man_t;
+typedef struct Hop_Obj_t_ Hop_Obj_t;
+typedef int Hop_Edge_t;
+
+// object types
+typedef enum {
+ AIG_NONE, // 0: non-existent object
+ AIG_CONST1, // 1: constant 1
+ AIG_PI, // 2: primary input
+ AIG_PO, // 3: primary output
+ AIG_AND, // 4: AND node
+ AIG_EXOR, // 5: EXOR node
+ AIG_VOID // 6: unused object
+} Hop_Type_t;
+
+// the AIG node
+struct Hop_Obj_t_ // 4 words
+{
+ void * pData; // misc
+ Hop_Obj_t * pFanin0; // fanin
+ Hop_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 (level)
+};
+
+// the AIG manager
+struct Hop_Man_t_
+{
+ // AIG nodes
+ Vec_Ptr_t * vPis; // the array of PIs
+ Vec_Ptr_t * vPos; // the array of POs
+ Hop_Obj_t * pConst1; // the constant 1 node
+ Hop_Obj_t Ghost; // the ghost node
+ // AIG node counters
+ int nObjs[AIG_VOID];// the number of objects by type
+ int nCreated; // the number of created objects
+ int nDeleted; // the number of deleted objects
+ // stuctural hash table
+ Hop_Obj_t ** pTable; // structural hash table
+ int nTableSize; // structural hash table size
+ // various data members
+ void * pData; // the temporary data
+ int nTravIds; // the current traversal ID
+ int fRefCount; // enables reference counting
+ int fCatchExor; // enables EXOR nodes
+ // memory management
+ Vec_Ptr_t * vChunks; // allocated memory pieces
+ Vec_Ptr_t * vPages; // memory pages used by nodes
+ Hop_Obj_t * pListFree; // the list of free 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))
+
+#ifndef PRT
+#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))
+#endif
+
+static inline int Hop_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); }
+static inline int Hop_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
+static inline int Hop_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
+static inline void Hop_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); }
+static inline void Hop_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); }
+
+static inline Hop_Obj_t * Hop_Regular( Hop_Obj_t * p ) { return (Hop_Obj_t *)((unsigned long)(p) & ~01); }
+static inline Hop_Obj_t * Hop_Not( Hop_Obj_t * p ) { return (Hop_Obj_t *)((unsigned long)(p) ^ 01); }
+static inline Hop_Obj_t * Hop_NotCond( Hop_Obj_t * p, int c ) { return (Hop_Obj_t *)((unsigned long)(p) ^ (c)); }
+static inline int Hop_IsComplement( Hop_Obj_t * p ) { return (int )(((unsigned long)p) & 01); }
+
+static inline Hop_Obj_t * Hop_ManConst0( Hop_Man_t * p ) { return Hop_Not(p->pConst1); }
+static inline Hop_Obj_t * Hop_ManConst1( Hop_Man_t * p ) { return p->pConst1; }
+static inline Hop_Obj_t * Hop_ManGhost( Hop_Man_t * p ) { return &p->Ghost; }
+static inline Hop_Obj_t * Hop_ManPi( Hop_Man_t * p, int i ) { return (Hop_Obj_t *)Vec_PtrEntry(p->vPis, i); }
+
+static inline Hop_Edge_t Hop_EdgeCreate( int Id, int fCompl ) { return (Id << 1) | fCompl; }
+static inline int Hop_EdgeId( Hop_Edge_t Edge ) { return Edge >> 1; }
+static inline int Hop_EdgeIsComplement( Hop_Edge_t Edge ) { return Edge & 1; }
+static inline Hop_Edge_t Hop_EdgeRegular( Hop_Edge_t Edge ) { return (Edge >> 1) << 1; }
+static inline Hop_Edge_t Hop_EdgeNot( Hop_Edge_t Edge ) { return Edge ^ 1; }
+static inline Hop_Edge_t Hop_EdgeNotCond( Hop_Edge_t Edge, int fCond ) { return Edge ^ fCond; }
+
+static inline int Hop_ManPiNum( Hop_Man_t * p ) { return p->nObjs[AIG_PI]; }
+static inline int Hop_ManPoNum( Hop_Man_t * p ) { return p->nObjs[AIG_PO]; }
+static inline int Hop_ManAndNum( Hop_Man_t * p ) { return p->nObjs[AIG_AND]; }
+static inline int Hop_ManExorNum( Hop_Man_t * p ) { return p->nObjs[AIG_EXOR]; }
+static inline int Hop_ManNodeNum( Hop_Man_t * p ) { return p->nObjs[AIG_AND]+p->nObjs[AIG_EXOR];}
+static inline int Hop_ManGetCost( Hop_Man_t * p ) { return p->nObjs[AIG_AND]+3*p->nObjs[AIG_EXOR]; }
+static inline int Hop_ManObjNum( Hop_Man_t * p ) { return p->nCreated - p->nDeleted; }
+
+static inline Hop_Type_t Hop_ObjType( Hop_Obj_t * pObj ) { return pObj->Type; }
+static inline int Hop_ObjIsNone( Hop_Obj_t * pObj ) { return pObj->Type == AIG_NONE; }
+static inline int Hop_ObjIsConst1( Hop_Obj_t * pObj ) { assert(!Hop_IsComplement(pObj)); return pObj->Type == AIG_CONST1; }
+static inline int Hop_ObjIsPi( Hop_Obj_t * pObj ) { return pObj->Type == AIG_PI; }
+static inline int Hop_ObjIsPo( Hop_Obj_t * pObj ) { return pObj->Type == AIG_PO; }
+static inline int Hop_ObjIsAnd( Hop_Obj_t * pObj ) { return pObj->Type == AIG_AND; }
+static inline int Hop_ObjIsExor( Hop_Obj_t * pObj ) { return pObj->Type == AIG_EXOR; }
+static inline int Hop_ObjIsNode( Hop_Obj_t * pObj ) { return pObj->Type == AIG_AND || pObj->Type == AIG_EXOR; }
+static inline int Hop_ObjIsTerm( Hop_Obj_t * pObj ) { return pObj->Type == AIG_PI || pObj->Type == AIG_PO || pObj->Type == AIG_CONST1; }
+static inline int Hop_ObjIsHash( Hop_Obj_t * pObj ) { return pObj->Type == AIG_AND || pObj->Type == AIG_EXOR; }
+
+static inline int Hop_ObjIsMarkA( Hop_Obj_t * pObj ) { return pObj->fMarkA; }
+static inline void Hop_ObjSetMarkA( Hop_Obj_t * pObj ) { pObj->fMarkA = 1; }
+static inline void Hop_ObjClearMarkA( Hop_Obj_t * pObj ) { pObj->fMarkA = 0; }
+
+static inline void Hop_ObjSetTravId( Hop_Obj_t * pObj, int TravId ) { pObj->pData = (void *)TravId; }
+static inline void Hop_ObjSetTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)p->nTravIds; }
+static inline void Hop_ObjSetTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(p->nTravIds - 1); }
+static inline int Hop_ObjIsTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int )((int)pObj->pData == p->nTravIds); }
+static inline int Hop_ObjIsTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int )((int)pObj->pData == p->nTravIds - 1); }
+
+static inline int Hop_ObjTravId( Hop_Obj_t * pObj ) { return (int)pObj->pData; }
+static inline int Hop_ObjPhase( Hop_Obj_t * pObj ) { return pObj->fPhase; }
+static inline int Hop_ObjRefs( Hop_Obj_t * pObj ) { return pObj->nRefs; }
+static inline void Hop_ObjRef( Hop_Obj_t * pObj ) { pObj->nRefs++; }
+static inline void Hop_ObjDeref( Hop_Obj_t * pObj ) { assert( pObj->nRefs > 0 ); pObj->nRefs--; }
+static inline void Hop_ObjClearRef( Hop_Obj_t * pObj ) { pObj->nRefs = 0; }
+static inline int Hop_ObjFaninC0( Hop_Obj_t * pObj ) { return Hop_IsComplement(pObj->pFanin0); }
+static inline int Hop_ObjFaninC1( Hop_Obj_t * pObj ) { return Hop_IsComplement(pObj->pFanin1); }
+static inline Hop_Obj_t * Hop_ObjFanin0( Hop_Obj_t * pObj ) { return Hop_Regular(pObj->pFanin0); }
+static inline Hop_Obj_t * Hop_ObjFanin1( Hop_Obj_t * pObj ) { return Hop_Regular(pObj->pFanin1); }
+static inline Hop_Obj_t * Hop_ObjChild0( Hop_Obj_t * pObj ) { return pObj->pFanin0; }
+static inline Hop_Obj_t * Hop_ObjChild1( Hop_Obj_t * pObj ) { return pObj->pFanin1; }
+static inline Hop_Obj_t * Hop_ObjChild0Copy( Hop_Obj_t * pObj ) { assert( !Hop_IsComplement(pObj) ); return Hop_ObjFanin0(pObj)? Hop_NotCond(Hop_ObjFanin0(pObj)->pData, Hop_ObjFaninC0(pObj)) : NULL; }
+static inline Hop_Obj_t * Hop_ObjChild1Copy( Hop_Obj_t * pObj ) { assert( !Hop_IsComplement(pObj) ); return Hop_ObjFanin1(pObj)? Hop_NotCond(Hop_ObjFanin1(pObj)->pData, Hop_ObjFaninC1(pObj)) : NULL; }
+static inline int Hop_ObjLevel( Hop_Obj_t * pObj ) { return pObj->nRefs; }
+static inline int Hop_ObjLevelNew( Hop_Obj_t * pObj ) { return 1 + Hop_ObjIsExor(pObj) + AIG_MAX(Hop_ObjFanin0(pObj)->nRefs, Hop_ObjFanin1(pObj)->nRefs); }
+static inline void Hop_ObjClean( Hop_Obj_t * pObj ) { memset( pObj, 0, sizeof(Hop_Obj_t) ); }
+static inline int Hop_ObjWhatFanin( Hop_Obj_t * pObj, Hop_Obj_t * pFanin )
+{
+ if ( Hop_ObjFanin0(pObj) == pFanin ) return 0;
+ if ( Hop_ObjFanin1(pObj) == pFanin ) return 1;
+ assert(0); return -1;
+}
+static inline int Hop_ObjFanoutC( Hop_Obj_t * pObj, Hop_Obj_t * pFanout )
+{
+ if ( Hop_ObjFanin0(pFanout) == pObj ) return Hop_ObjFaninC0(pObj);
+ if ( Hop_ObjFanin1(pFanout) == pObj ) return Hop_ObjFaninC1(pObj);
+ assert(0); return -1;
+}
+
+// create the ghost of the new node
+static inline Hop_Obj_t * Hop_ObjCreateGhost( Hop_Man_t * p, Hop_Obj_t * p0, Hop_Obj_t * p1, Hop_Type_t Type )
+{
+ Hop_Obj_t * pGhost;
+ assert( Type != AIG_AND || !Hop_ObjIsConst1(Hop_Regular(p0)) );
+ assert( p1 == NULL || !Hop_ObjIsConst1(Hop_Regular(p1)) );
+ assert( Type == AIG_PI || Hop_Regular(p0) != Hop_Regular(p1) );
+ pGhost = Hop_ManGhost(p);
+ pGhost->Type = Type;
+ pGhost->pFanin0 = p0 < p1? p0 : p1;
+ pGhost->pFanin1 = p0 < p1? p1 : p0;
+ return pGhost;
+}
+
+// internal memory manager
+static inline Hop_Obj_t * Hop_ManFetchMemory( Hop_Man_t * p )
+{
+ extern void Hop_ManAddMemory( Hop_Man_t * p );
+ Hop_Obj_t * pTemp;
+ if ( p->pListFree == NULL )
+ Hop_ManAddMemory( p );
+ pTemp = p->pListFree;
+ p->pListFree = *((Hop_Obj_t **)pTemp);
+ memset( pTemp, 0, sizeof(Hop_Obj_t) );
+ return pTemp;
+}
+static inline void Hop_ManRecycleMemory( Hop_Man_t * p, Hop_Obj_t * pEntry )
+{
+ pEntry->Type = AIG_NONE; // distinquishes dead node from live node
+ *((Hop_Obj_t **)pEntry) = p->pListFree;
+ p->pListFree = pEntry;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// ITERATORS ///
+////////////////////////////////////////////////////////////////////////
+
+// iterator over the primary inputs
+#define Hop_ManForEachPi( p, pObj, i ) \
+ Vec_PtrForEachEntry( p->vPis, pObj, i )
+// iterator over the primary outputs
+#define Hop_ManForEachPo( p, pObj, i ) \
+ Vec_PtrForEachEntry( p->vPos, pObj, i )
+// iterator over all objects, including those currently not used
+#define Hop_ManForEachNode( p, pObj, i ) \
+ for ( i = 0; i < p->nTableSize; i++ ) \
+ if ( ((pObj) = p->pTable[i]) == NULL ) {} else
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/*=== aigBalance.c ========================================================*/
+extern Hop_Man_t * Hop_ManBalance( Hop_Man_t * p, int fUpdateLevel );
+extern Hop_Obj_t * Hop_NodeBalanceBuildSuper( Hop_Man_t * p, Vec_Ptr_t * vSuper, Hop_Type_t Type, int fUpdateLevel );
+/*=== aigCheck.c ========================================================*/
+extern int Hop_ManCheck( Hop_Man_t * p );
+/*=== aigDfs.c ==========================================================*/
+extern Vec_Ptr_t * Hop_ManDfs( Hop_Man_t * p );
+extern Vec_Ptr_t * Hop_ManDfsNode( Hop_Man_t * p, Hop_Obj_t * pNode );
+extern int Hop_ManCountLevels( Hop_Man_t * p );
+extern void Hop_ManCreateRefs( Hop_Man_t * p );
+extern int Hop_DagSize( Hop_Obj_t * pObj );
+extern void Hop_ConeUnmark_rec( Hop_Obj_t * pObj );
+extern Hop_Obj_t * Hop_Transfer( Hop_Man_t * pSour, Hop_Man_t * pDest, Hop_Obj_t * pObj, int nVars );
+extern Hop_Obj_t * Hop_Compose( Hop_Man_t * p, Hop_Obj_t * pRoot, Hop_Obj_t * pFunc, int iVar );
+/*=== aigMan.c ==========================================================*/
+extern Hop_Man_t * Hop_ManStart();
+extern Hop_Man_t * Hop_ManDup( Hop_Man_t * p );
+extern void Hop_ManStop( Hop_Man_t * p );
+extern int Hop_ManCleanup( Hop_Man_t * p );
+extern void Hop_ManPrintStats( Hop_Man_t * p );
+/*=== aigMem.c ==========================================================*/
+extern void Hop_ManStartMemory( Hop_Man_t * p );
+extern void Hop_ManStopMemory( Hop_Man_t * p );
+/*=== aigObj.c ==========================================================*/
+extern Hop_Obj_t * Hop_ObjCreatePi( Hop_Man_t * p );
+extern Hop_Obj_t * Hop_ObjCreatePo( Hop_Man_t * p, Hop_Obj_t * pDriver );
+extern Hop_Obj_t * Hop_ObjCreate( Hop_Man_t * p, Hop_Obj_t * pGhost );
+extern void Hop_ObjConnect( Hop_Man_t * p, Hop_Obj_t * pObj, Hop_Obj_t * pFan0, Hop_Obj_t * pFan1 );
+extern void Hop_ObjDisconnect( Hop_Man_t * p, Hop_Obj_t * pObj );
+extern void Hop_ObjDelete( Hop_Man_t * p, Hop_Obj_t * pObj );
+extern void Hop_ObjDelete_rec( Hop_Man_t * p, Hop_Obj_t * pObj );
+/*=== aigOper.c =========================================================*/
+extern Hop_Obj_t * Hop_IthVar( Hop_Man_t * p, int i );
+extern Hop_Obj_t * Hop_Oper( Hop_Man_t * p, Hop_Obj_t * p0, Hop_Obj_t * p1, Hop_Type_t Type );
+extern Hop_Obj_t * Hop_And( Hop_Man_t * p, Hop_Obj_t * p0, Hop_Obj_t * p1 );
+extern Hop_Obj_t * Hop_Or( Hop_Man_t * p, Hop_Obj_t * p0, Hop_Obj_t * p1 );
+extern Hop_Obj_t * Hop_Exor( Hop_Man_t * p, Hop_Obj_t * p0, Hop_Obj_t * p1 );
+extern Hop_Obj_t * Hop_Mux( Hop_Man_t * p, Hop_Obj_t * pC, Hop_Obj_t * p1, Hop_Obj_t * p0 );
+extern Hop_Obj_t * Hop_Maj( Hop_Man_t * p, Hop_Obj_t * pA, Hop_Obj_t * pB, Hop_Obj_t * pC );
+extern Hop_Obj_t * Hop_Miter( Hop_Man_t * p, Vec_Ptr_t * vPairs );
+extern Hop_Obj_t * Hop_CreateAnd( Hop_Man_t * p, int nVars );
+extern Hop_Obj_t * Hop_CreateOr( Hop_Man_t * p, int nVars );
+extern Hop_Obj_t * Hop_CreateExor( Hop_Man_t * p, int nVars );
+/*=== aigTable.c ========================================================*/
+extern Hop_Obj_t * Hop_TableLookup( Hop_Man_t * p, Hop_Obj_t * pGhost );
+extern void Hop_TableInsert( Hop_Man_t * p, Hop_Obj_t * pObj );
+extern void Hop_TableDelete( Hop_Man_t * p, Hop_Obj_t * pObj );
+extern int Hop_TableCountEntries( Hop_Man_t * p );
+extern void Hop_TableProfile( Hop_Man_t * p );
+/*=== aigUtil.c =========================================================*/
+extern void Hop_ManIncrementTravId( Hop_Man_t * p );
+extern void Hop_ManCleanData( Hop_Man_t * p );
+extern void Hop_ObjCollectMulti( Hop_Obj_t * pFunc, Vec_Ptr_t * vSuper );
+extern int Hop_ObjIsMuxType( Hop_Obj_t * pObj );
+extern int Hop_ObjRecognizeExor( Hop_Obj_t * pObj, Hop_Obj_t ** ppFan0, Hop_Obj_t ** ppFan1 );
+extern Hop_Obj_t * Hop_ObjRecognizeMux( Hop_Obj_t * pObj, Hop_Obj_t ** ppObjT, Hop_Obj_t ** ppObjE );
+extern void Hop_ObjPrintVerilog( FILE * pFile, Hop_Obj_t * pObj, Vec_Vec_t * vLevels, int Level );
+extern void Hop_ObjPrintVerbose( Hop_Obj_t * pObj, int fHaig );
+extern void Hop_ManPrintVerbose( Hop_Man_t * p, int fHaig );
+extern void Hop_ManDumpBlif( Hop_Man_t * p, char * pFileName );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/temp/aig/aigBalance.c b/src/aig/hop/hopBalance.c
index 8806b654..73c90685 100644
--- a/src/temp/aig/aigBalance.c
+++ b/src/aig/hop/hopBalance.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [aigBalance.c]
+ FileName [hopBalance.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,21 +14,21 @@
Date [Ver. 1.0. Started - May 11, 2006.]
- Revision [$Id: aigBalance.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+ Revision [$Id: hopBalance.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "aig.h"
+#include "hop.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static Aig_Obj_t * Aig_NodeBalance_rec( Aig_Man_t * pNew, Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level, int fUpdateLevel );
-static Vec_Ptr_t * Aig_NodeBalanceCone( Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level );
-static int Aig_NodeBalanceFindLeft( Vec_Ptr_t * vSuper );
-static void Aig_NodeBalancePermute( Aig_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor );
-static void Aig_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Aig_Obj_t * pObj );
+static Hop_Obj_t * Hop_NodeBalance_rec( Hop_Man_t * pNew, Hop_Obj_t * pObj, Vec_Vec_t * vStore, int Level, int fUpdateLevel );
+static Vec_Ptr_t * Hop_NodeBalanceCone( Hop_Obj_t * pObj, Vec_Vec_t * vStore, int Level );
+static int Hop_NodeBalanceFindLeft( Vec_Ptr_t * vSuper );
+static void Hop_NodeBalancePermute( Hop_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor );
+static void Hop_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Hop_Obj_t * pObj );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -45,35 +45,35 @@ static void Aig_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Ai
SeeAlso []
***********************************************************************/
-Aig_Man_t * Aig_ManBalance( Aig_Man_t * p, int fUpdateLevel )
+Hop_Man_t * Hop_ManBalance( Hop_Man_t * p, int fUpdateLevel )
{
- Aig_Man_t * pNew;
- Aig_Obj_t * pObj, * pObjNew;
+ Hop_Man_t * pNew;
+ Hop_Obj_t * pObj, * pObjNew;
Vec_Vec_t * vStore;
int i;
// create the new manager
- pNew = Aig_ManStart();
+ pNew = Hop_ManStart();
pNew->fRefCount = 0;
// map the PI nodes
- Aig_ManCleanData( p );
- Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
- Aig_ManForEachPi( p, pObj, i )
- pObj->pData = Aig_ObjCreatePi(pNew);
+ Hop_ManCleanData( p );
+ Hop_ManConst1(p)->pData = Hop_ManConst1(pNew);
+ Hop_ManForEachPi( p, pObj, i )
+ pObj->pData = Hop_ObjCreatePi(pNew);
// balance the AIG
vStore = Vec_VecAlloc( 50 );
- Aig_ManForEachPo( p, pObj, i )
+ Hop_ManForEachPo( p, pObj, i )
{
- pObjNew = Aig_NodeBalance_rec( pNew, Aig_ObjFanin0(pObj), vStore, 0, fUpdateLevel );
- Aig_ObjCreatePo( pNew, Aig_NotCond( pObjNew, Aig_ObjFaninC0(pObj) ) );
+ pObjNew = Hop_NodeBalance_rec( pNew, Hop_ObjFanin0(pObj), vStore, 0, fUpdateLevel );
+ Hop_ObjCreatePo( pNew, Hop_NotCond( pObjNew, Hop_ObjFaninC0(pObj) ) );
}
Vec_VecFree( vStore );
// remove dangling nodes
-// Aig_ManCreateRefs( pNew );
-// if ( i = Aig_ManCleanup( pNew ) )
+// Hop_ManCreateRefs( pNew );
+// if ( i = Hop_ManCleanup( pNew ) )
// printf( "Cleanup after balancing removed %d dangling nodes.\n", i );
// check the resulting AIG
- if ( !Aig_ManCheck(pNew) )
- printf( "Aig_ManBalance(): The check has failed.\n" );
+ if ( !Hop_ManCheck(pNew) )
+ printf( "Hop_ManBalance(): The check has failed.\n" );
return pNew;
}
@@ -88,33 +88,33 @@ Aig_Man_t * Aig_ManBalance( Aig_Man_t * p, int fUpdateLevel )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_NodeBalance_rec( Aig_Man_t * pNew, Aig_Obj_t * pObjOld, Vec_Vec_t * vStore, int Level, int fUpdateLevel )
+Hop_Obj_t * Hop_NodeBalance_rec( Hop_Man_t * pNew, Hop_Obj_t * pObjOld, Vec_Vec_t * vStore, int Level, int fUpdateLevel )
{
- Aig_Obj_t * pObjNew;
+ Hop_Obj_t * pObjNew;
Vec_Ptr_t * vSuper;
int i;
- assert( !Aig_IsComplement(pObjOld) );
+ assert( !Hop_IsComplement(pObjOld) );
// return if the result is known
if ( pObjOld->pData )
return pObjOld->pData;
- assert( Aig_ObjIsNode(pObjOld) );
+ assert( Hop_ObjIsNode(pObjOld) );
// get the implication supergate
- vSuper = Aig_NodeBalanceCone( pObjOld, vStore, Level );
+ vSuper = Hop_NodeBalanceCone( pObjOld, vStore, Level );
// check if supergate contains two nodes in the opposite polarity
if ( vSuper->nSize == 0 )
- return pObjOld->pData = Aig_ManConst0(pNew);
+ return pObjOld->pData = Hop_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 = Aig_NodeBalance_rec( pNew, Aig_Regular(vSuper->pArray[i]), vStore, Level + 1, fUpdateLevel );
- vSuper->pArray[i] = Aig_NotCond( pObjNew, Aig_IsComplement(vSuper->pArray[i]) );
+ pObjNew = Hop_NodeBalance_rec( pNew, Hop_Regular(vSuper->pArray[i]), vStore, Level + 1, fUpdateLevel );
+ vSuper->pArray[i] = Hop_NotCond( pObjNew, Hop_IsComplement(vSuper->pArray[i]) );
}
// build the supergate
- pObjNew = Aig_NodeBalanceBuildSuper( pNew, vSuper, Aig_ObjType(pObjOld), fUpdateLevel );
+ pObjNew = Hop_NodeBalanceBuildSuper( pNew, vSuper, Hop_ObjType(pObjOld), fUpdateLevel );
// make sure the balanced node is not assigned
-// assert( pObjOld->Level >= Aig_Regular(pObjNew)->Level );
+// assert( pObjOld->Level >= Hop_Regular(pObjNew)->Level );
assert( pObjOld->pData == NULL );
return pObjOld->pData = pObjNew;
}
@@ -130,11 +130,11 @@ Aig_Obj_t * Aig_NodeBalance_rec( Aig_Man_t * pNew, Aig_Obj_t * pObjOld, Vec_Vec_
SeeAlso []
***********************************************************************/
-int Aig_NodeBalanceCone_rec( Aig_Obj_t * pRoot, Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
+int Hop_NodeBalanceCone_rec( Hop_Obj_t * pRoot, Hop_Obj_t * pObj, Vec_Ptr_t * vSuper )
{
int RetValue1, RetValue2, i;
// check if the node is visited
- if ( Aig_Regular(pObj)->fMarkB )
+ if ( Hop_Regular(pObj)->fMarkB )
{
// check if the node occurs in the same polarity
for ( i = 0; i < vSuper->nSize; i++ )
@@ -142,23 +142,23 @@ int Aig_NodeBalanceCone_rec( Aig_Obj_t * pRoot, Aig_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] == Aig_Not(pObj) )
+ if ( vSuper->pArray[i] == Hop_Not(pObj) )
return -1;
assert( 0 );
return 0;
}
// if the new node is complemented or a PI, another gate begins
- if ( pObj != pRoot && (Aig_IsComplement(pObj) || Aig_ObjType(pObj) != Aig_ObjType(pRoot) || Aig_ObjRefs(pObj) > 1) )
+ if ( pObj != pRoot && (Hop_IsComplement(pObj) || Hop_ObjType(pObj) != Hop_ObjType(pRoot) || Hop_ObjRefs(pObj) > 1) )
{
Vec_PtrPush( vSuper, pObj );
- Aig_Regular(pObj)->fMarkB = 1;
+ Hop_Regular(pObj)->fMarkB = 1;
return 0;
}
- assert( !Aig_IsComplement(pObj) );
- assert( Aig_ObjIsNode(pObj) );
+ assert( !Hop_IsComplement(pObj) );
+ assert( Hop_ObjIsNode(pObj) );
// go through the branches
- RetValue1 = Aig_NodeBalanceCone_rec( pRoot, Aig_ObjChild0(pObj), vSuper );
- RetValue2 = Aig_NodeBalanceCone_rec( pRoot, Aig_ObjChild1(pObj), vSuper );
+ RetValue1 = Hop_NodeBalanceCone_rec( pRoot, Hop_ObjChild0(pObj), vSuper );
+ RetValue2 = Hop_NodeBalanceCone_rec( pRoot, Hop_ObjChild1(pObj), vSuper );
if ( RetValue1 == -1 || RetValue2 == -1 )
return -1;
// return 1 if at least one branch has a duplicate
@@ -176,11 +176,11 @@ int Aig_NodeBalanceCone_rec( Aig_Obj_t * pRoot, Aig_Obj_t * pObj, Vec_Ptr_t * vS
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Aig_NodeBalanceCone( Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level )
+Vec_Ptr_t * Hop_NodeBalanceCone( Hop_Obj_t * pObj, Vec_Vec_t * vStore, int Level )
{
Vec_Ptr_t * vNodes;
int RetValue, i;
- assert( !Aig_IsComplement(pObj) );
+ assert( !Hop_IsComplement(pObj) );
// extend the storage
if ( Vec_VecSize( vStore ) <= Level )
Vec_VecPush( vStore, Level, 0 );
@@ -188,11 +188,11 @@ Vec_Ptr_t * Aig_NodeBalanceCone( Aig_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 = Aig_NodeBalanceCone_rec( pObj, pObj, vNodes );
+ RetValue = Hop_NodeBalanceCone_rec( pObj, pObj, vNodes );
assert( vNodes->nSize > 1 );
// unmark the visited nodes
Vec_PtrForEachEntry( vNodes, pObj, i )
- Aig_Regular(pObj)->fMarkB = 0;
+ Hop_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 )
@@ -211,9 +211,9 @@ Vec_Ptr_t * Aig_NodeBalanceCone( Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level
SeeAlso []
***********************************************************************/
-int Aig_NodeCompareLevelsDecrease( Aig_Obj_t ** pp1, Aig_Obj_t ** pp2 )
+int Hop_NodeCompareLevelsDecrease( Hop_Obj_t ** pp1, Hop_Obj_t ** pp2 )
{
- int Diff = Aig_ObjLevel(Aig_Regular(*pp1)) - Aig_ObjLevel(Aig_Regular(*pp2));
+ int Diff = Hop_ObjLevel(Hop_Regular(*pp1)) - Hop_ObjLevel(Hop_Regular(*pp2));
if ( Diff > 0 )
return -1;
if ( Diff < 0 )
@@ -232,24 +232,24 @@ int Aig_NodeCompareLevelsDecrease( Aig_Obj_t ** pp1, Aig_Obj_t ** pp2 )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_NodeBalanceBuildSuper( Aig_Man_t * p, Vec_Ptr_t * vSuper, Aig_Type_t Type, int fUpdateLevel )
+Hop_Obj_t * Hop_NodeBalanceBuildSuper( Hop_Man_t * p, Vec_Ptr_t * vSuper, Hop_Type_t Type, int fUpdateLevel )
{
- Aig_Obj_t * pObj1, * pObj2;
+ Hop_Obj_t * pObj1, * pObj2;
int LeftBound;
assert( vSuper->nSize > 1 );
// sort the new nodes by level in the decreasing order
- Vec_PtrSort( vSuper, Aig_NodeCompareLevelsDecrease );
+ Vec_PtrSort( vSuper, Hop_NodeCompareLevelsDecrease );
// balance the nodes
while ( vSuper->nSize > 1 )
{
// find the left bound on the node to be paired
- LeftBound = (!fUpdateLevel)? 0 : Aig_NodeBalanceFindLeft( vSuper );
+ LeftBound = (!fUpdateLevel)? 0 : Hop_NodeBalanceFindLeft( vSuper );
// find the node that can be shared (if no such node, randomize choice)
- Aig_NodeBalancePermute( p, vSuper, LeftBound, Type == AIG_EXOR );
+ Hop_NodeBalancePermute( p, vSuper, LeftBound, Type == AIG_EXOR );
// pull out the last two nodes
pObj1 = Vec_PtrPop(vSuper);
pObj2 = Vec_PtrPop(vSuper);
- Aig_NodeBalancePushUniqueOrderByLevel( vSuper, Aig_Oper(p, pObj1, pObj2, Type) );
+ Hop_NodeBalancePushUniqueOrderByLevel( vSuper, Hop_Oper(p, pObj1, pObj2, Type) );
}
return Vec_PtrEntry(vSuper, 0);
}
@@ -269,9 +269,9 @@ Aig_Obj_t * Aig_NodeBalanceBuildSuper( Aig_Man_t * p, Vec_Ptr_t * vSuper, Aig_Ty
SeeAlso []
***********************************************************************/
-int Aig_NodeBalanceFindLeft( Vec_Ptr_t * vSuper )
+int Hop_NodeBalanceFindLeft( Vec_Ptr_t * vSuper )
{
- Aig_Obj_t * pObjRight, * pObjLeft;
+ Hop_Obj_t * pObjRight, * pObjLeft;
int Current;
// if two or less nodes, pair with the first
if ( Vec_PtrSize(vSuper) < 3 )
@@ -285,13 +285,13 @@ int Aig_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 ( Aig_ObjLevel(Aig_Regular(pObjLeft)) != Aig_ObjLevel(Aig_Regular(pObjRight)) )
+ if ( Hop_ObjLevel(Hop_Regular(pObjLeft)) != Hop_ObjLevel(Hop_Regular(pObjRight)) )
break;
}
Current++;
// get the node, for which the equality holds
pObjLeft = Vec_PtrEntry( vSuper, Current );
- assert( Aig_ObjLevel(Aig_Regular(pObjLeft)) == Aig_ObjLevel(Aig_Regular(pObjRight)) );
+ assert( Hop_ObjLevel(Hop_Regular(pObjLeft)) == Hop_ObjLevel(Hop_Regular(pObjRight)) );
return Current;
}
@@ -307,9 +307,9 @@ int Aig_NodeBalanceFindLeft( Vec_Ptr_t * vSuper )
SeeAlso []
***********************************************************************/
-void Aig_NodeBalancePermute( Aig_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor )
+void Hop_NodeBalancePermute( Hop_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor )
{
- Aig_Obj_t * pObj1, * pObj2, * pObj3, * pGhost;
+ Hop_Obj_t * pObj1, * pObj2, * pObj3, * pGhost;
int RightBound, i;
// get the right bound
RightBound = Vec_PtrSize(vSuper) - 2;
@@ -319,20 +319,20 @@ void Aig_NodeBalancePermute( Aig_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 ( Aig_Regular(pObj1) == p->pConst1 || Aig_Regular(pObj2) == p->pConst1 )
+ if ( Hop_Regular(pObj1) == p->pConst1 || Hop_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 ( Aig_Regular(pObj3) == p->pConst1 )
+ if ( Hop_Regular(pObj3) == p->pConst1 )
{
Vec_PtrWriteEntry( vSuper, i, pObj2 );
Vec_PtrWriteEntry( vSuper, RightBound, pObj3 );
return;
}
- pGhost = Aig_ObjCreateGhost( p, pObj1, pObj3, fExor? AIG_EXOR : AIG_AND );
- if ( Aig_TableLookup( p, pGhost ) )
+ pGhost = Hop_ObjCreateGhost( p, pObj1, pObj3, fExor? AIG_EXOR : AIG_AND );
+ if ( Hop_TableLookup( p, pGhost ) )
{
if ( pObj3 == pObj2 )
return;
@@ -365,9 +365,9 @@ void Aig_NodeBalancePermute( Aig_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, i
SeeAlso []
***********************************************************************/
-void Aig_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Aig_Obj_t * pObj )
+void Hop_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Hop_Obj_t * pObj )
{
- Aig_Obj_t * pObj1, * pObj2;
+ Hop_Obj_t * pObj1, * pObj2;
int i;
if ( Vec_PtrPushUnique(vStore, pObj) )
return;
@@ -376,7 +376,7 @@ void Aig_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Aig_Obj_t * pObj
{
pObj1 = vStore->pArray[i ];
pObj2 = vStore->pArray[i-1];
- if ( Aig_ObjLevel(Aig_Regular(pObj1)) <= Aig_ObjLevel(Aig_Regular(pObj2)) )
+ if ( Hop_ObjLevel(Hop_Regular(pObj1)) <= Hop_ObjLevel(Hop_Regular(pObj2)) )
break;
vStore->pArray[i ] = pObj2;
vStore->pArray[i-1] = pObj1;
diff --git a/src/temp/aig_free/aigCheck.c b/src/aig/hop/hopCheck.c
index 61e4cf78..44bac2d7 100644
--- a/src/temp/aig_free/aigCheck.c
+++ b/src/aig/hop/hopCheck.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [aigCheck.c]
+ FileName [hopCheck.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - May 11, 2006.]
- Revision [$Id: aigCheck.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+ Revision [$Id: hopCheck.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "aig.h"
+#include "hop.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -39,66 +39,66 @@
SeeAlso []
***********************************************************************/
-int Aig_ManCheck( Aig_Man_t * p )
+int Hop_ManCheck( Hop_Man_t * p )
{
- Aig_Obj_t * pObj, * pObj2;
+ Hop_Obj_t * pObj, * pObj2;
int i;
// check primary inputs
- Aig_ManForEachPi( p, pObj, i )
+ Hop_ManForEachPi( p, pObj, i )
{
- if ( Aig_ObjFanin0(pObj) || Aig_ObjFanin1(pObj) )
+ if ( Hop_ObjFanin0(pObj) || Hop_ObjFanin1(pObj) )
{
- printf( "Aig_ManCheck: The PI node \"%p\" has fanins.\n", pObj );
+ printf( "Hop_ManCheck: The PI node \"%p\" has fanins.\n", pObj );
return 0;
}
}
// check primary outputs
- Aig_ManForEachPo( p, pObj, i )
+ Hop_ManForEachPo( p, pObj, i )
{
- if ( !Aig_ObjFanin0(pObj) )
+ if ( !Hop_ObjFanin0(pObj) )
{
- printf( "Aig_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj );
+ printf( "Hop_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj );
return 0;
}
- if ( Aig_ObjFanin1(pObj) )
+ if ( Hop_ObjFanin1(pObj) )
{
- printf( "Aig_ManCheck: The PO node \"%p\" has second fanin.\n", pObj );
+ printf( "Hop_ManCheck: The PO node \"%p\" has second fanin.\n", pObj );
return 0;
}
}
// check internal nodes
- Aig_ManForEachNode( p, pObj, i )
+ Hop_ManForEachNode( p, pObj, i )
{
- if ( !Aig_ObjFanin0(pObj) || !Aig_ObjFanin1(pObj) )
+ if ( !Hop_ObjFanin0(pObj) || !Hop_ObjFanin1(pObj) )
{
- printf( "Aig_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj );
+ printf( "Hop_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj );
return 0;
}
- if ( Aig_ObjFanin0(pObj) >= Aig_ObjFanin1(pObj) )
+ if ( Hop_ObjFanin0(pObj) >= Hop_ObjFanin1(pObj) )
{
- printf( "Aig_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj );
+ printf( "Hop_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj );
return 0;
}
- pObj2 = Aig_TableLookup( p, pObj );
+ pObj2 = Hop_TableLookup( p, pObj );
if ( pObj2 != pObj )
{
- printf( "Aig_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj );
+ printf( "Hop_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj );
return 0;
}
}
// count the total number of nodes
- if ( Aig_ManObjNum(p) != 1 + Aig_ManPiNum(p) + Aig_ManPoNum(p) + Aig_ManAndNum(p) + Aig_ManExorNum(p) )
+ if ( Hop_ManObjNum(p) != 1 + Hop_ManPiNum(p) + Hop_ManPoNum(p) + Hop_ManAndNum(p) + Hop_ManExorNum(p) )
{
- printf( "Aig_ManCheck: The number of created nodes is wrong.\n" );
+ printf( "Hop_ManCheck: The number of created nodes is wrong.\n" );
return 0;
}
// count the number of nodes in the table
- if ( Aig_TableCountEntries(p) != Aig_ManAndNum(p) + Aig_ManExorNum(p) )
+ if ( Hop_TableCountEntries(p) != Hop_ManAndNum(p) + Hop_ManExorNum(p) )
{
- printf( "Aig_ManCheck: The number of nodes in the structural hashing table is wrong.\n" );
+ printf( "Hop_ManCheck: The number of nodes in the structural hashing table is wrong.\n" );
return 0;
}
-// if ( !Aig_ManIsAcyclic(p) )
+// if ( !Hop_ManIsAcyclic(p) )
// return 0;
return 1;
}
diff --git a/src/temp/aig/aigDfs.c b/src/aig/hop/hopDfs.c
index c004cab0..49e5f221 100644
--- a/src/temp/aig/aigDfs.c
+++ b/src/aig/hop/hopDfs.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [aigDfs.c]
+ FileName [hopDfs.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - May 11, 2006.]
- Revision [$Id: aigDfs.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+ Revision [$Id: hopDfs.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "aig.h"
+#include "hop.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -39,15 +39,15 @@
SeeAlso []
***********************************************************************/
-void Aig_ManDfs_rec( Aig_Obj_t * pObj, Vec_Ptr_t * vNodes )
+void Hop_ManDfs_rec( Hop_Obj_t * pObj, Vec_Ptr_t * vNodes )
{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
return;
- Aig_ManDfs_rec( Aig_ObjFanin0(pObj), vNodes );
- Aig_ManDfs_rec( Aig_ObjFanin1(pObj), vNodes );
- assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjSetMarkA(pObj);
+ Hop_ManDfs_rec( Hop_ObjFanin0(pObj), vNodes );
+ Hop_ManDfs_rec( Hop_ObjFanin1(pObj), vNodes );
+ assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjSetMarkA(pObj);
Vec_PtrPush( vNodes, pObj );
}
@@ -62,16 +62,16 @@ void Aig_ManDfs_rec( Aig_Obj_t * pObj, Vec_Ptr_t * vNodes )
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Aig_ManDfs( Aig_Man_t * p )
+Vec_Ptr_t * Hop_ManDfs( Hop_Man_t * p )
{
Vec_Ptr_t * vNodes;
- Aig_Obj_t * pObj;
+ Hop_Obj_t * pObj;
int i;
- vNodes = Vec_PtrAlloc( Aig_ManNodeNum(p) );
- Aig_ManForEachNode( p, pObj, i )
- Aig_ManDfs_rec( pObj, vNodes );
- Aig_ManForEachNode( p, pObj, i )
- Aig_ObjClearMarkA(pObj);
+ vNodes = Vec_PtrAlloc( Hop_ManNodeNum(p) );
+ Hop_ManForEachNode( p, pObj, i )
+ Hop_ManDfs_rec( pObj, vNodes );
+ Hop_ManForEachNode( p, pObj, i )
+ Hop_ObjClearMarkA(pObj);
return vNodes;
}
@@ -86,16 +86,16 @@ Vec_Ptr_t * Aig_ManDfs( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Aig_ManDfsNode( Aig_Man_t * p, Aig_Obj_t * pNode )
+Vec_Ptr_t * Hop_ManDfsNode( Hop_Man_t * p, Hop_Obj_t * pNode )
{
Vec_Ptr_t * vNodes;
- Aig_Obj_t * pObj;
+ Hop_Obj_t * pObj;
int i;
- assert( !Aig_IsComplement(pNode) );
+ assert( !Hop_IsComplement(pNode) );
vNodes = Vec_PtrAlloc( 16 );
- Aig_ManDfs_rec( pNode, vNodes );
+ Hop_ManDfs_rec( pNode, vNodes );
Vec_PtrForEachEntry( vNodes, pObj, i )
- Aig_ObjClearMarkA(pObj);
+ Hop_ObjClearMarkA(pObj);
return vNodes;
}
@@ -110,28 +110,28 @@ Vec_Ptr_t * Aig_ManDfsNode( Aig_Man_t * p, Aig_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-int Aig_ManCountLevels( Aig_Man_t * p )
+int Hop_ManCountLevels( Hop_Man_t * p )
{
Vec_Ptr_t * vNodes;
- Aig_Obj_t * pObj;
+ Hop_Obj_t * pObj;
int i, LevelsMax, Level0, Level1;
// initialize the levels
- Aig_ManConst1(p)->pData = NULL;
- Aig_ManForEachPi( p, pObj, i )
+ Hop_ManConst1(p)->pData = NULL;
+ Hop_ManForEachPi( p, pObj, i )
pObj->pData = NULL;
// compute levels in a DFS order
- vNodes = Aig_ManDfs( p );
+ vNodes = Hop_ManDfs( p );
Vec_PtrForEachEntry( vNodes, pObj, i )
{
- Level0 = (int)Aig_ObjFanin0(pObj)->pData;
- Level1 = (int)Aig_ObjFanin1(pObj)->pData;
- pObj->pData = (void *)(1 + Aig_ObjIsExor(pObj) + AIG_MAX(Level0, Level1));
+ Level0 = (int)Hop_ObjFanin0(pObj)->pData;
+ Level1 = (int)Hop_ObjFanin1(pObj)->pData;
+ pObj->pData = (void *)(1 + Hop_ObjIsExor(pObj) + AIG_MAX(Level0, Level1));
}
Vec_PtrFree( vNodes );
// get levels of the POs
LevelsMax = 0;
- Aig_ManForEachPo( p, pObj, i )
- LevelsMax = AIG_MAX( LevelsMax, (int)Aig_ObjFanin0(pObj)->pData );
+ Hop_ManForEachPo( p, pObj, i )
+ LevelsMax = AIG_MAX( LevelsMax, (int)Hop_ObjFanin0(pObj)->pData );
return LevelsMax;
}
@@ -146,29 +146,29 @@ int Aig_ManCountLevels( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-void Aig_ManCreateRefs( Aig_Man_t * p )
+void Hop_ManCreateRefs( Hop_Man_t * p )
{
- Aig_Obj_t * pObj;
+ Hop_Obj_t * pObj;
int i;
if ( p->fRefCount )
return;
p->fRefCount = 1;
// clear refs
- Aig_ObjClearRef( Aig_ManConst1(p) );
- Aig_ManForEachPi( p, pObj, i )
- Aig_ObjClearRef( pObj );
- Aig_ManForEachNode( p, pObj, i )
- Aig_ObjClearRef( pObj );
- Aig_ManForEachPo( p, pObj, i )
- Aig_ObjClearRef( pObj );
+ Hop_ObjClearRef( Hop_ManConst1(p) );
+ Hop_ManForEachPi( p, pObj, i )
+ Hop_ObjClearRef( pObj );
+ Hop_ManForEachNode( p, pObj, i )
+ Hop_ObjClearRef( pObj );
+ Hop_ManForEachPo( p, pObj, i )
+ Hop_ObjClearRef( pObj );
// set refs
- Aig_ManForEachNode( p, pObj, i )
+ Hop_ManForEachNode( p, pObj, i )
{
- Aig_ObjRef( Aig_ObjFanin0(pObj) );
- Aig_ObjRef( Aig_ObjFanin1(pObj) );
+ Hop_ObjRef( Hop_ObjFanin0(pObj) );
+ Hop_ObjRef( Hop_ObjFanin1(pObj) );
}
- Aig_ManForEachPo( p, pObj, i )
- Aig_ObjRef( Aig_ObjFanin0(pObj) );
+ Hop_ManForEachPo( p, pObj, i )
+ Hop_ObjRef( Hop_ObjFanin0(pObj) );
}
/**Function*************************************************************
@@ -182,15 +182,15 @@ void Aig_ManCreateRefs( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-void Aig_ConeMark_rec( Aig_Obj_t * pObj )
+void Hop_ConeMark_rec( Hop_Obj_t * pObj )
{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
return;
- Aig_ConeMark_rec( Aig_ObjFanin0(pObj) );
- Aig_ConeMark_rec( Aig_ObjFanin1(pObj) );
- assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjSetMarkA( pObj );
+ Hop_ConeMark_rec( Hop_ObjFanin0(pObj) );
+ Hop_ConeMark_rec( Hop_ObjFanin1(pObj) );
+ assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjSetMarkA( pObj );
}
/**Function*************************************************************
@@ -204,15 +204,15 @@ void Aig_ConeMark_rec( Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-void Aig_ConeCleanAndMark_rec( Aig_Obj_t * pObj )
+void Hop_ConeCleanAndMark_rec( Hop_Obj_t * pObj )
{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
return;
- Aig_ConeCleanAndMark_rec( Aig_ObjFanin0(pObj) );
- Aig_ConeCleanAndMark_rec( Aig_ObjFanin1(pObj) );
- assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjSetMarkA( pObj );
+ Hop_ConeCleanAndMark_rec( Hop_ObjFanin0(pObj) );
+ Hop_ConeCleanAndMark_rec( Hop_ObjFanin1(pObj) );
+ assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjSetMarkA( pObj );
pObj->pData = NULL;
}
@@ -227,16 +227,16 @@ void Aig_ConeCleanAndMark_rec( Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-int Aig_ConeCountAndMark_rec( Aig_Obj_t * pObj )
+int Hop_ConeCountAndMark_rec( Hop_Obj_t * pObj )
{
int Counter;
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
return 0;
- Counter = 1 + Aig_ConeCountAndMark_rec( Aig_ObjFanin0(pObj) ) +
- Aig_ConeCountAndMark_rec( Aig_ObjFanin1(pObj) );
- assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjSetMarkA( pObj );
+ Counter = 1 + Hop_ConeCountAndMark_rec( Hop_ObjFanin0(pObj) ) +
+ Hop_ConeCountAndMark_rec( Hop_ObjFanin1(pObj) );
+ assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjSetMarkA( pObj );
return Counter;
}
@@ -251,15 +251,15 @@ int Aig_ConeCountAndMark_rec( Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-void Aig_ConeUnmark_rec( Aig_Obj_t * pObj )
+void Hop_ConeUnmark_rec( Hop_Obj_t * pObj )
{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || !Aig_ObjIsMarkA(pObj) )
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) || !Hop_ObjIsMarkA(pObj) )
return;
- Aig_ConeUnmark_rec( Aig_ObjFanin0(pObj) );
- Aig_ConeUnmark_rec( Aig_ObjFanin1(pObj) );
- assert( Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjClearMarkA( pObj );
+ Hop_ConeUnmark_rec( Hop_ObjFanin0(pObj) );
+ Hop_ConeUnmark_rec( Hop_ObjFanin1(pObj) );
+ assert( Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjClearMarkA( pObj );
}
/**Function*************************************************************
@@ -273,11 +273,11 @@ void Aig_ConeUnmark_rec( Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-int Aig_DagSize( Aig_Obj_t * pObj )
+int Hop_DagSize( Hop_Obj_t * pObj )
{
int Counter;
- Counter = Aig_ConeCountAndMark_rec( Aig_Regular(pObj) );
- Aig_ConeUnmark_rec( Aig_Regular(pObj) );
+ Counter = Hop_ConeCountAndMark_rec( Hop_Regular(pObj) );
+ Hop_ConeUnmark_rec( Hop_Regular(pObj) );
return Counter;
}
@@ -292,16 +292,16 @@ int Aig_DagSize( Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-void Aig_Transfer_rec( Aig_Man_t * pDest, Aig_Obj_t * pObj )
+void Hop_Transfer_rec( Hop_Man_t * pDest, Hop_Obj_t * pObj )
{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
return;
- 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 );
+ Hop_Transfer_rec( pDest, Hop_ObjFanin0(pObj) );
+ Hop_Transfer_rec( pDest, Hop_ObjFanin1(pObj) );
+ pObj->pData = Hop_And( pDest, Hop_ObjChild0Copy(pObj), Hop_ObjChild1Copy(pObj) );
+ assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjSetMarkA( pObj );
}
/**Function*************************************************************
@@ -315,27 +315,27 @@ void Aig_Transfer_rec( Aig_Man_t * pDest, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_Transfer( Aig_Man_t * pSour, Aig_Man_t * pDest, Aig_Obj_t * pRoot, int nVars )
+Hop_Obj_t * Hop_Transfer( Hop_Man_t * pSour, Hop_Man_t * pDest, Hop_Obj_t * pRoot, int nVars )
{
- Aig_Obj_t * pObj;
+ Hop_Obj_t * pObj;
int i;
// solve simple cases
if ( pSour == pDest )
return pRoot;
- if ( Aig_ObjIsConst1( Aig_Regular(pRoot) ) )
- return Aig_NotCond( Aig_ManConst1(pDest), Aig_IsComplement(pRoot) );
+ if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
+ return Hop_NotCond( Hop_ManConst1(pDest), Hop_IsComplement(pRoot) );
// set the PI mapping
- Aig_ManForEachPi( pSour, pObj, i )
+ Hop_ManForEachPi( pSour, pObj, i )
{
if ( i == nVars )
break;
- pObj->pData = Aig_IthVar(pDest, i);
+ pObj->pData = Hop_IthVar(pDest, i);
}
// transfer and set markings
- Aig_Transfer_rec( pDest, Aig_Regular(pRoot) );
+ Hop_Transfer_rec( pDest, Hop_Regular(pRoot) );
// clear the markings
- Aig_ConeUnmark_rec( Aig_Regular(pRoot) );
- return Aig_NotCond( Aig_Regular(pRoot)->pData, Aig_IsComplement(pRoot) );
+ Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
+ return Hop_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
/**Function*************************************************************
@@ -349,21 +349,21 @@ Aig_Obj_t * Aig_Transfer( Aig_Man_t * pSour, Aig_Man_t * pDest, Aig_Obj_t * pRoo
SeeAlso []
***********************************************************************/
-void Aig_Compose_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFunc, Aig_Obj_t * pVar )
+void Hop_Compose_rec( Hop_Man_t * p, Hop_Obj_t * pObj, Hop_Obj_t * pFunc, Hop_Obj_t * pVar )
{
- assert( !Aig_IsComplement(pObj) );
- if ( Aig_ObjIsMarkA(pObj) )
+ assert( !Hop_IsComplement(pObj) );
+ if ( Hop_ObjIsMarkA(pObj) )
return;
- if ( Aig_ObjIsConst1(pObj) || Aig_ObjIsPi(pObj) )
+ if ( Hop_ObjIsConst1(pObj) || Hop_ObjIsPi(pObj) )
{
pObj->pData = pObj == pVar ? pFunc : pObj;
return;
}
- 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 );
+ Hop_Compose_rec( p, Hop_ObjFanin0(pObj), pFunc, pVar );
+ Hop_Compose_rec( p, Hop_ObjFanin1(pObj), pFunc, pVar );
+ pObj->pData = Hop_And( p, Hop_ObjChild0Copy(pObj), Hop_ObjChild1Copy(pObj) );
+ assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjSetMarkA( pObj );
}
/**Function*************************************************************
@@ -377,19 +377,19 @@ void Aig_Compose_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFunc, Aig_Ob
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_Compose( Aig_Man_t * p, Aig_Obj_t * pRoot, Aig_Obj_t * pFunc, int iVar )
+Hop_Obj_t * Hop_Compose( Hop_Man_t * p, Hop_Obj_t * pRoot, Hop_Obj_t * pFunc, int iVar )
{
// quit if the PI variable is not defined
- if ( iVar >= Aig_ManPiNum(p) )
+ if ( iVar >= Hop_ManPiNum(p) )
{
- printf( "Aig_Compose(): The PI variable %d is not defined.\n", iVar );
+ printf( "Hop_Compose(): The PI variable %d is not defined.\n", iVar );
return NULL;
}
// recursively perform composition
- Aig_Compose_rec( p, Aig_Regular(pRoot), pFunc, Aig_ManPi(p, iVar) );
+ Hop_Compose_rec( p, Hop_Regular(pRoot), pFunc, Hop_ManPi(p, iVar) );
// clear the markings
- Aig_ConeUnmark_rec( Aig_Regular(pRoot) );
- return Aig_NotCond( Aig_Regular(pRoot)->pData, Aig_IsComplement(pRoot) );
+ Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
+ return Hop_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/temp/aig/aigMan.c b/src/aig/hop/hopMan.c
index bb39712f..18b8618b 100644
--- a/src/temp/aig/aigMan.c
+++ b/src/aig/hop/hopMan.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [aigMan.c]
+ FileName [hopMan.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - May 11, 2006.]
- Revision [$Id: aig_.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+ Revision [$Id: hopMan.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "aig.h"
+#include "hop.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -39,12 +39,12 @@
SeeAlso []
***********************************************************************/
-Aig_Man_t * Aig_ManStart()
+Hop_Man_t * Hop_ManStart()
{
- Aig_Man_t * p;
+ Hop_Man_t * p;
// start the manager
- p = ALLOC( Aig_Man_t, 1 );
- memset( p, 0, sizeof(Aig_Man_t) );
+ p = ALLOC( Hop_Man_t, 1 );
+ memset( p, 0, sizeof(Hop_Man_t) );
// perform initializations
p->nTravIds = 1;
p->fRefCount = 1;
@@ -53,16 +53,16 @@ Aig_Man_t * Aig_ManStart()
p->vPis = Vec_PtrAlloc( 100 );
p->vPos = Vec_PtrAlloc( 100 );
// prepare the internal memory manager
- Aig_ManStartMemory( p );
+ Hop_ManStartMemory( p );
// create the constant node
- p->pConst1 = Aig_ManFetchMemory( p );
+ p->pConst1 = Hop_ManFetchMemory( p );
p->pConst1->Type = AIG_CONST1;
p->pConst1->fPhase = 1;
p->nCreated = 1;
// start the table
p->nTableSize = 10007;
- p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize );
- memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
+ p->pTable = ALLOC( Hop_Obj_t *, p->nTableSize );
+ memset( p->pTable, 0, sizeof(Hop_Obj_t *) * p->nTableSize );
return p;
}
@@ -77,24 +77,24 @@ Aig_Man_t * Aig_ManStart()
SeeAlso []
***********************************************************************/
-void Aig_ManStop( Aig_Man_t * p )
+void Hop_ManStop( Hop_Man_t * p )
{
- Aig_Obj_t * pObj;
+ Hop_Obj_t * pObj;
int i;
// make sure the nodes have clean marks
- pObj = Aig_ManConst1(p);
+ pObj = Hop_ManConst1(p);
assert( !pObj->fMarkA && !pObj->fMarkB );
- Aig_ManForEachPi( p, pObj, i )
+ Hop_ManForEachPi( p, pObj, i )
assert( !pObj->fMarkA && !pObj->fMarkB );
- Aig_ManForEachPo( p, pObj, i )
+ Hop_ManForEachPo( p, pObj, i )
assert( !pObj->fMarkA && !pObj->fMarkB );
- Aig_ManForEachNode( p, pObj, i )
+ Hop_ManForEachNode( p, pObj, i )
assert( !pObj->fMarkA && !pObj->fMarkB );
// print time
if ( p->time1 ) { PRT( "time1", p->time1 ); }
if ( p->time2 ) { PRT( "time2", p->time2 ); }
-// Aig_TableProfile( p );
- if ( p->vChunks ) Aig_ManStopMemory( p );
+// Hop_TableProfile( p );
+ if ( p->vChunks ) Hop_ManStopMemory( p );
if ( p->vPis ) Vec_PtrFree( p->vPis );
if ( p->vPos ) Vec_PtrFree( p->vPos );
free( p->pTable );
@@ -112,23 +112,23 @@ void Aig_ManStop( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-int Aig_ManCleanup( Aig_Man_t * p )
+int Hop_ManCleanup( Hop_Man_t * p )
{
Vec_Ptr_t * vNodes;
- Aig_Obj_t * pNode;
+ Hop_Obj_t * pNode;
int i, nNodesOld;
assert( p->fRefCount );
- nNodesOld = Aig_ManNodeNum(p);
+ nNodesOld = Hop_ManNodeNum(p);
// collect roots of dangling nodes
vNodes = Vec_PtrAlloc( 100 );
- Aig_ManForEachNode( p, pNode, i )
- if ( Aig_ObjRefs(pNode) == 0 )
+ Hop_ManForEachNode( p, pNode, i )
+ if ( Hop_ObjRefs(pNode) == 0 )
Vec_PtrPush( vNodes, pNode );
// recursively remove dangling nodes
Vec_PtrForEachEntry( vNodes, pNode, i )
- Aig_ObjDelete_rec( p, pNode );
+ Hop_ObjDelete_rec( p, pNode );
Vec_PtrFree( vNodes );
- return nNodesOld - Aig_ManNodeNum(p);
+ return nNodesOld - Hop_ManNodeNum(p);
}
/**Function*************************************************************
@@ -142,14 +142,14 @@ int Aig_ManCleanup( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-void Aig_ManPrintStats( Aig_Man_t * p )
+void Hop_ManPrintStats( Hop_Man_t * p )
{
- printf( "PI/PO = %d/%d. ", Aig_ManPiNum(p), Aig_ManPoNum(p) );
- printf( "A = %7d. ", Aig_ManAndNum(p) );
- printf( "X = %5d. ", Aig_ManExorNum(p) );
+ printf( "PI/PO = %d/%d. ", Hop_ManPiNum(p), Hop_ManPoNum(p) );
+ printf( "A = %7d. ", Hop_ManAndNum(p) );
+ printf( "X = %5d. ", Hop_ManExorNum(p) );
printf( "Cre = %7d. ", p->nCreated );
printf( "Del = %7d. ", p->nDeleted );
- printf( "Lev = %3d. ", Aig_ManCountLevels(p) );
+ printf( "Lev = %3d. ", Hop_ManCountLevels(p) );
printf( "\n" );
}
diff --git a/src/temp/aig_free/aigMem.c b/src/aig/hop/hopMem.c
index 1be78a88..0665470a 100644
--- a/src/temp/aig_free/aigMem.c
+++ b/src/aig/hop/hopMem.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [aigMem.c]
+ FileName [hopMem.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - May 11, 2006.]
- Revision [$Id: aigMem.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+ Revision [$Id: hopMem.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "aig.h"
+#include "hop.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -43,7 +43,7 @@
SeeAlso []
***********************************************************************/
-void Aig_ManStartMemory( Aig_Man_t * p )
+void Hop_ManStartMemory( Hop_Man_t * p )
{
p->vChunks = Vec_PtrAlloc( 128 );
p->vPages = Vec_PtrAlloc( 128 );
@@ -60,7 +60,7 @@ void Aig_ManStartMemory( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-void Aig_ManStopMemory( Aig_Man_t * p )
+void Hop_ManStopMemory( Hop_Man_t * p )
{
void * pMemory;
int i;
@@ -83,15 +83,15 @@ void Aig_ManStopMemory( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-void Aig_ManAddMemory( Aig_Man_t * p )
+void Hop_ManAddMemory( Hop_Man_t * p )
{
char * pMemory;
int i, nBytes;
- assert( sizeof(Aig_Obj_t) <= 64 );
+ assert( sizeof(Hop_Obj_t) <= 64 );
assert( p->pListFree == NULL );
-// assert( (Aig_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
+// assert( (Hop_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
// allocate new memory page
- nBytes = sizeof(Aig_Obj_t) * (1<<IVY_PAGE_SIZE) + 64;
+ nBytes = sizeof(Hop_Obj_t) * (1<<IVY_PAGE_SIZE) + 64;
pMemory = ALLOC( char, nBytes );
Vec_PtrPush( p->vChunks, pMemory );
// align memory at the 32-byte boundary
@@ -99,11 +99,11 @@ void Aig_ManAddMemory( Aig_Man_t * p )
// remember the manager in the first entry
Vec_PtrPush( p->vPages, pMemory );
// break the memory down into nodes
- p->pListFree = (Aig_Obj_t *)pMemory;
+ p->pListFree = (Hop_Obj_t *)pMemory;
for ( i = 1; i <= IVY_PAGE_MASK; i++ )
{
- *((char **)pMemory) = pMemory + sizeof(Aig_Obj_t);
- pMemory += sizeof(Aig_Obj_t);
+ *((char **)pMemory) = pMemory + sizeof(Hop_Obj_t);
+ pMemory += sizeof(Hop_Obj_t);
}
*((char **)pMemory) = NULL;
}
diff --git a/src/temp/aig/aigObj.c b/src/aig/hop/hopObj.c
index 51ce6008..037203fb 100644
--- a/src/temp/aig/aigObj.c
+++ b/src/aig/hop/hopObj.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [aigObj.c]
+ FileName [hopObj.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - May 11, 2006.]
- Revision [$Id: aigObj.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+ Revision [$Id: hopObj.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "aig.h"
+#include "hop.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -39,10 +39,10 @@
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_ObjCreatePi( Aig_Man_t * p )
+Hop_Obj_t * Hop_ObjCreatePi( Hop_Man_t * p )
{
- Aig_Obj_t * pObj;
- pObj = Aig_ManFetchMemory( p );
+ Hop_Obj_t * pObj;
+ pObj = Hop_ManFetchMemory( p );
pObj->Type = AIG_PI;
Vec_PtrPush( p->vPis, pObj );
p->nObjs[AIG_PI]++;
@@ -61,18 +61,18 @@ Aig_Obj_t * Aig_ObjCreatePi( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_ObjCreatePo( Aig_Man_t * p, Aig_Obj_t * pDriver )
+Hop_Obj_t * Hop_ObjCreatePo( Hop_Man_t * p, Hop_Obj_t * pDriver )
{
- Aig_Obj_t * pObj;
- pObj = Aig_ManFetchMemory( p );
+ Hop_Obj_t * pObj;
+ pObj = Hop_ManFetchMemory( p );
pObj->Type = AIG_PO;
Vec_PtrPush( p->vPos, pObj );
// add connections
pObj->pFanin0 = pDriver;
if ( p->fRefCount )
- Aig_ObjRef( Aig_Regular(pDriver) );
+ Hop_ObjRef( Hop_Regular(pDriver) );
else
- pObj->nRefs = Aig_ObjLevel( Aig_Regular(pDriver) );
+ pObj->nRefs = Hop_ObjLevel( Hop_Regular(pDriver) );
// update node counters of the manager
p->nObjs[AIG_PO]++;
p->nCreated++;
@@ -90,19 +90,19 @@ Aig_Obj_t * Aig_ObjCreatePo( Aig_Man_t * p, Aig_Obj_t * pDriver )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_ObjCreate( Aig_Man_t * p, Aig_Obj_t * pGhost )
+Hop_Obj_t * Hop_ObjCreate( Hop_Man_t * p, Hop_Obj_t * pGhost )
{
- Aig_Obj_t * pObj;
- assert( !Aig_IsComplement(pGhost) );
- assert( Aig_ObjIsNode(pGhost) );
+ Hop_Obj_t * pObj;
+ assert( !Hop_IsComplement(pGhost) );
+ assert( Hop_ObjIsNode(pGhost) );
assert( pGhost == &p->Ghost );
// get memory for the new object
- pObj = Aig_ManFetchMemory( p );
+ pObj = Hop_ManFetchMemory( p );
pObj->Type = pGhost->Type;
// add connections
- Aig_ObjConnect( p, pObj, pGhost->pFanin0, pGhost->pFanin1 );
+ Hop_ObjConnect( p, pObj, pGhost->pFanin0, pGhost->pFanin1 );
// update node counters of the manager
- p->nObjs[Aig_ObjType(pObj)]++;
+ p->nObjs[Hop_ObjType(pObj)]++;
p->nCreated++;
return pObj;
}
@@ -118,10 +118,10 @@ Aig_Obj_t * Aig_ObjCreate( Aig_Man_t * p, Aig_Obj_t * pGhost )
SeeAlso []
***********************************************************************/
-void Aig_ObjConnect( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFan0, Aig_Obj_t * pFan1 )
+void Hop_ObjConnect( Hop_Man_t * p, Hop_Obj_t * pObj, Hop_Obj_t * pFan0, Hop_Obj_t * pFan1 )
{
- assert( !Aig_IsComplement(pObj) );
- assert( Aig_ObjIsNode(pObj) );
+ assert( !Hop_IsComplement(pObj) );
+ assert( Hop_ObjIsNode(pObj) );
// add the first fanin
pObj->pFanin0 = pFan0;
pObj->pFanin1 = pFan1;
@@ -129,14 +129,14 @@ void Aig_ObjConnect( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFan0, Aig_Obj
if ( p->fRefCount )
{
if ( pFan0 != NULL )
- Aig_ObjRef( Aig_ObjFanin0(pObj) );
+ Hop_ObjRef( Hop_ObjFanin0(pObj) );
if ( pFan1 != NULL )
- Aig_ObjRef( Aig_ObjFanin1(pObj) );
+ Hop_ObjRef( Hop_ObjFanin1(pObj) );
}
else
- pObj->nRefs = Aig_ObjLevelNew( pObj );
+ pObj->nRefs = Hop_ObjLevelNew( pObj );
// add the node to the structural hash table
- Aig_TableInsert( p, pObj );
+ Hop_TableInsert( p, pObj );
}
/**Function*************************************************************
@@ -150,17 +150,17 @@ void Aig_ObjConnect( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFan0, Aig_Obj
SeeAlso []
***********************************************************************/
-void Aig_ObjDisconnect( Aig_Man_t * p, Aig_Obj_t * pObj )
+void Hop_ObjDisconnect( Hop_Man_t * p, Hop_Obj_t * pObj )
{
- assert( !Aig_IsComplement(pObj) );
- assert( Aig_ObjIsNode(pObj) );
+ assert( !Hop_IsComplement(pObj) );
+ assert( Hop_ObjIsNode(pObj) );
// remove connections
if ( pObj->pFanin0 != NULL )
- Aig_ObjDeref(Aig_ObjFanin0(pObj));
+ Hop_ObjDeref(Hop_ObjFanin0(pObj));
if ( pObj->pFanin1 != NULL )
- Aig_ObjDeref(Aig_ObjFanin1(pObj));
+ Hop_ObjDeref(Hop_ObjFanin1(pObj));
// remove the node from the structural hash table
- Aig_TableDelete( p, pObj );
+ Hop_TableDelete( p, pObj );
// add the first fanin
pObj->pFanin0 = NULL;
pObj->pFanin1 = NULL;
@@ -177,21 +177,21 @@ void Aig_ObjDisconnect( Aig_Man_t * p, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-void Aig_ObjDelete( Aig_Man_t * p, Aig_Obj_t * pObj )
+void Hop_ObjDelete( Hop_Man_t * p, Hop_Obj_t * pObj )
{
- assert( !Aig_IsComplement(pObj) );
- assert( !Aig_ObjIsTerm(pObj) );
- assert( Aig_ObjRefs(pObj) == 0 );
+ assert( !Hop_IsComplement(pObj) );
+ assert( !Hop_ObjIsTerm(pObj) );
+ assert( Hop_ObjRefs(pObj) == 0 );
// update node counters of the manager
p->nObjs[pObj->Type]--;
p->nDeleted++;
// remove connections
- Aig_ObjDisconnect( p, pObj );
+ Hop_ObjDisconnect( p, pObj );
// remove PIs/POs from the arrays
- if ( Aig_ObjIsPi(pObj) )
+ if ( Hop_ObjIsPi(pObj) )
Vec_PtrRemove( p->vPis, pObj );
// free the node
- Aig_ManRecycleMemory( p, pObj );
+ Hop_ManRecycleMemory( p, pObj );
}
/**Function*************************************************************
@@ -205,20 +205,20 @@ void Aig_ObjDelete( Aig_Man_t * p, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-void Aig_ObjDelete_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
+void Hop_ObjDelete_rec( Hop_Man_t * p, Hop_Obj_t * pObj )
{
- Aig_Obj_t * pFanin0, * pFanin1;
- assert( !Aig_IsComplement(pObj) );
- if ( Aig_ObjIsConst1(pObj) || Aig_ObjIsPi(pObj) )
+ Hop_Obj_t * pFanin0, * pFanin1;
+ assert( !Hop_IsComplement(pObj) );
+ if ( Hop_ObjIsConst1(pObj) || Hop_ObjIsPi(pObj) )
return;
- assert( Aig_ObjIsNode(pObj) );
- pFanin0 = Aig_ObjFanin0(pObj);
- pFanin1 = Aig_ObjFanin1(pObj);
- Aig_ObjDelete( p, pObj );
- if ( pFanin0 && !Aig_ObjIsNone(pFanin0) && Aig_ObjRefs(pFanin0) == 0 )
- Aig_ObjDelete_rec( p, pFanin0 );
- if ( pFanin1 && !Aig_ObjIsNone(pFanin1) && Aig_ObjRefs(pFanin1) == 0 )
- Aig_ObjDelete_rec( p, pFanin1 );
+ assert( Hop_ObjIsNode(pObj) );
+ pFanin0 = Hop_ObjFanin0(pObj);
+ pFanin1 = Hop_ObjFanin1(pObj);
+ Hop_ObjDelete( p, pObj );
+ if ( pFanin0 && !Hop_ObjIsNone(pFanin0) && Hop_ObjRefs(pFanin0) == 0 )
+ Hop_ObjDelete_rec( p, pFanin0 );
+ if ( pFanin1 && !Hop_ObjIsNone(pFanin1) && Hop_ObjRefs(pFanin1) == 0 )
+ Hop_ObjDelete_rec( p, pFanin1 );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/temp/aig_free/aigOper.c b/src/aig/hop/hopOper.c
index 9985093e..a31ca0f2 100644
--- a/src/temp/aig_free/aigOper.c
+++ b/src/aig/hop/hopOper.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [aigOper.c]
+ FileName [hopOper.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,31 +14,31 @@
Date [Ver. 1.0. Started - May 11, 2006.]
- Revision [$Id: aigOper.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+ Revision [$Id: hopOper.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "aig.h"
+#include "hop.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
// procedure to detect an EXOR gate
-static inline int Aig_ObjIsExorType( Aig_Obj_t * p0, Aig_Obj_t * p1, Aig_Obj_t ** ppFan0, Aig_Obj_t ** ppFan1 )
+static inline int Hop_ObjIsExorType( Hop_Obj_t * p0, Hop_Obj_t * p1, Hop_Obj_t ** ppFan0, Hop_Obj_t ** ppFan1 )
{
- if ( !Aig_IsComplement(p0) || !Aig_IsComplement(p1) )
+ if ( !Hop_IsComplement(p0) || !Hop_IsComplement(p1) )
return 0;
- p0 = Aig_Regular(p0);
- p1 = Aig_Regular(p1);
- if ( !Aig_ObjIsAnd(p0) || !Aig_ObjIsAnd(p1) )
+ p0 = Hop_Regular(p0);
+ p1 = Hop_Regular(p1);
+ if ( !Hop_ObjIsAnd(p0) || !Hop_ObjIsAnd(p1) )
return 0;
- if ( Aig_ObjFanin0(p0) != Aig_ObjFanin0(p1) || Aig_ObjFanin1(p0) != Aig_ObjFanin1(p1) )
+ if ( Hop_ObjFanin0(p0) != Hop_ObjFanin0(p1) || Hop_ObjFanin1(p0) != Hop_ObjFanin1(p1) )
return 0;
- if ( Aig_ObjFaninC0(p0) == Aig_ObjFaninC0(p1) || Aig_ObjFaninC1(p0) == Aig_ObjFaninC1(p1) )
+ if ( Hop_ObjFaninC0(p0) == Hop_ObjFaninC0(p1) || Hop_ObjFaninC1(p0) == Hop_ObjFaninC1(p1) )
return 0;
- *ppFan0 = Aig_ObjChild0(p0);
- *ppFan1 = Aig_ObjChild1(p0);
+ *ppFan0 = Hop_ObjChild0(p0);
+ *ppFan1 = Hop_ObjChild1(p0);
return 1;
}
@@ -57,13 +57,13 @@ static inline int Aig_ObjIsExorType( Aig_Obj_t * p0, Aig_Obj_t * p1, Aig_Obj_t *
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_IthVar( Aig_Man_t * p, int i )
+Hop_Obj_t * Hop_IthVar( Hop_Man_t * p, int i )
{
int v;
- for ( v = Aig_ManPiNum(p); v <= i; v++ )
- Aig_ObjCreatePi( p );
+ for ( v = Hop_ManPiNum(p); v <= i; v++ )
+ Hop_ObjCreatePi( p );
assert( i < Vec_PtrSize(p->vPis) );
- return Aig_ManPi( p, i );
+ return Hop_ManPi( p, i );
}
/**Function*************************************************************
@@ -77,12 +77,12 @@ Aig_Obj_t * Aig_IthVar( Aig_Man_t * p, int i )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_Oper( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1, Aig_Type_t Type )
+Hop_Obj_t * Hop_Oper( Hop_Man_t * p, Hop_Obj_t * p0, Hop_Obj_t * p1, Hop_Type_t Type )
{
if ( Type == AIG_AND )
- return Aig_And( p, p0, p1 );
+ return Hop_And( p, p0, p1 );
if ( Type == AIG_EXOR )
- return Aig_Exor( p, p0, p1 );
+ return Hop_Exor( p, p0, p1 );
assert( 0 );
return NULL;
}
@@ -98,27 +98,27 @@ Aig_Obj_t * Aig_Oper( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1, Aig_Type_t
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_And( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
+Hop_Obj_t * Hop_And( Hop_Man_t * p, Hop_Obj_t * p0, Hop_Obj_t * p1 )
{
- Aig_Obj_t * pGhost, * pResult;
-// Aig_Obj_t * pFan0, * pFan1;
+ Hop_Obj_t * pGhost, * pResult;
+// Hop_Obj_t * pFan0, * pFan1;
// check trivial cases
if ( p0 == p1 )
return p0;
- 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);
+ if ( p0 == Hop_Not(p1) )
+ return Hop_Not(p->pConst1);
+ if ( Hop_Regular(p0) == p->pConst1 )
+ return p0 == p->pConst1 ? p1 : Hop_Not(p->pConst1);
+ if ( Hop_Regular(p1) == p->pConst1 )
+ return p1 == p->pConst1 ? p0 : Hop_Not(p->pConst1);
// check if it can be an EXOR gate
-// if ( Aig_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) )
-// return Aig_Exor( p, pFan0, pFan1 );
+// if ( Hop_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) )
+// return Hop_Exor( p, pFan0, pFan1 );
// check the table
- pGhost = Aig_ObjCreateGhost( p, p0, p1, AIG_AND );
- if ( pResult = Aig_TableLookup( p, pGhost ) )
+ pGhost = Hop_ObjCreateGhost( p, p0, p1, AIG_AND );
+ if ( pResult = Hop_TableLookup( p, pGhost ) )
return pResult;
- return Aig_ObjCreate( p, pGhost );
+ return Hop_ObjCreate( p, pGhost );
}
/**Function*************************************************************
@@ -132,26 +132,26 @@ Aig_Obj_t * Aig_And( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_Exor( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
+Hop_Obj_t * Hop_Exor( Hop_Man_t * p, Hop_Obj_t * p0, Hop_Obj_t * p1 )
{
/*
- Aig_Obj_t * pGhost, * pResult;
+ Hop_Obj_t * pGhost, * pResult;
// check trivial cases
if ( p0 == p1 )
- return Aig_Not(p->pConst1);
- if ( p0 == Aig_Not(p1) )
+ return Hop_Not(p->pConst1);
+ if ( p0 == Hop_Not(p1) )
return 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 );
+ if ( Hop_Regular(p0) == p->pConst1 )
+ return Hop_NotCond( p1, p0 == p->pConst1 );
+ if ( Hop_Regular(p1) == p->pConst1 )
+ return Hop_NotCond( p0, p1 == p->pConst1 );
// check the table
- pGhost = Aig_ObjCreateGhost( p, p0, p1, AIG_EXOR );
- if ( pResult = Aig_TableLookup( p, pGhost ) )
+ pGhost = Hop_ObjCreateGhost( p, p0, p1, AIG_EXOR );
+ if ( pResult = Hop_TableLookup( p, pGhost ) )
return pResult;
- return Aig_ObjCreate( p, pGhost );
+ return Hop_ObjCreate( p, pGhost );
*/
- return Aig_Or( p, Aig_And(p, p0, Aig_Not(p1)), Aig_And(p, Aig_Not(p0), p1) );
+ return Hop_Or( p, Hop_And(p, p0, Hop_Not(p1)), Hop_And(p, Hop_Not(p0), p1) );
}
/**Function*************************************************************
@@ -165,9 +165,9 @@ Aig_Obj_t * Aig_Exor( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_Or( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
+Hop_Obj_t * Hop_Or( Hop_Man_t * p, Hop_Obj_t * p0, Hop_Obj_t * p1 )
{
- return Aig_Not( Aig_And( p, Aig_Not(p0), Aig_Not(p1) ) );
+ return Hop_Not( Hop_And( p, Hop_Not(p0), Hop_Not(p1) ) );
}
/**Function*************************************************************
@@ -181,48 +181,48 @@ Aig_Obj_t * Aig_Or( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_Mux( Aig_Man_t * p, Aig_Obj_t * pC, Aig_Obj_t * p1, Aig_Obj_t * p0 )
+Hop_Obj_t * Hop_Mux( Hop_Man_t * p, Hop_Obj_t * pC, Hop_Obj_t * p1, Hop_Obj_t * p0 )
{
/*
- Aig_Obj_t * pTempA1, * pTempA2, * pTempB1, * pTempB2, * pTemp;
+ Hop_Obj_t * pTempA1, * pTempA2, * pTempB1, * pTempB2, * pTemp;
int Count0, Count1;
// consider trivial cases
- if ( p0 == Aig_Not(p1) )
- return Aig_Exor( p, pC, p0 );
+ if ( p0 == Hop_Not(p1) )
+ return Hop_Exor( p, pC, p0 );
// other cases can be added
// implement the first MUX (F = C * x1 + C' * x0)
// check for constants here!!!
- pTempA1 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, pC, p1, AIG_AND) );
- pTempA2 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pC), p0, AIG_AND) );
+ pTempA1 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, pC, p1, AIG_AND) );
+ pTempA2 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pC), p0, AIG_AND) );
if ( pTempA1 && pTempA2 )
{
- pTemp = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pTempA1), Aig_Not(pTempA2), AIG_AND) );
- if ( pTemp ) return Aig_Not(pTemp);
+ pTemp = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pTempA1), Hop_Not(pTempA2), AIG_AND) );
+ if ( pTemp ) return Hop_Not(pTemp);
}
Count0 = (pTempA1 != NULL) + (pTempA2 != NULL);
// implement the second MUX (F' = C * x1' + C' * x0')
- pTempB1 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, pC, Aig_Not(p1), AIG_AND) );
- pTempB2 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pC), Aig_Not(p0), AIG_AND) );
+ pTempB1 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, pC, Hop_Not(p1), AIG_AND) );
+ pTempB2 = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pC), Hop_Not(p0), AIG_AND) );
if ( pTempB1 && pTempB2 )
{
- pTemp = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pTempB1), Aig_Not(pTempB2), AIG_AND) );
+ pTemp = Hop_TableLookup( p, Hop_ObjCreateGhost(p, Hop_Not(pTempB1), Hop_Not(pTempB2), AIG_AND) );
if ( pTemp ) return pTemp;
}
Count1 = (pTempB1 != NULL) + (pTempB2 != NULL);
// compare and decide which one to implement
if ( Count0 >= Count1 )
{
- pTempA1 = pTempA1? pTempA1 : Aig_And(p, pC, p1);
- pTempA2 = pTempA2? pTempA2 : Aig_And(p, Aig_Not(pC), p0);
- return Aig_Or( p, pTempA1, pTempA2 );
+ pTempA1 = pTempA1? pTempA1 : Hop_And(p, pC, p1);
+ pTempA2 = pTempA2? pTempA2 : Hop_And(p, Hop_Not(pC), p0);
+ return Hop_Or( p, pTempA1, pTempA2 );
}
- 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 ) );
+ pTempB1 = pTempB1? pTempB1 : Hop_And(p, pC, Hop_Not(p1));
+ pTempB2 = pTempB2? pTempB2 : Hop_And(p, Hop_Not(pC), Hop_Not(p0));
+ return Hop_Not( Hop_Or( p, pTempB1, pTempB2 ) );
*/
- return Aig_Or( p, Aig_And(p, pC, p1), Aig_And(p, Aig_Not(pC), p0) );
+ return Hop_Or( p, Hop_And(p, pC, p1), Hop_And(p, Hop_Not(pC), p0) );
}
/**Function*************************************************************
@@ -236,9 +236,9 @@ Aig_Obj_t * Aig_Mux( Aig_Man_t * p, Aig_Obj_t * pC, Aig_Obj_t * p1, Aig_Obj_t *
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_Maj( Aig_Man_t * p, Aig_Obj_t * pA, Aig_Obj_t * pB, Aig_Obj_t * pC )
+Hop_Obj_t * Hop_Maj( Hop_Man_t * p, Hop_Obj_t * pA, Hop_Obj_t * pB, Hop_Obj_t * pC )
{
- return Aig_Or( p, Aig_Or(p, Aig_And(p, pA, pB), Aig_And(p, pA, pC)), Aig_And(p, pB, pC) );
+ return Hop_Or( p, Hop_Or(p, Hop_And(p, pA, pB), Hop_And(p, pA, pC)), Hop_And(p, pB, pC) );
}
/**Function*************************************************************
@@ -252,14 +252,14 @@ Aig_Obj_t * Aig_Maj( Aig_Man_t * p, Aig_Obj_t * pA, Aig_Obj_t * pB, Aig_Obj_t *
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_Multi_rec( Aig_Man_t * p, Aig_Obj_t ** ppObjs, int nObjs, Aig_Type_t Type )
+Hop_Obj_t * Hop_Multi_rec( Hop_Man_t * p, Hop_Obj_t ** ppObjs, int nObjs, Hop_Type_t Type )
{
- Aig_Obj_t * pObj1, * pObj2;
+ Hop_Obj_t * pObj1, * pObj2;
if ( nObjs == 1 )
return ppObjs[0];
- 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 );
+ pObj1 = Hop_Multi_rec( p, ppObjs, nObjs/2, Type );
+ pObj2 = Hop_Multi_rec( p, ppObjs + nObjs/2, nObjs - nObjs/2, Type );
+ return Hop_Oper( p, pObj1, pObj2, Type );
}
/**Function*************************************************************
@@ -273,11 +273,11 @@ Aig_Obj_t * Aig_Multi_rec( Aig_Man_t * p, Aig_Obj_t ** ppObjs, int nObjs, Aig_Ty
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_Multi( Aig_Man_t * p, Aig_Obj_t ** pArgs, int nArgs, Aig_Type_t Type )
+Hop_Obj_t * Hop_Multi( Hop_Man_t * p, Hop_Obj_t ** pArgs, int nArgs, Hop_Type_t Type )
{
assert( Type == AIG_AND || Type == AIG_EXOR );
assert( nArgs > 0 );
- return Aig_Multi_rec( p, pArgs, nArgs, Type );
+ return Hop_Multi_rec( p, pArgs, nArgs, Type );
}
/**Function*************************************************************
@@ -291,16 +291,16 @@ Aig_Obj_t * Aig_Multi( Aig_Man_t * p, Aig_Obj_t ** pArgs, int nArgs, Aig_Type_t
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_Miter( Aig_Man_t * p, Vec_Ptr_t * vPairs )
+Hop_Obj_t * Hop_Miter( Hop_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] = Aig_Not( Aig_Exor( p, vPairs->pArray[i], vPairs->pArray[i+1] ) );
+ vPairs->pArray[i/2] = Hop_Not( Hop_Exor( p, vPairs->pArray[i], vPairs->pArray[i+1] ) );
vPairs->nSize = vPairs->nSize/2;
- return Aig_Not( Aig_Multi_rec( p, (Aig_Obj_t **)vPairs->pArray, vPairs->nSize, AIG_AND ) );
+ return Hop_Not( Hop_Multi_rec( p, (Hop_Obj_t **)vPairs->pArray, vPairs->nSize, AIG_AND ) );
}
/**Function*************************************************************
@@ -314,13 +314,13 @@ Aig_Obj_t * Aig_Miter( Aig_Man_t * p, Vec_Ptr_t * vPairs )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_CreateAnd( Aig_Man_t * p, int nVars )
+Hop_Obj_t * Hop_CreateAnd( Hop_Man_t * p, int nVars )
{
- Aig_Obj_t * pFunc;
+ Hop_Obj_t * pFunc;
int i;
- pFunc = Aig_ManConst1( p );
+ pFunc = Hop_ManConst1( p );
for ( i = 0; i < nVars; i++ )
- pFunc = Aig_And( p, pFunc, Aig_IthVar(p, i) );
+ pFunc = Hop_And( p, pFunc, Hop_IthVar(p, i) );
return pFunc;
}
@@ -335,13 +335,13 @@ Aig_Obj_t * Aig_CreateAnd( Aig_Man_t * p, int nVars )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_CreateOr( Aig_Man_t * p, int nVars )
+Hop_Obj_t * Hop_CreateOr( Hop_Man_t * p, int nVars )
{
- Aig_Obj_t * pFunc;
+ Hop_Obj_t * pFunc;
int i;
- pFunc = Aig_ManConst0( p );
+ pFunc = Hop_ManConst0( p );
for ( i = 0; i < nVars; i++ )
- pFunc = Aig_Or( p, pFunc, Aig_IthVar(p, i) );
+ pFunc = Hop_Or( p, pFunc, Hop_IthVar(p, i) );
return pFunc;
}
@@ -356,13 +356,13 @@ Aig_Obj_t * Aig_CreateOr( Aig_Man_t * p, int nVars )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_CreateExor( Aig_Man_t * p, int nVars )
+Hop_Obj_t * Hop_CreateExor( Hop_Man_t * p, int nVars )
{
- Aig_Obj_t * pFunc;
+ Hop_Obj_t * pFunc;
int i;
- pFunc = Aig_ManConst0( p );
+ pFunc = Hop_ManConst0( p );
for ( i = 0; i < nVars; i++ )
- pFunc = Aig_Exor( p, pFunc, Aig_IthVar(p, i) );
+ pFunc = Hop_Exor( p, pFunc, Hop_IthVar(p, i) );
return pFunc;
}
diff --git a/src/temp/aig/aigTable.c b/src/aig/hop/hopTable.c
index 338faa45..4ce81982 100644
--- a/src/temp/aig/aigTable.c
+++ b/src/aig/hop/hopTable.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [aigTable.c]
+ FileName [hopTable.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,40 +14,40 @@
Date [Ver. 1.0. Started - May 11, 2006. ]
- Revision [$Id: aigTable.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+ Revision [$Id: hopTable.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "aig.h"
+#include "hop.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
// hashing the node
-static unsigned long Aig_Hash( Aig_Obj_t * pObj, int TableSize )
+static unsigned long Hop_Hash( Hop_Obj_t * pObj, int TableSize )
{
- 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;
+ unsigned long Key = Hop_ObjIsExor(pObj) * 1699;
+ Key ^= (long)Hop_ObjFanin0(pObj) * 7937;
+ Key ^= (long)Hop_ObjFanin1(pObj) * 2971;
+ Key ^= Hop_ObjFaninC0(pObj) * 911;
+ Key ^= Hop_ObjFaninC1(pObj) * 353;
return Key % TableSize;
}
// returns the place where this node is stored (or should be stored)
-static Aig_Obj_t ** Aig_TableFind( Aig_Man_t * p, Aig_Obj_t * pObj )
+static Hop_Obj_t ** Hop_TableFind( Hop_Man_t * p, Hop_Obj_t * pObj )
{
int i;
- assert( Aig_ObjChild0(pObj) && Aig_ObjChild1(pObj) );
- assert( Aig_ObjChild0(pObj) < Aig_ObjChild1(pObj) );
- for ( i = Aig_Hash(pObj, p->nTableSize); p->pTable[i]; i = (i+1) % p->nTableSize )
+ assert( Hop_ObjChild0(pObj) && Hop_ObjChild1(pObj) );
+ assert( Hop_ObjChild0(pObj) < Hop_ObjChild1(pObj) );
+ for ( i = Hop_Hash(pObj, p->nTableSize); p->pTable[i]; i = (i+1) % p->nTableSize )
if ( p->pTable[i] == pObj )
break;
return p->pTable + i;
}
-static void Aig_TableResize( Aig_Man_t * p );
+static void Hop_TableResize( Hop_Man_t * p );
static unsigned int Cudd_PrimeAig( unsigned int p );
////////////////////////////////////////////////////////////////////////
@@ -65,19 +65,19 @@ static unsigned int Cudd_PrimeAig( unsigned int p );
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_TableLookup( Aig_Man_t * p, Aig_Obj_t * pGhost )
+Hop_Obj_t * Hop_TableLookup( Hop_Man_t * p, Hop_Obj_t * pGhost )
{
int i;
- assert( !Aig_IsComplement(pGhost) );
- assert( Aig_ObjChild0(pGhost) && Aig_ObjChild1(pGhost) );
- assert( Aig_ObjChild0(pGhost) < Aig_ObjChild1(pGhost) );
- if ( p->fRefCount && (!Aig_ObjRefs(Aig_ObjFanin0(pGhost)) || !Aig_ObjRefs(Aig_ObjFanin1(pGhost))) )
+ assert( !Hop_IsComplement(pGhost) );
+ assert( Hop_ObjChild0(pGhost) && Hop_ObjChild1(pGhost) );
+ assert( Hop_ObjChild0(pGhost) < Hop_ObjChild1(pGhost) );
+ if ( p->fRefCount && (!Hop_ObjRefs(Hop_ObjFanin0(pGhost)) || !Hop_ObjRefs(Hop_ObjFanin1(pGhost))) )
return NULL;
- for ( i = Aig_Hash(pGhost, p->nTableSize); p->pTable[i]; i = (i+1) % p->nTableSize )
+ for ( i = Hop_Hash(pGhost, p->nTableSize); p->pTable[i]; i = (i+1) % p->nTableSize )
{
- if ( Aig_ObjChild0(p->pTable[i]) == Aig_ObjChild0(pGhost) &&
- Aig_ObjChild1(p->pTable[i]) == Aig_ObjChild1(pGhost) &&
- Aig_ObjType(p->pTable[i]) == Aig_ObjType(pGhost) )
+ if ( Hop_ObjChild0(p->pTable[i]) == Hop_ObjChild0(pGhost) &&
+ Hop_ObjChild1(p->pTable[i]) == Hop_ObjChild1(pGhost) &&
+ Hop_ObjType(p->pTable[i]) == Hop_ObjType(pGhost) )
return p->pTable[i];
}
return NULL;
@@ -94,14 +94,14 @@ Aig_Obj_t * Aig_TableLookup( Aig_Man_t * p, Aig_Obj_t * pGhost )
SeeAlso []
***********************************************************************/
-void Aig_TableInsert( Aig_Man_t * p, Aig_Obj_t * pObj )
+void Hop_TableInsert( Hop_Man_t * p, Hop_Obj_t * pObj )
{
- Aig_Obj_t ** ppPlace;
- assert( !Aig_IsComplement(pObj) );
- assert( Aig_TableLookup(p, pObj) == NULL );
- if ( p->nTableSize < 2 * Aig_ManNodeNum(p) )
- Aig_TableResize( p );
- ppPlace = Aig_TableFind( p, pObj );
+ Hop_Obj_t ** ppPlace;
+ assert( !Hop_IsComplement(pObj) );
+ assert( Hop_TableLookup(p, pObj) == NULL );
+ if ( p->nTableSize < 2 * Hop_ManNodeNum(p) )
+ Hop_TableResize( p );
+ ppPlace = Hop_TableFind( p, pObj );
assert( *ppPlace == NULL );
*ppPlace = pObj;
}
@@ -117,12 +117,12 @@ void Aig_TableInsert( Aig_Man_t * p, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-void Aig_TableDelete( Aig_Man_t * p, Aig_Obj_t * pObj )
+void Hop_TableDelete( Hop_Man_t * p, Hop_Obj_t * pObj )
{
- Aig_Obj_t * pEntry, ** ppPlace;
+ Hop_Obj_t * pEntry, ** ppPlace;
int i;
- assert( !Aig_IsComplement(pObj) );
- ppPlace = Aig_TableFind( p, pObj );
+ assert( !Hop_IsComplement(pObj) );
+ ppPlace = Hop_TableFind( p, pObj );
assert( *ppPlace == pObj ); // node should be in the table
*ppPlace = NULL;
// rehash the adjacent entries
@@ -131,7 +131,7 @@ void Aig_TableDelete( Aig_Man_t * p, Aig_Obj_t * pObj )
{
pEntry = p->pTable[i];
p->pTable[i] = 0;
- Aig_TableInsert( p, pEntry );
+ Hop_TableInsert( p, pEntry );
}
}
@@ -146,7 +146,7 @@ void Aig_TableDelete( Aig_Man_t * p, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-int Aig_TableCountEntries( Aig_Man_t * p )
+int Hop_TableCountEntries( Hop_Man_t * p )
{
int i, Counter = 0;
for ( i = 0; i < p->nTableSize; i++ )
@@ -165,18 +165,18 @@ int Aig_TableCountEntries( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-void Aig_TableResize( Aig_Man_t * p )
+void Hop_TableResize( Hop_Man_t * p )
{
- Aig_Obj_t ** pTableOld, ** ppPlace;
+ Hop_Obj_t ** pTableOld, ** ppPlace;
int nTableSizeOld, Counter, nEntries, e, clk;
clk = clock();
// save the old table
pTableOld = p->pTable;
nTableSizeOld = p->nTableSize;
// get the new table
- p->nTableSize = Cudd_PrimeAig( 5 * Aig_ManNodeNum(p) );
- p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize );
- memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
+ p->nTableSize = Cudd_PrimeAig( 5 * Hop_ManNodeNum(p) );
+ p->pTable = ALLOC( Hop_Obj_t *, p->nTableSize );
+ memset( p->pTable, 0, sizeof(Hop_Obj_t *) * p->nTableSize );
// rehash the entries from the old table
Counter = 0;
for ( e = 0; e < nTableSizeOld; e++ )
@@ -185,11 +185,11 @@ clk = clock();
continue;
Counter++;
// get the place where this entry goes in the table table
- ppPlace = Aig_TableFind( p, pTableOld[e] );
+ ppPlace = Hop_TableFind( p, pTableOld[e] );
assert( *ppPlace == NULL ); // should not be in the table
*ppPlace = pTableOld[e];
}
- nEntries = Aig_ManNodeNum(p);
+ nEntries = Hop_ManNodeNum(p);
// assert( Counter == nEntries );
// printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize );
// PRT( "Time", clock() - clk );
@@ -208,7 +208,7 @@ clk = clock();
SeeAlso []
******************************************************************************/
-void Aig_TableProfile( Aig_Man_t * p )
+void Hop_TableProfile( Hop_Man_t * p )
{
int i, Counter = 0;
for ( i = 0; i < p->nTableSize; i++ )
diff --git a/src/temp/aig/aigUtil.c b/src/aig/hop/hopUtil.c
index 6534a460..738caa4a 100644
--- a/src/temp/aig/aigUtil.c
+++ b/src/aig/hop/hopUtil.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [aigUtil.c]
+ FileName [hopUtil.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,11 +14,11 @@
Date [Ver. 1.0. Started - May 11, 2006.]
- Revision [$Id: aigUtil.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+ Revision [$Id: hopUtil.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "aig.h"
+#include "hop.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -39,10 +39,10 @@
SeeAlso []
***********************************************************************/
-void Aig_ManIncrementTravId( Aig_Man_t * p )
+void Hop_ManIncrementTravId( Hop_Man_t * p )
{
if ( p->nTravIds >= (1<<30)-1 )
- Aig_ManCleanData( p );
+ Hop_ManCleanData( p );
p->nTravIds++;
}
@@ -57,17 +57,17 @@ void Aig_ManIncrementTravId( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-void Aig_ManCleanData( Aig_Man_t * p )
+void Hop_ManCleanData( Hop_Man_t * p )
{
- Aig_Obj_t * pObj;
+ Hop_Obj_t * pObj;
int i;
p->nTravIds = 1;
- Aig_ManConst1(p)->pData = NULL;
- Aig_ManForEachPi( p, pObj, i )
+ Hop_ManConst1(p)->pData = NULL;
+ Hop_ManForEachPi( p, pObj, i )
pObj->pData = NULL;
- Aig_ManForEachPo( p, pObj, i )
+ Hop_ManForEachPo( p, pObj, i )
pObj->pData = NULL;
- Aig_ManForEachNode( p, pObj, i )
+ Hop_ManForEachNode( p, pObj, i )
pObj->pData = NULL;
}
@@ -82,15 +82,15 @@ void Aig_ManCleanData( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-void Aig_ObjCollectMulti_rec( Aig_Obj_t * pRoot, Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
+void Hop_ObjCollectMulti_rec( Hop_Obj_t * pRoot, Hop_Obj_t * pObj, Vec_Ptr_t * vSuper )
{
- if ( pRoot != pObj && (Aig_IsComplement(pObj) || Aig_ObjIsPi(pObj) || Aig_ObjType(pRoot) != Aig_ObjType(pObj)) )
+ if ( pRoot != pObj && (Hop_IsComplement(pObj) || Hop_ObjIsPi(pObj) || Hop_ObjType(pRoot) != Hop_ObjType(pObj)) )
{
Vec_PtrPushUnique(vSuper, pObj);
return;
}
- Aig_ObjCollectMulti_rec( pRoot, Aig_ObjChild0(pObj), vSuper );
- Aig_ObjCollectMulti_rec( pRoot, Aig_ObjChild1(pObj), vSuper );
+ Hop_ObjCollectMulti_rec( pRoot, Hop_ObjChild0(pObj), vSuper );
+ Hop_ObjCollectMulti_rec( pRoot, Hop_ObjChild1(pObj), vSuper );
}
/**Function*************************************************************
@@ -104,11 +104,11 @@ void Aig_ObjCollectMulti_rec( Aig_Obj_t * pRoot, Aig_Obj_t * pObj, Vec_Ptr_t * v
SeeAlso []
***********************************************************************/
-void Aig_ObjCollectMulti( Aig_Obj_t * pRoot, Vec_Ptr_t * vSuper )
+void Hop_ObjCollectMulti( Hop_Obj_t * pRoot, Vec_Ptr_t * vSuper )
{
- assert( !Aig_IsComplement(pRoot) );
+ assert( !Hop_IsComplement(pRoot) );
Vec_PtrClear( vSuper );
- Aig_ObjCollectMulti_rec( pRoot, pRoot, vSuper );
+ Hop_ObjCollectMulti_rec( pRoot, pRoot, vSuper );
}
/**Function*************************************************************
@@ -122,28 +122,28 @@ void Aig_ObjCollectMulti( Aig_Obj_t * pRoot, Vec_Ptr_t * vSuper )
SeeAlso []
***********************************************************************/
-int Aig_ObjIsMuxType( Aig_Obj_t * pNode )
+int Hop_ObjIsMuxType( Hop_Obj_t * pNode )
{
- Aig_Obj_t * pNode0, * pNode1;
+ Hop_Obj_t * pNode0, * pNode1;
// check that the node is regular
- assert( !Aig_IsComplement(pNode) );
+ assert( !Hop_IsComplement(pNode) );
// if the node is not AND, this is not MUX
- if ( !Aig_ObjIsAnd(pNode) )
+ if ( !Hop_ObjIsAnd(pNode) )
return 0;
// if the children are not complemented, this is not MUX
- if ( !Aig_ObjFaninC0(pNode) || !Aig_ObjFaninC1(pNode) )
+ if ( !Hop_ObjFaninC0(pNode) || !Hop_ObjFaninC1(pNode) )
return 0;
// get children
- pNode0 = Aig_ObjFanin0(pNode);
- pNode1 = Aig_ObjFanin1(pNode);
+ pNode0 = Hop_ObjFanin0(pNode);
+ pNode1 = Hop_ObjFanin1(pNode);
// if the children are not ANDs, this is not MUX
- if ( !Aig_ObjIsAnd(pNode0) || !Aig_ObjIsAnd(pNode1) )
+ if ( !Hop_ObjIsAnd(pNode0) || !Hop_ObjIsAnd(pNode1) )
return 0;
// otherwise the node is MUX iff it has a pair of equal grandchildren
- 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)));
+ return (Hop_ObjFanin0(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC0(pNode1))) ||
+ (Hop_ObjFanin0(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC1(pNode1))) ||
+ (Hop_ObjFanin1(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC0(pNode1))) ||
+ (Hop_ObjFanin1(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC1(pNode1)));
}
@@ -158,33 +158,33 @@ int Aig_ObjIsMuxType( Aig_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-int Aig_ObjRecognizeExor( Aig_Obj_t * pObj, Aig_Obj_t ** ppFan0, Aig_Obj_t ** ppFan1 )
+int Hop_ObjRecognizeExor( Hop_Obj_t * pObj, Hop_Obj_t ** ppFan0, Hop_Obj_t ** ppFan1 )
{
- Aig_Obj_t * p0, * p1;
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) )
+ Hop_Obj_t * p0, * p1;
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) )
return 0;
- if ( Aig_ObjIsExor(pObj) )
+ if ( Hop_ObjIsExor(pObj) )
{
- *ppFan0 = Aig_ObjChild0(pObj);
- *ppFan1 = Aig_ObjChild1(pObj);
+ *ppFan0 = Hop_ObjChild0(pObj);
+ *ppFan1 = Hop_ObjChild1(pObj);
return 1;
}
- assert( Aig_ObjIsAnd(pObj) );
- p0 = Aig_ObjChild0(pObj);
- p1 = Aig_ObjChild1(pObj);
- if ( !Aig_IsComplement(p0) || !Aig_IsComplement(p1) )
+ assert( Hop_ObjIsAnd(pObj) );
+ p0 = Hop_ObjChild0(pObj);
+ p1 = Hop_ObjChild1(pObj);
+ if ( !Hop_IsComplement(p0) || !Hop_IsComplement(p1) )
return 0;
- p0 = Aig_Regular(p0);
- p1 = Aig_Regular(p1);
- if ( !Aig_ObjIsAnd(p0) || !Aig_ObjIsAnd(p1) )
+ p0 = Hop_Regular(p0);
+ p1 = Hop_Regular(p1);
+ if ( !Hop_ObjIsAnd(p0) || !Hop_ObjIsAnd(p1) )
return 0;
- if ( Aig_ObjFanin0(p0) != Aig_ObjFanin0(p1) || Aig_ObjFanin1(p0) != Aig_ObjFanin1(p1) )
+ if ( Hop_ObjFanin0(p0) != Hop_ObjFanin0(p1) || Hop_ObjFanin1(p0) != Hop_ObjFanin1(p1) )
return 0;
- if ( Aig_ObjFaninC0(p0) == Aig_ObjFaninC0(p1) || Aig_ObjFaninC1(p0) == Aig_ObjFaninC1(p1) )
+ if ( Hop_ObjFaninC0(p0) == Hop_ObjFaninC0(p1) || Hop_ObjFaninC1(p0) == Hop_ObjFaninC1(p1) )
return 0;
- *ppFan0 = Aig_ObjChild0(p0);
- *ppFan1 = Aig_ObjChild1(p0);
+ *ppFan0 = Hop_ObjChild0(p0);
+ *ppFan1 = Hop_ObjChild1(p0);
return 1;
}
@@ -202,78 +202,78 @@ int Aig_ObjRecognizeExor( Aig_Obj_t * pObj, Aig_Obj_t ** ppFan0, Aig_Obj_t ** pp
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Aig_ObjRecognizeMux( Aig_Obj_t * pNode, Aig_Obj_t ** ppNodeT, Aig_Obj_t ** ppNodeE )
+Hop_Obj_t * Hop_ObjRecognizeMux( Hop_Obj_t * pNode, Hop_Obj_t ** ppNodeT, Hop_Obj_t ** ppNodeE )
{
- Aig_Obj_t * pNode0, * pNode1;
- assert( !Aig_IsComplement(pNode) );
- assert( Aig_ObjIsMuxType(pNode) );
+ Hop_Obj_t * pNode0, * pNode1;
+ assert( !Hop_IsComplement(pNode) );
+ assert( Hop_ObjIsMuxType(pNode) );
// get children
- pNode0 = Aig_ObjFanin0(pNode);
- pNode1 = Aig_ObjFanin1(pNode);
+ pNode0 = Hop_ObjFanin0(pNode);
+ pNode1 = Hop_ObjFanin1(pNode);
// find the control variable
- if ( Aig_ObjFanin1(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC1(pNode1)) )
+ if ( Hop_ObjFanin1(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC1(pNode1)) )
{
// if ( Fraig_IsComplement(pNode1->p2) )
- if ( Aig_ObjFaninC1(pNode0) )
+ if ( Hop_ObjFaninC1(pNode0) )
{ // pNode2->p2 is positive phase of C
- *ppNodeT = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
- *ppNodeE = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
- return Aig_ObjChild1(pNode1);//pNode2->p2;
+ *ppNodeT = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1);
+ *ppNodeE = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1);
+ return Hop_ObjChild1(pNode1);//pNode2->p2;
}
else
{ // pNode1->p2 is positive phase of C
- *ppNodeT = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
- *ppNodeE = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
- return Aig_ObjChild1(pNode0);//pNode1->p2;
+ *ppNodeT = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1);
+ *ppNodeE = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1);
+ return Hop_ObjChild1(pNode0);//pNode1->p2;
}
}
- else if ( Aig_ObjFanin0(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC0(pNode1)) )
+ else if ( Hop_ObjFanin0(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC0(pNode1)) )
{
// if ( Fraig_IsComplement(pNode1->p1) )
- if ( Aig_ObjFaninC0(pNode0) )
+ if ( Hop_ObjFaninC0(pNode0) )
{ // pNode2->p1 is positive phase of C
- *ppNodeT = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
- *ppNodeE = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
- return Aig_ObjChild0(pNode1);//pNode2->p1;
+ *ppNodeT = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2);
+ *ppNodeE = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2);
+ return Hop_ObjChild0(pNode1);//pNode2->p1;
}
else
{ // pNode1->p1 is positive phase of C
- *ppNodeT = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
- *ppNodeE = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
- return Aig_ObjChild0(pNode0);//pNode1->p1;
+ *ppNodeT = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2);
+ *ppNodeE = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2);
+ return Hop_ObjChild0(pNode0);//pNode1->p1;
}
}
- else if ( Aig_ObjFanin0(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC1(pNode1)) )
+ else if ( Hop_ObjFanin0(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC1(pNode1)) )
{
// if ( Fraig_IsComplement(pNode1->p1) )
- if ( Aig_ObjFaninC0(pNode0) )
+ if ( Hop_ObjFaninC0(pNode0) )
{ // pNode2->p2 is positive phase of C
- *ppNodeT = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
- *ppNodeE = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
- return Aig_ObjChild1(pNode1);//pNode2->p2;
+ *ppNodeT = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1);
+ *ppNodeE = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2);
+ return Hop_ObjChild1(pNode1);//pNode2->p2;
}
else
{ // pNode1->p1 is positive phase of C
- *ppNodeT = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
- *ppNodeE = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
- return Aig_ObjChild0(pNode0);//pNode1->p1;
+ *ppNodeT = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2);
+ *ppNodeE = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1);
+ return Hop_ObjChild0(pNode0);//pNode1->p1;
}
}
- else if ( Aig_ObjFanin1(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC0(pNode1)) )
+ else if ( Hop_ObjFanin1(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC0(pNode1)) )
{
// if ( Fraig_IsComplement(pNode1->p2) )
- if ( Aig_ObjFaninC1(pNode0) )
+ if ( Hop_ObjFaninC1(pNode0) )
{ // pNode2->p1 is positive phase of C
- *ppNodeT = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
- *ppNodeE = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
- return Aig_ObjChild0(pNode1);//pNode2->p1;
+ *ppNodeT = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2);
+ *ppNodeE = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1);
+ return Hop_ObjChild0(pNode1);//pNode2->p1;
}
else
{ // pNode1->p2 is positive phase of C
- *ppNodeT = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
- *ppNodeE = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
- return Aig_ObjChild1(pNode0);//pNode1->p2;
+ *ppNodeT = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1);
+ *ppNodeE = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2);
+ return Hop_ObjChild1(pNode0);//pNode1->p2;
}
}
assert( 0 ); // this is not MUX
@@ -293,36 +293,36 @@ Aig_Obj_t * Aig_ObjRecognizeMux( Aig_Obj_t * pNode, Aig_Obj_t ** ppNodeT, Aig_Ob
SeeAlso []
***********************************************************************/
-void Aig_ObjPrintVerilog( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, int Level )
+void Hop_ObjPrintVerilog( FILE * pFile, Hop_Obj_t * pObj, Vec_Vec_t * vLevels, int Level )
{
Vec_Ptr_t * vSuper;
- Aig_Obj_t * pFanin, * pFanin0, * pFanin1, * pFaninC;
+ Hop_Obj_t * pFanin, * pFanin0, * pFanin1, * pFaninC;
int fCompl, i;
// store the complemented attribute
- fCompl = Aig_IsComplement(pObj);
- pObj = Aig_Regular(pObj);
+ fCompl = Hop_IsComplement(pObj);
+ pObj = Hop_Regular(pObj);
// constant case
- if ( Aig_ObjIsConst1(pObj) )
+ if ( Hop_ObjIsConst1(pObj) )
{
fprintf( pFile, "%d", !fCompl );
return;
}
// PI case
- if ( Aig_ObjIsPi(pObj) )
+ if ( Hop_ObjIsPi(pObj) )
{
fprintf( pFile, "%s%s", fCompl? "~" : "", pObj->pData );
return;
}
// EXOR case
- if ( Aig_ObjIsExor(pObj) )
+ if ( Hop_ObjIsExor(pObj) )
{
Vec_VecExpand( vLevels, Level );
vSuper = Vec_VecEntry( vLevels, Level );
- Aig_ObjCollectMulti( pObj, vSuper );
+ Hop_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
Vec_PtrForEachEntry( vSuper, pFanin, i )
{
- Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin, (fCompl && i==0)), vLevels, Level+1 );
+ Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin, (fCompl && i==0)), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
fprintf( pFile, " ^ " );
}
@@ -330,25 +330,25 @@ void Aig_ObjPrintVerilog( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, i
return;
}
// MUX case
- if ( Aig_ObjIsMuxType(pObj) )
+ if ( Hop_ObjIsMuxType(pObj) )
{
- if ( Aig_ObjRecognizeExor( pObj, &pFanin0, &pFanin1 ) )
+ if ( Hop_ObjRecognizeExor( pObj, &pFanin0, &pFanin1 ) )
{
fprintf( pFile, "%s", (Level==0? "" : "(") );
- Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin0, fCompl), vLevels, Level+1 );
+ Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin0, fCompl), vLevels, Level+1 );
fprintf( pFile, " ^ " );
- Aig_ObjPrintVerilog( pFile, pFanin1, vLevels, Level+1 );
+ Hop_ObjPrintVerilog( pFile, pFanin1, vLevels, Level+1 );
fprintf( pFile, "%s", (Level==0? "" : ")") );
}
else
{
- pFaninC = Aig_ObjRecognizeMux( pObj, &pFanin1, &pFanin0 );
+ pFaninC = Hop_ObjRecognizeMux( pObj, &pFanin1, &pFanin0 );
fprintf( pFile, "%s", (Level==0? "" : "(") );
- Aig_ObjPrintVerilog( pFile, pFaninC, vLevels, Level+1 );
+ Hop_ObjPrintVerilog( pFile, pFaninC, vLevels, Level+1 );
fprintf( pFile, " ? " );
- Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin1, fCompl), vLevels, Level+1 );
+ Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin1, fCompl), vLevels, Level+1 );
fprintf( pFile, " : " );
- Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin0, fCompl), vLevels, Level+1 );
+ Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin0, fCompl), vLevels, Level+1 );
fprintf( pFile, "%s", (Level==0? "" : ")") );
}
return;
@@ -356,11 +356,11 @@ void Aig_ObjPrintVerilog( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, i
// AND case
Vec_VecExpand( vLevels, Level );
vSuper = Vec_VecEntry(vLevels, Level);
- Aig_ObjCollectMulti( pObj, vSuper );
+ Hop_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
Vec_PtrForEachEntry( vSuper, pFanin, i )
{
- Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin, fCompl), vLevels, Level+1 );
+ Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin, fCompl), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
fprintf( pFile, " %s ", fCompl? "|" : "&" );
}
@@ -380,19 +380,19 @@ void Aig_ObjPrintVerilog( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, i
SeeAlso []
***********************************************************************/
-void Aig_ObjPrintVerbose( Aig_Obj_t * pObj, int fHaig )
+void Hop_ObjPrintVerbose( Hop_Obj_t * pObj, int fHaig )
{
- assert( !Aig_IsComplement(pObj) );
+ assert( !Hop_IsComplement(pObj) );
printf( "Node %p : ", pObj );
- if ( Aig_ObjIsConst1(pObj) )
+ if ( Hop_ObjIsConst1(pObj) )
printf( "constant 1" );
- else if ( Aig_ObjIsPi(pObj) )
+ else if ( Hop_ObjIsPi(pObj) )
printf( "PI" );
else
printf( "AND( %p%s, %p%s )",
- Aig_ObjFanin0(pObj), (Aig_ObjFaninC0(pObj)? "\'" : " "),
- Aig_ObjFanin1(pObj), (Aig_ObjFaninC1(pObj)? "\'" : " ") );
- printf( " (refs = %3d)", Aig_ObjRefs(pObj) );
+ Hop_ObjFanin0(pObj), (Hop_ObjFaninC0(pObj)? "\'" : " "),
+ Hop_ObjFanin1(pObj), (Hop_ObjFaninC1(pObj)? "\'" : " ") );
+ printf( " (refs = %3d)", Hop_ObjRefs(pObj) );
}
/**Function*************************************************************
@@ -406,18 +406,18 @@ void Aig_ObjPrintVerbose( Aig_Obj_t * pObj, int fHaig )
SeeAlso []
***********************************************************************/
-void Aig_ManPrintVerbose( Aig_Man_t * p, int fHaig )
+void Hop_ManPrintVerbose( Hop_Man_t * p, int fHaig )
{
Vec_Ptr_t * vNodes;
- Aig_Obj_t * pObj;
+ Hop_Obj_t * pObj;
int i;
printf( "PIs: " );
- Aig_ManForEachPi( p, pObj, i )
+ Hop_ManForEachPi( p, pObj, i )
printf( " %p", pObj );
printf( "\n" );
- vNodes = Aig_ManDfs( p );
+ vNodes = Hop_ManDfs( p );
Vec_PtrForEachEntry( vNodes, pObj, i )
- Aig_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
+ Hop_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
printf( "\n" );
}
@@ -432,61 +432,61 @@ void Aig_ManPrintVerbose( Aig_Man_t * p, int fHaig )
SeeAlso []
***********************************************************************/
-void Aig_ManDumpBlif( Aig_Man_t * p, char * pFileName )
+void Hop_ManDumpBlif( Hop_Man_t * p, char * pFileName )
{
FILE * pFile;
Vec_Ptr_t * vNodes;
- Aig_Obj_t * pObj, * pConst1 = NULL;
+ Hop_Obj_t * pObj, * pConst1 = NULL;
int i, nDigits, Counter = 0;
- if ( Aig_ManPoNum(p) == 0 )
+ if ( Hop_ManPoNum(p) == 0 )
{
- printf( "Aig_ManDumpBlif(): AIG manager does not have POs.\n" );
+ printf( "Hop_ManDumpBlif(): AIG manager does not have POs.\n" );
return;
}
// collect nodes in the DFS order
- vNodes = Aig_ManDfs( p );
+ vNodes = Hop_ManDfs( p );
// assign IDs to objects
- Aig_ManConst1(p)->pData = (void *)Counter++;
- Aig_ManForEachPi( p, pObj, i )
+ Hop_ManConst1(p)->pData = (void *)Counter++;
+ Hop_ManForEachPi( p, pObj, i )
pObj->pData = (void *)Counter++;
- Aig_ManForEachPo( p, pObj, i )
+ Hop_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 Aig_ManDumpBlif() in ABC\n" );
+ fprintf( pFile, "# BLIF file written by procedure Hop_ManDumpBlif() in ABC\n" );
fprintf( pFile, "# http://www.eecs.berkeley.edu/~alanmi/abc/\n" );
fprintf( pFile, ".model test\n" );
// write PIs
fprintf( pFile, ".inputs" );
- Aig_ManForEachPi( p, pObj, i )
+ Hop_ManForEachPi( p, pObj, i )
fprintf( pFile, " n%0*d", nDigits, (int)pObj->pData );
fprintf( pFile, "\n" );
// write POs
fprintf( pFile, ".outputs" );
- Aig_ManForEachPo( p, pObj, i )
+ Hop_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)Aig_ObjFanin0(pObj)->pData,
- nDigits, (int)Aig_ObjFanin1(pObj)->pData,
+ nDigits, (int)Hop_ObjFanin0(pObj)->pData,
+ nDigits, (int)Hop_ObjFanin1(pObj)->pData,
nDigits, (int)pObj->pData );
- fprintf( pFile, "%d%d 1\n", !Aig_ObjFaninC0(pObj), !Aig_ObjFaninC1(pObj) );
+ fprintf( pFile, "%d%d 1\n", !Hop_ObjFaninC0(pObj), !Hop_ObjFaninC1(pObj) );
}
// write POs
- Aig_ManForEachPo( p, pObj, i )
+ Hop_ManForEachPo( p, pObj, i )
{
fprintf( pFile, ".names n%0*d n%0*d\n",
- nDigits, (int)Aig_ObjFanin0(pObj)->pData,
+ nDigits, (int)Hop_ObjFanin0(pObj)->pData,
nDigits, (int)pObj->pData );
- fprintf( pFile, "%d 1\n", !Aig_ObjFaninC0(pObj) );
- if ( Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) )
- pConst1 = Aig_ManConst1(p);
+ fprintf( pFile, "%d 1\n", !Hop_ObjFaninC0(pObj) );
+ if ( Hop_ObjIsConst1(Hop_ObjFanin0(pObj)) )
+ pConst1 = Hop_ManConst1(p);
}
if ( pConst1 )
fprintf( pFile, ".names n%0*d\n 1\n", nDigits, (int)pConst1->pData );
diff --git a/src/temp/aig/aig_.c b/src/aig/hop/hop_.c
index 468413fa..468413fa 100644
--- a/src/temp/aig/aig_.c
+++ b/src/aig/hop/hop_.c
diff --git a/src/aig/hop/module.make b/src/aig/hop/module.make
new file mode 100644
index 00000000..b06d91fd
--- /dev/null
+++ b/src/aig/hop/module.make
@@ -0,0 +1,9 @@
+SRC += src/aig/hop/hopBalance.c \
+ src/aig/hop/hopCheck.c \
+ src/aig/hop/hopDfs.c \
+ src/aig/hop/hopMan.c \
+ src/aig/hop/hopMem.c \
+ src/aig/hop/hopObj.c \
+ src/aig/hop/hopOper.c \
+ src/aig/hop/hopTable.c \
+ src/aig/hop/hopUtil.c
diff --git a/src/aig/ivy/attr.h b/src/aig/ivy/attr.h
new file mode 100644
index 00000000..5a760239
--- /dev/null
+++ b/src/aig/ivy/attr.h
@@ -0,0 +1,414 @@
+/**CFile****************************************************************
+
+ FileName [attr.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Network attributes.]
+
+ Synopsis [External declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: attr.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __ATTR_H__
+#define __ATTR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+#include "extra.h"
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Attr_ManStruct_t_ Attr_Man_t;
+struct Attr_ManStruct_t_
+{
+ // attribute info
+ int nAttrSize; // the size of each attribute in bytes
+ Extra_MmFixed_t * pManMem; // memory manager for attributes
+ int nAttrs; // the number of attributes allocated
+ void ** pAttrs; // the array of attributes
+ int fUseInt; // uses integer attributes
+ // attribute specific info
+ void * pManAttr; // the manager for this attribute
+ void (*pFuncFreeMan) (void *); // the procedure to call to free attribute-specific manager
+ void (*pFuncFreeObj) (void *, void *); // the procedure to call to free attribute-specific data
+};
+
+// at any time, an attribute of the given ID can be
+// - not available (p->nAttrs < Id)
+// - available but not allocated (p->nAttrs >= Id && p->pAttrs[Id] == NULL)
+// - available and allocated (p->nAttrs >= Id && p->pAttrs[Id] != NULL)
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Allocates the attribute manager.]
+
+ Description [The manager is simple if it does not need memory manager.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Attr_Man_t * Attr_ManAlloc( int nAttrSize, int fManMem )
+{
+ Attr_Man_t * p;
+ p = ALLOC( Attr_Man_t, 1 );
+ memset( p, 0, sizeof(Attr_Man_t) );
+ p->nAttrSize = nAttrSize;
+ if ( fManMem )
+ p->pManMem = Extra_MmFixedStart( nAttrSize );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Start the attribute manager for integers.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Attr_Man_t * Attr_ManStartInt( int nAttrs )
+{
+ Attr_Man_t * p;
+ p = Attr_ManAlloc( sizeof(int), 0 );
+ p->nAttrs = nAttrs;
+ p->pAttrs = (void **)ALLOC( int, nAttrs );
+ memset( (int *)p->pAttrs, 0, sizeof(int) * nAttrs );
+ p->fUseInt = 1;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Start the attribute manager for pointers.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Attr_Man_t * Attr_ManStartPtr( int nAttrs )
+{
+ Attr_Man_t * p;
+ p = Attr_ManAlloc( sizeof(void *), 0 );
+ p->nAttrs = nAttrs;
+ p->pAttrs = ALLOC( void *, nAttrs );
+ memset( p->pAttrs, 0, sizeof(void *) * nAttrs );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Start the attribute manager for the fixed entry size.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Attr_Man_t * Attr_ManStartPtrMem( int nAttrs, int nAttrSize )
+{
+ Attr_Man_t * p;
+ int i;
+ p = Attr_ManAlloc( nAttrSize, 1 );
+ p->nAttrs = nAttrs;
+ p->pAttrs = ALLOC( void *, nAttrs );
+ for ( i = 0; i < p->nAttrs; i++ )
+ {
+ p->pAttrs[i] = Extra_MmFixedEntryFetch( p->pManMem );
+ memset( p->pAttrs[i], 0, nAttrSize );
+ }
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Stop the attribute manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Attr_ManStop( Attr_Man_t * p )
+{
+ // free the attributes of objects
+ if ( p->pFuncFreeObj )
+ {
+ int i;
+ if ( p->fUseInt )
+ {
+ for ( i = 0; i < p->nAttrs; i++ )
+ if ( ((int *)p->pAttrs)[i] )
+ p->pFuncFreeObj( p->pManAttr, (void *)((int *)p->pAttrs)[i] );
+ }
+ else
+ {
+ for ( i = 0; i < p->nAttrs; i++ )
+ if ( p->pAttrs[i] )
+ p->pFuncFreeObj( p->pManAttr, p->pAttrs[i] );
+ }
+ }
+ // free the attribute manager
+ if ( p->pManAttr && p->pFuncFreeMan )
+ p->pFuncFreeMan( p->pManAttr );
+ // free the memory manager
+ if ( p->pManMem )
+ Extra_MmFixedStop( p->pManMem, 0 );
+ // free the attribute manager
+ FREE( p->pAttrs );
+ free( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads the attribute of the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Attr_ManReadAttrInt( Attr_Man_t * p, int Id )
+{
+ assert( p->fUseInt );
+ if ( Id >= p->nAttrs )
+ return 0;
+ return ((int *)p->pAttrs)[Id];
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads the attribute of the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void * Attr_ManReadAttrPtr( Attr_Man_t * p, int Id )
+{
+ assert( !p->fUseInt );
+ if ( Id >= p->nAttrs )
+ return NULL;
+ return p->pAttrs[Id];
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the attribute of the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Attr_ManWriteAttrInt( Attr_Man_t * p, int Id, int Attr )
+{
+ assert( p->fUseInt );
+ ((int *)p->pAttrs)[Id] = Attr;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the attribute of the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Attr_ManWriteAttrPtr( Attr_Man_t * p, int Id, void * pAttr )
+{
+ assert( !p->fUseInt );
+ assert( p->pManMem == NULL );
+ p->pAttrs[Id] = pAttr;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns or creates the pointer to the attribute of the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int * Attr_ManFetchSpotInt( Attr_Man_t * p, int Id )
+{
+ assert( p->fUseInt );
+ if ( Id >= p->nAttrs )
+ {
+ // save the old size
+ int i, nAttrsOld = p->nAttrs;
+ // get the new size
+ p->nAttrs = p->nAttrs? 2*p->nAttrs : 1024;
+ p->pAttrs = realloc( p->pAttrs, sizeof(int) * p->nAttrs );
+ // fill in the empty spots
+ for ( i = nAttrsOld; i < p->nAttrs; i++ )
+ ((int *)p->pAttrs)[Id] = 0;
+ }
+ return ((int *)p->pAttrs) + Id;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns or creates the pointer to the attribute of the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void ** Attr_ManFetchSpotPtr( Attr_Man_t * p, int Id )
+{
+ assert( !p->fUseInt );
+ if ( Id >= p->nAttrs )
+ {
+ // save the old size
+ int i, nAttrsOld = p->nAttrs;
+ // get the new size
+ p->nAttrs = p->nAttrs? 2*p->nAttrs : 1024;
+ p->pAttrs = realloc( p->pAttrs, sizeof(void *) * p->nAttrs );
+ // fill in the empty spots
+ for ( i = nAttrsOld; i < p->nAttrs; i++ )
+ p->pAttrs[Id] = NULL;
+ }
+ // if memory manager is available but entry is not created, create it
+ if ( p->pManMem && p->pAttrs[Id] != NULL )
+ {
+ p->pAttrs[Id] = Extra_MmFixedEntryFetch( p->pManMem );
+ memset( p->pAttrs[Id], 0, p->nAttrSize );
+ }
+ return p->pAttrs + Id;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns or creates the attribute of the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Attr_ManFetchAttrInt( Attr_Man_t * p, int Id )
+{
+ return *Attr_ManFetchSpotInt( p, Id );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns or creates the attribute of the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void * Attr_ManFetchAttrPtr( Attr_Man_t * p, int Id )
+{
+ return *Attr_ManFetchSpotPtr( p, Id );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets the attribute of the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Attr_ManSetAttrInt( Attr_Man_t * p, int Id, int Attr )
+{
+ *Attr_ManFetchSpotInt( p, Id ) = Attr;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets the attribute of the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Attr_ManSetAttrPtr( Attr_Man_t * p, int Id, void * pAttr )
+{
+ assert( p->pManMem == NULL );
+ *Attr_ManFetchSpotPtr( p, Id ) = pAttr;
+}
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/temp/ivy/ivy.h b/src/aig/ivy/ivy.h
index a8c8b289..91d4d767 100644
--- a/src/temp/ivy/ivy.h
+++ b/src/aig/ivy/ivy.h
@@ -139,10 +139,10 @@ struct Ivy_FraigParams_t_
int fDoSparse; // skip sparse functions
int nBTLimitNode; // conflict limit at a node
int nBTLimitMiter; // conflict limit at an output
- int nBTLimitGlobal; // conflict limit global
- int nInsLimitNode; // inspection limit at a node
- int nInsLimitMiter; // inspection limit at an output
- int nInsLimitGlobal; // inspection limit global
+// int nBTLimitGlobal; // conflict limit global
+// int nInsLimitNode; // inspection limit at a node
+// int nInsLimitMiter; // inspection limit at an output
+// int nInsLimitGlobal; // inspection limit global
};
diff --git a/src/temp/ivy/ivyBalance.c b/src/aig/ivy/ivyBalance.c
index 5627039a..5627039a 100644
--- a/src/temp/ivy/ivyBalance.c
+++ b/src/aig/ivy/ivyBalance.c
diff --git a/src/temp/ivy/ivyCanon.c b/src/aig/ivy/ivyCanon.c
index 5768b87e..5768b87e 100644
--- a/src/temp/ivy/ivyCanon.c
+++ b/src/aig/ivy/ivyCanon.c
diff --git a/src/temp/ivy/ivyCheck.c b/src/aig/ivy/ivyCheck.c
index 55448f19..55448f19 100644
--- a/src/temp/ivy/ivyCheck.c
+++ b/src/aig/ivy/ivyCheck.c
diff --git a/src/temp/ivy/ivyCut.c b/src/aig/ivy/ivyCut.c
index d918c96c..d918c96c 100644
--- a/src/temp/ivy/ivyCut.c
+++ b/src/aig/ivy/ivyCut.c
diff --git a/src/temp/ivy/ivyCutTrav.c b/src/aig/ivy/ivyCutTrav.c
index ea57c9f5..ea57c9f5 100644
--- a/src/temp/ivy/ivyCutTrav.c
+++ b/src/aig/ivy/ivyCutTrav.c
diff --git a/src/temp/ivy/ivyDfs.c b/src/aig/ivy/ivyDfs.c
index c27cba31..c27cba31 100644
--- a/src/temp/ivy/ivyDfs.c
+++ b/src/aig/ivy/ivyDfs.c
diff --git a/src/temp/ivy/ivyDsd.c b/src/aig/ivy/ivyDsd.c
index 3b8a2e68..3b8a2e68 100644
--- a/src/temp/ivy/ivyDsd.c
+++ b/src/aig/ivy/ivyDsd.c
diff --git a/src/temp/ivy/ivyFanout.c b/src/aig/ivy/ivyFanout.c
index 3930186a..3930186a 100644
--- a/src/temp/ivy/ivyFanout.c
+++ b/src/aig/ivy/ivyFanout.c
diff --git a/src/temp/ivy/ivyFastMap.c b/src/aig/ivy/ivyFastMap.c
index c4a043f2..c4a043f2 100644
--- a/src/temp/ivy/ivyFastMap.c
+++ b/src/aig/ivy/ivyFastMap.c
diff --git a/src/aig/ivy/ivyFpga.c b/src/aig/ivy/ivyFpga.c
new file mode 100644
index 00000000..122cc0e2
--- /dev/null
+++ b/src/aig/ivy/ivyFpga.c
@@ -0,0 +1,378 @@
+/**CFile****************************************************************
+
+ FileName [ivyFpga.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [And-Inverter Graph package.]
+
+ Synopsis [Prepares the AIG package to work as an FPGA mapper.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - May 11, 2006.]
+
+ Revision [$Id: ivyFpga.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "ivy.h"
+#include "attr.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Ivy_FpgaMan_t_ Ivy_FpgaMan_t;
+typedef struct Ivy_FpgaObj_t_ Ivy_FpgaObj_t;
+typedef struct Ivy_FpgaCut_t_ Ivy_FpgaCut_t;
+
+// manager
+struct Ivy_FpgaMan_t_
+{
+ Ivy_Man_t * pManIvy; // the AIG manager
+ Attr_Man_t * pManAttr; // the attribute manager
+ int nLutSize; // the LUT size
+ int nCutsMax; // the max number of cuts
+ int nEntrySize; // the size of the entry
+ int nEntryBase; // the size of the entry minus cut leaf arrays
+ int fVerbose; // the verbosity flag
+ // temporary cut storage
+ Ivy_FpgaCut_t * pCutStore; // the temporary cuts
+};
+
+// priority cut
+struct Ivy_FpgaCut_t_
+{
+ float Delay; // the delay of the cut
+ float AreaFlow; // the area flow of the cut
+ float Area; // the area of the cut
+ int nLeaves; // the number of leaves
+ int * pLeaves; // the array of fanins
+};
+
+// node extension
+struct Ivy_FpgaObj_t_
+{
+ unsigned Type : 4; // type
+ unsigned nCuts : 28; // the number of cuts
+ int Id; // integer ID
+ int nRefs; // the number of references
+ Ivy_FpgaObj_t * pFanin0; // the first fanin
+ Ivy_FpgaObj_t * pFanin1; // the second fanin
+ float Required; // required time of the onde
+ Ivy_FpgaCut_t * pCut; // the best cut
+ Ivy_FpgaCut_t Cuts[0]; // the cuts of the node
+};
+
+
+static Ivy_FpgaMan_t * Ivy_ManFpgaPrepare( Ivy_Man_t * p, int nLutSize, int nCutsMax, int fVerbose );
+static void Ivy_ManFpgaUndo( Ivy_FpgaMan_t * pFpga );
+static void Ivy_ObjFpgaCreate( Ivy_FpgaMan_t * pFpga, int ObjId );
+static void Ivy_ManFpgaDelay( Ivy_FpgaMan_t * pFpga );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Performs FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ivy_ManFpga( Ivy_Man_t * p, int nLutSize, int nCutsMax, int fVerbose )
+{
+ Ivy_FpgaMan_t * pFpga;
+ pFpga = Ivy_ManFpgaPrepare( p, nLutSize, nCutsMax, fVerbose );
+ Ivy_ManFpgaDelay( pFpga );
+ Ivy_ManFpgaUndo( pFpga );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prepares manager for FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Ivy_FpgaMan_t * Ivy_ManFpgaPrepare( Ivy_Man_t * p, int nLutSize, int nCutsMax, int fVerbose )
+{
+ Ivy_FpgaMan_t * pFpga;
+ Ivy_Obj_t * pObj;
+ int i;
+ pFpga = ALLOC( Ivy_FpgaMan_t, 1 );
+ memset( pFpga, 0, sizeof(Ivy_FpgaMan_t) );
+ // compute the size of the node
+ pFpga->pManIvy = p;
+ pFpga->nLutSize = nLutSize;
+ pFpga->nCutsMax = nCutsMax;
+ pFpga->fVerbose = fVerbose;
+ pFpga->nEntrySize = sizeof(Ivy_FpgaObj_t) + (nCutsMax + 1) * (sizeof(Ivy_FpgaCut_t) + sizeof(int) * nLutSize);
+ pFpga->nEntryBase = sizeof(Ivy_FpgaObj_t) + (nCutsMax + 1) * (sizeof(Ivy_FpgaCut_t));
+ pFpga->pManAttr = Attr_ManStartPtrMem( Ivy_ManObjIdMax(p) + 1, pFpga->nEntrySize );
+ if ( fVerbose )
+ printf( "Entry size = %d. Total memory = %5.2f Mb.\n", pFpga->nEntrySize,
+ 1.0 * pFpga->nEntrySize * (Ivy_ManObjIdMax(p) + 1) / (1<<20) );
+ // connect memory for cuts
+ Ivy_ManForEachObj( p, pObj, i )
+ Ivy_ObjFpgaCreate( pFpga, pObj->Id );
+ // create temporary cuts
+ pFpga->pCutStore = (Ivy_FpgaCut_t *)ALLOC( char, pFpga->nEntrySize * (nCutsMax + 1) * (nCutsMax + 1) );
+ memset( pFpga->pCutStore, 0, pFpga->nEntrySize * (nCutsMax + 1) * (nCutsMax + 1) );
+ {
+ int i, * pArrays;
+ pArrays = (int *)((char *)pFpga->pCutStore + sizeof(Ivy_FpgaCut_t) * (nCutsMax + 1) * (nCutsMax + 1));
+ for ( i = 0; i < (nCutsMax + 1) * (nCutsMax + 1); i++ )
+ pFpga->pCutStore[i].pLeaves = pArrays + i * pFpga->nLutSize;
+ }
+ return pFpga;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Quits the manager for FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ivy_ManFpgaUndo( Ivy_FpgaMan_t * pFpga )
+{
+ Attr_ManStop( pFpga->pManAttr );
+ free( pFpga );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Prepares the object for FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ivy_ObjFpgaCreate( Ivy_FpgaMan_t * pFpga, int ObjId )
+{
+ Ivy_FpgaObj_t * pObjFpga;
+ int i, * pArrays;
+ pObjFpga = Attr_ManReadAttrPtr( pFpga->pManAttr, ObjId );
+ pArrays = (int *)((char *)pObjFpga + pFpga->nEntryBase);
+ for ( i = 0; i <= pFpga->nCutsMax; i++ )
+ pObjFpga->Cuts[i].pLeaves = pArrays + i * pFpga->nLutSize;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Prepares the object for FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ivy_ObjFpgaMerge( Ivy_FpgaCut_t * pC0, Ivy_FpgaCut_t * pC1, Ivy_FpgaCut_t * pC, int nLimit )
+{
+ int i, k, c;
+ assert( pC0->nLeaves >= pC1->nLeaves );
+ // the case of the largest cut sizes
+ if ( pC0->nLeaves == nLimit && pC1->nLeaves == nLimit )
+ {
+ for ( i = 0; i < pC0->nLeaves; i++ )
+ if ( pC0->pLeaves[i] != pC1->pLeaves[i] )
+ return 0;
+ for ( i = 0; i < pC0->nLeaves; i++ )
+ pC->pLeaves[i] = pC0->pLeaves[i];
+ pC->nLeaves = pC0->nLeaves;
+ pC->Delay = 1 + IVY_MAX( pC0->Delay, pC1->Delay );
+ return 1;
+ }
+ // the case when one of the cuts is the largest
+ if ( pC0->nLeaves == nLimit )
+ {
+ for ( i = 0; i < pC1->nLeaves; i++ )
+ {
+ for ( k = pC0->nLeaves - 1; k >= 0; k-- )
+ if ( pC0->pLeaves[k] == pC1->pLeaves[i] )
+ break;
+ if ( k == -1 ) // did not find
+ return 0;
+ }
+ for ( i = 0; i < pC0->nLeaves; i++ )
+ pC->pLeaves[i] = pC0->pLeaves[i];
+ pC->nLeaves = pC0->nLeaves;
+ pC->Delay = 1 + IVY_MAX( pC0->Delay, pC1->Delay );
+ return 1;
+ }
+
+ // compare two cuts with different numbers
+ i = k = 0;
+ for ( c = 0; c < nLimit; c++ )
+ {
+ if ( k == pC1->nLeaves )
+ {
+ if ( i == pC0->nLeaves )
+ {
+ pC->nLeaves = c;
+ pC->Delay = 1 + IVY_MAX( pC0->Delay, pC1->Delay );
+ return 1;
+ }
+ pC->pLeaves[c] = pC0->pLeaves[i++];
+ continue;
+ }
+ if ( i == pC0->nLeaves )
+ {
+ if ( k == pC1->nLeaves )
+ {
+ pC->nLeaves = c;
+ pC->Delay = 1 + IVY_MAX( pC0->Delay, pC1->Delay );
+ return 1;
+ }
+ pC->pLeaves[c] = pC1->pLeaves[k++];
+ continue;
+ }
+ if ( pC0->pLeaves[i] < pC1->pLeaves[k] )
+ {
+ pC->pLeaves[c] = pC0->pLeaves[i++];
+ continue;
+ }
+ if ( pC0->pLeaves[i] > pC1->pLeaves[k] )
+ {
+ pC->pLeaves[c] = pC1->pLeaves[k++];
+ continue;
+ }
+ pC->pLeaves[c] = pC0->pLeaves[i++];
+ k++;
+ }
+ if ( i < pC0->nLeaves || k < pC1->nLeaves )
+ return 0;
+ pC->nLeaves = c;
+ pC->Delay = 1 + IVY_MAX( pC0->Delay, pC1->Delay );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prepares the object for FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ivy_FpgaCutCompare( Ivy_FpgaCut_t * pC0, Ivy_FpgaCut_t * pC1 )
+{
+ if ( pC0->Delay < pC1->Delay )
+ return -1;
+ if ( pC0->Delay > pC1->Delay )
+ return 1;
+ if ( pC0->nLeaves < pC1->nLeaves )
+ return -1;
+ if ( pC0->nLeaves > pC1->nLeaves )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prepares the object for FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ivy_ObjFpgaDelay( Ivy_FpgaMan_t * pFpga, int ObjId, int Fan0Id, int Fan1Id )
+{
+ Ivy_FpgaObj_t * pObjFpga, * pObjFpga0, * pObjFpga1;
+ int nCuts, i, k;
+ pObjFpga = Attr_ManReadAttrPtr( pFpga->pManAttr, ObjId );
+ pObjFpga0 = Attr_ManReadAttrPtr( pFpga->pManAttr, Fan0Id );
+ pObjFpga1 = Attr_ManReadAttrPtr( pFpga->pManAttr, Fan1Id );
+ // create cross-product of the cuts
+ nCuts = 0;
+ for ( i = 0; pObjFpga0->Cuts[i].nLeaves > 0 && i < pFpga->nCutsMax; i++ )
+ for ( k = 0; pObjFpga1->Cuts[k].nLeaves > 0 && k < pFpga->nCutsMax; k++ )
+ if ( Ivy_ObjFpgaMerge( pObjFpga0->Cuts + i, pObjFpga1->Cuts + k, pFpga->pCutStore + nCuts, pFpga->nLutSize ) )
+ nCuts++;
+ // sort the cuts
+ qsort( pFpga->pCutStore, nCuts, sizeof(Ivy_FpgaCut_t), (int (*)(const void *, const void *))Ivy_FpgaCutCompare );
+ // take the first
+ pObjFpga->Cuts[0].nLeaves = 1;
+ pObjFpga->Cuts[0].pLeaves[0] = ObjId;
+ pObjFpga->Cuts[0].Delay = pFpga->pCutStore[0].Delay;
+ pObjFpga->Cuts[1] = pFpga->pCutStore[0];
+}
+
+/**Function*************************************************************
+
+ Synopsis [Maps the nodes for delay.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ivy_ManFpgaDelay( Ivy_FpgaMan_t * pFpga )
+{
+ Ivy_FpgaObj_t * pObjFpga;
+ Ivy_Obj_t * pObj;
+ int i, DelayBest;
+ int clk = clock();
+ // set arrival times and trivial cuts at const 1 and PIs
+ pObjFpga = Attr_ManReadAttrPtr( pFpga->pManAttr, 0 );
+ pObjFpga->Cuts[0].nLeaves = 1;
+ Ivy_ManForEachPi( pFpga->pManIvy, pObj, i )
+ {
+ pObjFpga = Attr_ManReadAttrPtr( pFpga->pManAttr, pObj->Id );
+ pObjFpga->Cuts[0].nLeaves = 1;
+ pObjFpga->Cuts[0].pLeaves[0] = pObj->Id;
+ }
+ // map the internal nodes
+ Ivy_ManForEachNode( pFpga->pManIvy, pObj, i )
+ {
+ Ivy_ObjFpgaDelay( pFpga, pObj->Id, Ivy_ObjFaninId0(pObj), Ivy_ObjFaninId1(pObj) );
+ }
+ // get the best arrival time of the POs
+ DelayBest = 0;
+ Ivy_ManForEachPo( pFpga->pManIvy, pObj, i )
+ {
+ pObjFpga = Attr_ManReadAttrPtr( pFpga->pManAttr, Ivy_ObjFanin0(pObj)->Id );
+ if ( DelayBest < (int)pObjFpga->Cuts[1].Delay )
+ DelayBest = (int)pObjFpga->Cuts[1].Delay;
+ }
+ printf( "Best delay = %d. ", DelayBest );
+ PRT( "Time", clock() - clk );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/temp/ivy/ivyFraig.c b/src/aig/ivy/ivyFraig.c
index 209ff8e7..269ca257 100644
--- a/src/temp/ivy/ivyFraig.c
+++ b/src/aig/ivy/ivyFraig.c
@@ -18,9 +18,9 @@
***********************************************************************/
-#include "ivy.h"
#include "satSolver.h"
#include "extra.h"
+#include "ivy.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -50,6 +50,9 @@ struct Ivy_FraigMan_t_
{
// general info
Ivy_FraigParams_t * pParams; // various parameters
+ // temporary backtrack limits because "sint64" cannot be defined in Ivy_FraigParams_t ...
+ sint64 nBTLimitGlobal; // global limit on the number of backtracks
+ sint64 nInsLimitGlobal;// global limit on the number of clause inspects
// AIG manager
Ivy_Man_t * pManAig; // the starting AIG manager
Ivy_Man_t * pManFraig; // the final AIG manager
@@ -178,7 +181,7 @@ static inline unsigned Ivy_ObjRandomSim() { return (ran
static Ivy_FraigMan_t * Ivy_FraigStart( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams );
static Ivy_FraigMan_t * Ivy_FraigStartSimple( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams );
-static Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, sint64 * pnSatConfs, sint64 * pnSatInspects );
+static Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, sint64 nBTLimitGlobal, sint64 nInsLimitGlobal, sint64 * pnSatConfs, sint64 * pnSatInspects );
static void Ivy_FraigPrint( Ivy_FraigMan_t * p );
static void Ivy_FraigStop( Ivy_FraigMan_t * p );
static void Ivy_FraigSimulate( Ivy_FraigMan_t * p );
@@ -194,6 +197,11 @@ static void Ivy_FraigMiterProve( Ivy_FraigMan_t * p );
static void Ivy_FraigMiterPrint( Ivy_Man_t * pNtk, char * pString, int clk, int fVerbose );
static int * Ivy_FraigCreateModel( Ivy_FraigMan_t * p );
+static int Ivy_FraigNodesAreEquivBdd( Ivy_Obj_t * pObj1, Ivy_Obj_t * pObj2 );
+
+static sint64 s_nBTLimitGlobal = 0;
+static sint64 s_nInsLimitGlobal = 0;
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -224,10 +232,8 @@ void Ivy_FraigParamsDefault( Ivy_FraigParams_t * pParams )
pParams->nBTLimitNode = 100; // conflict limit at a node
pParams->nBTLimitMiter = 500000; // conflict limit at an output
- pParams->nBTLimitGlobal = 0; // conflict limit global
- pParams->nInsLimitNode = 0; // inspection limit at a node
- pParams->nInsLimitMiter = 0; // inspection limit at an output
- pParams->nInsLimitGlobal = 0; // inspection limit global
+// pParams->nBTLimitGlobal = 0; // conflict limit global
+// pParams->nInsLimitGlobal = 0; // inspection limit global
}
/**Function*************************************************************
@@ -247,7 +253,7 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars )
Ivy_FraigParams_t Params, * pIvyParams = &Params;
Ivy_Man_t * pManAig, * pManTemp;
int RetValue, nIter, Counter, clk, timeStart = clock();
- sint64 nSatConfs, nSatInspects, nInspectLimit;
+ sint64 nSatConfs, nSatInspects;
// start the network and parameters
pManAig = *ppManAig;
@@ -322,10 +328,9 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars )
if ( pParams->fUseFraiging )
{
clk = clock();
- nInspectLimit = pParams->nTotalInspectLimit? pParams->nTotalInspectLimit - pParams->nTotalInspectsMade : 0;
pIvyParams->nBTLimitNode = (int)(pParams->nFraigingLimitStart * pow(pParams->nFraigingLimitMulti,nIter));
pIvyParams->nBTLimitMiter = (int)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)) / Ivy_ManPoNum(pManAig);
- pManAig = Ivy_FraigPerform_int( pManTemp = pManAig, pIvyParams, &nSatConfs, &nSatInspects ); Ivy_ManStop( pManTemp );
+ pManAig = Ivy_FraigPerform_int( pManTemp = pManAig, pIvyParams, pParams->nTotalBacktrackLimit, pParams->nTotalInspectLimit, &nSatConfs, &nSatInspects ); Ivy_ManStop( pManTemp );
RetValue = Ivy_FraigMiterStatus( pManAig );
Ivy_FraigMiterPrint( pManAig, "Fraiging ", clk, pParams->fVerbose );
}
@@ -353,9 +358,14 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars )
fflush( stdout );
}
clk = clock();
- nInspectLimit = pParams->nTotalInspectLimit? pParams->nTotalInspectLimit - pParams->nTotalInspectsMade : 0;
pIvyParams->nBTLimitMiter = pParams->nMiteringLimitLast / Ivy_ManPoNum(pManAig);
+ if ( pParams->nTotalBacktrackLimit )
+ s_nBTLimitGlobal = pParams->nTotalBacktrackLimit - pParams->nTotalBacktracksMade;
+ if ( pParams->nTotalInspectLimit )
+ s_nInsLimitGlobal = pParams->nTotalInspectLimit - pParams->nTotalInspectsMade;
pManAig = Ivy_FraigMiter( pManTemp = pManAig, pIvyParams ); Ivy_ManStop( pManTemp );
+ s_nBTLimitGlobal = 0;
+ s_nInsLimitGlobal = 0;
RetValue = Ivy_FraigMiterStatus( pManAig );
Ivy_FraigMiterPrint( pManAig, "SAT solving", clk, pParams->fVerbose );
}
@@ -381,7 +391,7 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars )
SeeAlso []
***********************************************************************/
-Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, sint64 * pnSatConfs, sint64 * pnSatInspects )
+Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, sint64 nBTLimitGlobal, sint64 nInsLimitGlobal, sint64 * pnSatConfs, sint64 * pnSatInspects )
{
Ivy_FraigMan_t * p;
Ivy_Man_t * pManAigNew;
@@ -391,6 +401,10 @@ Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pPara
clk = clock();
assert( Ivy_ManLatchNum(pManAig) == 0 );
p = Ivy_FraigStart( pManAig, pParams );
+ // set global limits
+ p->nBTLimitGlobal = nBTLimitGlobal;
+ p->nInsLimitGlobal = nInsLimitGlobal;
+
Ivy_FraigSimulate( p );
Ivy_FraigSweep( p );
pManAigNew = p->pManFraig;
@@ -452,6 +466,9 @@ Ivy_Man_t * Ivy_FraigMiter( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams )
clk = clock();
assert( Ivy_ManLatchNum(pManAig) == 0 );
p = Ivy_FraigStartSimple( pManAig, pParams );
+ // set global limits
+ p->nBTLimitGlobal = s_nBTLimitGlobal;
+ p->nInsLimitGlobal = s_nInsLimitGlobal;
// duplicate internal nodes
Ivy_ManForEachNode( p->pManAig, pObj, i )
pObj->pEquiv = Ivy_And( p->pManFraig, Ivy_ObjChild0Equiv(pObj), Ivy_ObjChild1Equiv(pObj) );
@@ -2003,7 +2020,7 @@ void Ivy_FraigPrintActivity( Ivy_FraigMan_t * p )
***********************************************************************/
int Ivy_FraigNodesAreEquiv( Ivy_FraigMan_t * p, Ivy_Obj_t * pOld, Ivy_Obj_t * pNew )
{
- int pLits[4], RetValue, RetValue1, nBTLimit, clk;
+ int pLits[4], RetValue, RetValue1, nBTLimit, clk, clk2 = clock();
// make sure the nodes are not complemented
assert( !Ivy_IsComplement(pNew) );
@@ -2046,8 +2063,8 @@ clk = clock();
pLits[1] = toLitCond( Ivy_ObjSatNum(pNew), pOld->fPhase == pNew->fPhase );
//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
- nBTLimit, p->pParams->nInsLimitNode,
- p->pParams->nBTLimitGlobal, p->pParams->nInsLimitGlobal );
+ (sint64)nBTLimit, (sint64)0,
+ p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
{
@@ -2090,8 +2107,8 @@ clk = clock();
pLits[0] = toLitCond( Ivy_ObjSatNum(pOld), 1 );
pLits[1] = toLitCond( Ivy_ObjSatNum(pNew), pOld->fPhase ^ pNew->fPhase );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
- nBTLimit, p->pParams->nInsLimitNode,
- p->pParams->nBTLimitGlobal, p->pParams->nInsLimitGlobal );
+ (sint64)nBTLimit, (sint64)0,
+ p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
{
@@ -2118,7 +2135,19 @@ p->timeSatFail += clock() - clk;
p->nSatFailsReal++;
return -1;
}
-
+/*
+ // check BDD proof
+ {
+ int RetVal;
+ PRT( "Sat", clock() - clk2 );
+ clk2 = clock();
+ RetVal = Ivy_FraigNodesAreEquivBdd( pOld, pNew );
+// printf( "%d ", RetVal );
+ assert( RetVal );
+ PRT( "Bdd", clock() - clk2 );
+ printf( "\n" );
+ }
+*/
// return SAT proof
p->nSatProof++;
return 1;
@@ -2162,8 +2191,8 @@ int Ivy_FraigNodeIsConst( Ivy_FraigMan_t * p, Ivy_Obj_t * pNew )
clk = clock();
pLits[0] = toLitCond( Ivy_ObjSatNum(pNew), pNew->fPhase );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 1,
- p->pParams->nBTLimitMiter, p->pParams->nInsLimitMiter,
- p->pParams->nBTLimitGlobal, p->pParams->nInsLimitGlobal );
+ (sint64)p->pParams->nBTLimitMiter, (sint64)0,
+ p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
{
@@ -2513,6 +2542,161 @@ p->timeTrav += clock() - clk;
return 1;
}
+
+
+#include "cuddInt.h"
+
+/**Function*************************************************************
+
+ Synopsis [Checks equivalence using BDDs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Ivy_FraigNodesAreEquivBdd_int( DdManager * dd, DdNode * bFunc, Vec_Ptr_t * vFront, int Level )
+{
+ DdNode ** pFuncs;
+ DdNode * bFuncNew;
+ Vec_Ptr_t * vTemp;
+ Ivy_Obj_t * pObj, * pFanin;
+ int i, NewSize;
+ // create new frontier
+ vTemp = Vec_PtrAlloc( 100 );
+ Vec_PtrForEachEntry( vFront, pObj, i )
+ {
+ if ( (int)pObj->Level != Level )
+ {
+ pObj->fMarkB = 1;
+ pObj->TravId = Vec_PtrSize(vTemp);
+ Vec_PtrPush( vTemp, pObj );
+ continue;
+ }
+
+ pFanin = Ivy_ObjFanin0(pObj);
+ if ( pFanin->fMarkB == 0 )
+ {
+ pFanin->fMarkB = 1;
+ pFanin->TravId = Vec_PtrSize(vTemp);
+ Vec_PtrPush( vTemp, pFanin );
+ }
+
+ pFanin = Ivy_ObjFanin1(pObj);
+ if ( pFanin->fMarkB == 0 )
+ {
+ pFanin->fMarkB = 1;
+ pFanin->TravId = Vec_PtrSize(vTemp);
+ Vec_PtrPush( vTemp, pFanin );
+ }
+ }
+ // collect the permutation
+ NewSize = IVY_MAX(dd->size, Vec_PtrSize(vTemp));
+ pFuncs = ALLOC( DdNode *, NewSize );
+ Vec_PtrForEachEntry( vFront, pObj, i )
+ {
+ if ( (int)pObj->Level != Level )
+ pFuncs[i] = Cudd_bddIthVar( dd, pObj->TravId );
+ else
+ pFuncs[i] = Cudd_bddAnd( dd,
+ Cudd_NotCond( Cudd_bddIthVar(dd, Ivy_ObjFanin0(pObj)->TravId), Ivy_ObjFaninC0(pObj) ),
+ Cudd_NotCond( Cudd_bddIthVar(dd, Ivy_ObjFanin1(pObj)->TravId), Ivy_ObjFaninC1(pObj) ) );
+ Cudd_Ref( pFuncs[i] );
+ }
+ // add the remaining vars
+ assert( NewSize == dd->size );
+ for ( i = Vec_PtrSize(vFront); i < dd->size; i++ )
+ {
+ pFuncs[i] = Cudd_bddIthVar( dd, i );
+ Cudd_Ref( pFuncs[i] );
+ }
+
+ // create new
+ bFuncNew = Cudd_bddVectorCompose( dd, bFunc, pFuncs ); Cudd_Ref( bFuncNew );
+ // clean trav Id
+ Vec_PtrForEachEntry( vTemp, pObj, i )
+ {
+ pObj->fMarkB = 0;
+ pObj->TravId = 0;
+ }
+ // deref
+ for ( i = 0; i < dd->size; i++ )
+ Cudd_RecursiveDeref( dd, pFuncs[i] );
+ free( pFuncs );
+
+ free( vFront->pArray );
+ *vFront = *vTemp;
+
+ vTemp->nCap = vTemp->nSize = 0;
+ vTemp->pArray = NULL;
+ Vec_PtrFree( vTemp );
+
+ Cudd_Deref( bFuncNew );
+ return bFuncNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Checks equivalence using BDDs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ivy_FraigNodesAreEquivBdd( Ivy_Obj_t * pObj1, Ivy_Obj_t * pObj2 )
+{
+ static DdManager * dd = NULL;
+ DdNode * bFunc, * bTemp;
+ Vec_Ptr_t * vFront;
+ Ivy_Obj_t * pObj;
+ int i, RetValue, Iter, Level;
+ // start the manager
+ if ( dd == NULL )
+ dd = Cudd_Init( 50, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
+ // create front
+ vFront = Vec_PtrAlloc( 100 );
+ Vec_PtrPush( vFront, pObj1 );
+ Vec_PtrPush( vFront, pObj2 );
+ // get the function
+ bFunc = Cudd_bddXor( dd, Cudd_bddIthVar(dd,0), Cudd_bddIthVar(dd,1) ); Cudd_Ref( bFunc );
+ bFunc = Cudd_NotCond( bFunc, pObj1->fPhase != pObj2->fPhase );
+ // try running BDDs
+ for ( Iter = 0; ; Iter++ )
+ {
+ // find max level
+ Level = 0;
+ Vec_PtrForEachEntry( vFront, pObj, i )
+ if ( Level < (int)pObj->Level )
+ Level = (int)pObj->Level;
+ if ( Level == 0 )
+ break;
+ bFunc = Ivy_FraigNodesAreEquivBdd_int( dd, bTemp = bFunc, vFront, Level ); Cudd_Ref( bFunc );
+ Cudd_RecursiveDeref( dd, bTemp );
+ if ( bFunc == Cudd_ReadLogicZero(dd) ) // proved
+ {printf( "%d", Iter ); break;}
+ if ( Cudd_DagSize(bFunc) > 1000 )
+ {printf( "b" ); break;}
+ if ( dd->size > 120 )
+ {printf( "s" ); break;}
+ if ( Iter > 50 )
+ {printf( "i" ); break;}
+ }
+ if ( bFunc == Cudd_ReadLogicZero(dd) ) // unsat
+ RetValue = 1;
+ else if ( Level == 0 ) // sat
+ RetValue = 0;
+ else
+ RetValue = -1; // spaceout/timeout
+ Cudd_RecursiveDeref( dd, bFunc );
+ Vec_PtrFree( vFront );
+ return RetValue;
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/temp/ivy/ivyHaig.c b/src/aig/ivy/ivyHaig.c
index 87021600..87021600 100644
--- a/src/temp/ivy/ivyHaig.c
+++ b/src/aig/ivy/ivyHaig.c
diff --git a/src/temp/ivy/ivyIsop.c b/src/aig/ivy/ivyIsop.c
index 1887eb6a..1887eb6a 100644
--- a/src/temp/ivy/ivyIsop.c
+++ b/src/aig/ivy/ivyIsop.c
diff --git a/src/temp/ivy/ivyMan.c b/src/aig/ivy/ivyMan.c
index ac58cb61..2d99c4f1 100644
--- a/src/temp/ivy/ivyMan.c
+++ b/src/aig/ivy/ivyMan.c
@@ -411,7 +411,7 @@ int Ivy_ManLatchIsSelfFeed( Ivy_Obj_t * pLatch )
int Ivy_ManPropagateBuffers( Ivy_Man_t * p, int fUpdateLevel )
{
Ivy_Obj_t * pNode;
- int LimitFactor = 5;
+ int LimitFactor = 10;
int NodeBeg = Ivy_ManNodeNum(p);
int nSteps;
for ( nSteps = 0; Vec_PtrSize(p->vBufs) > 0; nSteps++ )
@@ -435,7 +435,7 @@ int Ivy_ManPropagateBuffers( Ivy_Man_t * p, int fUpdateLevel )
break;
}
}
- printf( "Number of steps = %d. Nodes beg = %d. Nodes end = %d.\n", nSteps, NodeBeg, Ivy_ManNodeNum(p) );
+// printf( "Number of steps = %d. Nodes beg = %d. Nodes end = %d.\n", nSteps, NodeBeg, Ivy_ManNodeNum(p) );
return nSteps;
}
diff --git a/src/temp/ivy/ivyMem.c b/src/aig/ivy/ivyMem.c
index 09c73c49..09c73c49 100644
--- a/src/temp/ivy/ivyMem.c
+++ b/src/aig/ivy/ivyMem.c
diff --git a/src/temp/ivy/ivyMulti.c b/src/aig/ivy/ivyMulti.c
index a7970156..a7970156 100644
--- a/src/temp/ivy/ivyMulti.c
+++ b/src/aig/ivy/ivyMulti.c
diff --git a/src/temp/ivy/ivyMulti8.c b/src/aig/ivy/ivyMulti8.c
index 059d1500..059d1500 100644
--- a/src/temp/ivy/ivyMulti8.c
+++ b/src/aig/ivy/ivyMulti8.c
diff --git a/src/temp/ivy/ivyObj.c b/src/aig/ivy/ivyObj.c
index 59dda19c..59dda19c 100644
--- a/src/temp/ivy/ivyObj.c
+++ b/src/aig/ivy/ivyObj.c
diff --git a/src/temp/ivy/ivyOper.c b/src/aig/ivy/ivyOper.c
index 8115ce4f..8115ce4f 100644
--- a/src/temp/ivy/ivyOper.c
+++ b/src/aig/ivy/ivyOper.c
diff --git a/src/temp/ivy/ivyResyn.c b/src/aig/ivy/ivyResyn.c
index f42d7464..f42d7464 100644
--- a/src/temp/ivy/ivyResyn.c
+++ b/src/aig/ivy/ivyResyn.c
diff --git a/src/temp/ivy/ivyRwr.c b/src/aig/ivy/ivyRwr.c
index 3f8720ba..3f8720ba 100644
--- a/src/temp/ivy/ivyRwr.c
+++ b/src/aig/ivy/ivyRwr.c
diff --git a/src/temp/ivy/ivyRwrAlg.c b/src/aig/ivy/ivyRwrAlg.c
index fc48deb0..fc48deb0 100644
--- a/src/temp/ivy/ivyRwrAlg.c
+++ b/src/aig/ivy/ivyRwrAlg.c
diff --git a/src/temp/ivy/ivySeq.c b/src/aig/ivy/ivySeq.c
index c1f3da2b..263a4398 100644
--- a/src/temp/ivy/ivySeq.c
+++ b/src/aig/ivy/ivySeq.c
@@ -53,7 +53,7 @@ static inline int Ivy_CutHashValue( int NodeId ) { return 1 << (NodeId % 31); }
***********************************************************************/
int Ivy_ManRewriteSeq( Ivy_Man_t * p, int fUseZeroCost, int fVerbose )
-{
+{
Rwt_Man_t * pManRwt;
Ivy_Obj_t * pNode;
int i, nNodes, nGain;
diff --git a/src/temp/ivy/ivyShow.c b/src/aig/ivy/ivyShow.c
index cd726e43..cd726e43 100644
--- a/src/temp/ivy/ivyShow.c
+++ b/src/aig/ivy/ivyShow.c
diff --git a/src/temp/ivy/ivyTable.c b/src/aig/ivy/ivyTable.c
index 2ac0ae49..2ac0ae49 100644
--- a/src/temp/ivy/ivyTable.c
+++ b/src/aig/ivy/ivyTable.c
diff --git a/src/temp/ivy/ivyUtil.c b/src/aig/ivy/ivyUtil.c
index 0e44c216..0e44c216 100644
--- a/src/temp/ivy/ivyUtil.c
+++ b/src/aig/ivy/ivyUtil.c
diff --git a/src/temp/ivy/ivy_.c b/src/aig/ivy/ivy_.c
index 65689689..65689689 100644
--- a/src/temp/ivy/ivy_.c
+++ b/src/aig/ivy/ivy_.c
diff --git a/src/aig/ivy/module.make b/src/aig/ivy/module.make
new file mode 100644
index 00000000..c1f7d1b8
--- /dev/null
+++ b/src/aig/ivy/module.make
@@ -0,0 +1,23 @@
+SRC += src/aig/ivy/ivyBalance.c \
+ src/aig/ivy/ivyCanon.c \
+ src/aig/ivy/ivyCheck.c \
+ src/aig/ivy/ivyCut.c \
+ src/aig/ivy/ivyCutTrav.c \
+ src/aig/ivy/ivyDfs.c \
+ src/aig/ivy/ivyDsd.c \
+ src/aig/ivy/ivyFanout.c \
+ src/aig/ivy/ivyFastMap.c \
+ src/aig/ivy/ivyFraig.c \
+ src/aig/ivy/ivyHaig.c \
+ src/aig/ivy/ivyIsop.c \
+ src/aig/ivy/ivyMan.c \
+ src/aig/ivy/ivyMem.c \
+ src/aig/ivy/ivyMulti.c \
+ src/aig/ivy/ivyObj.c \
+ src/aig/ivy/ivyOper.c \
+ src/aig/ivy/ivyResyn.c \
+ src/aig/ivy/ivyRwr.c \
+ src/aig/ivy/ivySeq.c \
+ src/aig/ivy/ivyShow.c \
+ src/aig/ivy/ivyTable.c \
+ src/aig/ivy/ivyUtil.c
diff --git a/src/temp/mem/mem.c b/src/aig/mem/mem.c
index 15199755..15199755 100644
--- a/src/temp/mem/mem.c
+++ b/src/aig/mem/mem.c
diff --git a/src/temp/mem/mem.h b/src/aig/mem/mem.h
index 611c968d..611c968d 100644
--- a/src/temp/mem/mem.h
+++ b/src/aig/mem/mem.h
diff --git a/src/aig/mem/module.make b/src/aig/mem/module.make
new file mode 100644
index 00000000..ae6fcbe4
--- /dev/null
+++ b/src/aig/mem/module.make
@@ -0,0 +1 @@
+SRC += src/aig/mem/mem.c
diff --git a/src/aig/rwt/module.make b/src/aig/rwt/module.make
new file mode 100644
index 00000000..2852f2ba
--- /dev/null
+++ b/src/aig/rwt/module.make
@@ -0,0 +1,3 @@
+SRC += src/hop/rwt/rwtDec.c \
+ src/hop/rwt/rwtMan.c \
+ src/hop/rwt/rwtUtil.c
diff --git a/src/temp/rwt/rwt.h b/src/aig/rwt/rwt.h
index 42a57ad6..42a57ad6 100644
--- a/src/temp/rwt/rwt.h
+++ b/src/aig/rwt/rwt.h
diff --git a/src/temp/rwt/rwtDec.c b/src/aig/rwt/rwtDec.c
index 98019629..98019629 100644
--- a/src/temp/rwt/rwtDec.c
+++ b/src/aig/rwt/rwtDec.c
diff --git a/src/temp/rwt/rwtMan.c b/src/aig/rwt/rwtMan.c
index 869043a4..869043a4 100644
--- a/src/temp/rwt/rwtMan.c
+++ b/src/aig/rwt/rwtMan.c
diff --git a/src/temp/rwt/rwtUtil.c b/src/aig/rwt/rwtUtil.c
index af3e1893..af3e1893 100644
--- a/src/temp/rwt/rwtUtil.c
+++ b/src/aig/rwt/rwtUtil.c
diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h
index f44a8022..c4c42f99 100644
--- a/src/base/abc/abc.h
+++ b/src/base/abc/abc.h
@@ -36,7 +36,7 @@ extern "C" {
#include <time.h>
#include "cuddInt.h"
-#include "aig.h"
+#include "hop.h"
#include "extra.h"
#include "solver.h"
#include "vec.h"
@@ -178,7 +178,6 @@ struct Abc_Ntk_t_
Vec_Ptr_t * vPios; // the array of PIOs
Vec_Ptr_t * vAsserts; // the array of assertions
Vec_Ptr_t * vBoxes; // the array of boxes
- Vec_Ptr_t * vCutSet; // the array of cutset nodes (used in the sequential AIG)
// the number of living objects
int nObjs; // the number of live objs
int nObjCounts[ABC_OBJ_NUMBER]; // the number of objects by type
@@ -196,8 +195,6 @@ struct Abc_Ntk_t_
Extra_MmStep_t * pMmStep; // memory manager for arrays
void * pManFunc; // functionality manager (AIG manager, BDD manager, or memory manager for SOPs)
// Abc_Lib_t * pVerLib; // for structural verilog designs
- void * pManGlob; // the global BDD manager
- Vec_Ptr_t * vFuncsGlob; // the global BDDs of CO functions
Abc_ManTime_t * pManTime; // the timing manager (for mapped networks) stores arrival/required times for all nodes
void * pManCut; // the cut manager (for AIGs) stores information about the cuts computed for the nodes
int LevelMax; // maximum number of levels
@@ -206,10 +203,8 @@ struct Abc_Ntk_t_
int * pModel; // counter-example (for miters)
Abc_Ntk_t * pExdc; // the EXDC network (if given)
void * pData; // misc
- // skew values (for latches)
- float maxMeanCycle; // maximum mean cycle time
- float globalSkew; // global skewing
- Vec_Flt_t * vSkews; // endpoint skewing
+ // node attributes
+ Vec_Ptr_t * vAttrs; // managers of various node attributes (node functionality, global BDDs, etc)
};
struct Abc_Lib_t_
@@ -282,7 +277,6 @@ static inline int Abc_NtkCiNum( Abc_Ntk_t * pNtk ) { return Ve
static inline int Abc_NtkCoNum( Abc_Ntk_t * pNtk ) { return Vec_PtrSize(pNtk->vCos); }
static inline int Abc_NtkAssertNum( Abc_Ntk_t * pNtk ) { return Vec_PtrSize(pNtk->vAsserts); }
static inline int Abc_NtkBoxNum( Abc_Ntk_t * pNtk ) { return Vec_PtrSize(pNtk->vBoxes); }
-static inline int Abc_NtkCutSetNodeNum( Abc_Ntk_t * pNtk ) { return Vec_PtrSize(pNtk->vCutSet); }
static inline int Abc_NtkBiNum( Abc_Ntk_t * pNtk ) { return pNtk->nObjCounts[ABC_OBJ_BI]; }
static inline int Abc_NtkBoNum( Abc_Ntk_t * pNtk ) { return pNtk->nObjCounts[ABC_OBJ_BO]; }
static inline int Abc_NtkNetNum( Abc_Ntk_t * pNtk ) { return pNtk->nObjCounts[ABC_OBJ_NET]; }
@@ -315,7 +309,6 @@ static inline Abc_Obj_t * Abc_NtkCi( Abc_Ntk_t * pNtk, int i ) { return (A
static inline Abc_Obj_t * Abc_NtkCo( Abc_Ntk_t * pNtk, int i ) { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vCos, i ); }
static inline Abc_Obj_t * Abc_NtkAssert( Abc_Ntk_t * pNtk, int i ) { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vAsserts, i );}
static inline Abc_Obj_t * Abc_NtkBox( Abc_Ntk_t * pNtk, int i ) { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vBoxes, i ); }
-static inline Abc_Obj_t * Abc_NtkCutSetNode( Abc_Ntk_t * pNtk, int i){ return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vCutSet, i ); }
// reading data members of the object
static inline unsigned Abc_ObjType( Abc_Obj_t * pObj ) { return pObj->Type; }
@@ -409,9 +402,12 @@ static inline bool Abc_LatchIsInit1( Abc_Obj_t * pLatch ) { assert(Ab
static inline bool Abc_LatchIsInitDc( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_DC; }
static inline int Abc_LatchInit( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return (int)pLatch->pData; }
-// skewing latches
-static inline void Abc_NtkSetLatSkew ( Abc_Ntk_t * pNtk, int lat, float skew ) { Vec_FltWriteEntry( pNtk->vSkews, lat, skew ); }
-static inline float Abc_NtkGetLatSkew ( Abc_Ntk_t * pNtk, int lat ) { if (lat >= Vec_FltSize( pNtk->vSkews )) return 0; else return Vec_FltEntry( pNtk->vSkews, lat ); }
+// global BDDs of the nodes
+static inline void * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk ) { return (void *)Vec_PtrEntry(pNtk->vAttrs, VEC_ATTR_GLOBAL_BDD); }
+static inline DdManager * Abc_NtkGlobalBddMan( Abc_Ntk_t * pNtk ) { return (DdManager *)Vec_AttMan( Abc_NtkGlobalBdds(pNtk) ); }
+static inline DdNode ** Abc_NtkGlobalBddArray( Abc_Ntk_t * pNtk ) { return (DdNode **)Vec_AttArray( Abc_NtkGlobalBdds(pNtk) ); }
+static inline DdNode * Abc_ObjGlobalBdd( Abc_Obj_t * pObj ) { return (DdNode *)Vec_AttEntry( Abc_NtkGlobalBdds(pObj->pNtk), pObj->Id ); }
+static inline void Abc_ObjSetGlobalBdd( Abc_Obj_t * pObj, DdNode * bF ) { Vec_AttWriteEntry( Abc_NtkGlobalBdds(pObj->pNtk), pObj->Id, bF ); }
// outputs the runtime in seconds
#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))
@@ -436,9 +432,6 @@ static inline float Abc_NtkGetLatSkew ( Abc_Ntk_t * pNtk, int lat )
#define Abc_AigForEachAnd( pNtk, pNode, i ) \
for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ ) \
if ( (pNode) == NULL || !Abc_AigNodeIsAnd(pNode) ) {} else
-#define Abc_SeqForEachCutsetNode( pNtk, pNode, i ) \
- for ( i = 0; (i < Abc_NtkCutSetNodeNum(pNtk)) && (((pNode) = Abc_NtkCutSetNode(pNtk, i)), 1); i++ )\
- if ( (pNode) == NULL ) {} else
// various boxes
#define Abc_NtkForEachBox( pNtk, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize((pNtk)->vBoxes)) && (((pObj) = Abc_NtkBox(pNtk, i)), 1); i++ )
@@ -489,7 +482,7 @@ extern Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtk );
extern void Abc_AigFree( Abc_Aig_t * pMan );
extern int Abc_AigCleanup( Abc_Aig_t * pMan );
extern bool Abc_AigCheck( Abc_Aig_t * pMan );
-extern int Abc_AigGetLevelNum( Abc_Ntk_t * pNtk );
+extern int Abc_AigLevel( Abc_Ntk_t * pNtk );
extern Abc_Obj_t * Abc_AigConst1( Abc_Ntk_t * pNtk );
extern Abc_Obj_t * Abc_AigAnd( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 );
extern Abc_Obj_t * Abc_AigAndLookup( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 );
@@ -536,7 +529,8 @@ extern Vec_Ptr_t * Abc_NtkSupport( Abc_Ntk_t * pNtk );
extern Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNodes );
extern Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk, int fCollectAll, int fCollectCos );
extern Vec_Vec_t * Abc_DfsLevelized( Abc_Obj_t * pNode, bool fTfi );
-extern int Abc_NtkGetLevelNum( Abc_Ntk_t * pNtk );
+extern int Abc_NtkLevel( Abc_Ntk_t * pNtk );
+extern int Abc_NtkLevelReverse( Abc_Ntk_t * pNtk );
extern bool Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk );
extern Vec_Ptr_t * Abc_AigGetLevelizedOrder( Abc_Ntk_t * pNtk, int fCollectCis );
/*=== abcFanio.c ==========================================================*/
@@ -652,8 +646,8 @@ extern Abc_Ntk_t * Abc_NtkAigToLogicSopBench( Abc_Ntk_t * pNtk );
/*=== abcNtbdd.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkDeriveFromBdd( DdManager * dd, DdNode * bFunc, char * pNamePo, Vec_Ptr_t * vNamesPi );
extern Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk );
-extern DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int fBddSizeMax, int fLatchOnly, int fReorder, int fVerbose );
-extern void Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk );
+extern DdManager * Abc_NtkBuildGlobalBdds( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fVerbose );
+extern DdManager * Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk, int fFreeMan );
/*=== abcNtk.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan );
extern Abc_Ntk_t * Abc_NtkStartFrom( Abc_Ntk_t * pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func );
@@ -759,7 +753,7 @@ extern Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels );
/*=== abcSweep.c ==========================================================*/
extern int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose );
extern int Abc_NtkCleanup( Abc_Ntk_t * pNtk, int fVerbose );
-extern int Abc_NtkCleanupSeq( Abc_Ntk_t * pNtk, int fVerbose );
+extern int Abc_NtkCleanupSeq( Abc_Ntk_t * pNtk, int fLatchSweep, int fAutoSweep, int fVerbose );
/*=== abcTiming.c ==========================================================*/
extern Abc_Time_t * Abc_NodeReadArrival( Abc_Obj_t * pNode );
extern Abc_Time_t * Abc_NodeReadRequired( Abc_Obj_t * pNode );
@@ -782,6 +776,7 @@ extern void Abc_NodeSetReverseLevel( Abc_Obj_t * pObj, int LevelR
extern int Abc_NodeReadReverseLevel( Abc_Obj_t * pObj );
extern int Abc_NodeReadRequiredLevel( Abc_Obj_t * pObj );
/*=== abcUtil.c ==========================================================*/
+extern void * Abc_NtkAttrFree( Abc_Ntk_t * pNtk, int Attr, int fFreeMan );
extern void Abc_NtkIncrementTravId( Abc_Ntk_t * pNtk );
extern void Abc_NtkOrderCisCos( Abc_Ntk_t * pNtk );
extern int Abc_NtkGetCubeNum( Abc_Ntk_t * pNtk );
diff --git a/src/base/abc/abcAig.c b/src/base/abc/abcAig.c
index ce430cf4..46070a11 100644
--- a/src/base/abc/abcAig.c
+++ b/src/base/abc/abcAig.c
@@ -269,7 +269,7 @@ bool Abc_AigCheck( Abc_Aig_t * pMan )
SeeAlso []
***********************************************************************/
-int Abc_AigGetLevelNum( Abc_Ntk_t * pNtk )
+int Abc_AigLevel( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pNode;
int i, LevelsMax;
diff --git a/src/base/abc/abcCheck.c b/src/base/abc/abcCheck.c
index eb5a8400..087d5150 100644
--- a/src/base/abc/abcCheck.c
+++ b/src/base/abc/abcCheck.c
@@ -580,12 +580,33 @@ bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch )
fprintf( stdout, "NodeCheck: Latch \"%s\" has wrong number (%d) of fanins.\n", Abc_ObjName(pLatch), Abc_ObjFaninNum(pLatch) );
Value = 0;
}
- // make sure the latch has only one fanin
+ // make sure the latch has only one fanout
if ( Abc_ObjFanoutNum(pLatch) != 1 )
{
fprintf( stdout, "NodeCheck: Latch \"%s\" has wrong number (%d) of fanouts.\n", Abc_ObjName(pLatch), Abc_ObjFanoutNum(pLatch) );
Value = 0;
}
+ // make sure the latch input has only one fanin
+ if ( Abc_ObjFaninNum(Abc_ObjFanin0(pLatch)) != 1 )
+ {
+ fprintf( stdout, "NodeCheck: Input of latch \"%s\" has wrong number (%d) of fanins.\n",
+ Abc_ObjName(Abc_ObjFanin0(pLatch)), Abc_ObjFaninNum(Abc_ObjFanin0(pLatch)) );
+ Value = 0;
+ }
+ // make sure the latch input has only one fanout
+ if ( Abc_ObjFanoutNum(Abc_ObjFanin0(pLatch)) != 1 )
+ {
+ fprintf( stdout, "NodeCheck: Input of latch \"%s\" has wrong number (%d) of fanouts.\n",
+ Abc_ObjName(Abc_ObjFanin0(pLatch)), Abc_ObjFanoutNum(Abc_ObjFanin0(pLatch)) );
+ Value = 0;
+ }
+ // make sure the latch output has only one fanin
+ if ( Abc_ObjFaninNum(Abc_ObjFanout0(pLatch)) != 1 )
+ {
+ fprintf( stdout, "NodeCheck: Output of latch \"%s\" has wrong number (%d) of fanins.\n",
+ Abc_ObjName(Abc_ObjFanout0(pLatch)), Abc_ObjFaninNum(Abc_ObjFanout0(pLatch)) );
+ Value = 0;
+ }
return Value;
}
diff --git a/src/base/abc/abcDfs.c b/src/base/abc/abcDfs.c
index a8edfbeb..5a0bf252 100644
--- a/src/base/abc/abcDfs.c
+++ b/src/base/abc/abcDfs.c
@@ -24,12 +24,12 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
+static void Abc_NtkDfs_iter( Vec_Ptr_t * vStack, Abc_Obj_t * pRoot, Vec_Ptr_t * vNodes );
static void Abc_NtkDfs_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes );
static void Abc_AigDfs_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes );
static void Abc_NtkDfsReverse_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes );
static void Abc_NtkNodeSupport_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes );
static void Abc_DfsLevelizedTfo_rec( Abc_Obj_t * pNode, Vec_Vec_t * vLevels );
-static int Abc_NtkGetLevelNum_rec( Abc_Obj_t * pNode );
static bool Abc_NtkIsAcyclic_rec( Abc_Obj_t * pNode );
////////////////////////////////////////////////////////////////////////
@@ -137,6 +137,101 @@ void Abc_NtkDfs_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes )
Vec_PtrPush( vNodes, pNode );
}
+/**Function*************************************************************
+
+ Synopsis [Returns the DFS ordered array of logic nodes.]
+
+ Description [Collects only the internal nodes, leaving CIs and CO.
+ However it marks with the current TravId both CIs and COs.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Abc_NtkDfsIter( Abc_Ntk_t * pNtk, int fCollectAll )
+{
+ Vec_Ptr_t * vNodes, * vStack;
+ Abc_Obj_t * pObj;
+ int i;
+ // set the traversal ID
+ Abc_NtkIncrementTravId( pNtk );
+ // start the array of nodes
+ vNodes = Vec_PtrAlloc( 1000 );
+ vStack = Vec_PtrAlloc( 1000 );
+ Abc_NtkForEachCo( pNtk, pObj, i )
+ {
+ Abc_NodeSetTravIdCurrent( pObj );
+ Abc_NtkDfs_iter( vStack, Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
+ }
+ // collect dangling nodes if asked to
+ if ( fCollectAll )
+ {
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ if ( !Abc_NodeIsTravIdCurrent(pObj) )
+ Abc_NtkDfs_iter( vStack, pObj, vNodes );
+ }
+ Vec_PtrFree( vStack );
+ return vNodes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Iterative version of the DFS procedure.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkDfs_iter( Vec_Ptr_t * vStack, Abc_Obj_t * pRoot, Vec_Ptr_t * vNodes )
+{
+ Abc_Obj_t * pNode, * pFanin;
+ int iFanin;
+ // if this node is already visited, skip
+ if ( Abc_NodeIsTravIdCurrent( pRoot ) )
+ return;
+ // mark the node as visited
+ Abc_NodeSetTravIdCurrent( pRoot );
+ // skip the CI
+ if ( Abc_ObjIsCi(pRoot) || (Abc_NtkIsStrash(pRoot->pNtk) && Abc_AigNodeIsConst(pRoot)) )
+ return;
+ // add the CI
+ Vec_PtrClear( vStack );
+ Vec_PtrPush( vStack, pRoot );
+ Vec_PtrPush( vStack, (void *)0 );
+ while ( Vec_PtrSize(vStack) > 0 )
+ {
+ // get the node and its fanin
+ iFanin = (int)Vec_PtrPop(vStack);
+ pNode = Vec_PtrPop(vStack);
+ assert( !Abc_ObjIsNet(pNode) );
+ // add it to the array of nodes if we finished
+ if ( iFanin == Abc_ObjFaninNum(pNode) )
+ {
+ Vec_PtrPush( vNodes, pNode );
+ continue;
+ }
+ // explore the next fanin
+ Vec_PtrPush( vStack, pNode );
+ Vec_PtrPush( vStack, (void *)(iFanin+1) );
+ // get the fanin
+ pFanin = Abc_ObjFanin0Ntk( Abc_ObjFanin(pNode,iFanin) );
+ // if this node is already visited, skip
+ if ( Abc_NodeIsTravIdCurrent( pFanin ) )
+ continue;
+ // mark the node as visited
+ Abc_NodeSetTravIdCurrent( pFanin );
+ // skip the CI
+ if ( Abc_ObjIsCi(pFanin) || (Abc_NtkIsStrash(pFanin->pNtk) && Abc_AigNodeIsConst(pFanin)) )
+ continue;
+ Vec_PtrPush( vStack, pFanin );
+ Vec_PtrPush( vStack, (void *)0 );
+ }
+}
+
/**Function*************************************************************
@@ -593,7 +688,7 @@ void Abc_DfsLevelizedTfo_rec( Abc_Obj_t * pNode, Vec_Vec_t * vLevels )
/**Function*************************************************************
- Synopsis [Computes the number of logic levels not counting PIs/POs.]
+ Synopsis [Recursively counts the number of logic levels of one node.]
Description []
@@ -602,24 +697,31 @@ void Abc_DfsLevelizedTfo_rec( Abc_Obj_t * pNode, Vec_Vec_t * vLevels )
SeeAlso []
***********************************************************************/
-int Abc_NtkGetLevelNum( Abc_Ntk_t * pNtk )
+int Abc_NtkLevel_rec( Abc_Obj_t * pNode )
{
- Abc_Obj_t * pNode;
- int i, LevelsMax;
- // set the traversal ID for this traversal
- Abc_NtkIncrementTravId( pNtk );
- // set the CI levels to zero
- Abc_NtkForEachCi( pNtk, pNode, i )
- pNode->Level = 0;
- // perform the traversal
- LevelsMax = 0;
- Abc_NtkForEachNode( pNtk, pNode, i )
+ Abc_Obj_t * pNext;
+ int i, Level;
+ assert( !Abc_ObjIsNet(pNode) );
+ // skip the PI
+ if ( Abc_ObjIsCi(pNode) )
+ return pNode->Level;
+ assert( Abc_ObjIsNode( pNode ) );
+ // if this node is already visited, return
+ if ( Abc_NodeIsTravIdCurrent( pNode ) )
+ return pNode->Level;
+ // mark the node as visited
+ Abc_NodeSetTravIdCurrent( pNode );
+ // visit the transitive fanin
+ pNode->Level = 0;
+ Abc_ObjForEachFanin( pNode, pNext, i )
{
- Abc_NtkGetLevelNum_rec( pNode );
- if ( LevelsMax < (int)pNode->Level )
- LevelsMax = (int)pNode->Level;
+ Level = Abc_NtkLevel_rec( Abc_ObjFanin0Ntk(pNext) );
+ if ( pNode->Level < (unsigned)Level )
+ pNode->Level = Level;
}
- return LevelsMax;
+ if ( Abc_ObjFaninNum(pNode) > 0 )
+ pNode->Level++;
+ return pNode->Level;
}
/**Function*************************************************************
@@ -633,18 +735,14 @@ int Abc_NtkGetLevelNum( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-int Abc_NtkGetLevelNum_rec( Abc_Obj_t * pNode )
+int Abc_NtkLevelReverse_rec( Abc_Obj_t * pNode )
{
- Abc_Obj_t * pFanin;
+ Abc_Obj_t * pNext;
int i, Level;
assert( !Abc_ObjIsNet(pNode) );
- if ( pNode->Id == 27278 )
- {
- int x = 0;
- }
// skip the PI
- if ( Abc_ObjIsCi(pNode) )
- return 0;
+ if ( Abc_ObjIsCo(pNode) )
+ return pNode->Level;
assert( Abc_ObjIsNode( pNode ) );
// if this node is already visited, return
if ( Abc_NodeIsTravIdCurrent( pNode ) )
@@ -653,17 +751,76 @@ int Abc_NtkGetLevelNum_rec( Abc_Obj_t * pNode )
Abc_NodeSetTravIdCurrent( pNode );
// visit the transitive fanin
pNode->Level = 0;
- Abc_ObjForEachFanin( pNode, pFanin, i )
+ Abc_ObjForEachFanout( pNode, pNext, i )
{
- Level = Abc_NtkGetLevelNum_rec( Abc_ObjFanin0Ntk(pFanin) );
+ Level = Abc_NtkLevelReverse_rec( Abc_ObjFanout0Ntk(pNext) );
if ( pNode->Level < (unsigned)Level )
pNode->Level = Level;
}
- if ( Abc_ObjFaninNum(pNode) > 0 )
- pNode->Level++;
+ pNode->Level++;
return pNode->Level;
}
+/**Function*************************************************************
+
+ Synopsis [Computes the number of logic levels not counting PIs/POs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkLevel( Abc_Ntk_t * pNtk )
+{
+ Abc_Obj_t * pNode;
+ int i, LevelsMax;
+ // set the CI levels to zero
+ Abc_NtkForEachCi( pNtk, pNode, i )
+ pNode->Level = 0;
+ // perform the traversal
+ LevelsMax = 0;
+ Abc_NtkIncrementTravId( pNtk );
+ Abc_NtkForEachNode( pNtk, pNode, i )
+ {
+ Abc_NtkLevel_rec( pNode );
+ if ( LevelsMax < (int)pNode->Level )
+ LevelsMax = (int)pNode->Level;
+ }
+ return LevelsMax;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the number of logic levels not counting PIs/POs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkLevelReverse( Abc_Ntk_t * pNtk )
+{
+ Abc_Obj_t * pNode;
+ int i, LevelsMax;
+ // set the CO levels to zero
+ Abc_NtkForEachCo( pNtk, pNode, i )
+ pNode->Level = 0;
+ // perform the traversal
+ LevelsMax = 0;
+ Abc_NtkIncrementTravId( pNtk );
+ Abc_NtkForEachNode( pNtk, pNode, i )
+ {
+ Abc_NtkLevelReverse_rec( pNode );
+ if ( LevelsMax < (int)pNode->Level )
+ LevelsMax = (int)pNode->Level;
+ }
+ return LevelsMax;
+}
+
/**Function*************************************************************
diff --git a/src/base/abc/abcFanio.c b/src/base/abc/abcFanio.c
index a988062f..e7ee3405 100644
--- a/src/base/abc/abcFanio.c
+++ b/src/base/abc/abcFanio.c
@@ -50,6 +50,10 @@ void Abc_ObjAddFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin )
Vec_IntPushMem( pObj->pNtk->pMmStep, &pFaninR->vFanouts, pObj->Id );
if ( Abc_ObjIsComplement(pFanin) )
Abc_ObjSetFaninC( pObj, Abc_ObjFaninNum(pObj)-1 );
+ if ( Abc_ObjIsNet(pObj) && Abc_ObjFaninNum(pObj) > 1 )
+ {
+ int x = 0;
+ }
}
diff --git a/src/base/abc/abcFunc.c b/src/base/abc/abcFunc.c
index 23afcd25..e2389fc6 100644
--- a/src/base/abc/abcFunc.c
+++ b/src/base/abc/abcFunc.c
@@ -29,8 +29,8 @@
#define ABC_MUX_CUBES 100000
static int Abc_ConvertZddToSop( DdManager * dd, DdNode * zCover, char * pSop, int nFanins, Vec_Str_t * vCube, int fPhase );
-static DdNode * Abc_ConvertAigToBdd( DdManager * dd, Aig_Obj_t * pRoot);
-static Aig_Obj_t * Abc_ConvertSopToAig( Aig_Man_t * pMan, char * pSop );
+static DdNode * Abc_ConvertAigToBdd( DdManager * dd, Hop_Obj_t * pRoot);
+static Hop_Obj_t * Abc_ConvertSopToAig( Hop_Man_t * pMan, char * pSop );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -533,13 +533,13 @@ int Abc_CountZddCubes( DdManager * dd, DdNode * zCover )
int Abc_NtkSopToAig( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pNode;
- Aig_Man_t * pMan;
+ Hop_Man_t * pMan;
int i;
assert( Abc_NtkIsSopLogic(pNtk) || Abc_NtkIsSopNetlist(pNtk) );
// start the functionality manager
- pMan = Aig_ManStart();
+ pMan = Hop_ManStart();
// convert each node from SOP to BDD
Abc_NtkForEachNode( pNtk, pNode, i )
@@ -572,32 +572,32 @@ int Abc_NtkSopToAig( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Abc_ConvertSopToAigInternal( Aig_Man_t * pMan, char * pSop )
+Hop_Obj_t * Abc_ConvertSopToAigInternal( Hop_Man_t * pMan, char * pSop )
{
- Aig_Obj_t * pAnd, * pSum;
+ Hop_Obj_t * pAnd, * pSum;
int i, Value, nFanins;
char * pCube;
// get the number of variables
nFanins = Abc_SopGetVarNum(pSop);
// go through the cubes of the node's SOP
- pSum = Aig_ManConst0(pMan);
+ pSum = Hop_ManConst0(pMan);
Abc_SopForEachCube( pSop, nFanins, pCube )
{
// create the AND of literals
- pAnd = Aig_ManConst1(pMan);
+ pAnd = Hop_ManConst1(pMan);
Abc_CubeForEachVar( pCube, Value, i )
{
if ( Value == '1' )
- pAnd = Aig_And( pMan, pAnd, Aig_IthVar(pMan,i) );
+ pAnd = Hop_And( pMan, pAnd, Hop_IthVar(pMan,i) );
else if ( Value == '0' )
- pAnd = Aig_And( pMan, pAnd, Aig_Not(Aig_IthVar(pMan,i)) );
+ pAnd = Hop_And( pMan, pAnd, Hop_Not(Hop_IthVar(pMan,i)) );
}
// add to the sum of cubes
- pSum = Aig_Or( pMan, pSum, pAnd );
+ pSum = Hop_Or( pMan, pSum, pAnd );
}
// decide whether to complement the result
if ( Abc_SopIsComplement(pSop) )
- pSum = Aig_Not(pSum);
+ pSum = Hop_Not(pSum);
return pSum;
}
@@ -612,16 +612,16 @@ Aig_Obj_t * Abc_ConvertSopToAigInternal( Aig_Man_t * pMan, char * pSop )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Abc_ConvertSopToAig( Aig_Man_t * pMan, char * pSop )
+Hop_Obj_t * Abc_ConvertSopToAig( Hop_Man_t * pMan, char * pSop )
{
- extern Aig_Obj_t * Dec_GraphFactorSop( Aig_Man_t * pMan, char * pSop );
+ extern Hop_Obj_t * Dec_GraphFactorSop( Hop_Man_t * pMan, char * pSop );
int fUseFactor = 1;
// consider the constant node
if ( Abc_SopGetVarNum(pSop) == 0 )
- return Aig_NotCond( Aig_ManConst1(pMan), Abc_SopIsConst0(pSop) );
+ return Hop_NotCond( Hop_ManConst1(pMan), Abc_SopIsConst0(pSop) );
// consider the special case of EXOR function
if ( Abc_SopIsExorType(pSop) )
- return Aig_NotCond( Aig_CreateExor(pMan, Abc_SopGetVarNum(pSop)), Abc_SopIsComplement(pSop) );
+ return Hop_NotCond( Hop_CreateExor(pMan, Abc_SopGetVarNum(pSop)), Abc_SopIsComplement(pSop) );
// decide when to use factoring
if ( fUseFactor && Abc_SopGetVarNum(pSop) > 2 && Abc_SopGetCubeNum(pSop) > 1 )
return Dec_GraphFactorSop( pMan, pSop );
@@ -642,7 +642,7 @@ Aig_Obj_t * Abc_ConvertSopToAig( Aig_Man_t * pMan, char * pSop )
int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pNode;
- Aig_Man_t * pMan;
+ Hop_Man_t * pMan;
DdManager * dd;
int nFaninsMax, i;
@@ -657,9 +657,9 @@ int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk )
// set the mapping of AIG nodes into the BDD nodes
pMan = pNtk->pManFunc;
- assert( Aig_ManPiNum(pMan) >= nFaninsMax );
+ assert( Hop_ManPiNum(pMan) >= nFaninsMax );
for ( i = 0; i < nFaninsMax; i++ )
- Aig_ManPi(pMan, i)->pData = Cudd_bddIthVar(dd, i);
+ Hop_ManPi(pMan, i)->pData = Cudd_bddIthVar(dd, i);
// convert each node from SOP to BDD
Abc_NtkForEachNode( pNtk, pNode, i )
@@ -674,7 +674,7 @@ int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk )
Cudd_Ref( pNode->pData );
}
- Aig_ManStop( pNtk->pManFunc );
+ Hop_ManStop( pNtk->pManFunc );
pNtk->pManFunc = dd;
// update the network type
@@ -693,17 +693,17 @@ int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-void Abc_ConvertAigToBdd_rec1( DdManager * dd, Aig_Obj_t * pObj )
+void Abc_ConvertAigToBdd_rec1( DdManager * dd, Hop_Obj_t * pObj )
{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
return;
- Abc_ConvertAigToBdd_rec1( dd, Aig_ObjFanin0(pObj) );
- Abc_ConvertAigToBdd_rec1( dd, Aig_ObjFanin1(pObj) );
- pObj->pData = Cudd_bddAnd( dd, (DdNode *)Aig_ObjChild0Copy(pObj), (DdNode *)Aig_ObjChild1Copy(pObj) );
+ Abc_ConvertAigToBdd_rec1( dd, Hop_ObjFanin0(pObj) );
+ Abc_ConvertAigToBdd_rec1( dd, Hop_ObjFanin1(pObj) );
+ pObj->pData = Cudd_bddAnd( dd, (DdNode *)Hop_ObjChild0Copy(pObj), (DdNode *)Hop_ObjChild1Copy(pObj) );
Cudd_Ref( pObj->pData );
- assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjSetMarkA( pObj );
+ assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjSetMarkA( pObj );
}
/**Function*************************************************************
@@ -717,17 +717,17 @@ void Abc_ConvertAigToBdd_rec1( DdManager * dd, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-void Abc_ConvertAigToBdd_rec2( DdManager * dd, Aig_Obj_t * pObj )
+void Abc_ConvertAigToBdd_rec2( DdManager * dd, Hop_Obj_t * pObj )
{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || !Aig_ObjIsMarkA(pObj) )
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) || !Hop_ObjIsMarkA(pObj) )
return;
- Abc_ConvertAigToBdd_rec2( dd, Aig_ObjFanin0(pObj) );
- Abc_ConvertAigToBdd_rec2( dd, Aig_ObjFanin1(pObj) );
+ Abc_ConvertAigToBdd_rec2( dd, Hop_ObjFanin0(pObj) );
+ Abc_ConvertAigToBdd_rec2( dd, Hop_ObjFanin1(pObj) );
Cudd_RecursiveDeref( dd, pObj->pData );
pObj->pData = NULL;
- assert( Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjClearMarkA( pObj );
+ assert( Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjClearMarkA( pObj );
}
/**Function*************************************************************
@@ -741,18 +741,18 @@ void Abc_ConvertAigToBdd_rec2( DdManager * dd, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-DdNode * Abc_ConvertAigToBdd( DdManager * dd, Aig_Obj_t * pRoot )
+DdNode * Abc_ConvertAigToBdd( DdManager * dd, Hop_Obj_t * pRoot )
{
DdNode * bFunc;
// check the case of a constant
- if ( Aig_ObjIsConst1( Aig_Regular(pRoot) ) )
- return Cudd_NotCond( Cudd_ReadOne(dd), Aig_IsComplement(pRoot) );
+ if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
+ return Cudd_NotCond( Cudd_ReadOne(dd), Hop_IsComplement(pRoot) );
// construct BDD
- Abc_ConvertAigToBdd_rec1( dd, Aig_Regular(pRoot) );
+ Abc_ConvertAigToBdd_rec1( dd, Hop_Regular(pRoot) );
// hold on to the result
- bFunc = Cudd_NotCond( Aig_Regular(pRoot)->pData, Aig_IsComplement(pRoot) ); Cudd_Ref( bFunc );
+ bFunc = Cudd_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) ); Cudd_Ref( bFunc );
// dereference BDD
- Abc_ConvertAigToBdd_rec2( dd, Aig_Regular(pRoot) );
+ Abc_ConvertAigToBdd_rec2( dd, Hop_Regular(pRoot) );
// return the result
Cudd_Deref( bFunc );
return bFunc;
diff --git a/src/base/abc/abcLatch.c b/src/base/abc/abcLatch.c
index e475fd2a..cf3ddaba 100644
--- a/src/base/abc/abcLatch.c
+++ b/src/base/abc/abcLatch.c
@@ -117,11 +117,11 @@ int Abc_NtkRemoveSelfFeedLatches( Abc_Ntk_t * pNtk )
{
if ( Abc_NtkLatchIsSelfFeed( pLatch ) )
{
- if ( Abc_NtkIsStrash(pNtk) || Abc_NtkIsSeq(pNtk) )
+ if ( Abc_NtkIsStrash(pNtk) )
pConst1 = Abc_AigConst1(pNtk);
else
pConst1 = Abc_NtkCreateNodeConst1(pNtk);
- Abc_ObjPatchFanin( pLatch, Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pConst1 );
+ Abc_ObjPatchFanin( Abc_ObjFanin0(pLatch), Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pConst1 );
Counter++;
}
}
diff --git a/src/base/abc/abcLib.c b/src/base/abc/abcLib.c
index 218df6ef..0036e687 100644
--- a/src/base/abc/abcLib.c
+++ b/src/base/abc/abcLib.c
@@ -47,7 +47,7 @@ Abc_Lib_t * Abc_LibCreate( char * pName )
p->pName = Extra_UtilStrsav( pName );
p->tModules = st_init_table( strcmp, st_strhash );
p->vModules = Vec_PtrAlloc( 100 );
- p->pManFunc = Aig_ManStart();
+ p->pManFunc = Hop_ManStart();
p->pLibrary = NULL;
return p;
}
@@ -70,7 +70,7 @@ void Abc_LibFree( Abc_Lib_t * pLib )
if ( pLib->pName )
free( pLib->pName );
if ( pLib->pManFunc )
- Aig_ManStop( pLib->pManFunc );
+ Hop_ManStop( pLib->pManFunc );
if ( pLib->tModules )
st_free_table( pLib->tModules );
if ( pLib->vModules )
diff --git a/src/base/abc/abcNetlist.c b/src/base/abc/abcNetlist.c
index 5ea9b369..1ce10209 100644
--- a/src/base/abc/abcNetlist.c
+++ b/src/base/abc/abcNetlist.c
@@ -251,15 +251,6 @@ Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk, int fDirect )
pNtkNew = Abc_NtkLogicSopToNetlist( pNtkTemp );
Abc_NtkDelete( pNtkTemp );
}
- else if ( Abc_NtkIsSeq(pNtk) )
- {
- assert( 0 );
-/*
- pNtkTemp = Abc_NtkSeqToLogicSop(pNtk);
- pNtkNew = Abc_NtkLogicSopToNetlist( pNtkTemp );
- Abc_NtkDelete( pNtkTemp );
-*/
- }
else if ( Abc_NtkIsBddLogic(pNtk) )
{
if ( !Abc_NtkBddToSop(pNtk, fDirect) )
@@ -328,13 +319,22 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk )
Abc_NtkCleanup( pNtk, 0 );
assert( Abc_NtkIsLogic(pNtk) );
- assert( Abc_NtkLogicHasSimpleCos(pNtk) );
+// assert( Abc_NtkLogicHasSimpleCos(pNtk) );
+ if ( !Abc_NtkLogicHasSimpleCos(pNtk) )
+ {
+ printf( "Abc_NtkLogicSopToNetlist() warning: The network is converted to have simple COs.\n" );
+ Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
+ }
+
if ( Abc_NtkIsBddLogic(pNtk) )
{
if ( !Abc_NtkBddToSop(pNtk,0) )
return NULL;
}
+// Abc_NtkForEachCo(pNtk, pObj, i)
+// Abc_ObjPrint( stdout, Abc_ObjFanin0(pObj) );
+
// start the netlist by creating PI/PO/Latch objects
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_NETLIST, pNtk->ntkFunc );
// create the CI nets and remember them in the new CI nodes
@@ -358,7 +358,7 @@ Abc_Ntk_t * Abc_NtkLogicSopToNetlist( Abc_Ntk_t * pNtk )
continue;
}
assert( Abc_ObjIsNode(pDriver) );
- // if the CO drive has no net, create it
+ // if the CO driver has no net, create it
if ( pDriver->pCopy->pCopy == NULL )
{
// create the CO net and connect it to CO
diff --git a/src/base/abc/abcNtk.c b/src/base/abc/abcNtk.c
index a3ce5145..f0642ffa 100644
--- a/src/base/abc/abcNtk.c
+++ b/src/base/abc/abcNtk.c
@@ -58,9 +58,7 @@ Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan
pNtk->vPos = Vec_PtrAlloc( 100 );
pNtk->vCis = Vec_PtrAlloc( 100 );
pNtk->vCos = Vec_PtrAlloc( 100 );
- pNtk->vCutSet = Vec_PtrAlloc( 100 );
pNtk->vBoxes = Vec_PtrAlloc( 100 );
- pNtk->vSkews = Vec_FltAlloc( 100 );
// start the memory managers
pNtk->pMmObj = fUseMemMan? Extra_MmFixedStart( sizeof(Abc_Obj_t) ) : NULL;
pNtk->pMmStep = fUseMemMan? Extra_MmStepStart( ABC_NUM_STEPS ) : NULL;
@@ -76,13 +74,15 @@ Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan
else if ( Abc_NtkHasBdd(pNtk) )
pNtk->pManFunc = Cudd_Init( 20, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
else if ( Abc_NtkHasAig(pNtk) )
- pNtk->pManFunc = Aig_ManStart();
+ pNtk->pManFunc = Hop_ManStart();
else if ( Abc_NtkHasMapping(pNtk) )
pNtk->pManFunc = Abc_FrameReadLibGen();
else if ( !Abc_NtkHasBlackbox(pNtk) )
assert( 0 );
// name manager
pNtk->pManName = Nm_ManCreate( 200 );
+ // attribute manager
+ pNtk->vAttrs = Vec_PtrStart( VEC_ATTR_TOTAL_NUM );
return pNtk;
}
@@ -301,40 +301,6 @@ Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk )
printf( "Warning: Structural hashing during duplication reduced %d nodes (this is a minor bug).\n",
Abc_NtkNodeNum(pNtk) - Abc_NtkNodeNum(pNtkNew) );
}
-/*
- else if ( Abc_NtkIsSeq(pNtk) )
- {
- // start the storage for initial states
- Seq_Resize( pNtkNew->pManFunc, Abc_NtkObjNumMax(pNtk) );
- // copy the nodes
- Abc_NtkForEachObj( pNtk, pObj, i )
- if ( pObj->pCopy == NULL )
- {
- Abc_NtkDupObj(pNtkNew, pObj, 0);
- pObj->pCopy->Level = pObj->Level;
- pObj->pCopy->fPhase = pObj->fPhase;
- }
- // connect the nodes
- Abc_NtkForEachObj( pNtk, pObj, i )
- {
- Abc_ObjForEachFanin( pObj, pFanin, k )
- {
- Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
- if ( Abc_ObjFaninC(pObj, k) )
- Abc_ObjSetFaninC( pObj->pCopy, k );
- if ( Seq_ObjFaninL(pObj, k) )
- Seq_NodeDupLats( pObj->pCopy, pObj, k );
- }
- }
- // relink the choice nodes
- Abc_AigForEachAnd( pNtk, pObj, i )
- if ( pObj->pData )
- pObj->pCopy->pData = ((Abc_Obj_t *)pObj->pData)->pCopy;
- // copy the cutset
- Abc_SeqForEachCutsetNode( pNtk, pObj, i )
- Vec_PtrPush( pNtkNew->vCutSet, pObj->pCopy );
- }
-*/
else
{
// duplicate the nets and nodes (CIs/COs/latches already dupped)
@@ -795,6 +761,7 @@ Abc_Ntk_t * Abc_NtkCreateWithNode( char * pSop )
void Abc_NtkDelete( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj;
+ void * pAttrMan;
int TotalMemory, i;
int LargePiece = (4 << ABC_NUM_STEPS);
if ( pNtk == NULL )
@@ -845,9 +812,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
Vec_PtrFree( pNtk->vCos );
Vec_PtrFree( pNtk->vAsserts );
Vec_PtrFree( pNtk->vObjs );
- Vec_PtrFree( pNtk->vCutSet );
Vec_PtrFree( pNtk->vBoxes );
- Vec_FltFree( pNtk->vSkews );
if ( pNtk->vLevelsR ) Vec_IntFree( pNtk->vLevelsR );
if ( pNtk->pModel ) free( pNtk->pModel );
TotalMemory = 0;
@@ -874,7 +839,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
else if ( Abc_NtkHasBdd(pNtk) )
Extra_StopManager( pNtk->pManFunc );
else if ( Abc_NtkHasAig(pNtk) )
- { if ( pNtk->pManFunc ) Aig_ManStop( pNtk->pManFunc ); }
+ { if ( pNtk->pManFunc ) Hop_ManStop( pNtk->pManFunc ); }
else if ( Abc_NtkHasMapping(pNtk) )
pNtk->pManFunc = NULL;
else if ( !Abc_NtkHasBlackbox(pNtk) )
@@ -891,6 +856,11 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
}
if ( pNtk->pBlackBoxes )
Vec_IntFree( pNtk->pBlackBoxes );
+ // free node attributes
+ Vec_PtrForEachEntry( pNtk->vAttrs, pAttrMan, i )
+ if ( pAttrMan )
+ Vec_AttFree( pAttrMan, 1 );
+ Vec_PtrFree( pNtk->vAttrs );
free( pNtk );
}
diff --git a/src/base/abc/abcObj.c b/src/base/abc/abcObj.c
index dc3ff73c..d0e1dc37 100644
--- a/src/base/abc/abcObj.c
+++ b/src/base/abc/abcObj.c
@@ -299,7 +299,7 @@ void Abc_NtkDeleteAll_rec( Abc_Obj_t * pObj )
Abc_NodeCollectFanins( pObj, vNodes );
Abc_NtkDeleteObj( pObj );
Vec_PtrForEachEntry( vNodes, pObj, i )
- if ( Abc_ObjFanoutNum(pObj) == 0 )
+ if ( !Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
Abc_NtkDeleteAll_rec( pObj );
Vec_PtrFree( vNodes );
}
@@ -342,7 +342,7 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName
else if ( Abc_NtkHasBdd(pNtkNew) )
pObjNew->pData = Cudd_bddTransfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData), Cudd_Ref(pObjNew->pData);
else if ( Abc_NtkHasAig(pNtkNew) )
- pObjNew->pData = Aig_Transfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData, Abc_ObjFaninNum(pObj));
+ pObjNew->pData = Hop_Transfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData, Abc_ObjFaninNum(pObj));
else if ( Abc_NtkHasMapping(pNtkNew) )
pObjNew->pData = pObj->pData;
else assert( 0 );
@@ -576,7 +576,7 @@ Abc_Obj_t * Abc_NtkCreateNodeConst0( Abc_Ntk_t * pNtk )
else if ( Abc_NtkHasBdd(pNtk) )
pNode->pData = Cudd_ReadLogicZero(pNtk->pManFunc), Cudd_Ref( pNode->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Aig_ManConst0(pNtk->pManFunc);
+ pNode->pData = Hop_ManConst0(pNtk->pManFunc);
else if ( Abc_NtkHasMapping(pNtk) )
pNode->pData = Mio_LibraryReadConst0(Abc_FrameReadLibGen());
else if ( !Abc_NtkHasBlackbox(pNtk) )
@@ -605,7 +605,7 @@ Abc_Obj_t * Abc_NtkCreateNodeConst1( Abc_Ntk_t * pNtk )
else if ( Abc_NtkHasBdd(pNtk) )
pNode->pData = Cudd_ReadOne(pNtk->pManFunc), Cudd_Ref( pNode->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Aig_ManConst1(pNtk->pManFunc);
+ pNode->pData = Hop_ManConst1(pNtk->pManFunc);
else if ( Abc_NtkHasMapping(pNtk) )
pNode->pData = Mio_LibraryReadConst1(Abc_FrameReadLibGen());
else if ( !Abc_NtkHasBlackbox(pNtk) )
@@ -635,7 +635,7 @@ Abc_Obj_t * Abc_NtkCreateNodeInv( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin )
else if ( Abc_NtkHasBdd(pNtk) )
pNode->pData = Cudd_Not(Cudd_bddIthVar(pNtk->pManFunc,0)), Cudd_Ref( pNode->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Aig_Not(Aig_IthVar(pNtk->pManFunc,0));
+ pNode->pData = Hop_Not(Hop_IthVar(pNtk->pManFunc,0));
else if ( Abc_NtkHasMapping(pNtk) )
pNode->pData = Mio_LibraryReadInv(Abc_FrameReadLibGen());
else
@@ -665,7 +665,7 @@ Abc_Obj_t * Abc_NtkCreateNodeBuf( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin )
else if ( Abc_NtkHasBdd(pNtk) )
pNode->pData = Cudd_bddIthVar(pNtk->pManFunc,0), Cudd_Ref( pNode->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Aig_IthVar(pNtk->pManFunc,0);
+ pNode->pData = Hop_IthVar(pNtk->pManFunc,0);
else if ( Abc_NtkHasMapping(pNtk) )
pNode->pData = Mio_LibraryReadBuf(Abc_FrameReadLibGen());
else
@@ -697,7 +697,7 @@ Abc_Obj_t * Abc_NtkCreateNodeAnd( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
else if ( Abc_NtkHasBdd(pNtk) )
pNode->pData = Extra_bddCreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData);
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Aig_CreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins) );
+ pNode->pData = Hop_CreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins) );
else
assert( 0 );
return pNode;
@@ -727,7 +727,7 @@ Abc_Obj_t * Abc_NtkCreateNodeOr( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
else if ( Abc_NtkHasBdd(pNtk) )
pNode->pData = Extra_bddCreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData);
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Aig_CreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins) );
+ pNode->pData = Hop_CreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins) );
else
assert( 0 );
return pNode;
@@ -757,7 +757,7 @@ Abc_Obj_t * Abc_NtkCreateNodeExor( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
else if ( Abc_NtkHasBdd(pNtk) )
pNode->pData = Extra_bddCreateExor( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData);
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Aig_CreateExor( pNtk->pManFunc, Vec_PtrSize(vFanins) );
+ pNode->pData = Hop_CreateExor( pNtk->pManFunc, Vec_PtrSize(vFanins) );
else
assert( 0 );
return pNode;
@@ -787,7 +787,7 @@ Abc_Obj_t * Abc_NtkCreateNodeMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_
else if ( Abc_NtkHasBdd(pNtk) )
pNode->pData = Cudd_bddIte(pNtk->pManFunc,Cudd_bddIthVar(pNtk->pManFunc,0),Cudd_bddIthVar(pNtk->pManFunc,1),Cudd_bddIthVar(pNtk->pManFunc,2)), Cudd_Ref( pNode->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Aig_Mux(pNtk->pManFunc,Aig_IthVar(pNtk->pManFunc,0),Aig_IthVar(pNtk->pManFunc,1),Aig_IthVar(pNtk->pManFunc,2));
+ pNode->pData = Hop_Mux(pNtk->pManFunc,Hop_IthVar(pNtk->pManFunc,0),Hop_IthVar(pNtk->pManFunc,1),Hop_IthVar(pNtk->pManFunc,2));
else
assert( 0 );
return pNode;
@@ -834,7 +834,7 @@ bool Abc_NodeIsConst0( Abc_Obj_t * pNode )
if ( Abc_NtkHasBdd(pNtk) )
return Cudd_IsComplement(pNode->pData);
if ( Abc_NtkHasAig(pNtk) )
- return Aig_IsComplement(pNode->pData);
+ return Hop_IsComplement(pNode->pData);
if ( Abc_NtkHasMapping(pNtk) )
return pNode->pData == Mio_LibraryReadConst0(Abc_FrameReadLibGen());
assert( 0 );
@@ -864,7 +864,7 @@ bool Abc_NodeIsConst1( Abc_Obj_t * pNode )
if ( Abc_NtkHasBdd(pNtk) )
return !Cudd_IsComplement(pNode->pData);
if ( Abc_NtkHasAig(pNtk) )
- return !Aig_IsComplement(pNode->pData);
+ return !Hop_IsComplement(pNode->pData);
if ( Abc_NtkHasMapping(pNtk) )
return pNode->pData == Mio_LibraryReadConst1(Abc_FrameReadLibGen());
assert( 0 );
@@ -894,7 +894,7 @@ bool Abc_NodeIsBuf( Abc_Obj_t * pNode )
if ( Abc_NtkHasBdd(pNtk) )
return !Cudd_IsComplement(pNode->pData);
if ( Abc_NtkHasAig(pNtk) )
- return !Aig_IsComplement(pNode->pData);
+ return !Hop_IsComplement(pNode->pData);
if ( Abc_NtkHasMapping(pNtk) )
return pNode->pData == Mio_LibraryReadBuf(Abc_FrameReadLibGen());
assert( 0 );
@@ -924,7 +924,7 @@ bool Abc_NodeIsInv( Abc_Obj_t * pNode )
if ( Abc_NtkHasBdd(pNtk) )
return Cudd_IsComplement(pNode->pData);
if ( Abc_NtkHasAig(pNtk) )
- return Aig_IsComplement(pNode->pData);
+ return Hop_IsComplement(pNode->pData);
if ( Abc_NtkHasMapping(pNtk) )
return pNode->pData == Mio_LibraryReadInv(Abc_FrameReadLibGen());
assert( 0 );
@@ -951,7 +951,7 @@ void Abc_NodeComplement( Abc_Obj_t * pNode )
else if ( Abc_NtkHasBdd(pNode->pNtk) )
pNode->pData = Cudd_Not( pNode->pData );
else if ( Abc_NtkHasAig(pNode->pNtk) )
- pNode->pData = Aig_Not( pNode->pData );
+ pNode->pData = Hop_Not( pNode->pData );
else
assert( 0 );
}
diff --git a/src/base/abc/abcShow.c b/src/base/abc/abcShow.c
index fa921391..ee86e8aa 100644
--- a/src/base/abc/abcShow.c
+++ b/src/base/abc/abcShow.c
@@ -79,109 +79,6 @@ void Abc_NodeShowBdd( Abc_Obj_t * pNode )
/**Function*************************************************************
- Synopsis [Visualizes AIG with choices.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abc_NtkShowAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodesShow )
-{
- FILE * pFile;
- Abc_Obj_t * pNode;
- Vec_Ptr_t * vNodes;
- char FileNameDot[200];
- int i;
-
- assert( Abc_NtkIsStrash(pNtk) );
- // create the file name
- Abc_ShowGetFileName( pNtk->pName, FileNameDot );
- // check that the file can be opened
- if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
- {
- fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
- return;
- }
- fclose( pFile );
-
- // collect all nodes in the network
- vNodes = Vec_PtrAlloc( 100 );
- Abc_NtkForEachObj( pNtk, pNode, i )
- Vec_PtrPush( vNodes, pNode );
- // write the DOT file
- Io_WriteDotAig( pNtk, vNodes, vNodesShow, FileNameDot, 0 );
- Vec_PtrFree( vNodes );
-
- // visualize the file
- Abc_ShowFile( FileNameDot );
-}
-
-/**Function*************************************************************
-
- Synopsis [Visualizes AIG with choices.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abc_NtkShowMulti( Abc_Ntk_t * pNtk )
-{
- FILE * pFile;
- Abc_Obj_t * pNode;
- Vec_Ptr_t * vNodes;
- char FileNameDot[200];
- int i;
- extern void Abc_NtkBalanceAttach( Abc_Ntk_t * pNtk );
- extern void Abc_NtkBalanceDetach( Abc_Ntk_t * pNtk );
- extern void Abc_NtkBalanceLevel( Abc_Ntk_t * pNtk );
-
- assert( Abc_NtkIsStrash(pNtk) );
- // create the file name
- Abc_ShowGetFileName( pNtk->pName, FileNameDot );
- // check that the file can be opened
- if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
- {
- fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
- return;
- }
- fclose( pFile );
-
- // get the implication supergates
- Abc_NtkBalanceAttach( pNtk );
- // set the levels based on the implication supergates
- Abc_NtkBalanceLevel( pNtk );
-
- // collect all nodes that are roots
- vNodes = Vec_PtrAlloc( 100 );
- Abc_NtkForEachCi( pNtk, pNode, i )
- Vec_PtrPush( vNodes, pNode );
- Abc_NtkForEachNode( pNtk, pNode, i )
- if ( pNode->pCopy || Abc_ObjFaninNum(pNode) == 0 )
- Vec_PtrPush( vNodes, pNode );
- Abc_NtkForEachPo( pNtk, pNode, i )
- Vec_PtrPush( vNodes, pNode );
-
- // write the DOT file
- Io_WriteDotAig( pNtk, vNodes, NULL, FileNameDot, 1 );
- Vec_PtrFree( vNodes );
-
- // undo the supergates
- Abc_NtkBalanceDetach( pNtk );
- // set the normal levels
- Abc_NtkGetLevelNum( pNtk );
-
- // visualize the file
- Abc_ShowFile( FileNameDot );
-}
-
-/**Function*************************************************************
-
Synopsis [Visualizes a reconvergence driven cut at the node.]
Description []
@@ -232,7 +129,7 @@ void Abc_NodeShowCut( Abc_Obj_t * pNode, int nNodeSizeMax, int nConeSizeMax )
// add the root node to the cone (for visualization)
Vec_PtrPush( vCutSmall, pNode );
// write the DOT file
- Io_WriteDotAig( pNode->pNtk, vInside, vCutSmall, FileNameDot, 0 );
+ Io_WriteDotNtk( pNode->pNtk, vInside, vCutSmall, FileNameDot, 0, 0 );
// stop the cut computation manager
Abc_NtkManCutStop( p );
@@ -251,7 +148,7 @@ void Abc_NodeShowCut( Abc_Obj_t * pNode, int nNodeSizeMax, int nConeSizeMax )
SeeAlso []
***********************************************************************/
-void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames )
+void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames, int fSeq, int fUseReverse )
{
FILE * pFile;
Abc_Obj_t * pNode;
@@ -259,8 +156,15 @@ void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames )
char FileNameDot[200];
int i;
- assert( !Abc_NtkIsStrash(pNtk) );
- Abc_NtkLogicToSop( pNtk, 0 );
+ assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
+ if ( Abc_NtkIsStrash(pNtk) && Abc_NtkGetChoiceNum(pNtk) )
+ {
+ printf( "Temporarily visualization of AIGs with choice nodes is disabled.\n" );
+ return;
+ }
+ // convert to logic SOP
+ if ( Abc_NtkIsLogic(pNtk) )
+ Abc_NtkLogicToSop( pNtk, 0 );
// create the file name
Abc_ShowGetFileName( pNtk->pName, FileNameDot );
// check that the file can be opened
@@ -274,10 +178,12 @@ void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames )
// collect all nodes in the network
vNodes = Vec_PtrAlloc( 100 );
Abc_NtkForEachObj( pNtk, pNode, i )
-// if ( !Abc_ObjIsBi(pNode) && !Abc_ObjIsBo(pNode) )
- Vec_PtrPush( vNodes, pNode );
+ Vec_PtrPush( vNodes, pNode );
// write the DOT file
- Io_WriteDotNtk( pNtk, vNodes, NULL, FileNameDot, fGateNames );
+ if ( fSeq )
+ Io_WriteDotSeq( pNtk, vNodes, NULL, FileNameDot, fGateNames, fUseReverse );
+ else
+ Io_WriteDotNtk( pNtk, vNodes, NULL, FileNameDot, fGateNames, fUseReverse );
Vec_PtrFree( vNodes );
// visualize the file
diff --git a/src/base/abc/abcSop.c b/src/base/abc/abcSop.c
index db0803c1..81d91499 100644
--- a/src/base/abc/abcSop.c
+++ b/src/base/abc/abcSop.c
@@ -768,7 +768,8 @@ bool Abc_SopCheck( char * pSop, int nFanins )
// compare the distance
if ( pCubes - pCubesOld != nFanins )
{
- fprintf( stdout, "Abc_SopCheck: SOP has a mismatch between its cover and its fanins.\n" );
+ fprintf( stdout, "Abc_SopCheck: SOP has a mismatch between its cover size (%d) and its fanin number (%d).\n",
+ pCubes - pCubesOld, nFanins );
return 0;
}
// check the output values for this cube
@@ -779,7 +780,7 @@ bool Abc_SopCheck( char * pSop, int nFanins )
fFound1 = 1;
else if ( *pCubes != 'x' && *pCubes != 'n' )
{
- fprintf( stdout, "Abc_SopCheck: SOP has a strange character in the output part of its cube.\n" );
+ fprintf( stdout, "Abc_SopCheck: SOP has a strange character (%c) in the output part of its cube.\n", *pCubes );
return 0;
}
// check the last symbol (new line)
diff --git a/src/base/abc/abcUtil.c b/src/base/abc/abcUtil.c
index fa1cd69a..12bb8341 100644
--- a/src/base/abc/abcUtil.c
+++ b/src/base/abc/abcUtil.c
@@ -34,6 +34,27 @@
/**Function*************************************************************
+ Synopsis [Frees one attribute manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void * Abc_NtkAttrFree( Abc_Ntk_t * pNtk, int Attr, int fFreeMan )
+{
+ void * pUserMan;
+ Vec_Att_t * pAttrMan;
+ pAttrMan = Vec_PtrEntry( pNtk->vAttrs, Attr );
+ Vec_PtrWriteEntry( pNtk->vAttrs, Attr, NULL );
+ pUserMan = Vec_AttFree( pAttrMan, fFreeMan );
+ return pUserMan;
+}
+
+/**Function*************************************************************
+
Synopsis [Increments the current traversal ID of the network.]
Description []
@@ -225,7 +246,7 @@ int Abc_NtkGetAigNodeNum( Abc_Ntk_t * pNtk )
assert( pNode->pData );
if ( Abc_NodeIsConst(pNode) )
continue;
- nNodes += pNode->pData? Aig_DagSize( pNode->pData ) : 0;
+ nNodes += pNode->pData? Hop_DagSize( pNode->pData ) : 0;
}
return nNodes;
}
@@ -356,7 +377,7 @@ int Abc_NtkGetChoiceNum( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pNode;
int i, Counter;
- if ( !Abc_NtkHasAig(pNtk) )
+ if ( !Abc_NtkIsStrash(pNtk) )
return 0;
Counter = 0;
Abc_NtkForEachNode( pNtk, pNode, i )
@@ -578,7 +599,7 @@ void Abc_NtkFixCoDriverProblem( Abc_Obj_t * pDriver, Abc_Obj_t * pNodeCo, int fD
Description [The COs of a logic network are simple under three conditions:
(1) The edge from CO to its driver is not complemented.
(2) If CI is a driver of a CO, they have the same name.]
- (2) If two COs share the same driver, they have the same name.]
+ (3) If two COs share the same driver, they have the same name.]
SideEffects []
@@ -621,7 +642,7 @@ bool Abc_NtkLogicHasSimpleCos( Abc_Ntk_t * pNtk )
Description [The COs of a logic network are simple under three conditions:
(1) The edge from CO to its driver is not complemented.
(2) If CI is a driver of a CO, they have the same name.]
- (2) If two COs share the same driver, they have the same name.
+ (3) If two COs share the same driver, they have the same name.
In some cases, such as FPGA mapping, we prevent the increase in delay
by duplicating the driver nodes, rather than adding invs/bufs.]
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index dffe4b99..9613ab40 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -22,10 +22,9 @@
#include "mainInt.h"
#include "fraig.h"
#include "fxu.h"
-#include "fpga.h"
-#include "pga.h"
#include "cut.h"
-//#include "seq.h"
+#include "fpga.h"
+#include "if.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -46,12 +45,10 @@ static int Abc_CommandPrintAuto ( Abc_Frame_t * pAbc, int argc, char ** arg
static int Abc_CommandPrintKMap ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPrintGates ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPrintSharing ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintSkews ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandShow ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandShowBdd ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandShowCut ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandShowAig ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandShowNtk ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandCollapse ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandStrash ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -123,7 +120,7 @@ static int Abc_CommandSuperChoiceLut ( Abc_Frame_t * pAbc, int argc, char ** arg
static int Abc_CommandFpga ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandFpgaFast ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPga ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandIf ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandScut ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandInit ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -145,9 +142,6 @@ static int Abc_CommandDebug ( Abc_Frame_t * pAbc, int argc, char ** arg
static int Abc_CommandTraceStart ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTraceCheck ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandHoward ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSkewForward ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -182,12 +176,10 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Printing", "print_kmap", Abc_CommandPrintKMap, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_gates", Abc_CommandPrintGates, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_sharing", Abc_CommandPrintSharing, 0 );
- Cmd_CommandAdd( pAbc, "Printing", "print_skews", Abc_CommandPrintSkews, 0 );
+ Cmd_CommandAdd( pAbc, "Printing", "show", Abc_CommandShow, 0 );
Cmd_CommandAdd( pAbc, "Printing", "show_bdd", Abc_CommandShowBdd, 0 );
Cmd_CommandAdd( pAbc, "Printing", "show_cut", Abc_CommandShowCut, 0 );
- Cmd_CommandAdd( pAbc, "Printing", "show_aig", Abc_CommandShowAig, 0 );
- Cmd_CommandAdd( pAbc, "Printing", "show_ntk", Abc_CommandShowNtk, 0 );
Cmd_CommandAdd( pAbc, "Synthesis", "collapse", Abc_CommandCollapse, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "strash", Abc_CommandStrash, 1 );
@@ -259,7 +251,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "FPGA mapping", "fpga", Abc_CommandFpga, 1 );
Cmd_CommandAdd( pAbc, "FPGA mapping", "ffpga", Abc_CommandFpgaFast, 1 );
- Cmd_CommandAdd( pAbc, "FPGA mapping", "pga", Abc_CommandPga, 1 );
+ Cmd_CommandAdd( pAbc, "FPGA mapping", "if", Abc_CommandIf, 1 );
// Cmd_CommandAdd( pAbc, "Sequential", "scut", Abc_CommandScut, 0 );
Cmd_CommandAdd( pAbc, "Sequential", "init", Abc_CommandInit, 1 );
@@ -281,9 +273,6 @@ void Abc_Init( Abc_Frame_t * pAbc )
// Cmd_CommandAdd( pAbc, "Verification", "trace_start", Abc_CommandTraceStart, 0 );
// Cmd_CommandAdd( pAbc, "Verification", "trace_check", Abc_CommandTraceCheck, 0 );
-// Cmd_CommandAdd( pAbc, "Sequential", "howard", Abc_CommandHoward, 0 );
-// Cmd_CommandAdd( pAbc, "Sequential", "skew_fwd", Abc_CommandSkewForward, 0 );
-
// Rwt_Man4ExploreStart();
// Map_Var3Print();
// Map_Var4Test();
@@ -1383,29 +1372,38 @@ usage:
SeeAlso []
***********************************************************************/
-int Abc_CommandPrintSkews( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandShow( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk;
int c;
- int fPrintAll;
+ int fSeq;
+ int fGateNames;
+ int fUseReverse;
+ extern void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames, int fSeq, int fUseReverse );
pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set defaults
- fPrintAll = 0;
+ fSeq = 0;
+ fGateNames = 0;
+ fUseReverse = 1;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "ah" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "rsgh" ) ) != EOF )
{
switch ( c )
{
- case 'a':
- fPrintAll = 1;
+ case 'r':
+ fUseReverse ^= 1;
+ break;
+ case 's':
+ fSeq ^= 1;
+ break;
+ case 'g':
+ fGateNames ^= 1;
break;
- case 'h':
- goto usage;
default:
goto usage;
}
@@ -1417,25 +1415,19 @@ int Abc_CommandPrintSkews( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
- if ( !Abc_NtkIsSeq(pNtk) && Abc_NtkLatchNum(pNtk) == 0 )
- {
- fprintf( pErr, "The network has no latches.\n" );
- return 0;
- }
-
- if ( pNtk->vSkews == NULL || pNtk->vSkews->nSize == 0 )
- {
- fprintf( pErr, "The network has no clock skew schedule.\n" );
- return 0;
- }
-
- Abc_NtkPrintSkews( pOut, pNtk, fPrintAll );
+ Abc_NtkShow( pNtk, fGateNames, fSeq, fUseReverse );
return 0;
usage:
- fprintf( pErr, "usage: print_skews [-h] [-a]\n" );
- fprintf( pErr, "\t prints information about a clock skew schedule\n" );
- fprintf( pErr, "\t-a : dumps the skew of every latch [default = no]\n");
+ fprintf( pErr, "usage: show [-srgh]\n" );
+ fprintf( pErr, " visualizes the network structure using DOT and GSVIEW\n" );
+#ifdef WIN32
+ fprintf( pErr, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
+ fprintf( pErr, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
+#endif
+ fprintf( pErr, "\t-s : toggles visualization of sequential networks [default = %s].\n", fSeq? "yes": "no" );
+ fprintf( pErr, "\t-r : toggles ordering nodes in reverse order [default = %s].\n", fUseReverse? "yes": "no" );
+ fprintf( pErr, "\t-g : toggles printing gate names for mapped network [default = %s].\n", fGateNames? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
return 1;
}
@@ -1628,145 +1620,6 @@ usage:
return 1;
}
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Abc_CommandShowAig( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
- int c;
- int fMulti;
- extern void Abc_NtkShowAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodesShow );
- extern void Abc_NtkShowMulti( Abc_Ntk_t * pNtk );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
- // set defaults
- fMulti = 0;
- Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "mh" ) ) != EOF )
- {
- switch ( c )
- {
- case 'm':
- fMulti ^= 1;
- break;
- default:
- goto usage;
- }
- }
-
- if ( pNtk == NULL )
- {
- fprintf( pErr, "Empty network.\n" );
- return 1;
- }
-
- if ( !Abc_NtkIsStrash(pNtk) )
- {
- fprintf( pErr, "Visualizing networks other than AIGs can be done using command \"show_ntk\".\n" );
- return 1;
- }
-
- if ( fMulti && !Abc_NtkIsStrash(pNtk) )
- {
- fprintf( pErr, "Visualizing multi-input ANDs cannot be done for sequential network (run \"unseq\").\n" );
- return 1;
- }
-
- if ( !fMulti )
- Abc_NtkShowAig( pNtk, NULL );
- else
- Abc_NtkShowMulti( pNtk );
- return 0;
-
-usage:
- fprintf( pErr, "usage: show_aig [-h]\n" );
- fprintf( pErr, " visualizes the AIG with choices using DOT and GSVIEW\n" );
-#ifdef WIN32
- fprintf( pErr, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
- fprintf( pErr, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
-#endif
- fprintf( pErr, "\t-m : toggles visualization of multi-input ANDs [default = %s].\n", fMulti? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- return 1;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Abc_CommandShowNtk( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
- int c;
- int fGateNames;
- extern void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
- // set defaults
- fGateNames = 0;
- Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "gh" ) ) != EOF )
- {
- switch ( c )
- {
- case 'g':
- fGateNames ^= 1;
- break;
- default:
- goto usage;
- }
- }
-
- if ( pNtk == NULL )
- {
- fprintf( pErr, "Empty network.\n" );
- return 1;
- }
-
- if ( Abc_NtkIsStrash(pNtk) )
- {
- fprintf( pErr, "Visualizing AIG can only be done using command \"show_aig\".\n" );
- return 1;
- }
- Abc_NtkShow( pNtk, fGateNames );
- return 0;
-
-usage:
- fprintf( pErr, "usage: show_ntk [-gh]\n" );
- fprintf( pErr, " visualizes the network structure using DOT and GSVIEW\n" );
-#ifdef WIN32
- fprintf( pErr, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
- fprintf( pErr, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
-#endif
- fprintf( pErr, "\t-g : toggles printing gate names for mapped network [default = %s].\n", fGateNames? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- return 1;
-}
-
/**Function*************************************************************
@@ -5136,8 +4989,8 @@ int Abc_CommandCycle( Abc_Frame_t * pAbc, int argc, char ** argv )
pErr = Abc_FrameReadErr(pAbc);
// set defaults
- nFrames = 50;
- fVerbose = 0;
+ nFrames = 100;
+ fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Fvh" ) ) != EOF )
{
@@ -5633,7 +5486,7 @@ int Abc_CommandIRewriteSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
pErr = Abc_FrameReadErr(pAbc);
// set defaults
- fUpdateLevel = 1;
+ fUpdateLevel = 0;
fUseZeroCost = 0;
fVerbose = 0;
Extra_UtilGetoptReset();
@@ -7343,7 +7196,7 @@ int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
usage:
if ( DelayTarget == -1 )
- sprintf( Buffer, "not used" );
+ sprintf( Buffer, "best possible" );
else
sprintf( Buffer, "%.2f", DelayTarget );
if ( nLutSize == -1 )
@@ -7394,7 +7247,7 @@ int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
fRecovery = 1;
fVerbose = 0;
DelayTarget =-1;
- nLutSize = 8;
+ nLutSize = 5;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "avhDK" ) ) != EOF )
{
@@ -7514,46 +7367,90 @@ usage:
SeeAlso []
***********************************************************************/
-int Abc_CommandPga( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
{
+ char Buffer[100];
+ char LutSize[100];
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
- Pga_Params_t Params, * pParams = &Params;
+ If_Par_t Pars, * pPars = &Pars;
int c;
- extern Abc_Ntk_t * Abc_NtkPga( Pga_Params_t * pParams );
+ extern Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set defaults
- memset( pParams, 0, sizeof(Pga_Params_t) );
- pParams->pNtk = pNtk;
- pParams->pLutLib = Abc_FrameReadLibLut();
- pParams->fAreaFlow = 1;
- pParams->fArea = 1;
- pParams->fSwitching = 0;
- pParams->fDropCuts = 0;
- pParams->fVerbose = 0;
+ memset( pPars, 0, sizeof(If_Par_t) );
+ pPars->Mode = 1;
+ pPars->nLutSize = 4;
+// pPars->pLutLib = Abc_FrameReadLibLut();
+ pPars->nCutsMax = 2;
+ pPars->fSeq = 0;
+ pPars->fLatchPaths = 0;
+ pPars->nLatches = 0;
+ pPars->pTimesArr = Abc_NtkGetCiArrivalFloats(pNtk);
+ pPars->pTimesReq = NULL;
+ pPars->DelayTarget = -1;
+ pPars->fVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "fapdvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "MKCDlsvh" ) ) != EOF )
{
switch ( c )
{
- case 'f':
- pParams->fAreaFlow ^= 1;
+ case 'M':
+ if ( globalUtilOptind >= argc )
+ {
+ fprintf( pErr, "Command line switch \"-M\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ pPars->Mode = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->Mode < 0 )
+ goto usage;
break;
- case 'a':
- pParams->fArea ^= 1;
+ case 'K':
+ if ( globalUtilOptind >= argc )
+ {
+ fprintf( pErr, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ pPars->nLutSize = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nLutSize < 0 )
+ goto usage;
break;
- case 'p':
- pParams->fSwitching ^= 1;
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ fprintf( pErr, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ pPars->nCutsMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nCutsMax < 0 )
+ goto usage;
break;
- case 'd':
- pParams->fDropCuts ^= 1;
+ case 'D':
+ if ( globalUtilOptind >= argc )
+ {
+ fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+ goto usage;
+ }
+ pPars->DelayTarget = (float)atof(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->DelayTarget <= 0.0 )
+ goto usage;
+ break;
+ case 'l':
+ pPars->fLatchPaths ^= 1;
+ break;
+ case 's':
+ pPars->fSeq ^= 1;
break;
case 'v':
- pParams->fVerbose ^= 1;
+ pPars->fVerbose ^= 1;
break;
case 'h':
default:
@@ -7567,8 +7464,18 @@ int Abc_CommandPga( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
- printf( "This command is not yet implemented.\n" );
- return 0;
+ if ( pPars->Mode < 0 || pPars->Mode > 4 )
+ {
+ fprintf( pErr, "Incorrect mapping mode.\n" );
+ return 1;
+ }
+
+ // set the latch paths
+ if ( pPars->fLatchPaths )
+ {
+ for ( c = 0; c < Abc_NtkPiNum(pNtk); c++ )
+ pPars->pTimesArr[c] = -ABC_INFINITY;
+ }
if ( !Abc_NtkIsStrash(pNtk) )
{
@@ -7588,7 +7495,7 @@ int Abc_CommandPga( Abc_Frame_t * pAbc, int argc, char ** argv )
}
fprintf( pOut, "The network was strashed and balanced before FPGA mapping.\n" );
// get the new network
- pNtkRes = Abc_NtkPga( pParams );
+ pNtkRes = Abc_NtkIf( pNtk, pPars );
if ( pNtkRes == NULL )
{
Abc_NtkDelete( pNtk );
@@ -7600,7 +7507,7 @@ int Abc_CommandPga( Abc_Frame_t * pAbc, int argc, char ** argv )
else
{
// get the new network
- pNtkRes = Abc_NtkPga( pParams );
+ pNtkRes = Abc_NtkIf( pNtk, pPars );
if ( pNtkRes == NULL )
{
fprintf( pErr, "FPGA mapping has failed.\n" );
@@ -7612,14 +7519,28 @@ int Abc_CommandPga( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: pga [-fapdvh]\n" );
- fprintf( pErr, "\t performs FPGA mapping of the current network\n" );
- fprintf( pErr, "\t-f : toggles area flow recovery [default = %s]\n", pParams->fAreaFlow? "yes": "no" );
- fprintf( pErr, "\t-a : toggles area recovery [default = %s]\n", pParams->fArea? "yes": "no" );
- fprintf( pErr, "\t-p : optimizes power by minimizing switching activity [default = %s]\n", pParams->fSwitching? "yes": "no" );
- fprintf( pErr, "\t-d : toggles dropping cuts to save memory [default = %s]\n", pParams->fDropCuts? "yes": "no" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", pParams->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : prints the command usage\n");
+ if ( pPars->DelayTarget == -1 )
+ sprintf( Buffer, "best possible" );
+ else
+ sprintf( Buffer, "%.2f", pPars->DelayTarget );
+ if ( pPars->nLutSize == -1 )
+ sprintf( LutSize, "library" );
+ else
+ sprintf( LutSize, "%d", pPars->nLutSize );
+ fprintf( pErr, "usage: if [-M num] [-K num] [-C num] [-D float] [-lsvh]\n" );
+ fprintf( pErr, "\t performs FPGA mapping of the network as follows:\n" );
+ fprintf( pErr, "\t 1 - delay only\n" );
+ fprintf( pErr, "\t 2 - area only\n" );
+ fprintf( pErr, "\t 3 - area under delay constraints\n" );
+ fprintf( pErr, "\t 4 - area under delay constraints with area recovery\n" );
+ fprintf( pErr, "\t-M num : the mapping mode [default = %d]\n", pPars->Mode );
+ fprintf( pErr, "\t-K num : the number of LUT inputs (2 < num < 32) [default = %s]\n", LutSize );
+ fprintf( pErr, "\t-C num : the max number of cuts to use (1 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
+ fprintf( pErr, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+ fprintf( pErr, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
+ fprintf( pErr, "\t-s : toggles sequential mapping [default = %s]\n", pPars->fSeq? "yes": "no" );
+ fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ fprintf( pErr, "\t-h : prints the command usage\n");
return 1;
}
@@ -7996,7 +7917,7 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
Mode = 5;
fForward = 0;
fBackward = 0;
- fVerbose = 1;
+ fVerbose = 0;
nMaxIters = 15;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Mfbvh" ) ) != EOF )
@@ -8048,6 +7969,12 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
}
+ if ( Mode < 0 || Mode > 6 )
+ {
+ fprintf( pErr, "The mode (%d) is incorrect. Retiming is not performed.\n", Mode );
+ return 0;
+ }
+
if ( Abc_NtkIsStrash(pNtk) )
{
if ( Abc_NtkGetChoiceNum(pNtk) )
@@ -8089,6 +8016,7 @@ usage:
fprintf( pErr, "\t 3: forward and backward min-area retiming\n" );
fprintf( pErr, "\t 4: forward and backward min-delay retiming\n" );
fprintf( pErr, "\t 5: mode 3 followed by mode 4\n" );
+ fprintf( pErr, "\t 6: Pan's optimum-delay retiming using binary search\n" );
fprintf( pErr, "\t-M num : the retiming algorithm to use [default = %d]\n", Mode );
fprintf( pErr, "\t-f : enables forward-only retiming in modes 3,4,5 [default = %s]\n", fForward? "yes": "no" );
fprintf( pErr, "\t-b : enables backward-only retiming in modes 3,4,5 [default = %s]\n", fBackward? "yes": "no" );
@@ -8488,6 +8416,8 @@ int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk;
int c;
+ int fLatchSweep;
+ int fAutoSweep;
int fVerbose;
pNtk = Abc_FrameReadNtk(pAbc);
@@ -8495,12 +8425,20 @@ int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
pErr = Abc_FrameReadErr(pAbc);
// set defaults
- fVerbose = 1;
+ fLatchSweep = 0;
+ fAutoSweep = 0;
+ fVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "lavh" ) ) != EOF )
{
switch ( c )
{
+ case 'l':
+ fLatchSweep ^= 1;
+ break;
+ case 'a':
+ fAutoSweep ^= 1;
+ break;
case 'v':
fVerbose ^= 1;
break;
@@ -8521,16 +8459,18 @@ int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
// modify the current network
- Abc_NtkCleanupSeq( pNtk, fVerbose );
+ Abc_NtkCleanupSeq( pNtk, fLatchSweep, fAutoSweep, fVerbose );
return 0;
usage:
- fprintf( pErr, "usage: scleanup [-vh]\n" );
+ fprintf( pErr, "usage: scleanup [-lavh]\n" );
fprintf( pErr, "\t performs sequential cleanup\n" );
fprintf( pErr, "\t - removes nodes/latches that do not feed into POs\n" );
fprintf( pErr, "\t - removes and shared latches driven by constants\n" );
fprintf( pErr, "\t - replaces autonomous logic by free PI variables\n" );
fprintf( pErr, "\t (the latter may change sequential behaviour)\n" );
+ fprintf( pErr, "\t-l : toggle sweeping latches [default = %s]\n", fLatchSweep? "yes": "no" );
+ fprintf( pErr, "\t-a : toggle removing autonomous logic [default = %s]\n", fAutoSweep? "yes": "no" );
fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
return 1;
@@ -8694,7 +8634,7 @@ int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults
fSat = 0;
fVerbose = 0;
- nFrames = 3;
+ nFrames = 5;
nSeconds = 20;
nConfLimit = 10000;
nInsLimit = 0;
@@ -8758,6 +8698,12 @@ int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
}
}
+ if ( Abc_NtkLatchNum(pNtk) == 0 )
+ {
+ printf( "The network has no latches. Used combinational command \"cec\".\n" );
+ return 0;
+ }
+
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
@@ -9290,168 +9236,6 @@ usage:
return 1;
}
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Abc_CommandHoward( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
- int c;
- int fVerbose;
- double result;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
- // set defaults
- fVerbose = 0;
- Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
- {
- switch ( c )
- {
- case 'v':
- fVerbose ^= 1;
- break;
- default:
- goto usage;
- }
- }
-
- if ( pNtk == NULL )
- {
- fprintf( pErr, "Empty network.\n" );
- return 1;
- }
-
- if ( !Abc_NtkIsSeq(pNtk) && Abc_NtkLatchNum(pNtk) == 0 )
- {
- fprintf( pErr, "The network has no latches. Analysis is not performed.\n" );
- return 0;
- }
-
- if ( Abc_NtkHasAig(pNtk) )
- {
- // quit if there are choice nodes
- if ( Abc_NtkGetChoiceNum(pNtk) )
- {
- fprintf( pErr, "Currently cannot analyze networks with choice nodes.\n" );
- return 0;
- }
-
- /*
- if ( Abc_NtkIsStrash(pNtk) )
- pNtkRes = Abc_NtkAigToSeq(pNtk);
- else
- pNtkRes = Abc_NtkDup(pNtk);
-
- */
-
- fprintf( pErr, "Currently cannot analyze unmapped networks.\n" );
- return 0;
- }
-
-// result = Seq_NtkHoward( pNtk, fVerbose );
- result = 0;
-
- if (result < 0) {
- fprintf( pErr, "Analysis failed.\n" );
- return 0;
- }
-
- printf("Maximum mean cycle time = %.2f\n", result);
-
- return 1;
-
-usage:
- fprintf( pErr, "usage: howard [-h]\n" );
- fprintf( pErr, "\t computes the maximum mean cycle time using Howard's algorithm\n" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- return 1;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Abc_CommandSkewForward( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
- int c;
- int fMinimize;
- float target;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
- // set defaults
- target = pNtk->maxMeanCycle;
- fMinimize = 0;
- Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "mh" ) ) != EOF )
- {
- switch ( c )
- {
- case 'm':
- fMinimize ^= 1;
- break;
- default:
- goto usage;
- }
- }
-
-
- if ( pNtk == NULL )
- {
- fprintf( pErr, "Empty network.\n" );
- return 1;
- }
-
- if ( !Abc_NtkIsSeq(pNtk) && Abc_NtkLatchNum(pNtk) == 0 )
- {
- fprintf( pErr, "The network has no latches.\n" );
- return 0;
- }
-
- if ( pNtk->vSkews == NULL || pNtk->vSkews->nSize == 0 )
- {
- fprintf( pErr, "The network has no clock skew schedule.\n" );
- return 0;
- }
-
-// Seq_NtkSkewForward( pNtk, target, fMinimize );
-
- return 1;
-
-usage:
- fprintf( pErr, "usage: skew_fwd [-h] [-m] [-t float]\n" );
- fprintf( pErr, "\t converts a skew schedule into a set of forward skews 0<skew<T\n" );
- fprintf( pErr, "\t-m : minimizes sum of skews [default = %s]\n", fMinimize? "yes": "no" );
- fprintf( pErr, "\t-t : clock period, T [default = maxMeanCycle] (unimplemented)\n");
- fprintf( pErr, "\t-h : print the command usage\n");
- return 1;
-}
-
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/base/abci/abcAuto.c b/src/base/abci/abcAuto.c
index cc6e8913..3b307ac2 100644
--- a/src/base/abci/abcAuto.c
+++ b/src/base/abci/abcAuto.c
@@ -49,16 +49,24 @@ void Abc_NtkAutoPrint( Abc_Ntk_t * pNtk, int Output, int fNaive, int fVerbose )
char ** pInputNames; // pointers to the CI names
char ** pOutputNames; // pointers to the CO names
int nOutputs, nInputs, i;
+ Vec_Ptr_t * vFuncsGlob;
+ Abc_Obj_t * pObj;
// compute the global BDDs
- if ( Abc_NtkGlobalBdds(pNtk, 10000000, 0, 1, fVerbose) == NULL )
+ if ( Abc_NtkBuildGlobalBdds(pNtk, 10000000, 1, 1, fVerbose) == NULL )
return;
// get information about the network
nInputs = Abc_NtkCiNum(pNtk);
nOutputs = Abc_NtkCoNum(pNtk);
- dd = pNtk->pManGlob;
- pbGlobal = (DdNode **)Vec_PtrArray( pNtk->vFuncsGlob );
+// dd = pNtk->pManGlob;
+ dd = Abc_NtkGlobalBddMan( pNtk );
+
+ // complement the global functions
+ vFuncsGlob = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
+ Abc_NtkForEachCo( pNtk, pObj, i )
+ Vec_PtrPush( vFuncsGlob, Abc_ObjGlobalBdd(pObj) );
+ pbGlobal = (DdNode **)Vec_PtrArray( vFuncsGlob );
// get the network names
pInputNames = Abc_NtkCollectCioNames( pNtk, 0 );
@@ -83,12 +91,14 @@ void Abc_NtkAutoPrint( Abc_Ntk_t * pNtk, int Output, int fNaive, int fVerbose )
Abc_NtkAutoPrintOne( dd, nInputs, pbGlobal, Output, pInputNames, pOutputNames, fNaive );
// deref the PO functions
- Abc_NtkFreeGlobalBdds( pNtk );
+// Abc_NtkFreeGlobalBdds( pNtk );
// stop the global BDD manager
- Extra_StopManager( pNtk->pManGlob );
- pNtk->pManGlob = NULL;
+// Extra_StopManager( pNtk->pManGlob );
+// pNtk->pManGlob = NULL;
+ Abc_NtkFreeGlobalBdds( pNtk, 1 );
free( pInputNames );
free( pOutputNames );
+ Vec_PtrFree( vFuncsGlob );
}
/**Function*************************************************************
diff --git a/src/base/abci/abcClpBdd.c b/src/base/abci/abcClpBdd.c
index 650f379f..ce67aff7 100644
--- a/src/base/abci/abcClpBdd.c
+++ b/src/base/abci/abcClpBdd.c
@@ -49,25 +49,27 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, i
assert( Abc_NtkIsStrash(pNtk) );
// compute the global BDDs
- if ( Abc_NtkGlobalBdds(pNtk, fBddSizeMax, 0, fReorder, fVerbose) == NULL )
+ if ( Abc_NtkBuildGlobalBdds(pNtk, fBddSizeMax, 1, fReorder, fVerbose) == NULL )
return NULL;
if ( fVerbose )
{
- printf( "The shared BDD size is %d nodes. ", Cudd_ReadKeys(pNtk->pManGlob) - Cudd_ReadDead(pNtk->pManGlob) );
+ DdManager * dd = Abc_NtkGlobalBddMan( pNtk );
+ printf( "The shared BDD size is %d nodes. ", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
PRT( "BDD construction time", clock() - clk );
}
// create the new network
pNtkNew = Abc_NtkFromGlobalBdds( pNtk );
- Abc_NtkFreeGlobalBdds( pNtk );
+// Abc_NtkFreeGlobalBdds( pNtk );
+ Abc_NtkFreeGlobalBdds( pNtk, 1 );
if ( pNtkNew == NULL )
{
- Cudd_Quit( pNtk->pManGlob );
- pNtk->pManGlob = NULL;
+// Cudd_Quit( pNtk->pManGlob );
+// pNtk->pManGlob = NULL;
return NULL;
}
- Extra_StopManager( pNtk->pManGlob );
- pNtk->pManGlob = NULL;
+// Extra_StopManager( pNtk->pManGlob );
+// pNtk->pManGlob = NULL;
// make the network minimum base
Abc_NtkMinimumBase( pNtkNew );
@@ -100,8 +102,9 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk )
{
ProgressBar * pProgress;
Abc_Ntk_t * pNtkNew;
- Abc_Obj_t * pNode, * pNodeNew;
- DdManager * dd = pNtk->pManGlob;
+ Abc_Obj_t * pNode, * pDriver, * pNodeNew;
+// DdManager * dd = pNtk->pManGlob;
+ DdManager * dd = Abc_NtkGlobalBddMan( pNtk );
int i;
// start the new network
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
@@ -112,7 +115,14 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk )
Abc_NtkForEachCo( pNtk, pNode, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
- pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, Vec_PtrEntry(pNtk->vFuncsGlob, i) );
+ pDriver = Abc_ObjFanin0(pNode);
+ if ( Abc_ObjIsCi(pDriver) && !strcmp(Abc_ObjName(pNode), Abc_ObjName(pDriver)) )
+ {
+ Abc_ObjAddFanin( pNode->pCopy, pDriver->pCopy );
+ continue;
+ }
+// pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, Vec_PtrEntry(pNtk->vFuncsGlob, i) );
+ pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, Abc_ObjGlobalBdd(pNode) );
Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
}
Extra_ProgressBarStop( pProgress );
diff --git a/src/base/abci/abcCut.c b/src/base/abci/abcCut.c
index c021728a..f1dd4ab5 100644
--- a/src/base/abci/abcCut.c
+++ b/src/base/abci/abcCut.c
@@ -202,6 +202,7 @@ void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * p )
***********************************************************************/
Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
{
+/*
Cut_Man_t * p;
Abc_Obj_t * pObj, * pNode;
int i, nIters, fStatus;
@@ -288,6 +289,8 @@ printf( "Converged after %d iterations.\n", nIters );
}
//Abc_NtkPrintCuts( p, pNtk, 1 );
return p;
+*/
+ return NULL;
}
/**Function*************************************************************
diff --git a/src/base/abci/abcDebug.c b/src/base/abci/abcDebug.c
index 4d37c496..7771148e 100644
--- a/src/base/abci/abcDebug.c
+++ b/src/base/abci/abcDebug.c
@@ -86,7 +86,8 @@ void Abc_NtkAutoDebug( Abc_Ntk_t * pNtk, int (*pFuncError) (Abc_Ntk_t *) )
else // no bug
Abc_NtkDelete( pNtkMod );
}
- printf( "Iteration %6d : Nodes = %6d. Steps = %6d. Error step = %3d. ", nIter, Abc_NtkObjNum(pNtk), nSteps, i );
+ printf( "Iter %6d : Latches = %6d. Nodes = %6d. Steps = %6d. Error step = %3d. ",
+ nIter, Abc_NtkLatchNum(pNtk), Abc_NtkNodeNum(pNtk), nSteps, i );
PRT( "Time", clock() - clk );
if ( i == nSteps ) // could not modify it while preserving the bug
break;
@@ -116,7 +117,11 @@ int Abc_NtkCountFaninsTotal( Abc_Ntk_t * pNtk )
Abc_NtkForEachObj( pNtk, pObj, i )
Abc_ObjForEachFanin( pObj, pFanin, k )
{
- if ( Abc_NodeIsConst(pFanin) )
+ if ( !Abc_ObjIsNode(pObj) && !Abc_ObjIsPo(pObj) )
+ continue;
+ if ( Abc_ObjIsPo(pObj) && Abc_NtkPoNum(pNtk) == 1 )
+ continue;
+ if ( Abc_ObjIsNode(pObj) && Abc_NodeIsConst(pFanin) )
continue;
Counter++;
}
@@ -141,7 +146,11 @@ int Abc_NtkFindGivenFanin( Abc_Ntk_t * pNtk, int Step, Abc_Obj_t ** ppObj, Abc_O
Abc_NtkForEachObj( pNtk, pObj, i )
Abc_ObjForEachFanin( pObj, pFanin, k )
{
- if ( Abc_NodeIsConst(pFanin) )
+ if ( !Abc_ObjIsNode(pObj) && !Abc_ObjIsPo(pObj) )
+ continue;
+ if ( Abc_ObjIsPo(pObj) && Abc_NtkPoNum(pNtk) == 1 )
+ continue;
+ if ( Abc_ObjIsNode(pObj) && Abc_NodeIsConst(pFanin) )
continue;
if ( Counter++ == Step )
{
@@ -166,6 +175,7 @@ int Abc_NtkFindGivenFanin( Abc_Ntk_t * pNtk, int Step, Abc_Obj_t ** ppObj, Abc_O
***********************************************************************/
Abc_Ntk_t * Abc_NtkAutoDebugModify( Abc_Ntk_t * pNtkInit, int Step, int fConst1 )
{
+ extern void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose );
Abc_Ntk_t * pNtk;
Abc_Obj_t * pObj, * pFanin, * pConst;
// copy the network
@@ -185,9 +195,9 @@ Abc_Ntk_t * Abc_NtkAutoDebugModify( Abc_Ntk_t * pNtkInit, int Step, int fConst1
Abc_NtkDeleteAll_rec( pFanin );
Abc_NtkSweep( pNtk, 0 );
- Abc_NtkCleanupSeq( pNtk, 0 );
+ Abc_NtkCleanupSeq( pNtk, 0, 0, 0 );
Abc_NtkLogicToSop( pNtk, 0 );
- Abc_NtkCycleInitStateSop( pNtk, 20, 0 );
+ Abc_NtkCycleInitStateSop( pNtk, 50, 0 );
return pNtk;
}
diff --git a/src/base/abci/abcDsd.c b/src/base/abci/abcDsd.c
index b38012cd..200f4eec 100644
--- a/src/base/abci/abcDsd.c
+++ b/src/base/abci/abcDsd.c
@@ -55,31 +55,22 @@ static int Abc_NodeFindMuxVar( DdManager * dd, DdNode * bFunc, int n
***********************************************************************/
Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort )
{
+ DdManager * dd;
Abc_Ntk_t * pNtkNew;
-
assert( Abc_NtkIsStrash(pNtk) );
-
- // perform FPGA mapping
- if ( Abc_NtkGlobalBdds(pNtk, 10000000, 0, 1, fVerbose) == NULL )
+ dd = Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, 1, fVerbose );
+ if ( dd == NULL )
return NULL;
if ( fVerbose )
- printf( "The shared BDD size is %d nodes.\n", Cudd_ReadKeys(pNtk->pManGlob) - Cudd_ReadDead(pNtk->pManGlob) );
-
+ printf( "The shared BDD size is %d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
// transform the result of mapping into a BDD network
pNtkNew = Abc_NtkDsdInternal( pNtk, fVerbose, fPrint, fShort );
+ Extra_StopManager( dd );
if ( pNtkNew == NULL )
- {
- Cudd_Quit( pNtk->pManGlob );
- pNtk->pManGlob = NULL;
return NULL;
- }
- Extra_StopManager( pNtk->pManGlob );
- pNtk->pManGlob = NULL;
-
+ // copy EXDC network
if ( pNtk->pExdc )
pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
-
- // make sure that everything is okay
if ( !Abc_NtkCheck( pNtkNew ) )
{
printf( "Abc_NtkDsdGlobal: The network check has failed.\n" );
@@ -102,26 +93,25 @@ Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool
***********************************************************************/
Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort )
{
- DdManager * dd = pNtk->pManGlob;
+ char ** ppNamesCi, ** ppNamesCo;
+ Vec_Ptr_t * vFuncsGlob;
Dsd_Manager_t * pManDsd;
Abc_Ntk_t * pNtkNew;
- DdNode * bFunc;
- char ** ppNamesCi, ** ppNamesCo;
+ DdManager * dd;
Abc_Obj_t * pObj;
int i;
// complement the global functions
+ vFuncsGlob = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
Abc_NtkForEachCo( pNtk, pObj, i )
- {
- bFunc = Vec_PtrEntry(pNtk->vFuncsGlob, i);
- Vec_PtrWriteEntry(pNtk->vFuncsGlob, i, Cudd_NotCond(bFunc, Abc_ObjFaninC0(pObj)) );
- }
+ Vec_PtrPush( vFuncsGlob, Cudd_NotCond(Abc_ObjGlobalBdd(pObj), Abc_ObjFaninC0(pObj)) );
// perform the decomposition
- assert( Vec_PtrSize(pNtk->vFuncsGlob) == Abc_NtkCoNum(pNtk) );
+ dd = Abc_NtkGlobalBddMan(pNtk);
pManDsd = Dsd_ManagerStart( dd, Abc_NtkCiNum(pNtk), fVerbose );
- Dsd_Decompose( pManDsd, (DdNode **)pNtk->vFuncsGlob->pArray, Abc_NtkCoNum(pNtk) );
- Abc_NtkFreeGlobalBdds( pNtk );
+ Dsd_Decompose( pManDsd, (DdNode **)vFuncsGlob->pArray, Abc_NtkCoNum(pNtk) );
+ Vec_PtrFree( vFuncsGlob );
+ Abc_NtkFreeGlobalBdds( pNtk, 0 );
if ( pManDsd == NULL )
{
Cudd_Quit( dd );
@@ -138,7 +128,6 @@ Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bo
Abc_NtkFinalize( pNtk, pNtkNew );
// fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
-
if ( fPrint )
{
ppNamesCi = Abc_NtkCollectCioNames( pNtk, 0 );
diff --git a/src/base/abci/abcFpgaFast.c b/src/base/abci/abcFpgaFast.c
index 3ad29291..356b855e 100644
--- a/src/base/abci/abcFpgaFast.c
+++ b/src/base/abci/abcFpgaFast.c
@@ -118,7 +118,7 @@ Abc_Ntk_t * Ivy_ManFpgaToAbc( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan )
// clone the node
pObj = Abc_NtkCloneObj( pObjAbc );
// set complemented functions
- pObj->pData = Aig_Not( pObjAbc->pData );
+ pObj->pData = Hop_Not( pObjAbc->pData );
// return the new node
pObjAbc = pObj;
}
@@ -172,9 +172,9 @@ Abc_Obj_t * Ivy_ManToAbcFast_rec( Abc_Ntk_t * pNtkNew, Ivy_Man_t * pMan, Ivy_Obj
Ivy_ManForEachNodeVec( pMan, vNodes, pNodeIvy, i )
{
if ( i < Vec_IntSize(vSupp) )
- pNodeIvy->pEquiv = (Ivy_Obj_t *)Aig_IthVar( pNtkNew->pManFunc, i );
+ pNodeIvy->pEquiv = (Ivy_Obj_t *)Hop_IthVar( pNtkNew->pManFunc, i );
else
- pNodeIvy->pEquiv = (Ivy_Obj_t *)Aig_And( pNtkNew->pManFunc, (Aig_Obj_t *)Ivy_ObjChild0Equiv(pNodeIvy), (Aig_Obj_t *)Ivy_ObjChild1Equiv(pNodeIvy) );
+ pNodeIvy->pEquiv = (Ivy_Obj_t *)Hop_And( pNtkNew->pManFunc, (Hop_Obj_t *)Ivy_ObjChild0Equiv(pNodeIvy), (Hop_Obj_t *)Ivy_ObjChild1Equiv(pNodeIvy) );
}
// set the local function
pObjAbc->pData = (Abc_Obj_t *)pObjIvy->pEquiv;
diff --git a/src/base/abci/abcIf.c b/src/base/abci/abcIf.c
new file mode 100644
index 00000000..6b3e0e7c
--- /dev/null
+++ b/src/base/abci/abcIf.c
@@ -0,0 +1,287 @@
+/**CFile****************************************************************
+
+ FileName [abcIf.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Network and node package.]
+
+ Synopsis [Interface with the FPGA mapping package.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: abcIf.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "if.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static If_Man_t * Abc_NtkToIf( Abc_Ntk_t * pNtk, If_Par_t * pPars );
+static Abc_Ntk_t * Abc_NtkFromIf( If_Man_t * pIfMan, Abc_Ntk_t * pNtk );
+static Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t * pIfObj );
+static Hop_Obj_t * Abc_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Cut_t * pCut );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Interface with the FPGA mapping package.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars )
+{
+ Abc_Ntk_t * pNtkNew;
+ If_Man_t * pIfMan;
+
+ assert( Abc_NtkIsStrash(pNtk) );
+
+ // print a warning about choice nodes
+ if ( Abc_NtkGetChoiceNum( pNtk ) )
+ printf( "Performing FPGA mapping with choices.\n" );
+
+ // perform FPGA mapping
+ pIfMan = Abc_NtkToIf( pNtk, pPars );
+ if ( pIfMan == NULL )
+ return NULL;
+ if ( !If_ManPerformMapping( pIfMan ) )
+ {
+ If_ManStop( pIfMan );
+ return NULL;
+ }
+
+ // transform the result of mapping into a BDD network
+ pNtkNew = Abc_NtkFromIf( pIfMan, pNtk );
+ if ( pNtkNew == NULL )
+ return NULL;
+ If_ManStop( pIfMan );
+
+ // duplicate EXDC
+ if ( pNtk->pExdc )
+ pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
+
+ // make sure that everything is okay
+ if ( !Abc_NtkCheck( pNtkNew ) )
+ {
+ printf( "Abc_NtkIf: The network check has failed.\n" );
+ Abc_NtkDelete( pNtkNew );
+ return NULL;
+ }
+ return pNtkNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Load the network into FPGA manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_Man_t * Abc_NtkToIf( Abc_Ntk_t * pNtk, If_Par_t * pPars )
+{
+ ProgressBar * pProgress;
+ If_Man_t * pIfMan;
+ Abc_Obj_t * pNode, * pFanin, * pPrev;
+ int i;
+
+ assert( Abc_NtkIsStrash(pNtk) );
+
+ // start the mapping manager and set its parameters
+ pIfMan = If_ManStart( pPars );
+
+ // create PIs and remember them in the old nodes
+ Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)If_ManConst1( pIfMan );
+ Abc_NtkForEachCi( pNtk, pNode, i )
+ pNode->pCopy = (Abc_Obj_t *)If_ManCreatePi( pIfMan );
+
+ // load the AIG into the mapper
+ pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) );
+ Abc_AigForEachAnd( pNtk, pNode, i )
+ {
+ Extra_ProgressBarUpdate( pProgress, i, NULL );
+ // add the node to the mapper
+ pNode->pCopy = (Abc_Obj_t *)If_ManCreateAnd( pIfMan,
+ (If_Obj_t *)Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode),
+ (If_Obj_t *)Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) );
+ // set up the choice node
+ if ( Abc_AigNodeIsChoice( pNode ) )
+ for ( pPrev = pNode, pFanin = pNode->pData; pFanin; pPrev = pFanin, pFanin = pFanin->pData )
+ If_ObjSetChoice( (If_Obj_t *)pPrev->pCopy, (If_Obj_t *)pFanin->pCopy );
+ }
+ Extra_ProgressBarStop( pProgress );
+
+ // set the primary outputs without copying the phase
+ Abc_NtkForEachCo( pNtk, pNode, i )
+ If_ManCreatePo( pIfMan, (If_Obj_t *)Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) );
+ return pIfMan;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the mapped network.]
+
+ Description [Assuming the copy field of the mapped nodes are NULL.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Ntk_t * Abc_NtkFromIf( If_Man_t * pIfMan, Abc_Ntk_t * pNtk )
+{
+ ProgressBar * pProgress;
+ Abc_Ntk_t * pNtkNew;
+ Abc_Obj_t * pNode, * pNodeNew;
+ int i, nDupGates;
+ // create the new network
+ pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_AIG );
+ // prepare the mapping manager
+ If_ManCleanNodeCopy( pIfMan );
+ If_ManCleanCutData( pIfMan );
+ // make the mapper point to the new network
+ If_ObjSetCopy( If_ManConst1(pIfMan), Abc_NtkCreateNodeConst1(pNtkNew) );
+ Abc_NtkForEachCi( pNtk, pNode, i )
+ If_ObjSetCopy( If_ManPi(pIfMan, i), pNode->pCopy );
+ // process the nodes in topological order
+ pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
+ Abc_NtkForEachCo( pNtk, pNode, i )
+ {
+ Extra_ProgressBarUpdate( pProgress, i, NULL );
+ pNodeNew = Abc_NodeFromIf_rec( pNtkNew, pIfMan, If_ObjFanin0(If_ManPo(pIfMan, i)) );
+ pNodeNew = Abc_ObjNotCond( pNodeNew, If_ObjFaninC0(If_ManPo(pIfMan, i)) );
+ Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
+ }
+ Extra_ProgressBarStop( pProgress );
+ // remove the constant node if not used
+ pNodeNew = (Abc_Obj_t *)If_ObjCopy( If_ManConst1(pIfMan) );
+ if ( Abc_ObjFanoutNum(pNodeNew) == 0 )
+ Abc_NtkDeleteObj( pNodeNew );
+ // decouple the PO driver nodes to reduce the number of levels
+ nDupGates = Abc_NtkLogicMakeSimpleCos( pNtkNew, 1 );
+// if ( nDupGates && If_ManReadVerbose(pIfMan) )
+// printf( "Duplicated %d gates to decouple the CO drivers.\n", nDupGates );
+ return pNtkNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derive one node after FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t * pIfObj )
+{
+ Abc_Obj_t * pNodeNew;
+ If_Cut_t * pCutBest;
+ If_Obj_t * pIfLeaf;
+ int i;
+ // return if the result if known
+ pNodeNew = (Abc_Obj_t *)If_ObjCopy( pIfObj );
+ if ( pNodeNew )
+ return pNodeNew;
+ assert( pIfObj->Type == IF_AND );
+ // get the parameters of the best cut
+ // create a new node
+ pNodeNew = Abc_NtkCreateNode( pNtkNew );
+ pCutBest = If_ObjCutBest( pIfObj );
+ If_CutForEachLeaf( pIfMan, pCutBest, pIfLeaf, i )
+ Abc_ObjAddFanin( pNodeNew, Abc_NodeFromIf_rec(pNtkNew, pIfMan, pIfLeaf) );
+ // derive the function of this node
+ pNodeNew->pData = Abc_NodeIfToHop( pNtkNew->pManFunc, pIfMan, pCutBest );
+ If_ObjSetCopy( pIfObj, pNodeNew );
+ return pNodeNew;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Recursively derives the truth table for the cut.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Hop_Obj_t * Abc_NodeIfToHop_rec( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Cut_t * pCut, Vec_Ptr_t * vVisited )
+{
+ Hop_Obj_t * gFunc, * gFunc0, * gFunc1;
+ // if the cut is visited, return the result
+ if ( If_CutData(pCut) )
+ return If_CutData(pCut);
+ // compute the functions of the children
+ gFunc0 = Abc_NodeIfToHop_rec( pHopMan, pIfMan, pCut->pOne, vVisited );
+ gFunc1 = Abc_NodeIfToHop_rec( pHopMan, pIfMan, pCut->pTwo, vVisited );
+ // get the function of the cut
+ gFunc = Hop_And( pHopMan, Hop_NotCond(gFunc0, pCut->fCompl0), Hop_NotCond(gFunc1, pCut->fCompl1) );
+ gFunc = Hop_NotCond( gFunc, pCut->Phase );
+ assert( If_CutData(pCut) == NULL );
+ If_CutSetData( pCut, gFunc );
+ // add this cut to the visited list
+ Vec_PtrPush( vVisited, pCut );
+ return gFunc;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the truth table for one cut.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Hop_Obj_t * Abc_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Cut_t * pCut )
+{
+ Hop_Obj_t * gFunc;
+ If_Obj_t * pLeaf;
+ int i;
+ assert( pCut->nLeaves > 1 );
+ // set the leaf variables
+ If_CutForEachLeaf( pIfMan, pCut, pLeaf, i )
+ If_CutSetData( If_ObjCutTriv(pLeaf), Hop_IthVar(pHopMan, i) );
+ // recursively compute the function while collecting visited cuts
+ Vec_PtrClear( pIfMan->vTemp );
+ gFunc = Abc_NodeIfToHop_rec( pHopMan, pIfMan, pCut, pIfMan->vTemp );
+// printf( "%d ", Vec_PtrSize(p->vTemp) );
+ // clean the cuts
+ If_CutForEachLeaf( pIfMan, pCut, pLeaf, i )
+ If_CutSetData( If_ObjCutTriv(pLeaf), NULL );
+ Vec_PtrForEachEntry( pIfMan->vTemp, pCut, i )
+ If_CutSetData( pCut, NULL );
+ return gFunc;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/base/abci/abcIvy.c b/src/base/abci/abcIvy.c
index 30ed21cf..be8b8ec5 100644
--- a/src/base/abci/abcIvy.c
+++ b/src/base/abci/abcIvy.c
@@ -53,6 +53,8 @@ static inline Abc_Obj_t * Abc_ObjFanin1Ivy( Abc_Ntk_t * p, Ivy_Obj_t * pObj ) {
static Vec_Int_t * Abc_NtkCollectLatchValuesIvy( Abc_Ntk_t * pNtk, int fUseDcs );
+extern int timeRetime;
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -72,6 +74,7 @@ Ivy_Man_t * Abc_NtkIvyBefore( Abc_Ntk_t * pNtk, int fSeq, int fUseDc )
{
Ivy_Man_t * pMan;
int fCleanup = 1;
+//timeRetime = clock();
assert( !Abc_NtkIsNetlist(pNtk) );
assert( !Abc_NtkIsSeq(pNtk) );
if ( Abc_NtkIsBddLogic(pNtk) )
@@ -107,6 +110,7 @@ Ivy_Man_t * Abc_NtkIvyBefore( Abc_Ntk_t * pNtk, int fSeq, int fUseDc )
Vec_IntFree( vInit );
// Ivy_ManPrintStats( pMan );
}
+//timeRetime = clock() - timeRetime;
return pMan;
}
@@ -184,17 +188,22 @@ Abc_Ntk_t * Abc_NtkIvyHaig( Abc_Ntk_t * pNtk, int nIters, int fUseZeroCost, int
{
Abc_Ntk_t * pNtkAig;
Ivy_Man_t * pMan;
- int i;
+// int i;
pMan = Abc_NtkIvyBefore( pNtk, 1, 1 );
if ( pMan == NULL )
return NULL;
+//timeRetime = clock();
Ivy_ManHaigStart( pMan, fVerbose );
// Ivy_ManRewriteSeq( pMan, 0, 0 );
- for ( i = 0; i < nIters; i++ )
- Ivy_ManRewriteSeq( pMan, fUseZeroCost, 0 );
- Ivy_ManHaigPostprocess( pMan, fVerbose );
+// for ( i = 0; i < nIters; i++ )
+// Ivy_ManRewriteSeq( pMan, fUseZeroCost, 0 );
+ Ivy_ManRewriteSeq( pMan, 0, 0 );
+ Ivy_ManRewriteSeq( pMan, 1, 0 );
+//printf( "Haig size = %d.\n", Ivy_ManNodeNum(pMan->pHaig) );
+// Ivy_ManHaigPostprocess( pMan, fVerbose );
+//timeRetime = clock() - timeRetime;
// write working AIG into the current network
// pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 1, 0 );
@@ -246,7 +255,9 @@ Abc_Ntk_t * Abc_NtkIvyRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeroC
pMan = Abc_NtkIvyBefore( pNtk, 0, 0 );
if ( pMan == NULL )
return NULL;
+//timeRetime = clock();
Ivy_ManRewritePre( pMan, fUpdateLevel, fUseZeroCost, fVerbose );
+//timeRetime = clock() - timeRetime;
pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 0, 0 );
Ivy_ManStop( pMan );
return pNtkAig;
@@ -270,7 +281,9 @@ Abc_Ntk_t * Abc_NtkIvyRewriteSeq( Abc_Ntk_t * pNtk, int fUseZeroCost, int fVerbo
pMan = Abc_NtkIvyBefore( pNtk, 1, 1 );
if ( pMan == NULL )
return NULL;
+//timeRetime = clock();
Ivy_ManRewriteSeq( pMan, fUseZeroCost, fVerbose );
+//timeRetime = clock() - timeRetime;
// Ivy_ManRewriteSeq( pMan, 1, 0 );
// Ivy_ManRewriteSeq( pMan, 1, 0 );
pNtkAig = Abc_NtkIvyAfter( pNtk, pMan, 1, 0 );
diff --git a/src/base/abci/abcLut.c b/src/base/abci/abcLut.c
index 61b1ce78..afa76cc8 100644
--- a/src/base/abci/abcLut.c
+++ b/src/base/abci/abcLut.c
@@ -104,7 +104,7 @@ int Abc_NtkSuperChoiceLut( Abc_Ntk_t * pNtk, int nLutSize, int nCutSizeMax, int
Abc_NtkForEachCi( pNtk, pObj, i )
pObj->Level = 0;
-//Abc_NtkGetLevelNum( pNtk );
+//Abc_NtkLevel( pNtk );
// start the managers
pManScl = Abc_ManSclStart( nLutSize, nCutSizeMax, 1000 );
diff --git a/src/base/abci/abcMini.c b/src/base/abci/abcMini.c
index 014eafd3..dc90bee0 100644
--- a/src/base/abci/abcMini.c
+++ b/src/base/abci/abcMini.c
@@ -24,8 +24,8 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static Aig_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtk );
-static Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan );
+static Hop_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtk );
+static Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtkOld, Hop_Man_t * pMan );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -45,29 +45,29 @@ static Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan );
Abc_Ntk_t * Abc_NtkMiniBalance( Abc_Ntk_t * pNtk )
{
Abc_Ntk_t * pNtkAig;
- Aig_Man_t * pMan, * pTemp;
+ Hop_Man_t * pMan, * pTemp;
assert( Abc_NtkIsStrash(pNtk) );
// convert to the AIG manager
pMan = Abc_NtkToAig( pNtk );
if ( pMan == NULL )
return NULL;
- if ( !Aig_ManCheck( pMan ) )
+ if ( !Hop_ManCheck( pMan ) )
{
printf( "AIG check has failed.\n" );
- Aig_ManStop( pMan );
+ Hop_ManStop( pMan );
return NULL;
}
// perform balance
- Aig_ManPrintStats( pMan );
-// Aig_ManDumpBlif( pMan, "aig_temp.blif" );
- pMan = Aig_ManBalance( pTemp = pMan, 1 );
- Aig_ManStop( pTemp );
- Aig_ManPrintStats( pMan );
+ Hop_ManPrintStats( pMan );
+// Hop_ManDumpBlif( pMan, "aig_temp.blif" );
+ pMan = Hop_ManBalance( pTemp = pMan, 1 );
+ Hop_ManStop( pTemp );
+ Hop_ManPrintStats( pMan );
// convert from the AIG manager
pNtkAig = Abc_NtkFromAig( pNtk, pMan );
if ( pNtkAig == NULL )
return NULL;
- Aig_ManStop( pMan );
+ Hop_ManStop( pMan );
// make sure everything is okay
if ( !Abc_NtkCheck( pNtkAig ) )
{
@@ -89,24 +89,24 @@ Abc_Ntk_t * Abc_NtkMiniBalance( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-Aig_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtk )
+Hop_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtk )
{
- Aig_Man_t * pMan;
+ Hop_Man_t * pMan;
Abc_Obj_t * pObj;
int i;
// create the manager
- pMan = Aig_ManStart();
+ pMan = Hop_ManStart();
// transfer the pointers to the basic nodes
- Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)Aig_ManConst1(pMan);
+ Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)Hop_ManConst1(pMan);
Abc_NtkForEachCi( pNtk, pObj, i )
- pObj->pCopy = (Abc_Obj_t *)Aig_ObjCreatePi(pMan);
+ pObj->pCopy = (Abc_Obj_t *)Hop_ObjCreatePi(pMan);
// perform the conversion of the internal nodes (assumes DFS ordering)
Abc_NtkForEachNode( pNtk, pObj, i )
- pObj->pCopy = (Abc_Obj_t *)Aig_And( pMan, (Aig_Obj_t *)Abc_ObjChild0Copy(pObj), (Aig_Obj_t *)Abc_ObjChild1Copy(pObj) );
+ pObj->pCopy = (Abc_Obj_t *)Hop_And( pMan, (Hop_Obj_t *)Abc_ObjChild0Copy(pObj), (Hop_Obj_t *)Abc_ObjChild1Copy(pObj) );
// create the POs
Abc_NtkForEachCo( pNtk, pObj, i )
- Aig_ObjCreatePo( pMan, (Aig_Obj_t *)Abc_ObjChild0Copy(pObj) );
- Aig_ManCleanup( pMan );
+ Hop_ObjCreatePo( pMan, (Hop_Obj_t *)Abc_ObjChild0Copy(pObj) );
+ Hop_ManCleanup( pMan );
return pMan;
}
@@ -121,26 +121,26 @@ Aig_Man_t * Abc_NtkToAig( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtk, Aig_Man_t * pMan )
+Abc_Ntk_t * Abc_NtkFromAig( Abc_Ntk_t * pNtk, Hop_Man_t * pMan )
{
Vec_Ptr_t * vNodes;
Abc_Ntk_t * pNtkNew;
- Aig_Obj_t * pObj;
+ Hop_Obj_t * pObj;
int i;
// perform strashing
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
// transfer the pointers to the basic nodes
- Aig_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew);
- Aig_ManForEachPi( pMan, pObj, i )
+ Hop_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew);
+ Hop_ManForEachPi( pMan, pObj, i )
pObj->pData = Abc_NtkCi(pNtkNew, i);
// rebuild the AIG
- vNodes = Aig_ManDfs( pMan );
+ vNodes = Hop_ManDfs( pMan );
Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
+ pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Hop_ObjChild0Copy(pObj), (Abc_Obj_t *)Hop_ObjChild1Copy(pObj) );
Vec_PtrFree( vNodes );
// connect the PO nodes
- Aig_ManForEachPo( pMan, pObj, i )
- Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), (Abc_Obj_t *)Aig_ObjChild0Copy(pObj) );
+ Hop_ManForEachPo( pMan, pObj, i )
+ Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), (Abc_Obj_t *)Hop_ObjChild0Copy(pObj) );
if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkFromAig(): Network check has failed.\n" );
return pNtkNew;
diff --git a/src/base/abci/abcNtbdd.c b/src/base/abci/abcNtbdd.c
index f99f7bce..bd035eb0 100644
--- a/src/base/abci/abcNtbdd.c
+++ b/src/base/abci/abcNtbdd.c
@@ -27,7 +27,7 @@
static void Abc_NtkBddToMuxesPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew );
static Abc_Obj_t * Abc_NodeBddToMuxes( Abc_Obj_t * pNodeOld, Abc_Ntk_t * pNtkNew );
static Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t * pNtkNew, st_table * tBdd2Node );
-static DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSizeMax, ProgressBar * pProgress, int * pCounter, int fVerbose );
+static DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSizeMax, int fDropInternal, ProgressBar * pProgress, int * pCounter, int fVerbose );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -243,85 +243,63 @@ Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t *
SeeAlso []
***********************************************************************/
-DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly, int fReorder, int fVerbose )
+DdManager * Abc_NtkBuildGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fDropInternal, int fReorder, int fVerbose )
{
ProgressBar * pProgress;
- Vec_Ptr_t * vFuncsGlob;
Abc_Obj_t * pObj, * pFanin;
- DdNode * bFunc;
+ Vec_Att_t * pAttMan;
DdManager * dd;
+ DdNode * bFunc;
int i, k, Counter;
// remove dangling nodes
Abc_AigCleanup( pNtk->pManFunc );
// start the manager
- assert( pNtk->pManGlob == NULL );
+ assert( Abc_NtkGlobalBdds(pNtk) == NULL );
dd = Cudd_Init( Abc_NtkCiNum(pNtk), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
+ pAttMan = Vec_AttAlloc( 0, Abc_NtkObjNumMax(pNtk) + 1, dd, Extra_StopManager, NULL, Cudd_RecursiveDeref );
+ Vec_PtrWriteEntry( pNtk->vAttrs, VEC_ATTR_GLOBAL_BDD, pAttMan );
+
// set reordering
if ( fReorder )
Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT );
- // clean storage for local BDDs
- Abc_NtkCleanCopy( pNtk );
- // set the elementary variables
- Abc_NtkForEachCi( pNtk, pObj, i )
- if ( Abc_ObjFanoutNum(pObj) > 0 )
- {
- pObj->pCopy = (Abc_Obj_t *)dd->vars[i];
- Cudd_Ref( dd->vars[i] );
- }
// assign the constant node BDD
pObj = Abc_AigConst1(pNtk);
if ( Abc_ObjFanoutNum(pObj) > 0 )
{
- pObj->pCopy = (Abc_Obj_t *)dd->one;
+ Abc_ObjSetGlobalBdd( pObj, dd->one );
Cudd_Ref( dd->one );
}
+ // set the elementary variables
+ Abc_NtkForEachCi( pNtk, pObj, i )
+ if ( Abc_ObjFanoutNum(pObj) > 0 )
+ {
+ Abc_ObjSetGlobalBdd( pObj, dd->vars[i] );
+ Cudd_Ref( dd->vars[i] );
+ }
// collect the global functions of the COs
Counter = 0;
- vFuncsGlob = Vec_PtrAlloc( 100 );
- if ( fLatchOnly )
+ // construct the BDDs
+ pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) );
+ Abc_NtkForEachCo( pNtk, pObj, i )
{
- // construct the BDDs
- pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) );
- Abc_NtkForEachLatchInput( pNtk, pObj, i )
+ bFunc = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin0(pObj), nBddSizeMax, fDropInternal, pProgress, &Counter, fVerbose );
+ if ( bFunc == NULL )
{
- bFunc = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin0(pObj), nBddSizeMax, pProgress, &Counter, fVerbose );
- if ( bFunc == NULL )
- {
- if ( fVerbose )
- printf( "Constructing global BDDs is aborted.\n" );
- Vec_PtrFree( vFuncsGlob );
- Cudd_Quit( dd );
- return NULL;
- }
- bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pObj) ); Cudd_Ref( bFunc );
- Vec_PtrPush( vFuncsGlob, bFunc );
- }
- Extra_ProgressBarStop( pProgress );
- }
- else
- {
- // construct the BDDs
- pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) );
- Abc_NtkForEachCo( pNtk, pObj, i )
- {
- bFunc = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin0(pObj), nBddSizeMax, pProgress, &Counter, fVerbose );
- if ( bFunc == NULL )
- {
- if ( fVerbose )
- printf( "Constructing global BDDs is aborted.\n" );
- Vec_PtrFree( vFuncsGlob );
- Cudd_Quit( dd );
- return NULL;
- }
- bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pObj) ); Cudd_Ref( bFunc );
- Vec_PtrPush( vFuncsGlob, bFunc );
+ if ( fVerbose )
+ printf( "Constructing global BDDs is aborted.\n" );
+ Abc_NtkFreeGlobalBdds( pNtk, 0 );
+ Cudd_Quit( dd );
+ return NULL;
}
- Extra_ProgressBarStop( pProgress );
+ bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pObj) ); Cudd_Ref( bFunc );
+ Abc_ObjSetGlobalBdd( pObj, bFunc );
}
+ Extra_ProgressBarStop( pProgress );
+
/*
// derefence the intermediate BDDs
Abc_NtkForEachNode( pNtk, pObj, i )
@@ -336,9 +314,9 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
Abc_NtkForEachObj( pNtk, pObj, i )
{
if ( pObj->pCopy != NULL )
- printf( "Abc_NtkGlobalBdds() error: Node %d has BDD assigned\n", pObj->Id );
+ printf( "Abc_NtkBuildGlobalBdds() error: Node %d has BDD assigned\n", pObj->Id );
if ( pObj->vFanouts.nSize > 0 )
- printf( "Abc_NtkGlobalBdds() error: Node %d has refs assigned\n", pObj->Id );
+ printf( "Abc_NtkBuildGlobalBdds() error: Node %d has refs assigned\n", pObj->Id );
}
*/
// reset references
@@ -353,8 +331,6 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 );
Cudd_AutodynDisable( dd );
}
- pNtk->pManGlob = dd;
- pNtk->vFuncsGlob = vFuncsGlob;
// Cudd_PrintInfo( dd, stdout );
return dd;
}
@@ -370,9 +346,10 @@ DdManager * Abc_NtkGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fLatchOnly
SeeAlso []
***********************************************************************/
-DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSizeMax, ProgressBar * pProgress, int * pCounter, int fVerbose )
+DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSizeMax, int fDropInternal, ProgressBar * pProgress, int * pCounter, int fVerbose )
{
DdNode * bFunc, * bFunc0, * bFunc1, * bFuncC;
+ int fDetectMuxes = 1;
assert( !Abc_ObjIsComplement(pNode) );
if ( Cudd_ReadKeys(dd)-Cudd_ReadDead(dd) > (unsigned)nBddSizeMax )
{
@@ -383,14 +360,14 @@ DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSize
return NULL;
}
// if the result is available return
- if ( pNode->pCopy == NULL )
+ if ( Abc_ObjGlobalBdd(pNode) == NULL )
{
Abc_Obj_t * pNodeC, * pNode0, * pNode1;
pNode0 = Abc_ObjFanin0(pNode);
pNode1 = Abc_ObjFanin1(pNode);
// check for the special case when it is MUX/EXOR
-// if ( 0 )
- if ( pNode0->pCopy == NULL && pNode1->pCopy == NULL &&
+ if ( fDetectMuxes &&
+ Abc_ObjGlobalBdd(pNode0) == NULL && Abc_ObjGlobalBdd(pNode1) == NULL &&
Abc_ObjIsNode(pNode0) && Abc_ObjFanoutNum(pNode0) == 1 &&
Abc_ObjIsNode(pNode1) && Abc_ObjFanoutNum(pNode1) == 1 &&
Abc_NodeIsMuxType(pNode) )
@@ -405,15 +382,15 @@ DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSize
pNodeC->vFanouts.nSize--;
// compute the result for all branches
- bFuncC = Abc_NodeGlobalBdds_rec( dd, pNodeC, nBddSizeMax, pProgress, pCounter, fVerbose );
+ bFuncC = Abc_NodeGlobalBdds_rec( dd, pNodeC, nBddSizeMax, fDropInternal, pProgress, pCounter, fVerbose );
if ( bFuncC == NULL )
return NULL;
Cudd_Ref( bFuncC );
- bFunc0 = Abc_NodeGlobalBdds_rec( dd, Abc_ObjRegular(pNode0), nBddSizeMax, pProgress, pCounter, fVerbose );
+ bFunc0 = Abc_NodeGlobalBdds_rec( dd, Abc_ObjRegular(pNode0), nBddSizeMax, fDropInternal, pProgress, pCounter, fVerbose );
if ( bFunc0 == NULL )
return NULL;
Cudd_Ref( bFunc0 );
- bFunc1 = Abc_NodeGlobalBdds_rec( dd, Abc_ObjRegular(pNode1), nBddSizeMax, pProgress, pCounter, fVerbose );
+ bFunc1 = Abc_NodeGlobalBdds_rec( dd, Abc_ObjRegular(pNode1), nBddSizeMax, fDropInternal, pProgress, pCounter, fVerbose );
if ( bFunc1 == NULL )
return NULL;
Cudd_Ref( bFunc1 );
@@ -432,11 +409,11 @@ DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSize
else
{
// compute the result for both branches
- bFunc0 = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin(pNode,0), nBddSizeMax, pProgress, pCounter, fVerbose );
+ bFunc0 = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin(pNode,0), nBddSizeMax, fDropInternal, pProgress, pCounter, fVerbose );
if ( bFunc0 == NULL )
return NULL;
Cudd_Ref( bFunc0 );
- bFunc1 = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin(pNode,1), nBddSizeMax, pProgress, pCounter, fVerbose );
+ bFunc1 = Abc_NodeGlobalBdds_rec( dd, Abc_ObjFanin(pNode,1), nBddSizeMax, fDropInternal, pProgress, pCounter, fVerbose );
if ( bFunc1 == NULL )
return NULL;
Cudd_Ref( bFunc1 );
@@ -450,26 +427,26 @@ DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSize
(*pCounter)++;
}
// set the result
- assert( pNode->pCopy == NULL );
- pNode->pCopy = (Abc_Obj_t *)bFunc;
+ assert( Abc_ObjGlobalBdd(pNode) == NULL );
+ Abc_ObjSetGlobalBdd( pNode, bFunc );
// increment the progress bar
if ( pProgress )
Extra_ProgressBarUpdate( pProgress, *pCounter, NULL );
}
// prepare the return value
- bFunc = (DdNode *)pNode->pCopy;
+ bFunc = Abc_ObjGlobalBdd(pNode);
// dereference BDD at the node
- if ( --pNode->vFanouts.nSize == 0 )
+ if ( --pNode->vFanouts.nSize == 0 && fDropInternal )
{
Cudd_Deref( bFunc );
- pNode->pCopy = NULL;
+ Abc_ObjSetGlobalBdd( pNode, NULL );
}
return bFunc;
}
/**Function*************************************************************
- Synopsis [Dereferences global BDDs of the network.]
+ Synopsis [Frees the global BDDs of the network.]
Description []
@@ -478,16 +455,9 @@ DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSize
SeeAlso []
***********************************************************************/
-void Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk )
-{
- DdNode * bFunc;
- int i;
- assert( pNtk->pManGlob );
- assert( pNtk->vFuncsGlob );
- Vec_PtrForEachEntry( pNtk->vFuncsGlob, bFunc, i )
- Cudd_RecursiveDeref( pNtk->pManGlob, bFunc );
- Vec_PtrFree( pNtk->vFuncsGlob );
- pNtk->vFuncsGlob = NULL;
+DdManager * Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk, int fFreeMan )
+{
+ return Abc_NtkAttrFree( pNtk, VEC_ATTR_GLOBAL_BDD, fFreeMan );
}
/**Function*************************************************************
@@ -503,6 +473,7 @@ void Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk )
***********************************************************************/
double Abc_NtkSpacePercentage( Abc_Obj_t * pNode )
{
+ /*
Vec_Ptr_t * vNodes;
Abc_Obj_t * pObj, * pNodeR;
DdManager * dd;
@@ -521,7 +492,7 @@ double Abc_NtkSpacePercentage( Abc_Obj_t * pNode )
Vec_PtrForEachEntry( vNodes, pObj, i )
pObj->pCopy = (Abc_Obj_t *)dd->vars[i];
// build the BDD of the cone
- bFunc = Abc_NodeGlobalBdds_rec( dd, pNodeR, 10000000, NULL, NULL, 1 ); Cudd_Ref( bFunc );
+ bFunc = Abc_NodeGlobalBdds_rec( dd, pNodeR, 10000000, 1, NULL, NULL, 1 ); Cudd_Ref( bFunc );
bFunc = Cudd_NotCond( bFunc, pNode != pNodeR );
// count minterms
Result = Cudd_CountMinterm( dd, bFunc, dd->size );
@@ -533,6 +504,8 @@ double Abc_NtkSpacePercentage( Abc_Obj_t * pNode )
Cudd_Quit( dd );
Vec_PtrFree( vNodes );
return Result;
+ */
+ return 0.0;
}
diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c
index bdca4a8e..40bf30a6 100644
--- a/src/base/abci/abcPrint.c
+++ b/src/base/abci/abcPrint.c
@@ -113,9 +113,9 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
}
if ( Abc_NtkIsStrash(pNtk) )
- fprintf( pFile, " lev = %3d", Abc_AigGetLevelNum(pNtk) );
+ fprintf( pFile, " lev = %3d", Abc_AigLevel(pNtk) );
else if ( !Abc_NtkIsSeq(pNtk) )
- fprintf( pFile, " lev = %3d", Abc_NtkGetLevelNum(pNtk) );
+ fprintf( pFile, " lev = %3d", Abc_NtkLevel(pNtk) );
fprintf( pFile, "\n" );
// print the statistic into a file
@@ -126,7 +126,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
fprintf( pTable, "%s ", pNtk->pName );
fprintf( pTable, "%d ", Abc_NtkPiNum(pNtk) );
fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
- fprintf( pTable, "%d ", Abc_AigGetLevelNum(pNtk) );
+ fprintf( pTable, "%d ", Abc_AigLevel(pNtk) );
fprintf( pTable, "\n" );
fclose( pTable );
}
@@ -150,7 +150,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
FILE * pTable;
pTable = fopen( "fpga/fpga_stats.txt", "a+" );
fprintf( pTable, "%s ", pNtk->pName );
- fprintf( pTable, "%d ", Abc_NtkGetLevelNum(pNtk) );
+ fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
fprintf( pTable, "%.2f ", (float)(s_MappingMem)/(float)(1<<20) );
fprintf( pTable, "%.2f", (float)(s_MappingTime)/(float)(CLOCKS_PER_SEC) );
@@ -159,23 +159,41 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
}
*/
-/*
+
// print the statistic into a file
{
static int Counter = 0;
extern int timeRetime;
FILE * pTable;
Counter++;
- pTable = fopen( "sap/stats_retime.txt", "a+" );
+ pTable = fopen( "a/ret__stats.txt", "a+" );
fprintf( pTable, "%s ", pNtk->pName );
fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
fprintf( pTable, "%d ", Abc_NtkLatchNum(pNtk) );
- fprintf( pTable, "%d ", Abc_NtkGetLevelNum(pNtk) );
+ fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
fprintf( pTable, "%.2f ", (float)(timeRetime)/(float)(CLOCKS_PER_SEC) );
if ( Counter % 4 == 0 )
fprintf( pTable, "\n" );
fclose( pTable );
}
+
+/*
+ // print the statistic into a file
+ {
+ static int Counter = 0;
+ extern int timeRetime;
+ FILE * pTable;
+ Counter++;
+ pTable = fopen( "d/stats.txt", "a+" );
+ fprintf( pTable, "%s ", pNtk->pName );
+// fprintf( pTable, "%d ", Abc_NtkPiNum(pNtk) );
+// fprintf( pTable, "%d ", Abc_NtkPoNum(pNtk) );
+// fprintf( pTable, "%d ", Abc_NtkLatchNum(pNtk) );
+ fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
+ fprintf( pTable, "%.2f ", (float)(timeRetime)/(float)(CLOCKS_PER_SEC) );
+ fprintf( pTable, "\n" );
+ fclose( pTable );
+ }
*/
/*
@@ -214,7 +232,8 @@ void Abc_NtkPrintIo( FILE * pFile, Abc_Ntk_t * pNtk )
fprintf( pFile, "Latches (%d): ", Abc_NtkLatchNum(pNtk) );
Abc_NtkForEachLatch( pNtk, pObj, i )
- fprintf( pFile, " %s", Abc_ObjName(pObj) );
+ fprintf( pFile, " %s(%s=%s)", Abc_ObjName(pObj),
+ Abc_ObjName(Abc_ObjFanout0(pObj)), Abc_ObjName(Abc_ObjFanin0(pObj)) );
fprintf( pFile, "\n" );
}
@@ -500,7 +519,7 @@ void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile, int fListN
if ( fListNodes )
{
int nLevels;
- nLevels = Abc_NtkGetLevelNum(pNtk);
+ nLevels = Abc_NtkLevel(pNtk);
printf( "Nodes by level:\n" );
for ( i = 0; i <= nLevels; i++ )
{
@@ -553,7 +572,7 @@ void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile, int fListN
int nOutsSum, nOutsTotal;
if ( !Abc_NtkIsStrash(pNtk) )
- Abc_NtkGetLevelNum(pNtk);
+ Abc_NtkLevel(pNtk);
LevelMax = 0;
Abc_NtkForEachCo( pNtk, pNode, i )
@@ -840,41 +859,6 @@ void Abc_NtkPrintStrSupports( Abc_Ntk_t * pNtk )
/**Function*************************************************************
- Synopsis [Prints information about the clock skew schedule.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abc_NtkPrintSkews( FILE * pFile, Abc_Ntk_t * pNtk, int fPrintAll ) {
-
- Abc_Obj_t * pObj;
- int i;
- int nNonZero = 0;
- float skew, sum = 0.0, avg;
-
- if (fPrintAll) fprintf( pFile, "Full Clock Skew Schedule:\n\tGlobal Skew = %.2f\n", pNtk->globalSkew );
-
- Abc_NtkForEachLatch( pNtk, pObj, i ) {
- skew = Abc_NtkGetLatSkew( pNtk, i );
- if ( skew != 0.0 ) {
- nNonZero++;
- sum += ABS( skew );
- }
- if (fPrintAll) fprintf( pFile, "\tLatch %d (Id = %d) \t Endpoint Skew = %.2f\n", i, pObj->Id, skew);
- }
-
- avg = sum / Abc_NtkLatchNum( pNtk );
-
- fprintf( pFile, "Endpoint Skews : Total |Skew| = %.2f\t Avg |Skew| = %.2f\t Non-Zero Skews = %d\n",
- sum, avg, nNonZero );
-}
-
-/**Function*************************************************************
-
Synopsis [Prints information about the object.]
Description []
@@ -942,6 +926,12 @@ void Abc_ObjPrint( FILE * pFile, Abc_Obj_t * pObj )
Abc_ObjForEachFanin( pObj, pFanin, i )
fprintf( pFile, "%d ", pFanin->Id );
fprintf( pFile, ") " );
+/*
+ fprintf( pFile, " Fanouts ( " );
+ Abc_ObjForEachFanout( pObj, pFanin, i )
+ fprintf( pFile, "%d(%c) ", pFanin->Id, Abc_NodeIsTravIdCurrent(pFanin)? '+' : '-' );
+ fprintf( pFile, ") " );
+*/
// print the logic function
if ( Abc_ObjIsNode(pObj) && Abc_NtkIsSopLogic(pObj->pNtk) )
fprintf( pFile, " %s", pObj->pData );
diff --git a/src/base/abci/abcProve.c b/src/base/abci/abcProve.c
index c9e5bfd7..fcd44d30 100644
--- a/src/base/abci/abcProve.c
+++ b/src/base/abci/abcProve.c
@@ -310,7 +310,7 @@ void Abc_NtkMiterPrint( Abc_Ntk_t * pNtk, char * pString, int clk, int fVerbose
if ( !fVerbose )
return;
printf( "Nodes = %7d. Levels = %4d. ", Abc_NtkNodeNum(pNtk),
- Abc_NtkIsStrash(pNtk)? Abc_AigGetLevelNum(pNtk) : Abc_NtkGetLevelNum(pNtk) );
+ Abc_NtkIsStrash(pNtk)? Abc_AigLevel(pNtk) : Abc_NtkLevel(pNtk) );
PRT( pString, clock() - clk );
}
diff --git a/src/base/abci/abcRefactor.c b/src/base/abci/abcRefactor.c
index 3d301cd6..0328d8d3 100644
--- a/src/base/abci/abcRefactor.c
+++ b/src/base/abci/abcRefactor.c
@@ -156,7 +156,7 @@ pManRef->timeTotal = clock() - clkStart;
if ( fUpdateLevel )
Abc_NtkStopReverseLevels( pNtk );
else
- Abc_NtkGetLevelNum( pNtk );
+ Abc_NtkLevel( pNtk );
// check
if ( !Abc_NtkCheck( pNtk ) )
{
diff --git a/src/base/abci/abcRestruct.c b/src/base/abci/abcRestruct.c
index 9dc84999..2d4f50fb 100644
--- a/src/base/abci/abcRestruct.c
+++ b/src/base/abci/abcRestruct.c
@@ -183,7 +183,7 @@ pManRst->timeTotal = clock() - clkStart;
if ( fUpdateLevel )
Abc_NtkStopReverseLevels( pNtk );
else
- Abc_NtkGetLevelNum( pNtk );
+ Abc_NtkLevel( pNtk );
// check
if ( !Abc_NtkCheck( pNtk ) )
{
diff --git a/src/base/abci/abcResub.c b/src/base/abci/abcResub.c
index 9fcc6979..19e6c50a 100644
--- a/src/base/abci/abcResub.c
+++ b/src/base/abci/abcResub.c
@@ -232,7 +232,7 @@ pManRes->timeTotal = clock() - clkStart;
if ( fUpdateLevel )
Abc_NtkStopReverseLevels( pNtk );
else
- Abc_NtkGetLevelNum( pNtk );
+ Abc_NtkLevel( pNtk );
// check
if ( !Abc_NtkCheck( pNtk ) )
{
diff --git a/src/base/abci/abcRewrite.c b/src/base/abci/abcRewrite.c
index 2af10271..151b5256 100644
--- a/src/base/abci/abcRewrite.c
+++ b/src/base/abci/abcRewrite.c
@@ -158,7 +158,7 @@ Rwr_ManAddTimeTotal( pManRwr, clock() - clkStart );
if ( fUpdateLevel )
Abc_NtkStopReverseLevels( pNtk );
else
- Abc_NtkGetLevelNum( pNtk );
+ Abc_NtkLevel( pNtk );
// check
if ( !Abc_NtkCheck( pNtk ) )
{
diff --git a/src/base/abci/abcRr.c b/src/base/abci/abcRr.c
index 63beac6c..b9fab415 100644
--- a/src/base/abci/abcRr.c
+++ b/src/base/abci/abcRr.c
@@ -104,7 +104,7 @@ int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFa
p->nFaninLevels = nFaninLevels;
p->nFanoutLevels = nFanoutLevels;
p->nNodesOld = Abc_NtkNodeNum(pNtk);
- p->nLevelsOld = Abc_AigGetLevelNum(pNtk);
+ p->nLevelsOld = Abc_AigLevel(pNtk);
// remember latch values
// Abc_NtkForEachLatch( pNtk, pNode, i )
// pNode->pNext = pNode->pData;
@@ -220,7 +220,7 @@ int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFa
// pNode->pData = pNode->pNext, pNode->pNext = NULL;
// put the nodes into the DFS order and reassign their IDs
Abc_NtkReassignIds( pNtk );
- Abc_NtkGetLevelNum( pNtk );
+ Abc_NtkLevel( pNtk );
// check
if ( !Abc_NtkCheck( pNtk ) )
{
@@ -298,7 +298,7 @@ void Abc_RRManPrintStats( Abc_RRMan_t * p )
printf( "Edges tried = %6d.\n", p->nEdgesTried );
printf( "Edges removed = %6d. (%5.2f %%)\n", p->nEdgesRemoved, 100.0*p->nEdgesRemoved/p->nEdgesTried );
printf( "Node gain = %6d. (%5.2f %%)\n", p->nNodesOld - Abc_NtkNodeNum(p->pNtk), Ratio );
- printf( "Level gain = %6d.\n", p->nLevelsOld - Abc_AigGetLevelNum(p->pNtk) );
+ printf( "Level gain = %6d.\n", p->nLevelsOld - Abc_AigLevel(p->pNtk) );
PRT( "Windowing ", p->timeWindow );
PRT( "Miter ", p->timeMiter );
PRT( " Construct ", p->timeMiter - p->timeProve );
diff --git a/src/base/abci/abcSat.c b/src/base/abci/abcSat.c
index 8d5dd2a7..55498288 100644
--- a/src/base/abci/abcSat.c
+++ b/src/base/abci/abcSat.c
@@ -458,7 +458,7 @@ int Abc_NtkMiterSatCreateInt( solver * pSat, Abc_Ntk_t * pNtk, int fJFront )
int i, k, fUseMuxes = 1;
int clk1 = clock(), clk;
int fOrderCiVarsFirst = 0;
- int nLevelsMax = Abc_AigGetLevelNum(pNtk);
+ int nLevelsMax = Abc_AigLevel(pNtk);
int RetValue = 0;
assert( Abc_NtkIsStrash(pNtk) );
diff --git a/src/base/abci/abcStrash.c b/src/base/abci/abcStrash.c
index e8dc9793..a3719b10 100644
--- a/src/base/abci/abcStrash.c
+++ b/src/base/abci/abcStrash.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [aigStrash.c]
+ FileName [abcStrash.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,7 +14,7 @@
Date [Ver. 1.0. Started - June 20, 2005.]
- Revision [$Id: aigStrash.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+ Revision [$Id: abcStrash.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
@@ -46,10 +46,12 @@ static void Abc_NtkStrashPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, bool fA
***********************************************************************/
Abc_Ntk_t * Abc_NtkRestrash( Abc_Ntk_t * pNtk, bool fCleanup )
{
+ extern int timeRetime;
Abc_Ntk_t * pNtkAig;
Abc_Obj_t * pObj;
- int i, nNodes;
+ int i, nNodes, RetValue;
assert( Abc_NtkIsStrash(pNtk) );
+//timeRetime = clock();
// print warning about choice nodes
if ( Abc_NtkGetChoiceNum( pNtk ) )
printf( "Warning: The choice nodes in the original AIG are removed by strashing.\n" );
@@ -58,7 +60,7 @@ Abc_Ntk_t * Abc_NtkRestrash( Abc_Ntk_t * pNtk, bool fCleanup )
// restrash the nodes (assuming a topological order of the old network)
Abc_NtkForEachNode( pNtk, pObj, i )
pObj->pCopy = Abc_AigAnd( pNtkAig->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
- // finalize the network
+ //l finalize the network
Abc_NtkFinalize( pNtk, pNtkAig );
// print warning about self-feed latches
// if ( Abc_NtkCountSelfFeedLatches(pNtkAig) )
@@ -76,6 +78,9 @@ Abc_Ntk_t * Abc_NtkRestrash( Abc_Ntk_t * pNtk, bool fCleanup )
Abc_NtkDelete( pNtkAig );
return NULL;
}
+//timeRetime = clock() - timeRetime;
+ if ( RetValue = Abc_NtkRemoveSelfFeedLatches(pNtkAig) )
+ printf( "Modified %d self-feeding latches. The result will not verify.\n", RetValue );
return pNtkAig;
}
@@ -106,7 +111,7 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes, bool fCleanup )
return NULL;
}
// perform strashing
- Abc_NtkCleanCopy( pNtk );
+// Abc_NtkCleanCopy( pNtk );
pNtkAig = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
Abc_NtkStrashPerform( pNtk, pNtkAig, fAllNodes );
Abc_NtkFinalize( pNtk, pNtkAig );
@@ -205,13 +210,17 @@ int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fAddPos )
***********************************************************************/
void Abc_NtkStrashPerform( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew, bool fAllNodes )
{
+ extern Vec_Ptr_t * Abc_NtkDfsIter( Abc_Ntk_t * pNtk, int fCollectAll );
ProgressBar * pProgress;
Vec_Ptr_t * vNodes;
Abc_Obj_t * pNodeOld;
- int i;
+ int i, clk = clock();
assert( Abc_NtkIsLogic(pNtkOld) );
assert( Abc_NtkIsStrash(pNtkNew) );
- vNodes = Abc_NtkDfs( pNtkOld, fAllNodes );
+// vNodes = Abc_NtkDfs( pNtkOld, fAllNodes );
+ vNodes = Abc_NtkDfsIter( pNtkOld, fAllNodes );
+//printf( "Nodes = %d. ", Vec_PtrSize(vNodes) );
+//PRT( "Time", clock() - clk );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
Vec_PtrForEachEntry( vNodes, pNodeOld, i )
{
@@ -233,16 +242,16 @@ void Abc_NtkStrashPerform( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew, bool fAllNo
SeeAlso []
***********************************************************************/
-void Abc_NodeStrash_rec( Abc_Aig_t * pMan, Aig_Obj_t * pObj )
+void Abc_NodeStrash_rec( Abc_Aig_t * pMan, Hop_Obj_t * pObj )
{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
return;
- Abc_NodeStrash_rec( pMan, Aig_ObjFanin0(pObj) );
- Abc_NodeStrash_rec( pMan, Aig_ObjFanin1(pObj) );
- pObj->pData = Abc_AigAnd( pMan, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
- assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjSetMarkA( pObj );
+ Abc_NodeStrash_rec( pMan, Hop_ObjFanin0(pObj) );
+ Abc_NodeStrash_rec( pMan, Hop_ObjFanin1(pObj) );
+ pObj->pData = Abc_AigAnd( pMan, (Abc_Obj_t *)Hop_ObjChild0Copy(pObj), (Abc_Obj_t *)Hop_ObjChild1Copy(pObj) );
+ assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjSetMarkA( pObj );
}
/**Function*************************************************************
@@ -258,8 +267,8 @@ void Abc_NodeStrash_rec( Abc_Aig_t * pMan, Aig_Obj_t * pObj )
***********************************************************************/
Abc_Obj_t * Abc_NodeStrash( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld )
{
- Aig_Man_t * pMan;
- Aig_Obj_t * pRoot;
+ Hop_Man_t * pMan;
+ Hop_Obj_t * pRoot;
Abc_Obj_t * pFanin;
int i;
assert( Abc_ObjIsNode(pNodeOld) );
@@ -269,15 +278,15 @@ Abc_Obj_t * Abc_NodeStrash( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld )
pRoot = pNodeOld->pData;
// check the constant case
if ( Abc_NodeIsConst(pNodeOld) )
- return Abc_ObjNotCond( Abc_AigConst1(pNtkNew), Aig_IsComplement(pRoot) );
+ return Abc_ObjNotCond( Abc_AigConst1(pNtkNew), Hop_IsComplement(pRoot) );
// set elementary variables
Abc_ObjForEachFanin( pNodeOld, pFanin, i )
- Aig_IthVar(pMan, i)->pData = pFanin->pCopy;
+ Hop_IthVar(pMan, i)->pData = pFanin->pCopy;
// strash the AIG of this node
- Abc_NodeStrash_rec( pNtkNew->pManFunc, Aig_Regular(pRoot) );
- Aig_ConeUnmark_rec( Aig_Regular(pRoot) );
+ Abc_NodeStrash_rec( pNtkNew->pManFunc, Hop_Regular(pRoot) );
+ Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
// return the final node
- return Abc_ObjNotCond( Aig_Regular(pRoot)->pData, Aig_IsComplement(pRoot) );
+ return Abc_ObjNotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
@@ -328,7 +337,7 @@ Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels )
assert( Abc_NtkIsStrash(pNtk) );
assert( Abc_NtkCoNum(pNtk) == 1 );
// get the cutoff level
- LevelCut = ABC_MAX( 0, Abc_AigGetLevelNum(pNtk) - nLevels );
+ LevelCut = ABC_MAX( 0, Abc_AigLevel(pNtk) - nLevels );
// start the network
pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
diff --git a/src/base/abci/abcSweep.c b/src/base/abci/abcSweep.c
index db926d17..1b63b23c 100644
--- a/src/base/abci/abcSweep.c
+++ b/src/base/abci/abcSweep.c
@@ -79,7 +79,7 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose )
if ( fUseTrick )
{
extern void * Abc_FrameReadLibGen();
- Aig_ManStop( pNtk->pManFunc );
+ Hop_ManStop( pNtk->pManFunc );
pNtk->pManFunc = Abc_FrameReadLibGen();
pNtk->ntkFunc = ABC_FUNC_MAP;
Abc_NtkForEachNode( pNtk, pObj, i )
@@ -269,7 +269,7 @@ void Abc_NtkFraigTransform( Abc_Ntk_t * pNtk, stmm_table * tEquiv, int fUseInv,
if ( stmm_count(tEquiv) == 0 )
return;
// assign levels to the nodes of the network
- Abc_NtkGetLevelNum( pNtk );
+ Abc_NtkLevel( pNtk );
// merge nodes in the classes
if ( Abc_NtkHasMapping( pNtk ) )
{
@@ -897,7 +897,7 @@ int Abc_NtkReplaceAutonomousLogic( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-int Abc_NtkCleanupSeq( Abc_Ntk_t * pNtk, int fVerbose )
+int Abc_NtkCleanupSeq( Abc_Ntk_t * pNtk, int fLatchSweep, int fAutoSweep, int fVerbose )
{
Vec_Ptr_t * vNodes;
int Counter;
@@ -910,20 +910,26 @@ int Abc_NtkCleanupSeq( Abc_Ntk_t * pNtk, int fVerbose )
if ( fVerbose )
printf( "Cleanup removed %4d dangling objects.\n", Counter );
// check if some of the latches can be removed
- Counter = Abc_NtkLatchSweep( pNtk );
- if ( fVerbose )
- printf( "Cleanup removed %4d redundant latches.\n", Counter );
+ if ( fLatchSweep )
+ {
+ Counter = Abc_NtkLatchSweep( pNtk );
+ if ( fVerbose )
+ printf( "Cleanup removed %4d redundant latches.\n", Counter );
+ }
// detect the autonomous components
- vNodes = Abc_NtkDfsSeqReverse( pNtk );
- Vec_PtrFree( vNodes );
- // replace them by PIs
- Counter = Abc_NtkReplaceAutonomousLogic( pNtk );
- if ( fVerbose )
- printf( "Cleanup added %4d additional PIs.\n", Counter );
- // remove the non-marked nodes
- Counter = Abc_NodeRemoveNonCurrentObjects( pNtk );
- if ( fVerbose )
- printf( "Cleanup removed %4d autonomous objects.\n", Counter );
+ if ( fAutoSweep )
+ {
+ vNodes = Abc_NtkDfsSeqReverse( pNtk );
+ Vec_PtrFree( vNodes );
+ // replace them by PIs
+ Counter = Abc_NtkReplaceAutonomousLogic( pNtk );
+ if ( fVerbose )
+ printf( "Cleanup added %4d additional PIs.\n", Counter );
+ // remove the non-marked nodes
+ Counter = Abc_NodeRemoveNonCurrentObjects( pNtk );
+ if ( fVerbose )
+ printf( "Cleanup removed %4d autonomous objects.\n", Counter );
+ }
// check
if ( !Abc_NtkCheck( pNtk ) )
printf( "Abc_NtkCleanupSeq: The network check has failed.\n" );
diff --git a/src/base/abci/abcSymm.c b/src/base/abci/abcSymm.c
index fad3bd92..d3fcb7c9 100644
--- a/src/base/abci/abcSymm.c
+++ b/src/base/abci/abcSymm.c
@@ -88,7 +88,7 @@ void Abc_NtkSymmetriesUsingBdds( Abc_Ntk_t * pNtk, int fNaive, int fVerbose )
// compute the global functions
clk = clock();
- dd = Abc_NtkGlobalBdds( pNtk, 10000000, 0, 1, fVerbose );
+ dd = Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, 1, fVerbose );
Cudd_AutodynDisable( dd );
Cudd_zddVarsFromBddVars( dd, 2 );
clkBdd = clock() - clk;
@@ -97,9 +97,10 @@ clk = clock();
Ntk_NetworkSymmsBdd( dd, pNtk, fNaive, fVerbose );
clkSym = clock() - clk;
// undo the global functions
- Abc_NtkFreeGlobalBdds( pNtk );
- Extra_StopManager( dd );
- pNtk->pManGlob = NULL;
+// Abc_NtkFreeGlobalBdds( pNtk );
+// Extra_StopManager( dd );
+// pNtk->pManGlob = NULL;
+ Abc_NtkFreeGlobalBdds( pNtk, 1 );
PRT( "Constructing BDDs", clkBdd );
PRT( "Computing symms ", clkSym );
@@ -129,7 +130,8 @@ void Ntk_NetworkSymmsBdd( DdManager * dd, Abc_Ntk_t * pNtk, int fNaive, int fVer
// compute symmetry info for each PO
Abc_NtkForEachCo( pNtk, pNode, i )
{
- bFunc = pNtk->vFuncsGlob->pArray[i];
+// bFunc = pNtk->vFuncsGlob->pArray[i];
+ bFunc = Abc_ObjGlobalBdd( pNode );
nSupps += Cudd_SupportSize( dd, bFunc );
if ( Cudd_IsConstant(bFunc) )
continue;
diff --git a/src/base/abci/abcTiming.c b/src/base/abci/abcTiming.c
index af06436f..93fa3fa5 100644
--- a/src/base/abci/abcTiming.c
+++ b/src/base/abci/abcTiming.c
@@ -648,8 +648,8 @@ void Abc_NtkStartReverseLevels( Abc_Ntk_t * pNtk )
int i, k, nLevelsCur;
// assert( Abc_NtkIsStrash(pNtk) );
// remember the maximum number of direct levels
-// pNtk->LevelMax = Abc_AigGetLevelNum(pNtk);
- pNtk->LevelMax = Abc_NtkGetLevelNum(pNtk);
+// pNtk->LevelMax = Abc_AigLevel(pNtk);
+ pNtk->LevelMax = Abc_NtkLevel(pNtk);
// start the reverse levels
pNtk->vLevelsR = Vec_IntAlloc( 0 );
Vec_IntFill( pNtk->vLevelsR, Abc_NtkObjNumMax(pNtk), 0 );
diff --git a/src/base/abci/abcUnate.c b/src/base/abci/abcUnate.c
index 48b7eb92..8fd2a12f 100644
--- a/src/base/abci/abcUnate.c
+++ b/src/base/abci/abcUnate.c
@@ -66,20 +66,22 @@ void Abc_NtkPrintUnateBdd( Abc_Ntk_t * pNtk, int fUseNaive, int fVerbose )
Abc_Obj_t * pNode;
Extra_UnateInfo_t * p;
DdManager * dd; // the BDD manager used to hold shared BDDs
- DdNode ** pbGlobal; // temporary storage for global BDDs
+// DdNode ** pbGlobal; // temporary storage for global BDDs
int TotalSupps = 0;
int TotalUnate = 0;
int i, clk = clock();
int clkBdd, clkUnate;
// compute the global BDDs
- if ( Abc_NtkGlobalBdds(pNtk, 10000000, 0, 1, fVerbose) == NULL )
+ dd = Abc_NtkBuildGlobalBdds(pNtk, 10000000, 1, 1, fVerbose);
+ if ( dd == NULL )
return;
clkBdd = clock() - clk;
// get information about the network
- dd = pNtk->pManGlob;
- pbGlobal = (DdNode **)Vec_PtrArray( pNtk->vFuncsGlob );
+// dd = pNtk->pManGlob;
+// dd = Abc_NtkGlobalBddMan( pNtk );
+// pbGlobal = (DdNode **)Vec_PtrArray( pNtk->vFuncsGlob );
// print the size of the BDDs
printf( "The shared BDD size is %d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
@@ -89,7 +91,8 @@ clkBdd = clock() - clk;
{
Abc_NtkForEachCo( pNtk, pNode, i )
{
- p = Extra_UnateComputeSlow( dd, pbGlobal[i] );
+// p = Extra_UnateComputeSlow( dd, pbGlobal[i] );
+ p = Extra_UnateComputeSlow( dd, Abc_ObjGlobalBdd(pNode) );
if ( fVerbose )
Extra_UnateInfoPrint( p );
TotalSupps += p->nVars;
@@ -104,7 +107,8 @@ clkBdd = clock() - clk;
Cudd_zddVarsFromBddVars( dd, 2 );
Abc_NtkForEachCo( pNtk, pNode, i )
{
- p = Extra_UnateComputeFast( dd, pbGlobal[i] );
+// p = Extra_UnateComputeFast( dd, pbGlobal[i] );
+ p = Extra_UnateComputeFast( dd, Abc_ObjGlobalBdd(pNode) );
if ( fVerbose )
Extra_UnateInfoPrint( p );
TotalSupps += p->nVars;
@@ -122,10 +126,11 @@ clkUnate = clock() - clk - clkBdd;
PRT( "Total ", clock() - clk );
// deref the PO functions
- Abc_NtkFreeGlobalBdds( pNtk );
+// Abc_NtkFreeGlobalBdds( pNtk );
// stop the global BDD manager
- Extra_StopManager( pNtk->pManGlob );
- pNtk->pManGlob = NULL;
+// Extra_StopManager( pNtk->pManGlob );
+// pNtk->pManGlob = NULL;
+ Abc_NtkFreeGlobalBdds( pNtk, 1 );
}
/**Function*************************************************************
diff --git a/src/base/abci/abcUnreach.c b/src/base/abci/abcUnreach.c
index e4873986..acd63771 100644
--- a/src/base/abci/abcUnreach.c
+++ b/src/base/abci/abcUnreach.c
@@ -58,7 +58,7 @@ int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNtk, bool fVerbose )
}
// compute the global BDDs of the latches
- dd = Abc_NtkGlobalBdds( pNtk, 10000000, 1, 1, fVerbose );
+ dd = Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, 1, fVerbose );
if ( dd == NULL )
return 0;
if ( fVerbose )
@@ -92,7 +92,7 @@ int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNtk, bool fVerbose )
pNtk->pExdc = Abc_NtkConstructExdc( dd, pNtk, bUnreach );
Cudd_RecursiveDeref( dd, bUnreach );
Extra_StopManager( dd );
- pNtk->pManGlob = NULL;
+// pNtk->pManGlob = NULL;
// make sure that everything is okay
if ( pNtk->pExdc && !Abc_NtkCheck( pNtk->pExdc ) )
@@ -137,13 +137,15 @@ DdNode * Abc_NtkTransitionRelation( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbo
Abc_NtkForEachLatch( pNtk, pNode, i )
{
bVar = Cudd_bddIthVar( dd, Abc_NtkCiNum(pNtk) + i );
- bProd = Cudd_bddXnor( dd, bVar, pNtk->vFuncsGlob->pArray[i] ); Cudd_Ref( bProd );
+// bProd = Cudd_bddXnor( dd, bVar, pNtk->vFuncsGlob->pArray[i] ); Cudd_Ref( bProd );
+ bProd = Cudd_bddXnor( dd, bVar, Abc_ObjGlobalBdd(Abc_ObjFanin0(pNode)) ); Cudd_Ref( bProd );
bRel = Cudd_bddAnd( dd, bTemp = bRel, bProd ); Cudd_Ref( bRel );
Cudd_RecursiveDeref( dd, bTemp );
Cudd_RecursiveDeref( dd, bProd );
}
// free the global BDDs
- Abc_NtkFreeGlobalBdds( pNtk );
+// Abc_NtkFreeGlobalBdds( pNtk );
+ Abc_NtkFreeGlobalBdds( pNtk, 0 );
// quantify the PI variables
bInputs = Extra_bddComputeRangeCube( dd, 0, Abc_NtkPiNum(pNtk) ); Cudd_Ref( bInputs );
diff --git a/src/base/abci/module.make b/src/base/abci/module.make
index 7db26629..04ed07a7 100644
--- a/src/base/abci/module.make
+++ b/src/base/abci/module.make
@@ -15,6 +15,7 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcFraig.c \
src/base/abci/abcFxu.c \
src/base/abci/abcGen.c \
+ src/base/abci/abcIf.c \
src/base/abci/abcIvy.c \
src/base/abci/abcLut.c \
src/base/abci/abcMap.c \
@@ -22,7 +23,6 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcMiter.c \
src/base/abci/abcNtbdd.c \
src/base/abci/abcOrder.c \
- src/base/abci/abcPga.c \
src/base/abci/abcPrint.c \
src/base/abci/abcProve.c \
src/base/abci/abcReconv.c \
diff --git a/src/base/io/io.c b/src/base/io/io.c
index 7a661664..b1ea03c1 100644
--- a/src/base/io/io.c
+++ b/src/base/io/io.c
@@ -1339,12 +1339,6 @@ int IoCommandWriteDot( Abc_Frame_t * pAbc, int argc, char **argv )
return 0;
}
- if ( !Abc_NtkHasAig(pAbc->pNtkCur) )
- {
- fprintf( stdout, "IoCommandWriteDot(): Currently can only process AIGs.\n" );
- return 0;
- }
-
if ( argc != globalUtilOptind + 1 )
{
goto usage;
@@ -1354,13 +1348,13 @@ int IoCommandWriteDot( Abc_Frame_t * pAbc, int argc, char **argv )
FileName = argv[globalUtilOptind];
// write the file
vNodes = Abc_NtkCollectObjects( pAbc->pNtkCur );
- Io_WriteDotAig( pAbc->pNtkCur, vNodes, NULL, FileName, 0 );
+ Io_WriteDotNtk( pAbc->pNtkCur, vNodes, NULL, FileName, 0, 0 );
Vec_PtrFree( vNodes );
return 0;
usage:
fprintf( pAbc->Err, "usage: write_dot [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the AIG into a DOT file\n" );
+ fprintf( pAbc->Err, "\t write the current network into a DOT file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
return 1;
@@ -1598,13 +1592,13 @@ int IoCommandWritePla( Abc_Frame_t * pAbc, int argc, char **argv )
return 0;
}
- if ( Abc_NtkGetLevelNum(pNtk) > 1 )
+ if ( Abc_NtkLevel(pNtk) > 1 )
{
fprintf( pAbc->Out, "PLA writing is available for collapsed networks.\n" );
return 0;
}
- if ( Abc_NtkGetLevelNum(pNtk) > 1 )
+ if ( Abc_NtkLevel(pNtk) > 1 )
{
fprintf( pAbc->Out, "PLA writing is available for collapsed networks.\n" );
return 0;
diff --git a/src/base/io/io.h b/src/base/io/io.h
index c42d2016..e7971b8d 100644
--- a/src/base/io/io.h
+++ b/src/base/io/io.h
@@ -86,8 +86,8 @@ extern int Io_WriteBench( Abc_Ntk_t * pNtk, char * FileName );
/*=== abcWriteCnf.c ==========================================================*/
extern int Io_WriteCnf( Abc_Ntk_t * pNtk, char * FileName );
/*=== abcWriteDot.c ==========================================================*/
-extern void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesShow, char * pFileName, int fMulti );
-extern void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesShow, char * pFileName, int fGateNames );
+extern void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesShow, char * pFileName, int fGateNames, int fUseReverse );
+extern void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesShow, char * pFileName, int fGateNames, int fUseReverse );
/*=== abcWriteEqn.c ==========================================================*/
extern void Io_WriteEqn( Abc_Ntk_t * pNtk, char * pFileName );
/*=== abcWriteGml.c ==========================================================*/
diff --git a/src/base/io/ioUtil.c b/src/base/io/ioUtil.c
index dff27dd1..fa2d6f25 100644
--- a/src/base/io/ioUtil.c
+++ b/src/base/io/ioUtil.c
@@ -132,7 +132,7 @@ Abc_Obj_t * Io_ReadCreateLatch( Abc_Ntk_t * pNtk, char * pNetLI, char * pNetLO )
pNet = Abc_NtkFindOrCreateNet( pNtk, pNetLO );
Abc_ObjAddFanin( pNet, pTerm );
// set latch name
- Abc_ObjAssignName( pLatch, pNetLO, "_latch" );
+ Abc_ObjAssignName( pLatch, pNetLO, "L" );
return pLatch;
}
diff --git a/src/base/io/ioWriteDot.c b/src/base/io/ioWriteDot.c
index 3cc3fcfe..084bd111 100644
--- a/src/base/io/ioWriteDot.c
+++ b/src/base/io/ioWriteDot.c
@@ -21,7 +21,6 @@
#include "io.h"
#include "main.h"
#include "mio.h"
-//#include "seqInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -36,7 +35,7 @@ static int Abc_NtkCountLogicNodes( Vec_Ptr_t * vNodes );
/**Function*************************************************************
- Synopsis [Writes the graph structure of AIG for DOT.]
+ Synopsis [Writes the graph structure of network for DOT.]
Description [Useful for graph visualization using tools such as GraphViz:
http://www.graphviz.org/]
@@ -46,14 +45,15 @@ static int Abc_NtkCountLogicNodes( Vec_Ptr_t * vNodes );
SeeAlso []
***********************************************************************/
-void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesShow, char * pFileName, int fMulti )
+void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesShow, char * pFileName, int fGateNames, int fUseReverse )
{
FILE * pFile;
- Abc_Obj_t * pNode, * pTemp, * pPrev;
- int LevelMin, LevelMax, fHasCos, Level, i;
+ Abc_Obj_t * pNode, * pFanin;
+ char * pSopString;
+ int LevelMin, LevelMax, fHasCos, Level, i, k, fHasBdds, fCompl;
int Limit = 300;
- assert( Abc_NtkHasAig(pNtk) );
+ assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
if ( vNodes->nSize < 1 )
{
@@ -74,6 +74,16 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
return;
}
+ // transform logic functions from BDD to SOP
+ if ( fHasBdds = Abc_NtkIsBddLogic(pNtk) )
+ {
+ if ( !Abc_NtkBddToSop(pNtk, 0) )
+ {
+ printf( "Io_WriteDotNtk(): Converting to SOPs has failed.\n" );
+ return;
+ }
+ }
+
// mark the nodes from the set
Vec_PtrForEachEntry( vNodes, pNode, i )
pNode->fMarkC = 1;
@@ -81,6 +91,17 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
Vec_PtrForEachEntry( vNodesShow, pNode, i )
pNode->fMarkB = 1;
+ // get the levels of nodes
+ LevelMax = Abc_NtkLevel( pNtk );
+ if ( fUseReverse )
+ {
+ LevelMin = Abc_NtkLevelReverse( pNtk );
+ assert( LevelMax == LevelMin );
+ Vec_PtrForEachEntry( vNodes, pNode, i )
+ if ( Abc_ObjIsNode(pNode) )
+ pNode->Level = LevelMax - pNode->Level + 1;
+ }
+
// find the largest and the smallest levels
LevelMin = 10000;
LevelMax = -1;
@@ -110,9 +131,9 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
}
// write the DOT header
- fprintf( pFile, "# %s\n", "AIG structure generated by ABC" );
+ fprintf( pFile, "# %s\n", "Network structure generated by ABC" );
fprintf( pFile, "\n" );
- fprintf( pFile, "digraph AIG {\n" );
+ fprintf( pFile, "digraph network {\n" );
fprintf( pFile, "size = \"7.5,10\";\n" );
// fprintf( pFile, "size = \"10,8.5\";\n" );
// fprintf( pFile, "size = \"14,11\";\n" );
@@ -169,7 +190,7 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
fprintf( pFile, " fontsize=20,\n" );
fprintf( pFile, " fontname = \"Times-Roman\",\n" );
fprintf( pFile, " label=\"" );
- fprintf( pFile, "%s", "AIG structure visualized by ABC" );
+ fprintf( pFile, "%s", "Network structure visualized by ABC" );
fprintf( pFile, "\\n" );
fprintf( pFile, "Benchmark \\\"%s\\\". ", pNtk->pName );
fprintf( pFile, "Time was %s. ", Extra_TimeStamp() );
@@ -187,7 +208,10 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
fprintf( pFile, " fontsize=18,\n" );
fprintf( pFile, " fontname = \"Times-Roman\",\n" );
fprintf( pFile, " label=\"" );
- fprintf( pFile, "The set contains %d logic nodes and spans %d levels.", Abc_NtkCountLogicNodes(vNodes), LevelMax - LevelMin + 1 );
+ if ( Abc_NtkObjNum(pNtk) == Vec_PtrSize(vNodes) )
+ fprintf( pFile, "The network contains %d logic nodes and %d latches.", Abc_NtkNodeNum(pNtk), Abc_NtkLatchNum(pNtk) );
+ else
+ fprintf( pFile, "The set contains %d logic nodes and spans %d levels.", Abc_NtkCountLogicNodes(vNodes), LevelMax - LevelMin + 1 );
fprintf( pFile, "\\n" );
fprintf( pFile, "\"\n" );
fprintf( pFile, " ];\n" );
@@ -207,9 +231,11 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
{
if ( !Abc_ObjIsCo(pNode) )
continue;
- fprintf( pFile, " Node%d%s [label = \"%s%s\"", pNode->Id,
- (Abc_ObjIsLatch(pNode)? "_in":""), Abc_ObjName(pNode), (Abc_ObjIsLatch(pNode)? "_in":"") );
- fprintf( pFile, ", shape = %s", (Abc_ObjIsLatch(pNode)? "box":"invtriangle") );
+ fprintf( pFile, " Node%d [label = \"%s%s\"",
+ pNode->Id,
+ (Abc_ObjIsBi(pNode)? Abc_ObjName(Abc_ObjFanout0(pNode)):Abc_ObjName(pNode)),
+ (Abc_ObjIsBi(pNode)? "_in":"") );
+ fprintf( pFile, ", shape = %s", (Abc_ObjIsBi(pNode)? "box":"invtriangle") );
if ( pNode->fMarkB )
fprintf( pFile, ", style = filled" );
fprintf( pFile, ", color = coral, fillcolor = coral" );
@@ -231,7 +257,17 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
{
if ( (int)pNode->Level != Level )
continue;
- fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id );
+// fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id );
+ if ( Abc_NtkIsStrash(pNtk) )
+ pSopString = "";
+ else if ( Abc_NtkHasMapping(pNtk) && fGateNames )
+ pSopString = Mio_GateReadName(pNode->pData);
+ else if ( Abc_NtkHasMapping(pNtk) )
+ pSopString = Abc_NtkPrintSop(Mio_GateReadSop(pNode->pData));
+ else
+ pSopString = Abc_NtkPrintSop(pNode->pData);
+ fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id, pNode->Id, pSopString );
+
fprintf( pFile, ", shape = ellipse" );
if ( pNode->fMarkB )
fprintf( pFile, ", style = filled" );
@@ -249,7 +285,7 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
fprintf( pFile, " rank = same;\n" );
// the labeling node of this level
fprintf( pFile, " Level%d;\n", LevelMin );
- // generat the PO nodes
+ // generate the PO nodes
Vec_PtrForEachEntry( vNodes, pNode, i )
{
if ( !Abc_ObjIsCi(pNode) )
@@ -266,9 +302,10 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
}
continue;
}
- fprintf( pFile, " Node%d%s [label = \"%s%s\"", pNode->Id,
- (Abc_ObjIsLatch(pNode)? "_out":""), Abc_ObjName(pNode), (Abc_ObjIsLatch(pNode)? "_out":"") );
- fprintf( pFile, ", shape = %s", (Abc_ObjIsLatch(pNode)? "box":"triangle") );
+ fprintf( pFile, " Node%d [label = \"%s\"",
+ pNode->Id,
+ (Abc_ObjIsBo(pNode)? Abc_ObjName(Abc_ObjFanin0(pNode)):Abc_ObjName(pNode)) );
+ fprintf( pFile, ", shape = %s", (Abc_ObjIsBo(pNode)? "box":"triangle") );
if ( pNode->fMarkB )
fprintf( pFile, ", style = filled" );
fprintf( pFile, ", color = coral, fillcolor = coral" );
@@ -285,88 +322,30 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
{
if ( (int)pNode->Level != LevelMax )
continue;
- fprintf( pFile, "title2 -> Node%d%s [style = invis];\n", pNode->Id,
- (Abc_ObjIsLatch(pNode)? "_in":"") );
+ fprintf( pFile, "title2 -> Node%d [style = invis];\n", pNode->Id );
}
// generate edges
Vec_PtrForEachEntry( vNodes, pNode, i )
{
- if ( Abc_ObjFaninNum(pNode) == 0 )
- continue;
-
- if ( Abc_ObjIsBo(pNode) )
- continue;
-
- if ( fMulti && Abc_ObjIsNode(pNode) )
- {
- Vec_Ptr_t * vSuper;
- Abc_Obj_t * pFanin;
- int k, fCompl;
- vSuper = (Vec_Ptr_t *)pNode->pCopy;
- assert( vSuper != NULL );
- Vec_PtrForEachEntry( vSuper, pFanin, k )
- {
- fCompl = Abc_ObjIsComplement(pFanin);
- pFanin = Abc_ObjRegular(pFanin);
- if ( !pFanin->fMarkC )
- continue;
-
- if ( Abc_ObjIsBi(pFanin) )
- continue;
-
- fprintf( pFile, "Node%d", pNode->Id );
- fprintf( pFile, " -> " );
- fprintf( pFile, "Node%d%s", pFanin->Id, (Abc_ObjIsLatch(pFanin)? "_out":"") );
- fprintf( pFile, " [" );
- fprintf( pFile, "style = %s", fCompl? "dotted" : "bold" );
- fprintf( pFile, "]" );
- fprintf( pFile, ";\n" );
- }
- continue;
- }
- // generate the edge from this node to the next
- if ( Abc_ObjFanin0(pNode)->fMarkC && !Abc_ObjIsBi(Abc_ObjFanin0(pNode)) )
- {
- fprintf( pFile, "Node%d%s", pNode->Id, (Abc_ObjIsLatch(pNode)? "_in":"") );
- fprintf( pFile, " -> " );
- fprintf( pFile, "Node%d%s", Abc_ObjFaninId0(pNode), (Abc_ObjIsLatch(Abc_ObjFanin0(pNode))? "_out":"") );
- fprintf( pFile, " [" );
- fprintf( pFile, "style = %s", Abc_ObjFaninC0(pNode)? "dotted" : "bold" );
-// if ( Abc_NtkIsSeq(pNode->pNtk) && Seq_ObjFaninL0(pNode) > 0 )
-// fprintf( pFile, ", label = \"%s\"", Seq_ObjFaninGetInitPrintable(pNode,0) );
- fprintf( pFile, "]" );
- fprintf( pFile, ";\n" );
- }
- if ( Abc_ObjFaninNum(pNode) == 1 )
+ if ( Abc_ObjIsLatch(pNode) )
continue;
- // generate the edge from this node to the next
- if ( Abc_ObjFanin1(pNode)->fMarkC && !Abc_ObjIsBi(Abc_ObjFanin1(pNode)) )
+ Abc_ObjForEachFanin( pNode, pFanin, k )
{
+ if ( Abc_ObjIsLatch(pFanin) )
+ continue;
+ fCompl = 0;
+ if ( Abc_NtkIsStrash(pNtk) )
+ fCompl = Abc_ObjFaninC(pNode, k);
+ // generate the edge from this node to the next
fprintf( pFile, "Node%d", pNode->Id );
fprintf( pFile, " -> " );
- fprintf( pFile, "Node%d%s", Abc_ObjFaninId1(pNode), (Abc_ObjIsLatch(Abc_ObjFanin1(pNode))? "_out":"") );
- fprintf( pFile, " [" );
- fprintf( pFile, "style = %s", Abc_ObjFaninC1(pNode)? "dotted" : "bold" );
-// if ( Abc_NtkIsSeq(pNode->pNtk) && Seq_ObjFaninL1(pNode) > 0 )
-// fprintf( pFile, ", label = \"%s\"", Seq_ObjFaninGetInitPrintable(pNode,1) );
+ fprintf( pFile, "Node%d", pFanin->Id );
+ fprintf( pFile, " [style = %s", fCompl? "dotted" : "bold" );
+// fprintf( pFile, ", label = \"%c\"", 'a' + k );
fprintf( pFile, "]" );
fprintf( pFile, ";\n" );
}
- // generate the edges between the equivalent nodes
- pPrev = pNode;
- for ( pTemp = pNode->pData; pTemp; pTemp = pTemp->pData )
- {
- if ( pTemp->fMarkC )
- {
- fprintf( pFile, "Node%d", pPrev->Id );
- fprintf( pFile, " -> " );
- fprintf( pFile, "Node%d", pTemp->Id );
- fprintf( pFile, " [style = %s]", (pPrev->fPhase ^ pTemp->fPhase)? "dotted" : "bold" );
- fprintf( pFile, ";\n" );
- pPrev = pTemp;
- }
- }
}
fprintf( pFile, "}" );
@@ -380,8 +359,13 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
if ( vNodesShow )
Vec_PtrForEachEntry( vNodesShow, pNode, i )
pNode->fMarkB = 0;
+
+ // convert the network back into BDDs if this is how it was
+ if ( fHasBdds )
+ Abc_NtkSopToBdd(pNtk);
}
+
/**Function*************************************************************
Synopsis [Writes the graph structure of network for DOT.]
@@ -394,15 +378,15 @@ void Io_WriteDotAig( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
SeeAlso []
***********************************************************************/
-void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesShow, char * pFileName, int fGateNames )
+void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesShow, char * pFileName, int fGateNames, int fUseReverse )
{
FILE * pFile;
Abc_Obj_t * pNode, * pFanin;
char * pSopString;
- int LevelMin, LevelMax, fHasCos, Level, i, k, fHasBdds;
+ int LevelMin, LevelMax, fHasCos, Level, i, k, fHasBdds, fCompl;
int Limit = 300;
- assert( !Abc_NtkIsStrash(pNtk) );
+ assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
if ( vNodes->nSize < 1 )
{
@@ -441,7 +425,15 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
pNode->fMarkB = 1;
// get the levels of nodes
- Abc_NtkGetLevelNum( pNtk );
+ LevelMax = Abc_NtkLevel( pNtk );
+ if ( fUseReverse )
+ {
+ LevelMin = Abc_NtkLevelReverse( pNtk );
+ assert( LevelMax == LevelMin );
+ Vec_PtrForEachEntry( vNodes, pNode, i )
+ if ( Abc_ObjIsNode(pNode) )
+ pNode->Level = LevelMax - pNode->Level + 1;
+ }
// find the largest and the smallest levels
LevelMin = 10000;
@@ -474,12 +466,15 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
// write the DOT header
fprintf( pFile, "# %s\n", "Network structure generated by ABC" );
fprintf( pFile, "\n" );
- fprintf( pFile, "digraph AIG {\n" );
+ fprintf( pFile, "digraph network {\n" );
fprintf( pFile, "size = \"7.5,10\";\n" );
+// fprintf( pFile, "size = \"10,8.5\";\n" );
+// fprintf( pFile, "size = \"14,11\";\n" );
+// fprintf( pFile, "page = \"8,11\";\n" );
// fprintf( pFile, "ranksep = 0.5;\n" );
// fprintf( pFile, "nodesep = 0.5;\n" );
fprintf( pFile, "center = true;\n" );
-// fprintf( pFile, "orientation = landscape;\n" );
+// fprintf( pFile, "orientation = landscape;\n" );
// fprintf( pFile, "edge [fontsize = 10];\n" );
// fprintf( pFile, "edge [dir = none];\n" );
fprintf( pFile, "edge [dir = back];\n" );
@@ -546,7 +541,10 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
fprintf( pFile, " fontsize=18,\n" );
fprintf( pFile, " fontname = \"Times-Roman\",\n" );
fprintf( pFile, " label=\"" );
- fprintf( pFile, "The set contains %d logic nodes and spans %d levels.", Abc_NtkCountLogicNodes(vNodes), LevelMax - LevelMin + 1 );
+ if ( Abc_NtkObjNum(pNtk) == Vec_PtrSize(vNodes) )
+ fprintf( pFile, "The network contains %d logic nodes and %d latches.", Abc_NtkNodeNum(pNtk), Abc_NtkLatchNum(pNtk) );
+ else
+ fprintf( pFile, "The set contains %d logic nodes and spans %d levels.", Abc_NtkCountLogicNodes(vNodes), LevelMax - LevelMin + 1 );
fprintf( pFile, "\\n" );
fprintf( pFile, "\"\n" );
fprintf( pFile, " ];\n" );
@@ -564,11 +562,10 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
// generate the PO nodes
Vec_PtrForEachEntry( vNodes, pNode, i )
{
- if ( !Abc_ObjIsCo(pNode) )
+ if ( !Abc_ObjIsPo(pNode) )
continue;
- fprintf( pFile, " Node%d%s [label = \"%s%s\"", pNode->Id,
- (Abc_ObjIsLatch(pNode)? "_in":""), Abc_ObjName(pNode), (Abc_ObjIsLatch(pNode)? "_in":"") );
- fprintf( pFile, ", shape = %s", (Abc_ObjIsLatch(pNode)? "box":"invtriangle") );
+ fprintf( pFile, " Node%d [label = \"%s\"", pNode->Id, Abc_ObjName(pNode) );
+ fprintf( pFile, ", shape = %s", "invtriangle" );
if ( pNode->fMarkB )
fprintf( pFile, ", style = filled" );
fprintf( pFile, ", color = coral, fillcolor = coral" );
@@ -586,12 +583,14 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
fprintf( pFile, " rank = same;\n" );
// the labeling node of this level
fprintf( pFile, " Level%d;\n", Level );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Abc_NtkForEachNode( pNtk, pNode, i )
{
if ( (int)pNode->Level != Level )
continue;
// fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id );
- if ( Abc_NtkHasMapping(pNtk) && fGateNames )
+ if ( Abc_NtkIsStrash(pNtk) )
+ pSopString = "";
+ else if ( Abc_NtkHasMapping(pNtk) && fGateNames )
pSopString = Mio_GateReadName(pNode->pData);
else if ( Abc_NtkHasMapping(pNtk) )
pSopString = Abc_NtkPrintSop(Mio_GateReadSop(pNode->pData));
@@ -619,7 +618,9 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
// generate the PO nodes
Vec_PtrForEachEntry( vNodes, pNode, i )
{
- if ( !Abc_ObjIsCi(pNode) )
+ if ( pNode->Level > 0 )
+ continue;
+ if ( !Abc_ObjIsPi(pNode) )
{
// check if the costant node is present
if ( Abc_ObjFaninNum(pNode) == 0 && Abc_ObjFanoutNum(pNode) > 0 )
@@ -633,9 +634,8 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
}
continue;
}
- fprintf( pFile, " Node%d%s [label = \"%s%s\"", pNode->Id,
- (Abc_ObjIsLatch(pNode)? "_out":""), Abc_ObjName(pNode), (Abc_ObjIsLatch(pNode)? "_out":"") );
- fprintf( pFile, ", shape = %s", (Abc_ObjIsLatch(pNode)? "box":"triangle") );
+ fprintf( pFile, " Node%d [label = \"%s\"", pNode->Id, Abc_ObjName(pNode) );
+ fprintf( pFile, ", shape = %s", "triangle" );
if ( pNode->fMarkB )
fprintf( pFile, ", style = filled" );
fprintf( pFile, ", color = coral, fillcolor = coral" );
@@ -646,34 +646,61 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
fprintf( pFile, "\n" );
}
+// fprintf( pFile, "{\n" );
+ Vec_PtrForEachEntry( vNodes, pNode, i )
+ {
+ if ( !Abc_ObjIsLatch(pNode) )
+ continue;
+ fprintf( pFile, "Node%d [label = \"%s\"", pNode->Id, Abc_ObjName(pNode) );
+ fprintf( pFile, ", shape = box" );
+ if ( pNode->fMarkB )
+ fprintf( pFile, ", style = filled" );
+ fprintf( pFile, ", color = coral, fillcolor = coral" );
+ fprintf( pFile, "];\n" );
+ }
+// fprintf( pFile, "}" );
+// fprintf( pFile, "\n" );
+ fprintf( pFile, "\n" );
+
// generate invisible edges from the square down
fprintf( pFile, "title1 -> title2 [style = invis];\n" );
Vec_PtrForEachEntry( vNodes, pNode, i )
{
if ( (int)pNode->Level != LevelMax )
continue;
- fprintf( pFile, "title2 -> Node%d%s [style = invis];\n", pNode->Id,
- (Abc_ObjIsLatch(pNode)? "_in":"") );
+ if ( !Abc_ObjIsPo(pNode) )
+ continue;
+ fprintf( pFile, "title2 -> Node%d [style = invis];\n", pNode->Id );
}
// generate edges
Vec_PtrForEachEntry( vNodes, pNode, i )
{
+ if ( Abc_ObjIsBi(pNode) || Abc_ObjIsBo(pNode) )
+ continue;
Abc_ObjForEachFanin( pNode, pFanin, k )
{
- if ( !Abc_ObjFanin0(pNode)->fMarkC )
- continue;
-
- // added to fix the bug after adding boxes
- if ( Abc_ObjIsBo(pNode) || Abc_ObjIsBi(pFanin) )
+ fCompl = 0;
+ if ( Abc_NtkIsStrash(pNtk) )
+ {
+ if ( Abc_ObjIsBi(pFanin) )
+ fCompl = Abc_ObjFaninC(pFanin, k);
+ else
+ fCompl = Abc_ObjFaninC(pNode, k);
+ }
+ if ( Abc_ObjIsBi(pFanin) || Abc_ObjIsBo(pFanin) )
+ pFanin = Abc_ObjFanin0(pFanin);
+ if ( Abc_ObjIsBi(pFanin) || Abc_ObjIsBo(pFanin) )
+ pFanin = Abc_ObjFanin0(pFanin);
+ if ( !pFanin->fMarkC )
continue;
// generate the edge from this node to the next
- fprintf( pFile, "Node%d%s", pNode->Id, (Abc_ObjIsLatch(pNode)? "_in":"") );
+ fprintf( pFile, "Node%d", pNode->Id );
fprintf( pFile, " -> " );
- fprintf( pFile, "Node%d%s", Abc_ObjFaninId(pNode,k), (Abc_ObjIsLatch(Abc_ObjFanin(pNode,k))? "_out":"") );
- fprintf( pFile, " [style = bold" );
- fprintf( pFile, ", label = \"%c\"", 'a' + k );
+ fprintf( pFile, "Node%d", pFanin->Id );
+ fprintf( pFile, " [style = %s", fCompl? "dotted" : "bold" );
+// fprintf( pFile, ", label = \"%c\"", 'a' + k );
fprintf( pFile, "]" );
fprintf( pFile, ";\n" );
}
@@ -696,6 +723,7 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
Abc_NtkSopToBdd(pNtk);
}
+
/**Function*************************************************************
Synopsis [Computes the printable SOP form.]
diff --git a/src/base/io/ioWritePla.c b/src/base/io/ioWritePla.c
index 4da8aca8..b119751c 100644
--- a/src/base/io/ioWritePla.c
+++ b/src/base/io/ioWritePla.c
@@ -47,7 +47,7 @@ int Io_WritePla( Abc_Ntk_t * pNtk, char * pFileName )
FILE * pFile;
assert( Abc_NtkIsSopNetlist(pNtk) );
- assert( Abc_NtkGetLevelNum(pNtk) == 1 );
+ assert( Abc_NtkLevel(pNtk) == 1 );
pFile = fopen( pFileName, "w" );
if ( pFile == NULL )
diff --git a/src/base/io/ioWriteVer.c b/src/base/io/ioWriteVer.c
index 381e6e28..9be3d8b3 100644
--- a/src/base/io/ioWriteVer.c
+++ b/src/base/io/ioWriteVer.c
@@ -463,7 +463,7 @@ void Io_WriteVerilogVerLibStyle( FILE * pFile, Abc_Ntk_t * pNtk )
Vec_Vec_t * vLevels;
Abc_Ntk_t * pNtkGate;
Abc_Obj_t * pObj, * pTerm, * pFanin;
- Aig_Obj_t * pFunc;
+ Hop_Obj_t * pFunc;
int i, k, Counter, nDigits;
Counter = 1;
@@ -495,13 +495,13 @@ void Io_WriteVerilogVerLibStyle( FILE * pFile, Abc_Ntk_t * pNtk )
fprintf( pFile, " assign %s = ", Io_WriteVerilogGetName(Abc_ObjFanout0(pObj)) );
// set the input names
Abc_ObjForEachFanin( pObj, pFanin, k )
- Aig_IthVar(pNtk->pManFunc, k)->pData = Extra_UtilStrsav(Io_WriteVerilogGetName(pFanin));
+ Hop_IthVar(pNtk->pManFunc, k)->pData = Extra_UtilStrsav(Io_WriteVerilogGetName(pFanin));
// write the formula
- Aig_ObjPrintVerilog( pFile, pFunc, vLevels, 0 );
+ Hop_ObjPrintVerilog( pFile, pFunc, vLevels, 0 );
fprintf( pFile, ";\n" );
// clear the input names
Abc_ObjForEachFanin( pObj, pFanin, k )
- free( Aig_IthVar(pNtk->pManFunc, k)->pData );
+ free( Hop_IthVar(pNtk->pManFunc, k)->pData );
}
Vec_VecFree( vLevels );
}
diff --git a/src/base/main/libSupport.c b/src/base/main/libSupport.c
index cdfd98b8..471ea09e 100644
--- a/src/base/main/libSupport.c
+++ b/src/base/main/libSupport.c
@@ -49,7 +49,7 @@ void open_libs() {
env = getenv ("ABC_LIB_PATH");
if (env == NULL) {
- printf("Warning: ABC_LIB_PATH not defined. Looking into the current directory.\n");
+// printf("Warning: ABC_LIB_PATH not defined. Looking into the current directory.\n");
init_p = malloc (2*sizeof(char));
init_p[0]='.'; init_p[1] = 0;
} else {
@@ -67,7 +67,7 @@ void open_libs() {
dirp = opendir(p);
if (dirp == NULL) {
- printf("Warning: directory in ABC_LIB_PATH does not exist (%s).\n", p);
+// printf("Warning: directory in ABC_LIB_PATH does not exist (%s).\n", p);
continue;
}
diff --git a/src/base/ver/module.make b/src/base/ver/module.make
new file mode 100644
index 00000000..2cc37803
--- /dev/null
+++ b/src/base/ver/module.make
@@ -0,0 +1,4 @@
+SRC += src/base/ver/verCore.c \
+ src/base/ver/verFormula.c \
+ src/base/ver/verParse.c \
+ src/base/ver/verStream.c
diff --git a/src/temp/ver/ver.h b/src/base/ver/ver.h
index c7c18f79..c7c18f79 100644
--- a/src/temp/ver/ver.h
+++ b/src/base/ver/ver.h
diff --git a/src/temp/ver/verCore.c b/src/base/ver/verCore.c
index 352a4361..9048337b 100644
--- a/src/temp/ver/verCore.c
+++ b/src/base/ver/verCore.c
@@ -457,7 +457,7 @@ int Ver_ParseAssign( Ver_Man_t * pMan )
Abc_Ntk_t * pNtk = pMan->pNtkCur;
Abc_Obj_t * pNode, * pNet;
char * pWord, * pName, * pEquation;
- Aig_Obj_t * pFunc;
+ Hop_Obj_t * pFunc;
char Symbol;
int i, Length, fReduction;
@@ -932,7 +932,7 @@ int Ver_ParseGate( Ver_Man_t * pMan, Abc_Ntk_t * pNtkGate )
int Ver_ParseGateStandard( Ver_Man_t * pMan, Ver_GateType_t GateType )
{
Ver_Stream_t * p = pMan->pReader;
- Aig_Man_t * pAig = pMan->pNtkCur->pManFunc;
+ Hop_Man_t * pAig = pMan->pNtkCur->pManFunc;
Abc_Obj_t * pNet, * pNode;
char * pWord, Symbol;
// this is gate name - throw it away
@@ -996,15 +996,15 @@ int Ver_ParseGateStandard( Ver_Man_t * pMan, Ver_GateType_t GateType )
}
// add logic function
if ( GateType == VER_GATE_AND || GateType == VER_GATE_NAND )
- pNode->pData = Aig_CreateAnd( pAig, Abc_ObjFaninNum(pNode) );
+ pNode->pData = Hop_CreateAnd( pAig, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_OR || GateType == VER_GATE_NOR )
- pNode->pData = Aig_CreateOr( pAig, Abc_ObjFaninNum(pNode) );
+ pNode->pData = Hop_CreateOr( pAig, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_XOR || GateType == VER_GATE_XNOR )
- pNode->pData = Aig_CreateExor( pAig, Abc_ObjFaninNum(pNode) );
+ pNode->pData = Hop_CreateExor( pAig, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_BUF || GateType == VER_GATE_NOT )
- pNode->pData = Aig_CreateAnd( pAig, Abc_ObjFaninNum(pNode) );
+ pNode->pData = Hop_CreateAnd( pAig, Abc_ObjFaninNum(pNode) );
if ( GateType == VER_GATE_NAND || GateType == VER_GATE_NOR || GateType == VER_GATE_XNOR || GateType == VER_GATE_NOT )
- pNode->pData = Aig_Not( pNode->pData );
+ pNode->pData = Hop_Not( pNode->pData );
return 1;
}
diff --git a/src/temp/ver/verFormula.c b/src/base/ver/verFormula.c
index fd8777c3..cfe3e0c8 100644
--- a/src/temp/ver/verFormula.c
+++ b/src/base/ver/verFormula.c
@@ -52,7 +52,7 @@
#define VER_PARSE_FLAG_OPER 3 // after operation symbol is received
#define VER_PARSE_FLAG_ERROR 4 // when error is detected
-static Aig_Obj_t * Ver_FormulaParserTopOper( Aig_Man_t * pMan, Vec_Ptr_t * vStackFn, int Oper );
+static Hop_Obj_t * Ver_FormulaParserTopOper( Hop_Man_t * pMan, Vec_Ptr_t * vStackFn, int Oper );
static int Ver_FormulaParserFindVar( char * pString, Vec_Ptr_t * vNames );
////////////////////////////////////////////////////////////////////////
@@ -72,7 +72,7 @@ static int Ver_FormulaParserFindVar( char * pString, Vec_Ptr_t * vNames
***********************************************************************/
void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_Ptr_t * vStackFn, Vec_Int_t * vStackOp, char * pErrorMessage )
{
- Aig_Obj_t * bFunc, * bTemp;
+ Hop_Obj_t * bFunc, * bTemp;
char * pTemp;
int nParans, Flag;
int Oper, Oper1, Oper2;
@@ -118,7 +118,7 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_
// treat Constant 0 as a variable
case VER_PARSE_SYM_CONST0:
- Vec_PtrPush( vStackFn, Aig_ManConst0(pMan) ); // Cudd_Ref( Aig_ManConst0(pMan) );
+ Vec_PtrPush( vStackFn, Hop_ManConst0(pMan) ); // Cudd_Ref( Hop_ManConst0(pMan) );
if ( Flag == VER_PARSE_FLAG_VAR )
{
sprintf( pErrorMessage, "Parse_FormulaParser(): No operation symbol before constant 0." );
@@ -130,7 +130,7 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_
// the same for Constant 1
case VER_PARSE_SYM_CONST1:
- Vec_PtrPush( vStackFn, Aig_ManConst1(pMan) ); // Cudd_Ref( Aig_ManConst1(pMan) );
+ Vec_PtrPush( vStackFn, Hop_ManConst1(pMan) ); // Cudd_Ref( Hop_ManConst1(pMan) );
if ( Flag == VER_PARSE_FLAG_VAR )
{
sprintf( pErrorMessage, "Parse_FormulaParser(): No operation symbol before constant 1." );
@@ -240,7 +240,7 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_
sprintf( pErrorMessage, "Parse_FormulaParser(): Incorrect state." );
return NULL;
}
- bTemp = Aig_IthVar( pMan, v );
+ bTemp = Hop_IthVar( pMan, v );
Vec_PtrPush( vStackFn, bTemp ); // Cudd_Ref( bTemp );
Flag = VER_PARSE_FLAG_VAR;
break;
@@ -264,7 +264,7 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_
else
{
// Vec_PtrPush( vStackFn, Cudd_Not(Vec_PtrPop(vStackFn)) );
- Vec_PtrPush( vStackFn, Aig_Not(Vec_PtrPop(vStackFn)) );
+ Vec_PtrPush( vStackFn, Hop_Not(Vec_PtrPop(vStackFn)) );
}
}
else // if ( Flag == VER_PARSE_FLAG_OPER )
@@ -331,25 +331,25 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Ver_FormulaParserTopOper( Aig_Man_t * pMan, Vec_Ptr_t * vStackFn, int Oper )
+Hop_Obj_t * Ver_FormulaParserTopOper( Hop_Man_t * pMan, Vec_Ptr_t * vStackFn, int Oper )
{
- Aig_Obj_t * bArg0, * bArg1, * bArg2, * bFunc;
+ Hop_Obj_t * bArg0, * bArg1, * bArg2, * bFunc;
// perform the given operation
bArg2 = Vec_PtrPop( vStackFn );
bArg1 = Vec_PtrPop( vStackFn );
if ( Oper == VER_PARSE_OPER_AND )
- bFunc = Aig_And( pMan, bArg1, bArg2 );
+ bFunc = Hop_And( pMan, bArg1, bArg2 );
else if ( Oper == VER_PARSE_OPER_XOR )
- bFunc = Aig_Exor( pMan, bArg1, bArg2 );
+ bFunc = Hop_Exor( pMan, bArg1, bArg2 );
else if ( Oper == VER_PARSE_OPER_OR )
- bFunc = Aig_Or( pMan, bArg1, bArg2 );
+ bFunc = Hop_Or( pMan, bArg1, bArg2 );
else if ( Oper == VER_PARSE_OPER_EQU )
- bFunc = Aig_Not( Aig_Exor( pMan, bArg1, bArg2 ) );
+ bFunc = Hop_Not( Hop_Exor( pMan, bArg1, bArg2 ) );
else if ( Oper == VER_PARSE_OPER_MUX )
{
bArg0 = Vec_PtrPop( vStackFn );
// bFunc = Cudd_bddIte( dd, bArg0, bArg1, bArg2 ); Cudd_Ref( bFunc );
- bFunc = Aig_Mux( pMan, bArg0, bArg1, bArg2 );
+ bFunc = Hop_Mux( pMan, bArg0, bArg1, bArg2 );
// Cudd_RecursiveDeref( dd, bArg0 );
// Cudd_Deref( bFunc );
}
@@ -426,7 +426,7 @@ int Ver_FormulaParserFindVar( char * pString, Vec_Ptr_t * vNames )
***********************************************************************/
void * Ver_FormulaReduction( char * pFormula, void * pMan, Vec_Ptr_t * vNames, char * pErrorMessage )
{
- Aig_Obj_t * pRes;
+ Hop_Obj_t * pRes;
int v, fCompl;
char Symbol;
@@ -454,12 +454,12 @@ void * Ver_FormulaReduction( char * pFormula, void * pMan, Vec_Ptr_t * vNames, c
}
// compute the function
if ( Symbol == '&' )
- pRes = Aig_CreateAnd( pMan, Vec_PtrSize(vNames)/2 );
+ pRes = Hop_CreateAnd( pMan, Vec_PtrSize(vNames)/2 );
else if ( Symbol == '|' )
- pRes = Aig_CreateOr( pMan, Vec_PtrSize(vNames)/2 );
+ pRes = Hop_CreateOr( pMan, Vec_PtrSize(vNames)/2 );
else if ( Symbol == '^' )
- pRes = Aig_CreateExor( pMan, Vec_PtrSize(vNames)/2 );
- return Aig_NotCond( pRes, fCompl );
+ pRes = Hop_CreateExor( pMan, Vec_PtrSize(vNames)/2 );
+ return Hop_NotCond( pRes, fCompl );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/temp/ver/verParse.c b/src/base/ver/verParse.c
index 8a78e75b..8a78e75b 100644
--- a/src/temp/ver/verParse.c
+++ b/src/base/ver/verParse.c
diff --git a/src/temp/ver/verStream.c b/src/base/ver/verStream.c
index 7956b13c..7956b13c 100644
--- a/src/temp/ver/verStream.c
+++ b/src/base/ver/verStream.c
diff --git a/src/temp/ver/verWords.c b/src/base/ver/verWords.c
index f9d27010..f9d27010 100644
--- a/src/temp/ver/verWords.c
+++ b/src/base/ver/verWords.c
diff --git a/src/temp/ver/ver_.c b/src/base/ver/ver_.c
index 76599dac..76599dac 100644
--- a/src/temp/ver/ver_.c
+++ b/src/base/ver/ver_.c
diff --git a/src/map/fpga/fpga.h b/src/map/fpga/fpga.h
index d89f6dc9..188420b1 100644
--- a/src/map/fpga/fpga.h
+++ b/src/map/fpga/fpga.h
@@ -32,7 +32,7 @@ extern "C" {
////////////////////////////////////////////////////////////////////////
// the maximum size of LUTs used for mapping
-#define FPGA_MAX_LUTSIZE 10
+#define FPGA_MAX_LUTSIZE 32
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
diff --git a/src/map/fpga/fpgaCut.c b/src/map/fpga/fpgaCut.c
index 3bb5feb4..c2aba4a3 100644
--- a/src/map/fpga/fpgaCut.c
+++ b/src/map/fpga/fpgaCut.c
@@ -684,7 +684,8 @@ int Fpga_CutMergeTwo( Fpga_Cut_t * pCut1, Fpga_Cut_t * pCut2, Fpga_Node_t * ppNo
{
min = i;
for ( k = i+1; k < nTotal; k++ )
- if ( ppNodes[k] < ppNodes[min] )
+// if ( ppNodes[k] < ppNodes[min] ) // reported bug fix (non-determinism!)
+ if ( ppNodes[k]->Num < ppNodes[min]->Num )
min = k;
pNodeTemp = ppNodes[i];
ppNodes[i] = ppNodes[min];
diff --git a/src/map/if/if.h b/src/map/if/if.h
new file mode 100644
index 00000000..04e1541e
--- /dev/null
+++ b/src/map/if/if.h
@@ -0,0 +1,255 @@
+/**CFile****************************************************************
+
+ FileName [if.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [FPGA mapping based on priority cuts.]
+
+ Synopsis [External declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: if.h,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __IF_H__
+#define __IF_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 "mem.h"
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+// the maximum size of LUTs used for mapping (should be the same as FPGA_MAX_LUTSIZE defined in "fpga.h"!!!)
+#define IF_MAX_LUTSIZE 32
+
+// object types
+typedef enum {
+ IF_NONE, // 0: non-existent object
+ IF_CONST1, // 1: constant 1
+ IF_PI, // 2: primary input
+ IF_PO, // 3: primary output
+ IF_AND, // 4: AND node
+ IF_BI, // 5: box input
+ IF_BO, // 6: box output
+ IF_BOX, // 7: box
+ IF_VOID // 8: unused object
+} Hop_Type_t;
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct If_Par_t_ If_Par_t;
+typedef struct If_Lib_t_ If_Lib_t;
+typedef struct If_Man_t_ If_Man_t;
+typedef struct If_Obj_t_ If_Obj_t;
+typedef struct If_Cut_t_ If_Cut_t;
+
+// parameters
+struct If_Par_t_
+{
+ int Mode; // the mapping mode
+ int nLutSize; // the LUT size
+ If_Lib_t * pLutLib; // the LUT library
+ int nCutsMax; // the max number of cuts
+ int fVerbose; // the verbosity flag
+ int fSeq; // sequential mapping
+ int fLatchPaths; // reset timing on latch paths
+ int nLatches; // the number of latches
+ float DelayTarget; // delay target
+ float * pTimesArr; // arrival times
+ float * pTimesReq; // required times
+};
+
+// the LUT library
+struct If_Lib_t_
+{
+ char * pName; // the name of the LUT library
+ int LutMax; // the maximum LUT size
+ float pLutAreas[IF_MAX_LUTSIZE+1]; // the areas of LUTs
+ float pLutDelays[IF_MAX_LUTSIZE+1];// the delays of LUTs
+};
+
+// manager
+struct If_Man_t_
+{
+ // mapping parameters
+ If_Par_t * pPars;
+ // mapping nodes
+ If_Obj_t * pConst1; // the constant 1 node
+ Vec_Ptr_t * vPis; // the primary inputs
+ Vec_Ptr_t * vPos; // the primary outputs
+ Vec_Ptr_t * vObjs; // all objects
+ Vec_Ptr_t * vMapped; // objects used in the mapping
+ Vec_Ptr_t * vTemp; // temporary array
+ int nObjs[IF_VOID];// the number of objects by type
+ // various data
+ int nLevelMax; // the max number of AIG levels
+ float fEpsilon; // epsilon used for comparison
+ float RequiredGlo; // global required times
+ float AreaGlo; // global area
+ // memory management
+ Mem_Fixed_t * pMem; // memory manager
+ int nEntrySize; // the size of the entry
+ int nEntryBase; // the size of the entry minus cut leaf arrays
+ // temporary cut storage
+ int nCuts; // the number of cuts used
+ If_Cut_t ** ppCuts; // the storage space for cuts
+};
+
+// priority cut
+struct If_Cut_t_
+{
+ float Delay; // the delay of the cut
+ float Flow; // the area flow of the cut
+ float Area; // the area of the cut
+ If_Cut_t * pOne; // the parent cut
+ If_Cut_t * pTwo; // the parent cut
+ char fCompl0; // the complemented attribute
+ char fCompl1; // the complemented attribute
+ char Phase; // the complemented attribute
+ char nLeaves; // the number of leaves
+ int * pLeaves; // the array of fanins
+};
+
+// node extension
+struct If_Obj_t_
+{
+ unsigned Type : 4; // object
+ unsigned fCompl0 : 1; // complemented attribute
+ unsigned fCompl1 : 1; // complemented attribute
+ unsigned fPhase : 1; // phase of the node
+ unsigned fMark : 1; // multipurpose mark
+ unsigned Level : 24; // logic level of the node
+ int Id; // integer ID
+ int nRefs; // the number of references
+ short nCuts; // the number of cuts
+ short iCut; // the number of the best cut
+ If_Obj_t * pFanin0; // the first fanin
+ If_Obj_t * pFanin1; // the second fanin
+ If_Obj_t * pEquiv; // the choice node
+ float EstRefs; // estimated reference counter
+ float Required; // required time of the onde
+ void * pCopy; // used for duplication
+ If_Cut_t Cuts[0]; // the cuts of the node
+};
+
+static inline If_Obj_t * If_ManConst1( If_Man_t * p ) { return p->pConst1; }
+static inline If_Obj_t * If_ManPi( If_Man_t * p, int i ) { return (If_Obj_t *)Vec_PtrEntry( p->vPis, i ); }
+static inline If_Obj_t * If_ManPo( If_Man_t * p, int i ) { return (If_Obj_t *)Vec_PtrEntry( p->vPos, i ); }
+static inline If_Obj_t * If_ManObj( If_Man_t * p, int i ) { return (If_Obj_t *)Vec_PtrEntry( p->vObjs, i ); }
+static inline If_Cut_t * If_ManCut( If_Man_t * p, int i ) { return p->ppCuts[i]; }
+
+static inline int If_ObjIsConst1( If_Obj_t * pObj ) { return pObj->Type == IF_CONST1; }
+static inline int If_ObjIsPi( If_Obj_t * pObj ) { return pObj->Type == IF_PI; }
+static inline int If_ObjIsPo( If_Obj_t * pObj ) { return pObj->Type == IF_PO; }
+static inline int If_ObjIsAnd( If_Obj_t * pObj ) { return pObj->Type == IF_AND; }
+static inline int If_ObjIsBi( If_Obj_t * pObj ) { return pObj->Type == IF_BI; }
+static inline int If_ObjIsBo( If_Obj_t * pObj ) { return pObj->Type == IF_BO; }
+static inline int If_ObjIsBox( If_Obj_t * pObj ) { return pObj->Type == IF_BOX; }
+
+static inline If_Obj_t * If_ObjFanin0( If_Obj_t * pObj ) { return pObj->pFanin0; }
+static inline If_Obj_t * If_ObjFanin1( If_Obj_t * pObj ) { return pObj->pFanin1; }
+static inline int If_ObjFaninC0( If_Obj_t * pObj ) { return pObj->fCompl0; }
+static inline int If_ObjFaninC1( If_Obj_t * pObj ) { return pObj->fCompl1; }
+static inline void * If_ObjCopy( If_Obj_t * pObj ) { return pObj->pCopy; }
+static inline void If_ObjSetCopy( If_Obj_t * pObj, void * pCopy ) { pObj->pCopy = pCopy; }
+static inline void If_ObjSetChoice( If_Obj_t * pObj, If_Obj_t * pEqu ) { pObj->pEquiv = pEqu; }
+
+static inline If_Cut_t * If_ObjCut( If_Obj_t * pObj, int iCut ) { return pObj->Cuts + iCut; }
+static inline If_Cut_t * If_ObjCutTriv( If_Obj_t * pObj ) { return pObj->Cuts; }
+static inline If_Cut_t * If_ObjCutBest( If_Obj_t * pObj ) { return pObj->Cuts + pObj->iCut; }
+
+static inline void * If_CutData( If_Cut_t * pCut ) { return *(void **)pCut; }
+static inline void If_CutSetData( If_Cut_t * pCut, void * pData ) { *(void **)pCut = pData; }
+
+static inline float If_CutLutDelay( If_Man_t * p, If_Cut_t * pCut ) { return p->pPars->pLutLib? p->pPars->pLutLib->pLutDelays[pCut->nLeaves] : (float)1.0; }
+static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { return p->pPars->pLutLib? p->pPars->pLutLib->pLutAreas[pCut->nLeaves] : (float)1.0; }
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+#define IF_MIN(a,b) (((a) < (b))? (a) : (b))
+#define IF_MAX(a,b) (((a) > (b))? (a) : (b))
+
+// the small and large numbers (min/max float are 1.17e-38/3.40e+38)
+#define IF_FLOAT_LARGE ((float)1.0e+20)
+#define IF_FLOAT_SMALL ((float)1.0e-20)
+#define IF_INT_LARGE (10000000)
+
+// iterator over the primary inputs
+#define If_ManForEachPi( p, pObj, i ) \
+ Vec_PtrForEachEntry( p->vPis, pObj, i )
+// iterator over the primary outputs
+#define If_ManForEachPo( p, pObj, i ) \
+ Vec_PtrForEachEntry( p->vPos, pObj, i )
+// iterator over the latches
+#define If_ManForEachLatch( p, pObj, i ) \
+ Vec_PtrForEachEntryStart( p->vPos, pObj, i, p->pPars->nLatches )
+// iterator over all objects, including those currently not used
+#define If_ManForEachObj( p, pObj, i ) \
+ Vec_PtrForEachEntry( p->vObjs, pObj, i )
+// iterator over logic nodes (AND and EXOR gates)
+#define If_ManForEachNode( p, pObj, i ) \
+ If_ManForEachObj( p, pObj, i ) if ( pObj->Type != IF_AND ) {} else
+// iterator over cuts of the node
+#define If_ObjForEachCut( pObj, pCut, i ) \
+ for ( i = 0; (i < (int)(pObj)->nCuts) && ((pCut) = (pObj)->Cuts + i); i++ )
+// iterator over cuts of the node
+#define If_ObjForEachCutStart( pObj, pCut, i, Start ) \
+ for ( i = Start; (i < (int)(pObj)->nCuts) && ((pCut) = (pObj)->Cuts + i); i++ )
+// iterator leaves of the cut
+#define If_CutForEachLeaf( p, pCut, pLeaf, i ) \
+ for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i++ )
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/*=== ifMan.c ==========================================================*/
+extern If_Man_t * If_ManStart( If_Par_t * pPars );
+extern void If_ManStop( If_Man_t * p );
+extern If_Obj_t * If_ManCreatePi( If_Man_t * p );
+extern If_Obj_t * If_ManCreatePo( If_Man_t * p, If_Obj_t * pDriver, int fCompl0 );
+extern If_Obj_t * If_ManCreateAnd( If_Man_t * p, If_Obj_t * pFan0, int fCompl0, If_Obj_t * pFan1, int fCompl1 );
+/*=== ifMap.c ==========================================================*/
+extern int If_ManPerformMapping( If_Man_t * p );
+/*=== ifUtil.c ==========================================================*/
+extern float If_ManDelayMax( If_Man_t * p );
+extern void If_ManCleanNodeCopy( If_Man_t * p );
+extern void If_ManCleanCutData( If_Man_t * p );
+extern float If_ManScanMapping( If_Man_t * p );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/map/if/ifCore.c b/src/map/if/ifCore.c
new file mode 100644
index 00000000..4d7e92d0
--- /dev/null
+++ b/src/map/if/ifCore.c
@@ -0,0 +1,47 @@
+/**CFile****************************************************************
+
+ FileName [ifCore.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [FPGA mapping based on priority cuts.]
+
+ Synopsis [The central part of the mapper.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: ifCore.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "if.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/map/if/ifCut.c b/src/map/if/ifCut.c
new file mode 100644
index 00000000..0318e5e5
--- /dev/null
+++ b/src/map/if/ifCut.c
@@ -0,0 +1,47 @@
+/**CFile****************************************************************
+
+ FileName [ifCut.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [FPGA mapping based on priority cuts.]
+
+ Synopsis [Cut computation.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: ifCut.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "if.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/map/if/ifMan.c b/src/map/if/ifMan.c
new file mode 100644
index 00000000..616c5cf6
--- /dev/null
+++ b/src/map/if/ifMan.c
@@ -0,0 +1,250 @@
+/**CFile****************************************************************
+
+ FileName [ifMan.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [FPGA mapping based on priority cuts.]
+
+ Synopsis [Mapping manager.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: ifMan.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "if.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static If_Obj_t * If_ManSetupObj( If_Man_t * p );
+static If_Cut_t ** If_ManSetupCuts( If_Man_t * p );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Starts the AIG manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_Man_t * If_ManStart( If_Par_t * pPars )
+{
+ If_Man_t * p;
+ // start the manager
+ p = ALLOC( If_Man_t, 1 );
+ memset( p, 0, sizeof(If_Man_t) );
+ p->pPars = pPars;
+ p->fEpsilon = (float)0.001;
+ // allocate arrays for nodes
+ p->vPis = Vec_PtrAlloc( 100 );
+ p->vPos = Vec_PtrAlloc( 100 );
+ p->vObjs = Vec_PtrAlloc( 100 );
+ p->vMapped = Vec_PtrAlloc( 100 );
+ p->vTemp = Vec_PtrAlloc( 100 );
+ // prepare the memory manager
+ p->nEntrySize = sizeof(If_Obj_t) + p->pPars->nCutsMax * (sizeof(If_Cut_t) + sizeof(int) * p->pPars->nLutSize);
+ p->nEntryBase = sizeof(If_Obj_t) + p->pPars->nCutsMax * (sizeof(If_Cut_t));
+ p->pMem = Mem_FixedStart( p->nEntrySize );
+ // create the constant node
+ p->pConst1 = If_ManSetupObj( p );
+ p->pConst1->Type = IF_CONST1;
+ p->pConst1->fPhase = 1;
+ // create temporary cuts
+ p->ppCuts = If_ManSetupCuts( p );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManStop( If_Man_t * p )
+{
+ If_Cut_t * pTemp;
+ int i;
+ Vec_PtrFree( p->vPis );
+ Vec_PtrFree( p->vPos );
+ Vec_PtrFree( p->vObjs );
+ Vec_PtrFree( p->vMapped );
+ Vec_PtrFree( p->vTemp );
+ Mem_FixedStop( p->pMem, 0 );
+ // free pars memory
+ if ( p->pPars->pTimesArr )
+ FREE( p->pPars->pTimesArr );
+ if ( p->pPars->pTimesReq )
+ FREE( p->pPars->pTimesReq );
+ // free temporary cut memory
+ pTemp = p->ppCuts[0];
+ for ( i = 1; i < p->pPars->nCutsMax * p->pPars->nCutsMax; i++ )
+ if ( pTemp > p->ppCuts[i] )
+ pTemp = p->ppCuts[i];
+ free( pTemp );
+ free( p->ppCuts );
+ free( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates primary input.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_Obj_t * If_ManCreatePi( If_Man_t * p )
+{
+ If_Obj_t * pObj;
+ pObj = If_ManSetupObj( p );
+ pObj->Type = IF_PI;
+ Vec_PtrPush( p->vPis, pObj );
+ p->nObjs[IF_PI]++;
+ return pObj;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates primary output with the given driver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_Obj_t * If_ManCreatePo( If_Man_t * p, If_Obj_t * pDriver, int fCompl0 )
+{
+ If_Obj_t * pObj;
+ pObj = If_ManSetupObj( p );
+ pObj->Type = IF_PO;
+ pObj->fCompl0 = fCompl0;
+ Vec_PtrPush( p->vPos, pObj );
+ pObj->pFanin0 = pDriver; pDriver->nRefs++;
+ p->nObjs[IF_PO]++;
+ return pObj;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Create the new node assuming it does not exist.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_Obj_t * If_ManCreateAnd( If_Man_t * p, If_Obj_t * pFan0, int fCompl0, If_Obj_t * pFan1, int fCompl1 )
+{
+ If_Obj_t * pObj;
+ // get memory for the new object
+ pObj = If_ManSetupObj( p );
+ pObj->Type = IF_AND;
+ pObj->fCompl0 = fCompl0;
+ pObj->fCompl1 = fCompl1;
+ pObj->pFanin0 = pFan0; pFan0->nRefs++;
+ pObj->pFanin1 = pFan1; pFan1->nRefs++;
+ pObj->fPhase = (fCompl0? !pFan0->fPhase : pFan0->fPhase) & (fCompl1? !pFan1->fPhase : pFan1->fPhase);
+ pObj->Level = 1 + IF_MAX( pFan0->Level, pFan1->Level );
+ if ( p->nLevelMax < (int)pObj->Level )
+ p->nLevelMax = (int)pObj->Level;
+ p->nObjs[IF_AND]++;
+ return pObj;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prepares memory for the node with cuts.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_Obj_t * If_ManSetupObj( If_Man_t * p )
+{
+ If_Obj_t * pObj;
+ int i, * pArrays;
+ // get memory for the object
+ pObj = (If_Obj_t *)Mem_FixedEntryFetch( p->pMem );
+ memset( pObj, 0, p->nEntryBase );
+ // organize memory
+ pArrays = (int *)((char *)pObj + p->nEntryBase);
+ for ( i = 0; i < p->pPars->nCutsMax; i++ )
+ pObj->Cuts[i].pLeaves = pArrays + i * p->pPars->nLutSize;
+ // assign ID and save
+ pObj->Id = Vec_PtrSize(p->vObjs);
+ Vec_PtrPush( p->vObjs, pObj );
+ // assign elementary cut
+ pObj->nCuts = 1;
+ pObj->Cuts[0].nLeaves = 1;
+ pObj->Cuts[0].pLeaves[0] = pObj->Id;
+ pObj->iCut = 0;
+ // set the required times
+ pObj->Required = IF_FLOAT_LARGE;
+ return pObj;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prepares memory for additional cuts of the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_Cut_t ** If_ManSetupCuts( If_Man_t * p )
+{
+ If_Cut_t ** pCutStore;
+ int * pArrays, nCutSize, nCutsTotal, i;
+ nCutsTotal = p->pPars->nCutsMax * p->pPars->nCutsMax;
+ nCutSize = sizeof(If_Cut_t) + sizeof(int) * p->pPars->nLutSize;
+ pCutStore = (If_Cut_t **)ALLOC( If_Cut_t *, (nCutsTotal + 1) );
+ memset( pCutStore, 0, sizeof(If_Cut_t *) * (nCutsTotal + 1) );
+ pCutStore[0] = (If_Cut_t *)ALLOC( char, nCutSize * nCutsTotal );
+ memset( pCutStore[0], 0, nCutSize * nCutsTotal );
+ for ( i = 1; i < nCutsTotal; i++ )
+ pCutStore[i] = (If_Cut_t *)((char *)pCutStore[0] + sizeof(If_Cut_t) * i);
+ pArrays = (int *)((char *)pCutStore[0] + sizeof(If_Cut_t) * nCutsTotal);
+ for ( i = 0; i < nCutsTotal; i++ )
+ pCutStore[i]->pLeaves = pArrays + i * p->pPars->nLutSize;
+ return pCutStore;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/map/if/ifMap.c b/src/map/if/ifMap.c
new file mode 100644
index 00000000..5f2c4133
--- /dev/null
+++ b/src/map/if/ifMap.c
@@ -0,0 +1,391 @@
+/**CFile****************************************************************
+
+ FileName [ifMap.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [FPGA mapping based on priority cuts.]
+
+ Synopsis [Mapping procedures.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: ifMap.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "if.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Prepares the object for FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_CutMerge( If_Cut_t * pC0, If_Cut_t * pC1, If_Cut_t * pC, int nLimit )
+{
+ int i, k, c;
+ assert( pC0->nLeaves >= pC1->nLeaves );
+ // the case of the largest cut sizes
+ if ( pC0->nLeaves == nLimit && pC1->nLeaves == nLimit )
+ {
+ for ( i = 0; i < pC0->nLeaves; i++ )
+ if ( pC0->pLeaves[i] != pC1->pLeaves[i] )
+ return 0;
+ for ( i = 0; i < pC0->nLeaves; i++ )
+ pC->pLeaves[i] = pC0->pLeaves[i];
+ pC->nLeaves = pC0->nLeaves;
+ return 1;
+ }
+ // the case when one of the cuts is the largest
+ if ( pC0->nLeaves == nLimit )
+ {
+ for ( i = 0; i < pC1->nLeaves; i++ )
+ {
+ for ( k = pC0->nLeaves - 1; k >= 0; k-- )
+ if ( pC0->pLeaves[k] == pC1->pLeaves[i] )
+ break;
+ if ( k == -1 ) // did not find
+ return 0;
+ }
+ for ( i = 0; i < pC0->nLeaves; i++ )
+ pC->pLeaves[i] = pC0->pLeaves[i];
+ pC->nLeaves = pC0->nLeaves;
+ return 1;
+ }
+
+ // compare two cuts with different numbers
+ i = k = 0;
+ for ( c = 0; c < nLimit; c++ )
+ {
+ if ( k == pC1->nLeaves )
+ {
+ if ( i == pC0->nLeaves )
+ {
+ pC->nLeaves = c;
+ return 1;
+ }
+ pC->pLeaves[c] = pC0->pLeaves[i++];
+ continue;
+ }
+ if ( i == pC0->nLeaves )
+ {
+ if ( k == pC1->nLeaves )
+ {
+ pC->nLeaves = c;
+ return 1;
+ }
+ pC->pLeaves[c] = pC1->pLeaves[k++];
+ continue;
+ }
+ if ( pC0->pLeaves[i] < pC1->pLeaves[k] )
+ {
+ pC->pLeaves[c] = pC0->pLeaves[i++];
+ continue;
+ }
+ if ( pC0->pLeaves[i] > pC1->pLeaves[k] )
+ {
+ pC->pLeaves[c] = pC1->pLeaves[k++];
+ continue;
+ }
+ pC->pLeaves[c] = pC0->pLeaves[i++];
+ k++;
+ }
+ if ( i < pC0->nLeaves || k < pC1->nLeaves )
+ return 0;
+ pC->nLeaves = c;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prepares the object for FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_CutCompareDelay( If_Cut_t ** ppC0, If_Cut_t ** ppC1 )
+{
+ If_Cut_t * pC0 = *ppC0;
+ If_Cut_t * pC1 = *ppC1;
+ if ( pC0->Delay < pC1->Delay )
+ return -1;
+ if ( pC0->Delay > pC1->Delay )
+ return 1;
+ if ( pC0->nLeaves < pC1->nLeaves )
+ return -1;
+ if ( pC0->nLeaves > pC1->nLeaves )
+ return 1;
+ if ( pC0->Flow < pC1->Flow )
+ return -1;
+ if ( pC0->Flow > pC1->Flow )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prepares the object for FPGA mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_CutCompareArea( If_Cut_t ** ppC0, If_Cut_t ** ppC1 )
+{
+ If_Cut_t * pC0 = *ppC0;
+ If_Cut_t * pC1 = *ppC1;
+ if ( pC0->Flow < pC1->Flow )
+ return -1;
+ if ( pC0->Flow > pC1->Flow )
+ return 1;
+ if ( pC0->nLeaves < pC1->nLeaves )
+ return -1;
+ if ( pC0->nLeaves > pC1->nLeaves )
+ return 1;
+ if ( pC0->Delay < pC1->Delay )
+ return -1;
+ if ( pC0->Delay > pC1->Delay )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes delay.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
+{
+ If_Obj_t * pLeaf;
+ float Delay;
+ int i;
+ Delay = -IF_FLOAT_LARGE;
+ If_CutForEachLeaf( p, pCut, pLeaf, i )
+ Delay = IF_MAX( Delay, If_ObjCutBest(pLeaf)->Delay );
+ return Delay + If_CutLutDelay(p, pCut);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes area flow.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float If_CutFlow( If_Man_t * p, If_Cut_t * pCut )
+{
+ If_Obj_t * pLeaf;
+ float Flow;
+ int i;
+ Flow = If_CutLutArea(p, pCut);
+ If_CutForEachLeaf( p, pCut, pLeaf, i )
+ Flow += If_ObjCutBest(pLeaf)->Flow / pLeaf->EstRefs;
+ return Flow;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes area of the first level.]
+
+ Description [The cut need to be derefed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float If_CutArea1( If_Man_t * p, If_Cut_t * pCut )
+{
+ If_Obj_t * pLeaf;
+ float Area;
+ int i;
+ Area = If_CutLutArea(p, pCut);
+ If_CutForEachLeaf( p, pCut, pLeaf, i )
+ if ( pLeaf->nRefs == 0 )
+ Area += If_CutLutArea(p, If_ObjCutBest(pLeaf));
+ return Area;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes area of the first level.]
+
+ Description [The cut need to be derefed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_CutRef1( If_Man_t * p, If_Cut_t * pCut )
+{
+ If_Obj_t * pLeaf;
+ int i;
+ If_CutForEachLeaf( p, pCut, pLeaf, i )
+ pLeaf->nRefs++;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes area of the first level.]
+
+ Description [The cut need to be derefed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_CutDeref1( If_Man_t * p, If_Cut_t * pCut )
+{
+ If_Obj_t * pLeaf;
+ int i;
+ If_CutForEachLeaf( p, pCut, pLeaf, i )
+ pLeaf->nRefs--;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes area of the first level.]
+
+ Description [The cut need to be derefed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_CutCopy( If_Cut_t * pCutDest, If_Cut_t * pCutSrc )
+{
+ int * pArray;
+ pArray = pCutDest->pLeaves;
+ *pCutDest = *pCutSrc;
+ pCutDest->pLeaves = pArray;
+ memcpy( pCutDest->pLeaves, pCutSrc->pLeaves, sizeof(int) * pCutSrc->nLeaves );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Finds the best cut.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ObjPerformMapping( If_Man_t * p, If_Obj_t * pObj )
+{
+ If_Cut_t * pCut0, * pCut1, * pCut;
+ int i, k;
+ // create cross-product of the cuts
+ p->nCuts = 0;
+ pCut = p->ppCuts[0];
+ If_ObjForEachCut( pObj->pFanin0, pCut0, i )
+ If_ObjForEachCut( pObj->pFanin1, pCut1, k )
+ {
+ if ( pCut0->nLeaves < pCut1->nLeaves )
+ {
+ if ( !If_CutMerge( pCut1, pCut0, pCut, p->pPars->nLutSize ) )
+ continue;
+ }
+ else
+ {
+ if ( !If_CutMerge( pCut0, pCut1, pCut, p->pPars->nLutSize ) )
+ continue;
+ }
+ // the cuts have been successfully merged
+ pCut->pOne = pCut0; pCut->fCompl0 = pObj->fCompl0;
+ pCut->pTwo = pCut1; pCut->fCompl1 = pObj->fCompl1;
+// pCut->Phase = ...
+ pCut->Delay = If_CutDelay( p, pCut );
+ pCut->Flow = If_CutFlow( p, pCut );
+ // prepare room for the next cut
+ pCut = p->ppCuts[++p->nCuts];
+ }
+ // sort the cuts
+ if ( p->pPars->Mode == 1 ) // delay
+ qsort( p->ppCuts, p->nCuts, sizeof(If_Cut_t *), (int (*)(const void *, const void *))If_CutCompareDelay );
+ else
+ qsort( p->ppCuts, p->nCuts, sizeof(If_Cut_t *), (int (*)(const void *, const void *))If_CutCompareArea );
+ // take the first
+ pObj->nCuts = IF_MIN( p->nCuts + 1, p->pPars->nCutsMax );
+ If_ObjForEachCutStart( pObj, pCut, i, 1 )
+ If_CutCopy( pCut, p->ppCuts[i-1] );
+ pObj->iCut = 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Maps the nodes for delay.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_ManPerformMapping( If_Man_t * p )
+{
+ If_Obj_t * pObj;
+ float DelayBest;
+ int i, clk = clock();
+ // set arrival times and trivial cuts at const 1 and PIs
+ If_ManConst1(p)->Cuts[0].Delay = 0.0;
+ If_ManForEachPi( p, pObj, i )
+ pObj->Cuts[0].Delay = p->pPars->pTimesArr[i];
+ // set the initial fanout estimates
+ If_ManForEachObj( p, pObj, i )
+ pObj->EstRefs = (float)pObj->nRefs;
+ // map the internal nodes
+ If_ManForEachNode( p, pObj, i )
+ If_ObjPerformMapping( p, pObj );
+ // get the best arrival time of the POs
+ DelayBest = If_ManDelayMax(p);
+ printf( "Best delay = %d. ", (int)DelayBest );
+ PRT( "Time", clock() - clk );
+ return 1;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/map/if/ifUtil.c b/src/map/if/ifUtil.c
new file mode 100644
index 00000000..1144fa3f
--- /dev/null
+++ b/src/map/if/ifUtil.c
@@ -0,0 +1,229 @@
+/**CFile****************************************************************
+
+ FileName [ifUtil.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [FPGA mapping based on priority cuts.]
+
+ Synopsis [Various utilities.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: ifUtil.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "if.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Returns the max delay of the POs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float If_ManDelayMax( If_Man_t * p )
+{
+ If_Obj_t * pObj;
+ float DelayBest;
+ int i;
+ DelayBest = -IF_FLOAT_LARGE;
+ If_ManForEachPo( p, pObj, i )
+ if ( DelayBest < If_ObjCutBest( If_ObjFanin0(pObj) )->Delay )
+ DelayBest = If_ObjCutBest( If_ObjFanin0(pObj) )->Delay;
+ return DelayBest;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets all the node copy to NULL.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManCleanNodeCopy( If_Man_t * p )
+{
+ If_Obj_t * pObj;
+ int i;
+ If_ManForEachObj( p, pObj, i )
+ If_ObjSetCopy( pObj, NULL );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets all the cut data to NULL.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManCleanCutData( If_Man_t * p )
+{
+ If_Obj_t * pObj;
+ If_Cut_t * pCut;
+ int i, k;
+ If_ManForEachObj( p, pObj, i )
+ If_ObjForEachCut( pObj, pCut, k )
+ If_CutSetData( pCut, NULL );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes area, references, and nodes used in the mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float If_ManScanMapping_rec( If_Man_t * p, If_Obj_t * pObj, If_Obj_t ** ppStore )
+{
+ If_Obj_t * pLeaf;
+ If_Cut_t * pCutBest;
+ float aArea;
+ int i;
+ if ( pObj->nRefs++ || If_ObjIsPi(pObj) || If_ObjIsConst1(pObj) )
+ return 0.0;
+ // store the node in the structure by level
+ assert( If_ObjIsAnd(pObj) );
+ pObj->pCopy = (char *)ppStore[pObj->Level];
+ ppStore[pObj->Level] = pObj;
+ // visit the transitive fanin of the selected cut
+ pCutBest = If_ObjCutBest(pObj);
+ aArea = If_CutLutArea( p, pCutBest );
+ If_CutForEachLeaf( p, pCutBest, pLeaf, i )
+ aArea += If_ManScanMapping_rec( p, pLeaf, ppStore );
+ return aArea;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes area, references, and nodes used in the mapping.]
+
+ Description [Collects the nodes in reverse topological order in array
+ p->vMapping.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float If_ManScanMapping( If_Man_t * p )
+{
+ If_Obj_t * pObj, ** ppStore;
+ float aArea;
+ int i;
+ // clean all references
+ If_ManForEachObj( p, pObj, i )
+ {
+ pObj->Required = IF_FLOAT_LARGE;
+ pObj->nRefs = 0;
+ }
+ // allocate place to store the nodes
+ ppStore = ALLOC( If_Obj_t *, p->nLevelMax + 1 );
+ memset( ppStore, 0, sizeof(If_Obj_t *) * (p->nLevelMax + 1) );
+ // collect nodes reachable from POs in the DFS order through the best cuts
+ aArea = 0;
+ If_ManForEachPo( p, pObj, i )
+ aArea += If_ManScanMapping_rec( p, If_ObjFanin0(pObj), ppStore );
+ // reconnect the nodes in reverse topological order
+ Vec_PtrClear( p->vMapped );
+ for ( i = p->nLevelMax; i >= 0; i-- )
+ for ( pObj = ppStore[i]; pObj; pObj = pObj->pCopy )
+ Vec_PtrPush( p->vMapped, pObj );
+ free( ppStore );
+ return aArea;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the required times of all nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManComputeRequired( If_Man_t * p, int fFirstTime )
+{
+ If_Obj_t * pObj, * pLeaf;
+ If_Cut_t * pCutBest;
+ float Required;
+ int i, k;
+ // compute area, clean required times, collect nodes used in the mapping
+ p->AreaGlo = If_ManScanMapping( p );
+ // get the global required times
+ p->RequiredGlo = If_ManDelayMax( p );
+ // update the required times according to the target
+ if ( p->pPars->DelayTarget != -1 )
+ {
+ if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
+ {
+ if ( fFirstTime )
+ printf( "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
+ }
+ else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
+ {
+ if ( fFirstTime )
+ printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
+ p->RequiredGlo = p->pPars->DelayTarget;
+ }
+ }
+ // set the required times for the POs
+ if ( p->pPars->fLatchPaths )
+ {
+ If_ManForEachLatch( p, pObj, i )
+ If_ObjFanin0(pObj)->Required = p->RequiredGlo;
+ }
+ else
+ {
+ If_ManForEachPo( p, pObj, i )
+ If_ObjFanin0(pObj)->Required = p->RequiredGlo;
+ }
+ // go through the nodes in the reverse topological order
+ Vec_PtrForEachEntry( p->vMapped, pObj, k )
+ {
+ // get the best cut of the node
+ pCutBest = If_ObjCutBest(pObj);
+ // get the required times for the leaves of the cut
+ Required = pObj->Required - If_CutLutDelay( p, pCutBest );
+ // update the required time of the leaves
+ If_CutForEachLeaf( p, pCutBest, pLeaf, i )
+ pLeaf->Required = IF_MIN( pLeaf->Required, Required );
+ }
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/map/if/if_.c b/src/map/if/if_.c
new file mode 100644
index 00000000..d2960077
--- /dev/null
+++ b/src/map/if/if_.c
@@ -0,0 +1,47 @@
+/**CFile****************************************************************
+
+ FileName [if_.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [FPGA mapping based on priority cuts.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 21, 2006.]
+
+ Revision [$Id: if_.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "if.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/map/if/module.make b/src/map/if/module.make
new file mode 100644
index 00000000..be044da2
--- /dev/null
+++ b/src/map/if/module.make
@@ -0,0 +1,4 @@
+SRC += src/map/if/ifCore.c \
+ src/map/if/ifMan.c \
+ src/map/if/ifMap.c \
+ src/map/if/ifUtil.c
diff --git a/src/map/pga/module.make b/src/map/pga/module.make
deleted file mode 100644
index 2a45327e..00000000
--- a/src/map/pga/module.make
+++ /dev/null
@@ -1,4 +0,0 @@
-SRC += src/map/pga/pgaCore.c \
- src/map/pga/pgaMan.c \
- src/map/pga/pgaMatch.c \
- src/map/pga/pgaUtil.c
diff --git a/src/map/pga/pga.h b/src/map/pga/pga.h
deleted file mode 100644
index 4b2a9df4..00000000
--- a/src/map/pga/pga.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/**CFile****************************************************************
-
- FileName [pga.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [FPGA mapper.]
-
- Synopsis [External declarations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: pga.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __PGA_H__
-#define __PGA_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-typedef struct Pga_ManStruct_t_ Pga_Man_t;
-typedef struct Pga_ParamsStruct_t_ Pga_Params_t;
-
-struct Pga_ParamsStruct_t_
-{
- // data for mapping
- Abc_Ntk_t * pNtk; // the network to be mapped
- Fpga_LutLib_t * pLutLib; // the LUT library
- float * pSwitching; // switching activity for each node
- // mapping parameters
- int fDropCuts; // enables cut dropping
- int fAreaFlow; // enables area flow minimization
- int fArea; // enables area minimization
- int fSwitching; // enables switching activity minimization
- int fVerbose; // enables verbose output
-};
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/*=== pgaApi.c ==========================================================*/
-extern Vec_Ptr_t * Pga_DoMapping( Pga_Man_t * p );
-/*=== pgaMan.c ==========================================================*/
-extern Pga_Man_t * Pga_ManStart( Pga_Params_t * pParams );
-extern void Pga_ManStop( Pga_Man_t * p );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/map/pga/pgaCore.c b/src/map/pga/pgaCore.c
deleted file mode 100644
index 240c24fd..00000000
--- a/src/map/pga/pgaCore.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/**CFile****************************************************************
-
- FileName [pgaCore.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [FPGA mapper.]
-
- Synopsis [External APIs of the FPGA manager.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: pgaCore.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "pgaInt.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-static void Pga_MappingInitCis( Pga_Man_t * p );
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Performs technology mapping for the given object graph.]
-
- Description [The object graph is stored in the mapping manager.
- First, all the AND-nodes, which fanout into the POs, are collected
- in the DFS fashion. Next, three steps are performed: the k-feasible
- cuts are computed for each node, the truth tables are computed for
- each cut, and the delay-optimal matches are assigned for each node.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Pga_DoMapping( Pga_Man_t * p )
-{
- int fShowSwitching = 0;
- float aAreaTotalCur;
- int Iter, clk, clkTotal = clock();
-
- // assign the arrival times of the PIs
- Pga_MappingInitCis( p );
-
- // map the AIG for delay
-clk = clock();
- Pga_MappingMatches( p, 0 );
-p->timeDelay = clock() - clk;
-
- // compute area, set references, and collect nodes used in the mapping
- Iter = 1;
- aAreaTotalCur = Pga_MappingSetRefsAndArea( p );
-if ( p->pParams->fVerbose )
-{
-printf( "Iteration %dD : Area = %8.1f ", Iter++, aAreaTotalCur );
-if ( fShowSwitching )
-printf( "Switch = %8.1f ", Pga_MappingGetSwitching(p) );
-PRT( "Time", p->timeDelay );
-}
-
- if ( p->pParams->fAreaFlow )
- {
-clk = clock();
- // compute the required times and the fanouts
- Pga_MappingComputeRequired( p );
- // remap topologically
- Pga_MappingMatches( p, 1 );
-p->timeAreaFlow = clock() - clk;
- // get the resulting area
- aAreaTotalCur = Pga_MappingSetRefsAndArea( p );
- // note that here we do not update the reference counter
- // for some reason, this works better on benchmarks
-if ( p->pParams->fVerbose )
-{
-printf( "Iteration %dF : Area = %8.1f ", Iter++, aAreaTotalCur );
-if ( fShowSwitching )
-printf( "Switch = %8.1f ", Pga_MappingGetSwitching(p) );
-PRT( "Time", p->timeAreaFlow );
-}
- }
-
- if ( p->pParams->fArea )
- {
-clk = clock();
- // compute the required times and the fanouts
- Pga_MappingComputeRequired( p );
- // remap topologically
- if ( p->pParams->fSwitching )
- Pga_MappingMatches( p, 3 );
- else
- Pga_MappingMatches( p, 2 );
-p->timeArea = clock() - clk;
- // get the resulting area
- aAreaTotalCur = Pga_MappingSetRefsAndArea( p );
-if ( p->pParams->fVerbose )
-{
-printf( "Iteration %d%s : Area = %8.1f ", Iter++, (p->pParams->fSwitching?"S":"A"), aAreaTotalCur );
-if ( fShowSwitching )
-printf( "Switch = %8.1f ", Pga_MappingGetSwitching(p) );
-PRT( "Time", p->timeArea );
-}
- }
- p->AreaGlobal = aAreaTotalCur;
-
- if ( p->pParams->fVerbose )
- Pga_MappingPrintOutputArrivals( p );
-
- // return the mapping
- return Pga_MappingResults( p );
-}
-
-/**Function*************************************************************
-
- Synopsis [Initializes the CI node arrival times.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Pga_MappingInitCis( Pga_Man_t * p )
-{
- Pga_Node_t * pNode;
- float * pCiArrs;
- int i;
- // get the CI arrival times
- pCiArrs = Abc_NtkGetCiArrivalFloats( p->pParams->pNtk );
- // assign the arrival times of the PIs
- Pga_ManForEachCi( p, pNode, i )
- pNode->Match.Delay = pCiArrs[i];
- free( pCiArrs );
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/map/pga/pgaInt.h b/src/map/pga/pgaInt.h
deleted file mode 100644
index da9aa9a9..00000000
--- a/src/map/pga/pgaInt.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/**CFile****************************************************************
-
- FileName [pgaInt.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [FPGA mapper.]
-
- Synopsis [Internal declarations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: pgaInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __PGA_INT_H__
-#define __PGA_INT_H__
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-#include <stdio.h>
-#include "abc.h"
-#include "fraig.h"
-#include "fpga.h"
-#include "cut.h"
-#include "pga.h"
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-typedef struct Pga_NodeStruct_t_ Pga_Node_t;
-typedef struct Pga_MatchStruct_t_ Pga_Match_t;
-
-struct Pga_ManStruct_t_
-{
- // mapping parameters
- Pga_Params_t * pParams; // input data
- // mapping structures
- Pga_Node_t * pMemory; // the memory for all mapping structures
- Vec_Ptr_t * vStructs; // mapping structures one-to-one with ABC nodes
- Vec_Ptr_t * vOrdering; // mapping nodes ordered by level
- // k-feasible cuts
- int nVarsMax; // the "k" of k-feasible cuts
- Cut_Man_t * pManCut; // the cut manager
- // LUT library
- float * pLutDelays; // the delay of the LUTs
- float * pLutAreas; // the areas of the LUTs
- float Epsilon;
- // global parameters
- float AreaGlobal; // the total area of this mapping
- float ArrivalGlobal; // the largest delay of any path
- float RequiredGlobal;// the global required time (may be different from largest delay)
- float RequiredUser; // the required time given by the user
- // runtime stats
- int timeToMap; // the time to start the mapper
- int timeCuts; // the time to compute the cuts
- int timeDelay; // the time to compute delay
- int timeAreaFlow; // the time to perform area flow optimization
- int timeArea; // the time to perform area flow optimization
- int timeToNet; // the time to transform back to network
- int timeTotal; // the total time
- int time1; // temporary
- int time2; // temporary
-};
-
-struct Pga_MatchStruct_t_
-{
- Cut_Cut_t * pCut; // the best cut
- float Delay; // the arrival time of this cut
- float Area; // the area of this cut
-};
-
-struct Pga_NodeStruct_t_
-{
- int Id; // ID of the node
- int nRefs; // the number of references
- float EstRefs; // the estimated reference counter
- float Required; // the required time
- float Switching; // the switching activity
- Pga_Match_t Match; // the best match at the node
-};
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-static inline Pga_Node_t * Pga_Node( Pga_Man_t * p, int Id ) { return p->vStructs->pArray[Id]; }
-
-// iterator through the CIs
-#define Pga_ManForEachCi( p, pCi, i ) \
- for ( i = 0; (i < Abc_NtkCiNum(p->pParams->pNtk)) && (((pCi) = Pga_Node(p, Abc_NtkCi(p->pParams->pNtk,i)->Id)), 1); i++ )
-// iterator through the CO derivers
-#define Pga_ManForEachCoDriver( p, pCo, i ) \
- for ( i = 0; (i < Abc_NtkCoNum(p->pParams->pNtk)) && (((pCo) = Pga_Node(p, Abc_ObjFaninId0(Abc_NtkCo(p->pParams->pNtk,i)))), 1); i++ )
-// iterators through the CIs and internal nodes
-#define Pga_ManForEachObjDirect( p, pNode, i ) \
- Vec_PtrForEachEntry( p->vOrdering, pNode, i )
-#define Pga_ManForEachObjReverse( p, pNode, i ) \
- Vec_PtrForEachEntryReverse( p->vOrdering, pNode, i )
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/*=== pgaMatch.c ==========================================================*/
-extern void Pga_MappingMatches( Pga_Man_t * p, int Mode );
-/*=== pgaUtil.c ==========================================================*/
-extern Vec_Ptr_t * Pga_MappingResults( Pga_Man_t * p );
-extern float Pga_TimeComputeArrivalMax( Pga_Man_t * p );
-extern void Pga_MappingComputeRequired( Pga_Man_t * p );
-extern float Pga_MappingSetRefsAndArea( Pga_Man_t * p );
-extern float Pga_MappingGetSwitching( Pga_Man_t * p );
-extern void Pga_MappingPrintOutputArrivals( Pga_Man_t * p );
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/map/pga/pgaMan.c b/src/map/pga/pgaMan.c
deleted file mode 100644
index 4ecc2ca7..00000000
--- a/src/map/pga/pgaMan.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/**CFile****************************************************************
-
- FileName [pgaMan.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [FPGA mapper.]
-
- Synopsis [Mapping manager.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: pgaMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "pgaInt.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-static Cut_Man_t * Pga_ManStartCutMan( Pga_Params_t * pParamsPga );
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Starts the manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Pga_Man_t * Pga_ManStart( Pga_Params_t * pParams )
-{
- Pga_Man_t * p;
- Pga_Node_t * pNode;
- Cut_Man_t * pManCut;
- Abc_Ntk_t * pNtk;
- Abc_Obj_t * pObj;
- int i, Counter;
- int clk = clock();
-
- // make sure the network is given
- pNtk = pParams->pNtk;
- if ( pNtk == NULL )
- {
- printf( "Network is not specified.\n" );
- return NULL;
- }
- if ( !Abc_NtkIsStrash(pNtk) )
- {
- printf( "Mapping can only be applied to an AIG.\n" );
- return NULL;
- }
- // the cut manager if given should be in sinc
- pManCut = pNtk->pManCut;
- if ( pManCut && Cut_ManReadVarsMax(pManCut) != Fpga_LutLibReadVarMax(pParams->pLutLib) )
- {
- printf( "The precomputed cuts have different size.\n" );
- return NULL;
- }
- // make sure the nodes are in the topological order
- if ( !Abc_NtkIsDfsOrdered(pNtk) )
- {
- printf( "The nodes of the network are not DFS ordered.\n" );
-// Abc_NtkReassignIds( pNtk );
- return NULL;
- }
- // make sure there are no dangling nodes (unless they are choices)
-
- // start the mapping manager
- p = ALLOC( Pga_Man_t, 1 );
- memset( p, 0, sizeof(Pga_Man_t) );
- p->pParams = pParams;
- p->nVarsMax = Fpga_LutLibReadVarMax(pParams->pLutLib);
- p->pManCut = pManCut? pManCut : Pga_ManStartCutMan(pParams);
- p->vOrdering = Abc_AigGetLevelizedOrder(pNtk, 0); // what happens with dangling nodes???
- p->pLutAreas = Fpga_LutLibReadLutAreas(pParams->pLutLib);
- p->pLutDelays = Fpga_LutLibReadLutDelays(pParams->pLutLib);
- p->Epsilon = (float)0.00001;
-
- // allocate mapping structures
- p->pMemory = ALLOC( Pga_Node_t, Abc_NtkObjNum(pNtk) );
- memset( p->pMemory, 0, sizeof(Pga_Node_t) * Abc_NtkObjNum(pNtk) );
- p->vStructs = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) );
- Counter = 0;
- Abc_NtkForEachObj( pNtk, pObj, i )
- {
- pNode = p->pMemory + Counter++;
- pNode->Id = pObj->Id;
- pNode->nRefs = pObj->vFanouts.nSize;
- pNode->Required = ABC_INFINITY;
- pNode->Match.Area = ABC_INFINITY;
- // skip secondary nodes
- if ( Abc_ObjFanoutNum(pObj) == 0 )
- continue;
- Vec_PtrWriteEntry( p->vStructs, pObj->Id, pNode );
- }
- assert( Counter == Abc_NtkObjNum(pNtk) );
- // update order to depend on mapping nodes
- Vec_PtrForEachEntry( p->vOrdering, pObj, i )
- Vec_PtrWriteEntry( p->vOrdering, i, Pga_Node(p,pObj->Id) );
-p->timeToMap = clock() - clk;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Stops the manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Pga_ManStop( Pga_Man_t * p )
-{
- Cut_ManStop( p->pManCut );
- Vec_PtrFree( p->vOrdering );
- Vec_PtrFree( p->vStructs );
- free( p->pMemory );
- free( p );
-}
-
-/**Function*************************************************************
-
- Synopsis [Starts the cut manager for FPGA mapping.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Cut_Man_t * Pga_ManStartCutMan( Pga_Params_t * pParamsPga )
-{
- static Cut_Params_t Params, * pParams = &Params;
- Abc_Ntk_t * pNtk = pParamsPga->pNtk;
- Cut_Man_t * pManCut;
- Abc_Obj_t * pObj;
- int i;
- // start the cut manager
- memset( pParams, 0, sizeof(Cut_Params_t) );
- pParams->nVarsMax = Fpga_LutLibReadVarMax(pParamsPga->pLutLib); // max cut size
- pParams->nKeepMax = 250; // the max number of cuts kept at a node
- pParams->fTruth = 0; // compute truth tables
- pParams->fFilter = 1; // filter dominated cuts
- pParams->fSeq = 0; // compute sequential cuts
- pParams->fDrop = pParamsPga->fDropCuts; // drop cuts on the fly
- pParams->fVerbose = 0; // the verbosiness flag
- pParams->nIdsMax = Abc_NtkObjNumMax( pNtk );
- pManCut = Cut_ManStart( pParams );
- if ( pParams->fDrop )
- Cut_ManSetFanoutCounts( pManCut, Abc_NtkFanoutCounts(pNtk) );
- // set cuts for PIs
- Abc_NtkForEachCi( pNtk, pObj, i )
- if ( Abc_ObjFanoutNum(pObj) > 0 )
- Cut_NodeSetTriv( pManCut, pObj->Id );
- return pManCut;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/map/pga/pgaMatch.c b/src/map/pga/pgaMatch.c
deleted file mode 100644
index 186fbf64..00000000
--- a/src/map/pga/pgaMatch.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/**CFile****************************************************************
-
- FileName [pgaMatch.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [FPGA mapper.]
-
- Synopsis [Mapping procedures.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: pgaMatch.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "pgaInt.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-static char * s_Modes[4] = { "Delay", "Flow", "Area", "Switch" };
-
-static int Pga_MappingMatchNode( Pga_Man_t * p, int NodeId, Cut_Cut_t * pList, int Mode );
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Performs mapping for delay, area-flow, area, switching.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Pga_MappingMatches( Pga_Man_t * p, int Mode )
-{
- ProgressBar * pProgress;
- Abc_Ntk_t * pNtk;
- Abc_Obj_t * pObj;
- Cut_Cut_t * pList;
- int i, clk;
-
- assert( Mode >= 0 && Mode <= 2 );
-
- // match LUTs with nodes in the topological order
- pNtk = p->pParams->pNtk;
- pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
- Abc_NtkForEachObj( pNtk, pObj, i )
- {
- // skip the CIs
- if ( Abc_ObjIsCi(pObj) )
- continue;
- // when we reached a CO, it is time to deallocate the cuts
- if ( Abc_ObjIsCo(pObj) )
- {
- if ( p->pParams->fDropCuts )
- Cut_NodeTryDroppingCuts( p->pManCut, Abc_ObjFaninId0(pObj) );
- continue;
- }
- // skip constant node, it has no cuts
-// if ( Abc_NodeIsConst(pObj) )
-// continue;
- // get the cuts
-clk = clock();
- pList = Abc_NodeGetCutsRecursive( p->pManCut, pObj, 0, 0 );
-p->timeCuts += clock() - clk;
- // match the node
- Pga_MappingMatchNode( p, pObj->Id, pList, Mode );
- Extra_ProgressBarUpdate( pProgress, i, s_Modes[Mode] );
- }
- Extra_ProgressBarStop( pProgress );
-}
-
-
-
-
-/**Function*************************************************************
-
- Synopsis [Computes the match of the cut.]
-
- Description [Returns 1 if feasible.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline float Pga_CutGetArrival( Pga_Man_t * p, Cut_Cut_t * pCut )
-{
- float DelayCur, DelayWorst;
- unsigned i;
- assert( pCut->nLeaves > 1 );
- DelayWorst = -ABC_INFINITY;
- for ( i = 0; i < pCut->nLeaves; i++ )
- {
- DelayCur = Pga_Node(p, pCut->pLeaves[i])->Match.Delay;
- if ( DelayWorst < DelayCur )
- DelayWorst = DelayCur;
- }
- DelayWorst += p->pLutDelays[pCut->nLeaves];
- return DelayWorst;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes the match of the cut.]
-
- Description [Returns 1 if feasible.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline float Pga_CutGetAreaFlow( Pga_Man_t * p, Cut_Cut_t * pCut )
-{
- float Flow;
- Pga_Node_t * pNode;
- unsigned i;
- assert( pCut->nLeaves > 1 );
- Flow = p->pLutAreas[pCut->nLeaves];
- for ( i = 0; i < pCut->nLeaves; i++ )
- {
- pNode = Pga_Node(p, pCut->pLeaves[i]);
- assert( pNode->EstRefs > 0 );
- Flow += pNode->Match.Area / pNode->EstRefs;
- }
- return Flow;
-}
-
-/**function*************************************************************
-
- synopsis [References the cut.]
-
- description [This procedure is similar to the procedure NodeReclaim.]
-
- sideeffects []
-
- seealso []
-
-***********************************************************************/
-float Pga_CutRef( Pga_Man_t * p, Pga_Node_t * pNode, Cut_Cut_t * pCut )
-{
- Pga_Node_t * pFanin;
- float aArea;
- unsigned i;
- // start the area of this cut
- aArea = p->pLutAreas[pCut->nLeaves];
- // go through the children
- for ( i = 0; i < pCut->nLeaves; i++ )
- {
- pFanin = Pga_Node(p, pCut->pLeaves[i]);
- assert( pFanin->nRefs >= 0 );
- if ( pFanin->nRefs++ > 0 )
- continue;
- if ( pFanin->Match.pCut == NULL )
- continue;
- aArea += Pga_CutRef( p, pFanin, pFanin->Match.pCut );
- }
- return aArea;
-}
-
-/**function*************************************************************
-
- synopsis [Dereferences the cut.]
-
- description [This procedure is similar to the procedure NodeRecusiveDeref.]
-
- sideeffects []
-
- seealso []
-
-***********************************************************************/
-float Pga_CutDeref( Pga_Man_t * p, Pga_Node_t * pNode, Cut_Cut_t * pCut )
-{
- Pga_Node_t * pFanin;
- float aArea;
- unsigned i;
- // start the area of this cut
- aArea = p->pLutAreas[pCut->nLeaves];
- // go through the children
- for ( i = 0; i < pCut->nLeaves; i++ )
- {
- pFanin = Pga_Node(p, pCut->pLeaves[i]);
- assert( pFanin->nRefs > 0 );
- if ( --pFanin->nRefs > 0 )
- continue;
- if ( pFanin->Match.pCut == NULL )
- continue;
- aArea += Pga_CutDeref( p, pFanin, pFanin->Match.pCut );
- }
- return aArea;
-}
-
-/**function*************************************************************
-
- synopsis [Computes the exact area associated with the cut.]
-
- description [Assumes that the cut is deferenced.]
-
- sideeffects []
-
- seealso []
-
-***********************************************************************/
-static inline float Pga_CutGetAreaDerefed( Pga_Man_t * p, Pga_Node_t * pNode, Cut_Cut_t * pCut )
-{
- float aResult, aResult2;
- assert( pCut->nLeaves > 1 );
- aResult2 = Pga_CutRef( p, pNode, pCut );
- aResult = Pga_CutDeref( p, pNode, pCut );
- assert( aResult == aResult2 );
- return aResult;
-}
-
-
-
-/**Function*************************************************************
-
- Synopsis [Computes the match of the cut.]
-
- Description [Returns 1 if feasible.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Pga_MappingMatchCut( Pga_Man_t * p, Pga_Node_t * pNode, Cut_Cut_t * pCut, int Mode, Pga_Match_t * pMatch )
-{
- // compute the arrival time of the cut and its area flow
- pMatch->Delay = Pga_CutGetArrival( p, pCut );
- // drop the cut if it does not meet the required times
- if ( pMatch->Delay > pNode->Required + p->Epsilon )
- return 0;
- // get the second parameter
- if ( Mode == 0 || Mode == 1 )
- pMatch->Area = Pga_CutGetAreaFlow( p, pCut );
- else if ( Mode == 2 )
- pMatch->Area = Pga_CutGetAreaDerefed( p, pNode, pCut );
-// else if ( Mode == 3 )
-// pMatch->Area = Pga_CutGetSwitching( p, pNode, pCut );
- // if no cut is assigned, use the current one
- pMatch->pCut = pCut;
- return 1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Compares two matches.]
-
- Description [Returns 1 if the second match is better.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Pga_MappingCompareMatches( Pga_Man_t * p, Pga_Match_t * pMatchBest, Pga_Match_t * pMatchCur, int Mode )
-{
- if ( pMatchBest->pCut == NULL )
- return 1;
- if ( Mode == 0 )
- {
- // compare delays
- if ( pMatchBest->Delay < pMatchCur->Delay - p->Epsilon )
- return 0;
- if ( pMatchBest->Delay > pMatchCur->Delay + p->Epsilon )
- return 1;
- // compare areas
- if ( pMatchBest->Area < pMatchCur->Area - p->Epsilon )
- return 0;
- if ( pMatchBest->Area > pMatchCur->Area + p->Epsilon )
- return 1;
- // if equal, do not update
- return 0;
- }
- else
- {
- // compare areas
- if ( pMatchBest->Area < pMatchCur->Area - p->Epsilon )
- return 0;
- if ( pMatchBest->Area > pMatchCur->Area + p->Epsilon )
- return 1;
- // compare delays
- if ( pMatchBest->Delay < pMatchCur->Delay - p->Epsilon )
- return 0;
- if ( pMatchBest->Delay > pMatchCur->Delay + p->Epsilon )
- return 1;
- // if equal, do not update
- return 0;
- }
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Computes the best matching for one node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Pga_MappingMatchNode( Pga_Man_t * p, int NodeId, Cut_Cut_t * pList, int Mode )
-{
- Pga_Match_t MatchCur, * pMatchCur = &MatchCur;
- Pga_Match_t MatchBest, * pMatchBest = &MatchBest;
- Pga_Node_t * pNode;
- Cut_Cut_t * pCut;
-
- // get the mapping node
- pNode = Pga_Node( p, NodeId );
-
- // prepare for mapping
- if ( Mode == 0 )
- pNode->EstRefs = (float)pNode->nRefs;
- else if ( Mode == 1 )
- pNode->EstRefs = (float)((2.0 * pNode->EstRefs + pNode->nRefs) / 3.0);
- else if ( Mode == 2 && pNode->nRefs > 0 )
- Pga_CutDeref( p, pNode, pNode->Match.pCut );
-// else if ( Mode == 3 && pNode->nRefs > 0 )
-// Pga_CutDerefSwitch( p, pNode, pNode->Match.pCut );
-
- // start the best match
- pMatchBest->pCut = NULL;
-
- // go through the other cuts
- assert( pList->pNext );
- for ( pCut = pList->pNext; pCut; pCut = pCut->pNext )
- {
- // compute match for this cut
- if ( !Pga_MappingMatchCut( p, pNode, pCut, Mode, pMatchCur ) )
- continue;
- // compare matches
- if ( !Pga_MappingCompareMatches( p, pMatchBest, pMatchCur, Mode ) )
- continue;
- // the best match should be updated
- *pMatchBest = *pMatchCur;
- }
-
- // make sure the match is found
- if ( pMatchBest->pCut != NULL )
- pNode->Match = *pMatchBest;
- else
- {
- assert( 0 );
-// Pga_MappingMatchCut( p, pNode, pCut, Mode, pNode->Match );
- }
-
- // reference the best cut
- if ( Mode == 2 && pNode->nRefs > 0 )
- Pga_CutRef( p, pNode, pNode->Match.pCut );
-// else if ( Mode == 3 && pNode->nRefs > 0 )
-// Pga_CutRefSwitch( p, pNode, pNode->Match.pCut );
- return 1;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/map/pga/pgaUtil.c b/src/map/pga/pgaUtil.c
deleted file mode 100644
index c79e3515..00000000
--- a/src/map/pga/pgaUtil.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/**CFile****************************************************************
-
- FileName [pgaUtil.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [FPGA mapper.]
-
- Synopsis [Verious utilities.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: pgaUtil.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "pgaInt.h"
-
-#define PGA_CO_LIST_SIZE 5
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Returns the results of mapping.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Pga_MappingResults( Pga_Man_t * p )
-{
- Vec_Ptr_t * vResult;
- Pga_Node_t * pNode;
- int i;
- vResult = Vec_PtrAlloc( 1000 );
- Pga_ManForEachObjDirect( p, pNode, i )
- {
- // skip the CIs and nodes not used in the mapping
- if ( !pNode->Match.pCut || !pNode->nRefs )
- continue;
- pNode->Match.pCut->uSign = pNode->Id;
- Vec_PtrPush( vResult, pNode->Match.pCut );
- }
- return vResult;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes the maximum arrival times.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-float Pga_TimeComputeArrivalMax( Pga_Man_t * p )
-{
- Pga_Node_t * pNode;
- float ArrivalMax;
- int i;
- ArrivalMax = -ABC_INFINITY;
- Pga_ManForEachCoDriver( p, pNode, i )
- ArrivalMax = ABC_MAX( ArrivalMax, pNode->Match.Delay );
- return ArrivalMax;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Computes required times of all nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Pga_MappingComputeRequired( Pga_Man_t * p )
-{
- Pga_Node_t * pNode, * pFanin;
- Cut_Cut_t * pCutBest;
- float RequiredNew;
- int i, k;
- // clean the required times of all nodes
- Pga_ManForEachObjDirect( p, pNode, i )
- pNode->Required = ABC_INFINITY;
- // get the global required times
- p->AreaGlobal = Pga_TimeComputeArrivalMax( p );
- p->RequiredGlobal = ABC_MAX( p->AreaGlobal, p->RequiredUser );
- // set the global required times of the CO drivers
- Pga_ManForEachCoDriver( p, pNode, i )
- pNode->Required = p->RequiredGlobal;
- // propagate the required times in the reverse topological order
- Pga_ManForEachObjReverse( p, pNode, i )
- {
- // skip the CIs and nodes not used in the mapping
- if ( !pNode->Match.pCut || !pNode->nRefs )
- continue;
- // get the required time for children
- pCutBest = pNode->Match.pCut;
- RequiredNew = pNode->Required - p->pLutDelays[pCutBest->nLeaves];
- // update the required time of the children
- for ( k = 0; k < (int)pCutBest->nLeaves; k++ )
- {
- pFanin = Pga_Node( p, pCutBest->pLeaves[k] );
- pFanin->Required = ABC_MIN( pFanin->Required, RequiredNew );
- }
- }
- // check that the required times does not contradict the arrival times
- Pga_ManForEachObjDirect( p, pNode, i )
- assert( !pNode->Match.pCut || pNode->Match.Delay < pNode->Required + p->Epsilon );
-
-}
-
-/**Function*************************************************************
-
- Synopsis [Sets references and computes area for the current mapping.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-float Pga_MappingSetRefsAndArea( Pga_Man_t * p )
-{
- Pga_Node_t * pNode, * pFanin;
- Cut_Cut_t * pCutBest;
- float AreaTotal;
- int i, k;
- // clean all the references
- Pga_ManForEachObjDirect( p, pNode, i )
- pNode->nRefs = 0;
- // set the references of the CO drivers
- Pga_ManForEachCoDriver( p, pNode, i )
- pNode->nRefs++;
- // go through the nodes in the reverse order
- AreaTotal = 0.0;
- Pga_ManForEachObjReverse( p, pNode, i )
- {
- // skip the CIs and nodes not used in the mapping
- if ( !pNode->Match.pCut || !pNode->nRefs )
- continue;
- // increate the reference count of the children
- pCutBest = pNode->Match.pCut;
- AreaTotal += p->pLutAreas[pCutBest->nLeaves];
- // update the required time of the children
- for ( k = 0; k < (int)pCutBest->nLeaves; k++ )
- {
- pFanin = Pga_Node( p, pCutBest->pLeaves[k] );
- pFanin->nRefs++;
- }
- }
- return AreaTotal;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes switching activity of the mapping.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-float Pga_MappingGetSwitching( Pga_Man_t * p )
-{
- float Switching;
- Pga_Node_t * pNode;
- int i;
- Switching = 0;
- Pga_ManForEachObjDirect( p, pNode, i )
- {
- // skip the CIs and nodes not used in the mapping
- if ( !pNode->Match.pCut || !pNode->nRefs )
- continue;
- Switching += pNode->Switching;
- }
- return Switching;
-}
-
-/**Function*************************************************************
-
- Synopsis [Compares the outputs by their arrival times.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Pga_MappingCompareOutputDelay( Pga_Node_t ** ppNode1, Pga_Node_t ** ppNode2 )
-{
- Pga_Node_t * pNode1 = *ppNode1;
- Pga_Node_t * pNode2 = *ppNode2;
- float Arrival1 = pNode1->Match.Delay;
- float Arrival2 = pNode2->Match.Delay;
- if ( Arrival1 < Arrival2 )
- return -1;
- if ( Arrival1 > Arrival2 )
- return 1;
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Finds given number of latest arriving COs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Pga_MappingFindLatest( Pga_Man_t * p, int * pNodes, int nNodesMax )
-{
- Pga_Node_t * pNodeI, * pNodeK;
- Abc_Obj_t * pObjCo;
- int nNodes, i, k, v;
- assert( Abc_NtkCoNum(p->pParams->pNtk) >= nNodesMax );
- pNodes[0] = 0;
- nNodes = 1;
-// for ( i = 1; i < p->nOutputs; i++ )
- Pga_ManForEachCoDriver( p, pNodeI, i )
- {
- for ( k = nNodes - 1; k >= 0; k-- )
- {
- pObjCo = Abc_NtkCo( p->pParams->pNtk, pNodes[k] );
- pNodeK = Pga_Node( p, Abc_ObjFaninId0(pObjCo) );
- if ( Pga_MappingCompareOutputDelay( &pNodeK, &pNodeI ) >= 0 )
- break;
- }
- if ( k == nNodesMax - 1 )
- continue;
- if ( nNodes < nNodesMax )
- nNodes++;
- for ( v = nNodes - 1; v > k+1; v-- )
- pNodes[v] = pNodes[v-1];
- pNodes[k+1] = i;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Prints a bunch of latest arriving outputs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Pga_MappingPrintOutputArrivals( Pga_Man_t * p )
-{
- int pSorted[PGA_CO_LIST_SIZE];
- Abc_Ntk_t * pNtk = p->pParams->pNtk;
- Abc_Obj_t * pObjCo;
- Pga_Node_t * pNode;
- int Limit, MaxNameSize, i;
-
- // determine the number of nodes to print
- Limit = (Abc_NtkCoNum(pNtk) < PGA_CO_LIST_SIZE)? Abc_NtkCoNum(pNtk) : PGA_CO_LIST_SIZE;
-
- // determine the order
- Pga_MappingFindLatest( p, pSorted, Limit );
-
- // determine max size of the node's name
- MaxNameSize = 0;
- for ( i = 0; i < Limit; i++ )
- {
- pObjCo = Abc_NtkCo( pNtk, pSorted[i] );
- if ( MaxNameSize < (int)strlen( Abc_ObjName(pObjCo) ) )
- MaxNameSize = strlen( Abc_ObjName(pObjCo) );
- }
-
- // print the latest outputs
- for ( i = 0; i < Limit; i++ )
- {
- // get the i-th latest output
- pObjCo = Abc_NtkCo( pNtk, pSorted[i] );
- pNode = Pga_Node( p, pObjCo->Id );
- // print out the best arrival time
- printf( "Output %-*s : ", MaxNameSize + 3, Abc_ObjName(pObjCo) );
- printf( "Delay = %8.2f ", (double)pNode->Match.Delay );
- if ( Abc_ObjFaninC0(pObjCo) )
- printf( "NEG" );
- else
- printf( "POS" );
- printf( "\n" );
- }
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/misc/vec/vec.h b/src/misc/vec/vec.h
index a3943f2d..f23cc178 100644
--- a/src/misc/vec/vec.h
+++ b/src/misc/vec/vec.h
@@ -38,6 +38,7 @@ extern "C" {
#include "vecStr.h"
#include "vecPtr.h"
#include "vecVec.h"
+#include "vecAtt.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
diff --git a/src/misc/vec/vecAtt.h b/src/misc/vec/vecAtt.h
new file mode 100644
index 00000000..bfe3eac8
--- /dev/null
+++ b/src/misc/vec/vecAtt.h
@@ -0,0 +1,392 @@
+/**CFile****************************************************************
+
+ FileName [vecAtt.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Resizable arrays.]
+
+ Synopsis [Array of user-specified attiributes.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: vecAtt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __Vec_Att_H__
+#define __Vec_Att_H__
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+#include <stdio.h>
+#include "extra.h"
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+// various attributes
+typedef enum {
+ VEC_ATTR_NONE = 0, // 0
+ VEC_ATTR_COPY, // 1
+ VEC_ATTR_LOCAL_AIG, // 2
+ VEC_ATTR_LOCAL_SOP, // 3
+ VEC_ATTR_LOCAL_BDD, // 4
+ VEC_ATTR_GLOBAL_AIG, // 5
+ VEC_ATTR_GLOBAL_SOP, // 6
+ VEC_ATTR_GLOBAL_BDD, // 7
+ VEC_ATTR_LEVEL, // 8
+ VEC_ATTR_LEVEL_REV, // 9
+ VEC_ATTR_RETIME_LAG, // 10
+ VEC_ATTR_FRAIG, // 11
+ VEC_ATTR_DATA1, // 12
+ VEC_ATTR_DATA2, // 13
+ VEC_ATTR_DATA3, // 14
+ VEC_ATTR_TOTAL_NUM // 15
+} Vec_AttrType_t;
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Vec_Att_t_ Vec_Att_t;
+struct Vec_Att_t_
+{
+ // storage for attributes
+ int nCap; // the size of array allocated
+ int * pArrayInt; // the integer attribute array
+ void ** pArrayPtr; // the pointer attribute array
+ // attribute specific info
+ void * pMan; // the manager for this attribute
+ void (*pFuncFreeMan) (void *); // the procedure to free the manager
+ void*(*pFuncStartObj)(void *); // the procedure to start one attribute
+ void (*pFuncFreeObj) (void *, void *); // the procedure to free one attribute
+};
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Allocates a vector with the given capacity.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Att_t * Vec_AttAlloc(
+ int fInteger, int nSize, void * pMan,
+ void (*pFuncFreeMan) (void *),
+ void*(*pFuncStartObj)(void *),
+ void (*pFuncFreeObj) (void *, void *) )
+{
+ Vec_Att_t * p;
+ p = ALLOC( Vec_Att_t, 1 );
+ memset( p, 0, sizeof(Vec_Att_t) );
+ p->pMan = pMan;
+ p->pFuncFreeMan = pFuncFreeMan;
+ p->pFuncStartObj = pFuncStartObj;
+ p->pFuncFreeObj = pFuncFreeObj;
+ p->nCap = nSize? nSize : 16;
+ if ( fInteger )
+ {
+ p->pArrayInt = ALLOC( int, p->nCap );
+ memset( p->pArrayInt, 0xff, sizeof(int) * p->nCap );
+ }
+ else
+ {
+ p->pArrayPtr = ALLOC( void *, p->nCap );
+ memset( p->pArrayPtr, 0, sizeof(void *) * p->nCap );
+ }
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Frees the vector.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void * Vec_AttFree( Vec_Att_t * p, int fFreeMan )
+{
+ void * pMan;
+ if ( p == NULL )
+ return NULL;
+ // free the attributes of objects
+ if ( p->pFuncFreeObj )
+ {
+ int i;
+ if ( p->pArrayInt )
+ {
+ for ( i = 0; i < p->nCap; i++ )
+ if ( p->pArrayInt[i] )
+ p->pFuncFreeObj( p->pMan, (void *)p->pArrayInt[i] );
+ }
+ else
+ {
+ for ( i = 0; i < p->nCap; i++ )
+ if ( p->pArrayPtr[i] )
+ p->pFuncFreeObj( p->pMan, p->pArrayPtr[i] );
+ }
+ }
+ // free the memory manager
+ pMan = fFreeMan? NULL : p->pMan;
+ if ( p->pMan && fFreeMan )
+ p->pFuncFreeMan( p->pMan );
+ FREE( p->pArrayInt );
+ FREE( p->pArrayPtr );
+ FREE( p );
+ return pMan;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Clears the vector.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_AttClear( Vec_Att_t * p )
+{
+ // free the attributes of objects
+ if ( p->pFuncFreeObj )
+ {
+ int i;
+ if ( p->pArrayInt )
+ {
+ if ( p->pFuncFreeObj )
+ for ( i = 0; i < p->nCap; i++ )
+ if ( p->pArrayInt[i] )
+ p->pFuncFreeObj( p->pMan, (void *)p->pArrayInt[i] );
+ }
+ else
+ {
+ if ( p->pFuncFreeObj )
+ for ( i = 0; i < p->nCap; i++ )
+ if ( p->pArrayPtr[i] )
+ p->pFuncFreeObj( p->pMan, p->pArrayPtr[i] );
+ }
+ }
+ if ( p->pArrayInt )
+ memset( p->pArrayInt, 0xff, sizeof(int) * p->nCap );
+ else
+ memset( p->pArrayPtr, 0, sizeof(void *) * p->nCap );
+
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deletes one entry from the attribute manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_AttFreeEntry( Vec_Att_t * p, int i )
+{
+ if ( i >= p->nCap )
+ return;
+ if ( p->pMan )
+ {
+ if ( p->pArrayInt[i] && p->pFuncFreeObj )
+ p->pFuncFreeObj( p->pMan, (void *)p->pArrayInt[i] );
+ if ( p->pArrayPtr[i] && p->pFuncFreeObj )
+ p->pFuncFreeObj( p->pMan, (void *)p->pArrayPtr[i] );
+ }
+ if ( p->pArrayInt )
+ p->pArrayInt[i] = ~(unsigned)0;
+ else
+ p->pArrayPtr[i] = NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resizes the vector to the given capacity.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_AttGrow( Vec_Att_t * p, int nCapMin )
+{
+ if ( p->nCap >= nCapMin )
+ return;
+ if ( p->pArrayInt )
+ {
+ p->pArrayInt = REALLOC( int, p->pArrayInt, nCapMin );
+ memset( p->pArrayInt + nCapMin, 0xff, sizeof(int) * (nCapMin - p->nCap) );
+ }
+ else
+ {
+ p->pArrayPtr = REALLOC( void *, p->pArrayPtr, nCapMin );
+ memset( p->pArrayPtr + nCapMin, 0, sizeof(void *) * (nCapMin - p->nCap) );
+ }
+ p->nCap = nCapMin;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the entry into its place.]
+
+ Description [Only works if the manager is not defined.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_AttWriteEntry( Vec_Att_t * p, int i, void * pEntry )
+{
+ assert( p->pArrayPtr );
+ assert( p->pFuncStartObj == NULL );
+ if ( i >= p->nCap )
+ Vec_AttGrow( p, (2 * p->nCap > i)? 2 * p->nCap : i );
+ p->pArrayPtr[i] = pEntry;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the entry into its place.]
+
+ Description [Only works if the manager is not defined.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_AttWriteEntryInt( Vec_Att_t * p, int i, int Entry )
+{
+ assert( p->pArrayInt );
+ assert( p->pFuncStartObj == NULL );
+ if ( i >= p->nCap )
+ Vec_AttGrow( p, (2 * p->nCap > i)? 2 * p->nCap : i );
+ p->pArrayInt[i] = Entry;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the entry.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void * Vec_AttEntry( Vec_Att_t * p, int i )
+{
+ assert( p->pArrayPtr );
+ if ( i >= p->nCap )
+ Vec_AttGrow( p, (2 * p->nCap > i)? 2 * p->nCap : i );
+ if ( p->pArrayPtr[i] == NULL && p->pFuncStartObj )
+ p->pArrayPtr[i] = p->pFuncStartObj( p->pMan );
+ return p->pArrayPtr[i];
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the entry.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_AttEntryInt( Vec_Att_t * p, int i )
+{
+ assert( p->pArrayInt );
+ assert( p->pMan == NULL );
+ if ( i >= p->nCap )
+ Vec_AttGrow( p, (2 * p->nCap > i)? 2 * p->nCap : i );
+ return p->pArrayInt[i];
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the entry.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void * Vec_AttMan( Vec_Att_t * p )
+{
+ return p->pMan;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of attributes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void ** Vec_AttArray( Vec_Att_t * p )
+{
+ return p->pArrayPtr;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of attributes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int * Vec_AttArrayInt( Vec_Att_t * p )
+{
+ return p->pArrayInt;
+}
+
+#endif
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/opt/cut/abcCut.c b/src/opt/cut/abcCut.c
index 35814593..3b70e9c1 100644
--- a/src/opt/cut/abcCut.c
+++ b/src/opt/cut/abcCut.c
@@ -218,6 +218,7 @@ void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * p )
***********************************************************************/
Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
{
+/*
Cut_Man_t * p;
Abc_Obj_t * pObj, * pNode;
int i, nIters, fStatus;
@@ -303,6 +304,7 @@ printf( "Converged after %d iterations.\n", nIters );
}
//Abc_NtkPrintCuts( p, pNtk, 1 );
return p;
+*/
}
/**Function*************************************************************
diff --git a/src/opt/dec/decAbc.c b/src/opt/dec/decAbc.c
index 23d60826..bd960c14 100644
--- a/src/opt/dec/decAbc.c
+++ b/src/opt/dec/decAbc.c
@@ -214,26 +214,26 @@ void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, bool fUpda
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Dec_GraphToNetworkAig( Aig_Man_t * pMan, Dec_Graph_t * pGraph )
+Hop_Obj_t * Dec_GraphToNetworkAig( Hop_Man_t * pMan, Dec_Graph_t * pGraph )
{
Dec_Node_t * pNode;
- Aig_Obj_t * pAnd0, * pAnd1;
+ Hop_Obj_t * pAnd0, * pAnd1;
int i;
// check for constant function
if ( Dec_GraphIsConst(pGraph) )
- return Aig_NotCond( Aig_ManConst1(pMan), Dec_GraphIsComplement(pGraph) );
+ return Hop_NotCond( Hop_ManConst1(pMan), Dec_GraphIsComplement(pGraph) );
// check for a literal
if ( Dec_GraphIsVar(pGraph) )
- return Aig_NotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Hop_NotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
// build the AIG nodes corresponding to the AND gates of the graph
Dec_GraphForEachNode( pGraph, pNode, i )
{
- pAnd0 = Aig_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Aig_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
- pNode->pFunc = Aig_And( pMan, pAnd0, pAnd1 );
+ pAnd0 = Hop_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Hop_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
+ pNode->pFunc = Hop_And( pMan, pAnd0, pAnd1 );
}
// complement the result if necessary
- return Aig_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Hop_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
}
/**Function*************************************************************
@@ -247,9 +247,9 @@ Aig_Obj_t * Dec_GraphToNetworkAig( Aig_Man_t * pMan, Dec_Graph_t * pGraph )
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Dec_GraphFactorSop( Aig_Man_t * pMan, char * pSop )
+Hop_Obj_t * Dec_GraphFactorSop( Hop_Man_t * pMan, char * pSop )
{
- Aig_Obj_t * pFunc;
+ Hop_Obj_t * pFunc;
Dec_Graph_t * pFForm;
Dec_Node_t * pNode;
int i;
@@ -257,7 +257,7 @@ Aig_Obj_t * Dec_GraphFactorSop( Aig_Man_t * pMan, char * pSop )
pFForm = Dec_Factor( pSop );
// collect the fanins
Dec_GraphForEachLeaf( pFForm, pNode, i )
- pNode->pFunc = Aig_IthVar( pMan, i );
+ pNode->pFunc = Hop_IthVar( pMan, i );
// perform strashing
pFunc = Dec_GraphToNetworkAig( pMan, pFForm );
Dec_GraphFree( pFForm );
diff --git a/src/opt/ret/module.make b/src/opt/ret/module.make
index c65021c4..4b14365e 100644
--- a/src/opt/ret/module.make
+++ b/src/opt/ret/module.make
@@ -3,5 +3,6 @@ SRC += src/opt/ret/retArea.c \
src/opt/ret/retDelay.c \
src/opt/ret/retFlow.c \
src/opt/ret/retIncrem.c \
- src/opt/ret/retInit.c
+ src/opt/ret/retInit.c \
+ src/opt/ret/retLvalue.c
diff --git a/src/opt/ret/retArea.c b/src/opt/ret/retArea.c
index 41d19592..5eec8e80 100644
--- a/src/opt/ret/retArea.c
+++ b/src/opt/ret/retArea.c
@@ -24,12 +24,9 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static int Abc_NtkRetimeMinAreaFwd( Abc_Ntk_t * pNtk, int fVerbose );
-static Abc_Ntk_t * Abc_NtkRetimeMinAreaBwd( Abc_Ntk_t * pNtk, int fVerbose );
+static Abc_Ntk_t * Abc_NtkRetimeMinAreaOne( Abc_Ntk_t * pNtk, int fForward, int fVerbose );
static void Abc_NtkRetimeMinAreaPrepare( Abc_Ntk_t * pNtk, int fForward );
-static Vec_Ptr_t * Abc_NtkRetimeMinAreaAddBuffers( Abc_Ntk_t * pNtk );
-static void Abc_NtkRetimeMinAreaRemoveBuffers( Abc_Ntk_t * pNtk, Vec_Ptr_t * vBuffers );
-static void Abc_NtkRetimeMinAreaInitValue( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut );
+static void Abc_NtkRetimeMinAreaInitValues( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut );
static Abc_Ntk_t * Abc_NtkRetimeMinAreaConstructNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut );
static void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fForward );
@@ -55,6 +52,7 @@ int Abc_NtkRetimeMinArea( Abc_Ntk_t * pNtk, int fForwardOnly, int fBackwardOnly,
Abc_Ntk_t * pNtkTotal = NULL, * pNtkBottom;
Vec_Int_t * vValuesNew = NULL, * vValues;
int nLatches = Abc_NtkLatchNum(pNtk);
+ int fOneFrame = 0;
assert( !fForwardOnly || !fBackwardOnly );
// there should not be black boxes
assert( Abc_NtkIsSopLogic(pNtk) );
@@ -62,17 +60,24 @@ int Abc_NtkRetimeMinArea( Abc_Ntk_t * pNtk, int fForwardOnly, int fBackwardOnly,
// reorder CI/CO/latch inputs
Abc_NtkOrderCisCos( pNtk );
// perform forward retiming
-// Abc_NtkRetimeMinAreaFwd( pNtk, fVerbose );
-// pNtkTotal = Abc_NtkRetimeMinAreaBwd( pNtk, fVerbose );
if ( !fBackwardOnly )
- while ( Abc_NtkRetimeMinAreaFwd( pNtk, fVerbose ) );
+ {
+ if ( fOneFrame )
+ Abc_NtkRetimeMinAreaOne( pNtk, 1, fVerbose );
+ else
+ while ( Abc_NtkRetimeMinAreaOne( pNtk, 1, fVerbose ) );
+ }
// remember initial values
vValues = Abc_NtkCollectLatchValues( pNtk );
// perform backward retiming
if ( !fForwardOnly )
-// pNtkTotal = Abc_NtkRetimeMinAreaBwd( pNtk, fVerbose );
- while ( pNtkBottom = Abc_NtkRetimeMinAreaBwd( pNtk, fVerbose ) )
- pNtkTotal = Abc_NtkAttachBottom( pNtkTotal, pNtkBottom );
+ {
+ if ( fOneFrame )
+ pNtkTotal = Abc_NtkRetimeMinAreaOne( pNtk, 0, fVerbose );
+ else
+ while ( pNtkBottom = Abc_NtkRetimeMinAreaOne( pNtk, 0, fVerbose ) )
+ pNtkTotal = Abc_NtkAttachBottom( pNtkTotal, pNtkBottom );
+ }
// compute initial values
vValuesNew = Abc_NtkRetimeInitialValues( pNtkTotal, vValues, fVerbose );
if ( pNtkTotal ) Abc_NtkDelete( pNtkTotal );
@@ -80,8 +85,8 @@ int Abc_NtkRetimeMinArea( Abc_Ntk_t * pNtk, int fForwardOnly, int fBackwardOnly,
Abc_NtkInsertLatchValues( pNtk, vValuesNew );
if ( vValuesNew ) Vec_IntFree( vValuesNew );
if ( vValues ) Vec_IntFree( vValues );
- // fix the COs
- Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
+ // fix the COs (this changes the circuit structure)
+// Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
// check for correctness
if ( !Abc_NtkCheck( pNtk ) )
fprintf( stdout, "Abc_NtkRetimeMinArea(): Network check has failed.\n" );
@@ -91,7 +96,7 @@ int Abc_NtkRetimeMinArea( Abc_Ntk_t * pNtk, int fForwardOnly, int fBackwardOnly,
/**Function*************************************************************
- Synopsis [Performs min-area retiming forward.]
+ Synopsis [Performs min-area retiming backward.]
Description []
@@ -100,33 +105,35 @@ int Abc_NtkRetimeMinArea( Abc_Ntk_t * pNtk, int fForwardOnly, int fBackwardOnly,
SeeAlso []
***********************************************************************/
-int Abc_NtkRetimeMinAreaFwd( Abc_Ntk_t * pNtk, int fVerbose )
-{
- Vec_Ptr_t * vBuffers, * vMinCut;
+Abc_Ntk_t * Abc_NtkRetimeMinAreaOne( Abc_Ntk_t * pNtk, int fForward, int fVerbose )
+{
+ Abc_Ntk_t * pNtkNew = NULL;
+ Vec_Ptr_t * vMinCut;
int nLatches = Abc_NtkLatchNum(pNtk);
- // mark current latches and TFO(PIs)
- Abc_NtkRetimeMinAreaPrepare( pNtk, 1 );
- // add buffers on edges feeding into the marked nodes
- vBuffers = Abc_NtkRetimeMinAreaAddBuffers( pNtk );
+ // mark current latches and TFI(POs)
+ Abc_NtkRetimeMinAreaPrepare( pNtk, fForward );
// run the maximum forward flow
- vMinCut = Abc_NtkMaxFlow( pNtk, 1, fVerbose );
- assert( Vec_PtrSize(vMinCut) <= Abc_NtkLatchNum(pNtk) );
+ vMinCut = Abc_NtkMaxFlow( pNtk, fForward, fVerbose );
+// assert( Vec_PtrSize(vMinCut) <= Abc_NtkLatchNum(pNtk) );
// create new latch boundary if there is improvement
if ( Vec_PtrSize(vMinCut) < Abc_NtkLatchNum(pNtk) )
{
- Abc_NtkRetimeMinAreaInitValue( pNtk, vMinCut );
- Abc_NtkRetimeMinAreaUpdateLatches( pNtk, vMinCut, 1 );
+ pNtkNew = (Abc_Ntk_t *)1;
+ if ( fForward )
+ Abc_NtkRetimeMinAreaInitValues( pNtk, vMinCut );
+ else
+ pNtkNew = Abc_NtkRetimeMinAreaConstructNtk( pNtk, vMinCut );
+ Abc_NtkRetimeMinAreaUpdateLatches( pNtk, vMinCut, fForward );
}
// clean up
- Abc_NtkRetimeMinAreaRemoveBuffers( pNtk, vBuffers );
Vec_PtrFree( vMinCut );
Abc_NtkCleanMarkA( pNtk );
- return nLatches - Abc_NtkLatchNum(pNtk);
+ return pNtkNew;
}
/**Function*************************************************************
- Synopsis [Performs min-area retiming backward.]
+ Synopsis [Marks the cone with MarkA.]
Description []
@@ -135,26 +142,23 @@ int Abc_NtkRetimeMinAreaFwd( Abc_Ntk_t * pNtk, int fVerbose )
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkRetimeMinAreaBwd( Abc_Ntk_t * pNtk, int fVerbose )
+void Abc_NtkMarkCone_rec( Abc_Obj_t * pObj, int fForward )
{
- Abc_Ntk_t * pNtkNew = NULL;
- Vec_Ptr_t * vMinCut;
- int nLatches = Abc_NtkLatchNum(pNtk);
- // mark current latches and TFI(POs)
- Abc_NtkRetimeMinAreaPrepare( pNtk, 0 );
- // run the maximum forward flow
- vMinCut = Abc_NtkMaxFlow( pNtk, 0, fVerbose );
- assert( Vec_PtrSize(vMinCut) <= Abc_NtkLatchNum(pNtk) );
- // create new latch boundary if there is improvement
- if ( Vec_PtrSize(vMinCut) < Abc_NtkLatchNum(pNtk) )
+ Abc_Obj_t * pNext;
+ int i;
+ if ( pObj->fMarkA )
+ return;
+ pObj->fMarkA = 1;
+ if ( fForward )
+ {
+ Abc_ObjForEachFanout( pObj, pNext, i )
+ Abc_NtkMarkCone_rec( pNext, fForward );
+ }
+ else
{
- pNtkNew = Abc_NtkRetimeMinAreaConstructNtk( pNtk, vMinCut );
- Abc_NtkRetimeMinAreaUpdateLatches( pNtk, vMinCut, 0 );
+ Abc_ObjForEachFanin( pObj, pNext, i )
+ Abc_NtkMarkCone_rec( pNext, fForward );
}
- // clean up
- Vec_PtrFree( vMinCut );
- Abc_NtkCleanMarkA( pNtk );
- return pNtkNew;
}
/**Function*************************************************************
@@ -168,22 +172,22 @@ Abc_Ntk_t * Abc_NtkRetimeMinAreaBwd( Abc_Ntk_t * pNtk, int fVerbose )
SeeAlso []
***********************************************************************/
-void Abc_NtkMarkCone_rec( Abc_Obj_t * pObj, int fForward )
+void Abc_NtkUnmarkCone_rec( Abc_Obj_t * pObj, int fForward )
{
Abc_Obj_t * pNext;
int i;
- if ( pObj->fMarkA )
+ if ( !pObj->fMarkA || Abc_ObjIsLatch(pObj) )
return;
- pObj->fMarkA = 1;
+ pObj->fMarkA = 0;
if ( fForward )
{
Abc_ObjForEachFanout( pObj, pNext, i )
- Abc_NtkMarkCone_rec( pNext, fForward );
+ Abc_NtkUnmarkCone_rec( pNext, fForward );
}
else
{
Abc_ObjForEachFanin( pObj, pNext, i )
- Abc_NtkMarkCone_rec( pNext, fForward );
+ Abc_NtkUnmarkCone_rec( pNext, fForward );
}
}
@@ -200,8 +204,9 @@ void Abc_NtkMarkCone_rec( Abc_Obj_t * pObj, int fForward )
***********************************************************************/
void Abc_NtkRetimeMinAreaPrepare( Abc_Ntk_t * pNtk, int fForward )
{
- Abc_Obj_t * pObj;
- int i;
+ Vec_Ptr_t * vNodes;
+ Abc_Obj_t * pObj, * pFanin;
+ int i, k;
if ( fForward )
{
// mark the frontier
@@ -212,9 +217,20 @@ void Abc_NtkRetimeMinAreaPrepare( Abc_Ntk_t * pNtk, int fForward )
pObj->fMarkA = 1;
Abc_ObjFanin0(pObj)->fMarkA = 1;
}
- // mark the nodes reachable from the POs
+ // mark the nodes reachable from the PIs
Abc_NtkForEachPi( pNtk, pObj, i )
Abc_NtkMarkCone_rec( pObj, fForward );
+ // collect the unmarked fanins of the marked nodes
+ vNodes = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachObj( pNtk, pObj, i )
+ if ( pObj->fMarkA )
+ Abc_ObjForEachFanin( pObj, pFanin, k )
+ if ( !pFanin->fMarkA )
+ Vec_PtrPush( vNodes, pFanin );
+ // mark these nodes
+ Vec_PtrForEachEntry( vNodes, pObj, i )
+ pObj->fMarkA = 1;
+ Vec_PtrFree( vNodes );
}
else
{
@@ -234,81 +250,6 @@ void Abc_NtkRetimeMinAreaPrepare( Abc_Ntk_t * pNtk, int fForward )
/**Function*************************************************************
- Synopsis [Add extra buffers.]
-
- Description [This is needed to make sure that forward retiming
- works correctly. This has to do with the nodes in the TFO cone
- of the PIs having multiple incoming edges.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Abc_NtkRetimeMinAreaAddBuffers( Abc_Ntk_t * pNtk )
-{
- Vec_Ptr_t * vFeeds, * vFanouts;
- Abc_Obj_t * pObj, * pFanin, * pFanout, * pBuffer;
- int i, k;
- // collect all nodes that are feeding into the marked nodes
- Abc_NtkIncrementTravId(pNtk);
- vFeeds = Vec_PtrAlloc( 100 );
- Abc_NtkForEachObj( pNtk, pObj, i )
- {
- if ( !pObj->fMarkA )
- continue;
- Abc_ObjForEachFanin( pObj, pFanin, k )
- if ( !pFanin->fMarkA && !Abc_NodeIsTravIdCurrent(pFanin) )
- {
- Abc_NodeSetTravIdCurrent( pFanin );
- Vec_PtrPush( vFeeds, pFanin );
- }
- }
- // add buffers for each such node
- vFanouts = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( vFeeds, pObj, i )
- {
- // create and remember the buffers
- pBuffer = Abc_NtkCreateNodeBuf( pNtk, pObj );
- Vec_PtrWriteEntry( vFeeds, i, pBuffer );
- // patch the fanin of each marked fanout to point to the buffer
- Abc_NodeCollectFanouts( pObj, vFanouts );
- Vec_PtrForEachEntry( vFanouts, pFanout, k )
- if ( pFanout->fMarkA )
- Abc_ObjPatchFanin( pFanout, pObj, pBuffer );
- }
- Vec_PtrFree( vFanouts );
- // mark the new buffers
- Vec_PtrForEachEntry( vFeeds, pObj, i )
- pObj->fMarkA = 1;
- return vFeeds;
-}
-
-/**Function*************************************************************
-
- Synopsis [Removes extra buffers.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abc_NtkRetimeMinAreaRemoveBuffers( Abc_Ntk_t * pNtk, Vec_Ptr_t * vBuffers )
-{
- Abc_Obj_t * pObj;
- int i;
- Vec_PtrForEachEntry( vBuffers, pObj, i )
- {
- Abc_ObjTransferFanout( pObj, Abc_ObjFanin0(pObj) );
- Abc_NtkDeleteObj( pObj );
- }
- Vec_PtrFree( vBuffers );
-}
-
-/**Function*************************************************************
-
Synopsis [Compute initial values.]
Description []
@@ -318,7 +259,7 @@ void Abc_NtkRetimeMinAreaRemoveBuffers( Abc_Ntk_t * pNtk, Vec_Ptr_t * vBuffers )
SeeAlso []
***********************************************************************/
-int Abc_NtkRetimeMinAreaInitValue_rec( Abc_Obj_t * pObj )
+int Abc_NtkRetimeMinAreaInitValues_rec( Abc_Obj_t * pObj )
{
Abc_Obj_t * pFanin;
int i;
@@ -330,13 +271,13 @@ int Abc_NtkRetimeMinAreaInitValue_rec( Abc_Obj_t * pObj )
if ( Abc_ObjIsBo(pObj) )
{
assert( Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) );
- pObj->pCopy = (void *)Abc_NtkRetimeMinAreaInitValue_rec( Abc_ObjFanin0(pObj) );
+ pObj->pCopy = (void *)Abc_NtkRetimeMinAreaInitValues_rec( Abc_ObjFanin0(pObj) );
return (int)pObj->pCopy;
}
assert( Abc_ObjIsNode(pObj) );
// visit the fanins
Abc_ObjForEachFanin( pObj, pFanin, i )
- Abc_NtkRetimeMinAreaInitValue_rec( pFanin );
+ Abc_NtkRetimeMinAreaInitValues_rec( pFanin );
// compute the value of the node
pObj->pCopy = (void *)Abc_ObjSopSimulate(pObj);
return (int)pObj->pCopy;
@@ -353,7 +294,7 @@ int Abc_NtkRetimeMinAreaInitValue_rec( Abc_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-void Abc_NtkRetimeMinAreaInitValue( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut )
+void Abc_NtkRetimeMinAreaInitValues( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut )
{
Abc_Obj_t * pObj;
int i;
@@ -366,7 +307,10 @@ void Abc_NtkRetimeMinAreaInitValue( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut )
}
// propagate initial values
Vec_PtrForEachEntry( vMinCut, pObj, i )
- Abc_NtkRetimeMinAreaInitValue_rec( pObj );
+ Abc_NtkRetimeMinAreaInitValues_rec( pObj );
+ // unmark the latches
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ Abc_NodeSetTravIdPrevious( pObj );
}
/**Function*************************************************************
@@ -439,6 +383,9 @@ Abc_Ntk_t * Abc_NtkRetimeMinAreaConstructNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMin
// unmark the nodes in the cut
Vec_PtrForEachEntry( vMinCut, pObj, i )
Abc_NodeSetTravIdPrevious( pObj );
+ // unmark the latches
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ Abc_NodeSetTravIdPrevious( pObj );
// assign dummy node names
Abc_NtkAddDummyPiNames( pNtkNew );
Abc_NtkAddDummyPoNames( pNtkNew );
@@ -449,79 +396,10 @@ Abc_Ntk_t * Abc_NtkRetimeMinAreaConstructNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMin
/**Function*************************************************************
- Synopsis [Mark the inside of the min-cut with current traversal ID.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abc_NtkRetimeMinAreaMarkInside_rec( Abc_Obj_t * pObj, int fForward )
-{
- Abc_Obj_t * pNext;
- int i;
- // skip visited nodes
- if ( Abc_NodeIsTravIdCurrent(pObj) )
- return;
- Abc_NodeSetTravIdCurrent( pObj );
- // make sure we never reach PIs/POs/latches
- if ( Abc_ObjIsPi(pObj) || Abc_ObjIsPo(pObj) || Abc_ObjIsLatch(pObj) )
- printf( "Abc_NtkRetimeMinAreaMarkInside(): The set of nodes is not a cut. Internal error!!!\n" );
- // continue to explore the cone
- if ( fForward )
- {
- Abc_ObjForEachFanout( pObj, pNext, i )
- Abc_NtkRetimeMinAreaMarkInside_rec( pNext, fForward );
- }
- else
- {
- Abc_ObjForEachFanin( pObj, pNext, i )
- Abc_NtkRetimeMinAreaMarkInside_rec( pNext, fForward );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Marks the inside of the min-cut with current traversal ID.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abc_NtkRetimeMinAreaMarkInside( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fForward )
-{
- Abc_Obj_t * pObj;
- int i;
- // mark the mincut
- Abc_NtkIncrementTravId(pNtk);
- Vec_PtrForEachEntry( vMinCut, pObj, i )
- Abc_NodeSetTravIdCurrent( pObj );
- // mark the area inside of the cut
- if ( fForward )
- {
- Abc_NtkForEachLatch( pNtk, pObj, i )
- Abc_NtkRetimeMinAreaMarkInside_rec( Abc_ObjFanout0(pObj), fForward );
- }
- else
- {
- Abc_NtkForEachLatch( pNtk, pObj, i )
- Abc_NtkRetimeMinAreaMarkInside_rec( Abc_ObjFanin0(pObj), fForward );
- // unmark the nodes in the cut
- Vec_PtrForEachEntry( vMinCut, pObj, i )
- Abc_NodeSetTravIdPrevious( pObj );
- }
-}
-
-/**Function*************************************************************
-
Synopsis [Updates the network after backward retiming.]
- Description []
+ Description [Assumes that fMarkA denotes all nodes reachabe from
+ the latches toward the cut.]
SideEffects []
@@ -530,11 +408,9 @@ void Abc_NtkRetimeMinAreaMarkInside( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int
***********************************************************************/
void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fForward )
{
- Vec_Ptr_t * vCis, * vCos, * vBoxes, * vBoxesNew, * vNodes;
- Abc_Obj_t * pObj, * pLatch, * pLatchIn, * pLatchOut, * pNext;
+ Vec_Ptr_t * vCis, * vCos, * vBoxes, * vBoxesNew, * vNodes, * vBuffers;
+ Abc_Obj_t * pObj, * pLatch, * pLatchIn, * pLatchOut, * pNext, * pBuffer;
int i, k;
- // mark the inside of min-cut with new trav ID
- Abc_NtkRetimeMinAreaMarkInside( pNtk, vMinCut, fForward );
// create new latches
Vec_PtrShrink( pNtk->vCis, Abc_NtkCiNum(pNtk) - Abc_NtkLatchNum(pNtk) );
Vec_PtrShrink( pNtk->vCos, Abc_NtkCoNum(pNtk) - Abc_NtkLatchNum(pNtk) );
@@ -548,6 +424,7 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
Vec_PtrPush( vBoxesNew, pObj );
// create or reuse latches
vNodes = Vec_PtrAlloc( 100 );
+ vBuffers = Vec_PtrAlloc( 100 );
Vec_PtrForEachEntry( vMinCut, pObj, i )
{
if ( Abc_ObjIsCi(pObj) && fForward )
@@ -558,6 +435,27 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
assert( Abc_ObjIsBo(pLatchOut) && Abc_ObjIsLatch(pLatch) && Abc_ObjIsBi(pLatchIn) );
// mark the latch as reused
Abc_NodeSetTravIdCurrent( pLatch );
+
+ // check if there are marked fanouts
+ // (these are fanouts to be connected to the latch input)
+ Abc_ObjForEachFanout( pObj, pNext, k )
+ if ( pNext->fMarkA )
+ break;
+ if ( k < Abc_ObjFanoutNum(pObj) )
+ {
+ // add the buffer
+ pBuffer = Abc_NtkCreateNodeBuf( pNtk, Abc_ObjFanin0(pLatchIn) );
+ Abc_ObjPatchFanin( pLatchIn, Abc_ObjFanin0(pLatchIn), pBuffer );
+ Vec_PtrPush( vBuffers, pBuffer );
+ // redirect edges to the unvisited fanouts of the node
+ Abc_NodeCollectFanouts( pObj, vNodes );
+ Vec_PtrForEachEntry( vNodes, pNext, k )
+ if ( pNext->fMarkA )
+ Abc_ObjPatchFanin( pNext, pObj, pBuffer );
+ }
+ assert( Abc_ObjFanoutNum(pObj) > 0 );
+// if ( Abc_ObjFanoutNum(pObj) == 0 )
+// Abc_NtkDeleteObj_rec( pObj, 0 );
}
else if ( Abc_ObjIsCo(pObj) && !fForward )
{
@@ -567,14 +465,15 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
assert( Abc_ObjIsBo(pLatchOut) && Abc_ObjIsLatch(pLatch) && Abc_ObjIsBi(pLatchIn) );
// mark the latch as reused
Abc_NodeSetTravIdCurrent( pLatch );
+ assert( !Abc_ObjFanin0(pLatchIn)->fMarkA );
}
else
{
pLatchOut = Abc_NtkCreateBo(pNtk);
pLatch = Abc_NtkCreateLatch(pNtk);
pLatchIn = Abc_NtkCreateBi(pNtk);
- Abc_ObjAssignName( pLatchOut, Abc_ObjName(pLatchOut), NULL );
- Abc_ObjAssignName( pLatchIn, Abc_ObjName(pLatchIn), NULL );
+ Abc_ObjAssignName( pLatchOut, Abc_ObjName(pLatch), "_out" );
+ Abc_ObjAssignName( pLatchIn, Abc_ObjName(pLatch), "_in" );
// connect
Abc_ObjAddFanin( pLatchOut, pLatch );
Abc_ObjAddFanin( pLatch, pLatchIn );
@@ -584,7 +483,7 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
// redirect edges to the unvisited fanouts of the node
Abc_NodeCollectFanouts( pObj, vNodes );
Vec_PtrForEachEntry( vNodes, pNext, k )
- if ( !Abc_NodeIsTravIdCurrent(pNext) )
+ if ( !pNext->fMarkA )
Abc_ObjPatchFanin( pNext, pObj, pLatchOut );
}
else
@@ -592,7 +491,7 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
// redirect edges to the visited fanouts of the node
Abc_NodeCollectFanouts( pObj, vNodes );
Vec_PtrForEachEntry( vNodes, pNext, k )
- if ( Abc_NodeIsTravIdCurrent(pNext) )
+ if ( pNext->fMarkA )
Abc_ObjPatchFanin( pNext, pObj, pLatchOut );
}
// connect latch to the node
@@ -603,6 +502,13 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
Vec_PtrPush( vCos, pLatchIn );
}
Vec_PtrFree( vNodes );
+ // remove buffers
+ Vec_PtrForEachEntry( vBuffers, pObj, i )
+ {
+ Abc_ObjTransferFanout( pObj, Abc_ObjFanin0(pObj) );
+ Abc_NtkDeleteObj( pObj );
+ }
+ Vec_PtrFree( vBuffers );
// remove useless latches
Vec_PtrForEachEntry( vBoxes, pObj, i )
{
@@ -626,6 +532,7 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
Vec_PtrFree( vBoxes );
}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/opt/ret/retCore.c b/src/opt/ret/retCore.c
index 8ef4e79b..a0e66c92 100644
--- a/src/opt/ret/retCore.c
+++ b/src/opt/ret/retCore.c
@@ -44,11 +44,21 @@ int timeRetime = 0;
int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOnly, int fVerbose )
{
int nLatches = Abc_NtkLatchNum(pNtk);
- int nLevels = Abc_NtkGetLevelNum(pNtk);
+ int nLevels = Abc_NtkLevel(pNtk);
int RetValue = 0, clkTotal = clock();
- assert( Mode > 0 && Mode < 6 );
+ int nNodesOld, nLatchesOld;
+ assert( Mode > 0 && Mode < 7 );
assert( !fForwardOnly || !fBackwardOnly );
- // perform forward retiming
+
+ // cleanup the network
+ nNodesOld = Abc_NtkNodeNum(pNtk);
+ nLatchesOld = Abc_NtkLatchNum(pNtk);
+ Abc_NtkCleanupSeq(pNtk, 0, 0, 0);
+ if ( nNodesOld > Abc_NtkNodeNum(pNtk) || nLatchesOld > Abc_NtkLatchNum(pNtk) )
+ printf( "Cleanup before retiming removed %d dangling nodes and %d dangling latches.\n",
+ nNodesOld - Abc_NtkNodeNum(pNtk), nLatchesOld - Abc_NtkLatchNum(pNtk) );
+
+ // perform retiming
switch ( Mode )
{
case 1: // forward
@@ -73,6 +83,9 @@ int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOn
if ( !fForwardOnly )
RetValue += Abc_NtkRetimeIncremental( pNtk, 0, 1, fVerbose );
break;
+ case 6: // Pan's algorithm
+ RetValue = Abc_NtkRetimeLValue( pNtk, 200, fVerbose );
+ break;
default:
printf( "Unknown retiming option.\n" );
break;
@@ -80,7 +93,7 @@ int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOn
if ( fVerbose )
{
printf( "Reduction in area = %3d. Reduction in delay = %3d. ",
- nLatches - Abc_NtkLatchNum(pNtk), nLevels - Abc_NtkGetLevelNum(pNtk) );
+ nLatches - Abc_NtkLatchNum(pNtk), nLevels - Abc_NtkLevel(pNtk) );
PRT( "Total runtime", clock() - clkTotal );
}
timeRetime = clock() - clkTotal;
@@ -104,8 +117,11 @@ int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk )
Abc_Ntk_t * pNtkRet;
assert( Abc_NtkIsLogic(pNtk) );
Abc_NtkLogicToSop( pNtk, 0 );
+// if ( !Abc_NtkCheck( pNtk ) )
+// fprintf( stdout, "Abc_NtkRetimeDebug(): Network check has failed.\n" );
+// Io_WriteBlifLogic( pNtk, "debug_temp.blif", 1 );
pNtkRet = Abc_NtkDup( pNtk );
- Abc_NtkRetime( pNtkRet, 3, 0, 1, 0 );
+ Abc_NtkRetime( pNtkRet, 3, 0, 1, 0 ); // debugging backward flow
return !Abc_NtkSecFraig( pNtk, pNtkRet, 10000, 3, 0 );
}
diff --git a/src/opt/ret/retDelay.c b/src/opt/ret/retDelay.c
index d2d87447..80c75729 100644
--- a/src/opt/ret/retDelay.c
+++ b/src/opt/ret/retDelay.c
@@ -76,7 +76,7 @@ int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int fForward, int fInitial, int
Vec_Ptr_t * vCritical;
Vec_Int_t * vValues;
Abc_Obj_t * pObj;
- int i, k, IterBest, DelayCur, DelayBest, DelayStart;
+ int i, k, IterBest, DelayCur, DelayBest, DelayStart, LatchesBest;
// transfer intitial values
if ( fInitial )
{
@@ -90,8 +90,15 @@ int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int fForward, int fInitial, int
pNtkNew = Abc_NtkRetimeBackwardInitialStart( pNtk );
}
}
+if ( fVerbose )
+{
+ if ( !fInitial )
+ printf( "Performing analysis:\n" );
+ else
+ printf( "Moving latches to the best position:\n" );
+}
// find the best iteration
- DelayBest = ABC_INFINITY; IterBest = 0;
+ DelayBest = ABC_INFINITY; IterBest = 0; LatchesBest = Abc_NtkLatchNum(pNtk);
vCritical = Vec_PtrAlloc( 100 );
for ( i = 0; ; i++ )
{
@@ -102,16 +109,29 @@ int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int fForward, int fInitial, int
// record this position if it has the best delay
if ( DelayBest > DelayCur )
{
+if ( fVerbose )
+ printf( "%s Iter = %3d. Delay = %3d. Latches = %5d. Delta = %6.2f. Ratio = %4.2f %%\n",
+ fForward ? "Fwd": "Bwd", i, DelayCur, Abc_NtkLatchNum(pNtk),
+ 1.0*(Abc_NtkLatchNum(pNtk)-LatchesBest)/(DelayBest-DelayCur),
+ 100.0*(Abc_NtkLatchNum(pNtk)-LatchesBest)/Abc_NtkLatchNum(pNtk)/(DelayBest-DelayCur) );
+
DelayBest = DelayCur;
IterBest = i;
+ LatchesBest = Abc_NtkLatchNum(pNtk);
}
// quit after timing analysis
if ( i == nIterLimit )
break;
+ // skip if 10 interations did not give improvement
+ if ( i - IterBest > 20 )
+ break;
// try retiming to improve the delay
Vec_PtrForEachEntry( vCritical, pObj, k )
if ( Abc_NtkRetimeNodeIsEnabled(pObj, fForward) )
Abc_NtkRetimeNode( pObj, fForward, fInitial );
+ // share latches
+ if ( !fForward )
+ Abc_NtkRetimeShareLatches( pNtk, fInitial );
}
Vec_PtrFree( vCritical );
// transfer the initial state back to the latches
diff --git a/src/opt/ret/retFlow.c b/src/opt/ret/retFlow.c
index 642a1f69..24d7bf57 100644
--- a/src/opt/ret/retFlow.c
+++ b/src/opt/ret/retFlow.c
@@ -46,14 +46,40 @@ static inline Abc_Obj_t * Abc_ObjGetFaninPath( Abc_Obj_t * pObj )
return pFanin;
return NULL;
}
+static inline Abc_Obj_t * Abc_ObjGetPredecessorBwd( Abc_Obj_t * pObj )
+{
+ Abc_Obj_t * pNext;
+ int i;
+ Abc_ObjForEachFanout( pObj, pNext, i )
+ if ( Abc_ObjGetPath(pNext) == pObj )
+ return pNext;
+ Abc_ObjForEachFanin( pObj, pNext, i )
+ if ( Abc_ObjGetPath(pNext) == pObj )
+ return pNext;
+ return NULL;
+}
+static inline Abc_Obj_t * Abc_ObjGetPredecessorFwd( Abc_Obj_t * pObj )
+{
+ Abc_Obj_t * pNext;
+ int i;
+ Abc_ObjForEachFanin( pObj, pNext, i )
+ if ( Abc_ObjGetPath(pNext) == pObj )
+ return pNext;
+ Abc_ObjForEachFanout( pObj, pNext, i )
+ if ( Abc_ObjGetPath(pNext) == pObj )
+ return pNext;
+ return NULL;
+}
-static int Abc_NtkMaxFlowPath( Abc_Ntk_t * pNtk, int * pStart, int fForward );
static int Abc_NtkMaxFlowBwdPath_rec( Abc_Obj_t * pObj );
static int Abc_NtkMaxFlowFwdPath_rec( Abc_Obj_t * pObj );
-static Vec_Ptr_t * Abc_NtkMaxFlowMinCut( Abc_Ntk_t * pNtk );
+static int Abc_NtkMaxFlowBwdPath2_rec( Abc_Obj_t * pObj );
+static int Abc_NtkMaxFlowFwdPath2_rec( Abc_Obj_t * pObj );
+static Vec_Ptr_t * Abc_NtkMaxFlowMinCut( Abc_Ntk_t * pNtk, int fForward );
+static void Abc_NtkMaxFlowMinCutUpdate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fForward );
static int Abc_NtkMaxFlowVerifyCut( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fForward );
+static void Abc_NtkMaxFlowPrintCut( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut );
static void Abc_NtkMaxFlowPrintFlow( Abc_Ntk_t * pNtk, int fForward );
-static void Abc_NtkMaxFlowPrintCut( Vec_Ptr_t * vMinCut );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -93,6 +119,7 @@ void Abc_NtkMaxFlowTest( Abc_Ntk_t * pNtk )
vMinCut = Abc_NtkMaxFlow( pNtk, 0, 1 );
Vec_PtrFree( vMinCut );
Abc_NtkCleanMarkA( pNtk );
+
}
/**Function*************************************************************
@@ -109,37 +136,102 @@ void Abc_NtkMaxFlowTest( Abc_Ntk_t * pNtk )
Vec_Ptr_t * Abc_NtkMaxFlow( Abc_Ntk_t * pNtk, int fForward, int fVerbose )
{
Vec_Ptr_t * vMinCut;
- int Flow, RetValue;
+ Abc_Obj_t * pLatch;
+ int Flow, FlowCur, RetValue, i;
int clk = clock();
- int Start = 0;
+ int fUseDirectedFlow = 1;
// find the max-flow
Abc_NtkCleanCopy( pNtk );
- for ( Flow = 0; Abc_NtkMaxFlowPath( pNtk, &Start, fForward ); Flow++ );
+ Flow = 0;
+ Abc_NtkIncrementTravId(pNtk);
+ Abc_NtkForEachLatch( pNtk, pLatch, i )
+ {
+ if ( fForward )
+ {
+// assert( !Abc_ObjFanout0(pLatch)->fMarkA );
+ FlowCur = Abc_NtkMaxFlowFwdPath2_rec( Abc_ObjFanout0(pLatch) );
+ Flow += FlowCur;
+ }
+ else
+ {
+ assert( !Abc_ObjFanin0(pLatch)->fMarkA );
+ FlowCur = Abc_NtkMaxFlowBwdPath2_rec( Abc_ObjFanin0(pLatch) );
+ Flow += FlowCur;
+ }
+ if ( FlowCur )
+ Abc_NtkIncrementTravId(pNtk);
+ }
+
+ if ( !fUseDirectedFlow )
+ {
+ Abc_NtkIncrementTravId(pNtk);
+ Abc_NtkForEachLatch( pNtk, pLatch, i )
+ {
+ if ( fForward )
+ {
+ // assert( !Abc_ObjFanout0(pLatch)->fMarkA );
+ FlowCur = Abc_NtkMaxFlowFwdPath_rec( Abc_ObjFanout0(pLatch) );
+ Flow += FlowCur;
+ }
+ else
+ {
+ assert( !Abc_ObjFanin0(pLatch)->fMarkA );
+ FlowCur = Abc_NtkMaxFlowBwdPath_rec( Abc_ObjFanin0(pLatch) );
+ Flow += FlowCur;
+ }
+ if ( FlowCur )
+ Abc_NtkIncrementTravId(pNtk);
+ }
+ }
// Abc_NtkMaxFlowPrintFlow( pNtk, fForward );
+ // mark the nodes reachable from the latches
+ Abc_NtkIncrementTravId(pNtk);
+ Abc_NtkForEachLatch( pNtk, pLatch, i )
+ {
+ if ( fForward )
+ {
+// assert( !Abc_ObjFanout0(pLatch)->fMarkA );
+ if ( fUseDirectedFlow )
+ RetValue = Abc_NtkMaxFlowFwdPath2_rec( Abc_ObjFanout0(pLatch) );
+ else
+ RetValue = Abc_NtkMaxFlowFwdPath_rec( Abc_ObjFanout0(pLatch) );
+ }
+ else
+ {
+ assert( !Abc_ObjFanin0(pLatch)->fMarkA );
+ if ( fUseDirectedFlow )
+ RetValue = Abc_NtkMaxFlowBwdPath2_rec( Abc_ObjFanin0(pLatch) );
+ else
+ RetValue = Abc_NtkMaxFlowBwdPath_rec( Abc_ObjFanin0(pLatch) );
+ }
+ assert( RetValue == 0 );
+ }
+
// find the min-cut with the smallest volume
- RetValue = Abc_NtkMaxFlowPath( pNtk, NULL, fForward );
- assert( RetValue == 0 );
- vMinCut = Abc_NtkMaxFlowMinCut( pNtk );
+ vMinCut = Abc_NtkMaxFlowMinCut( pNtk, fForward );
+ // verify the cut
if ( !Abc_NtkMaxFlowVerifyCut(pNtk, vMinCut, fForward) )
printf( "Abc_NtkMaxFlow() error! The computed min-cut is not a cut!\n" );
+ // make the cut retimable
+ Abc_NtkMaxFlowMinCutUpdate( pNtk, vMinCut, fForward );
// report the results
if ( fVerbose )
{
- printf( "Latches = %6d. %s max-flow = %6d. Min-cut = %6d. ",
+ printf( "L = %6d. %s max-flow = %6d. Min-cut = %6d. ",
Abc_NtkLatchNum(pNtk), fForward? "Forward " : "Backward", Flow, Vec_PtrSize(vMinCut) );
PRT( "Time", clock() - clk );
}
-// Abc_NtkMaxFlowPrintCut( vMinCut );
+// Abc_NtkMaxFlowPrintCut( pNtk, vMinCut );
return vMinCut;
}
/**Function*************************************************************
- Synopsis [Finds and augments one path.]
+ Synopsis [Tries to find an augmenting path originating in this node.]
Description []
@@ -148,35 +240,44 @@ PRT( "Time", clock() - clk );
SeeAlso []
***********************************************************************/
-int Abc_NtkMaxFlowPath( Abc_Ntk_t * pNtk, int * pStart, int fForward )
+int Abc_NtkMaxFlowBwdPath_rec( Abc_Obj_t * pObj )
{
- Abc_Obj_t * pLatch;
- int i, LatchStart = pStart? *pStart : 0;
- Abc_NtkIncrementTravId(pNtk);
- Vec_PtrForEachEntryStart( pNtk->vBoxes, pLatch, i, LatchStart )
+ Abc_Obj_t * pNext, * pPred;
+ int i;
+ // skip visited nodes
+ if ( Abc_NodeIsTravIdCurrent(pObj) )
+ return 0;
+ Abc_NodeSetTravIdCurrent(pObj);
+ // get the predecessor
+ pPred = Abc_ObjGetPredecessorBwd( pObj );
+ // process node without flow
+ if ( !Abc_ObjGetPath(pObj) )
{
- if ( !Abc_ObjIsLatch(pLatch) )
- continue;
- if ( fForward )
- {
- assert( !Abc_ObjFanout0(pLatch)->fMarkA );
- if ( Abc_NtkMaxFlowFwdPath_rec( Abc_ObjFanout0(pLatch) ) )
- {
- if ( pStart ) *pStart = i + 1;
- return 1;
- }
- }
- else
- {
- assert( !Abc_ObjFanin0(pLatch)->fMarkA );
- if ( Abc_NtkMaxFlowBwdPath_rec( Abc_ObjFanin0(pLatch) ) )
- {
- if ( pStart ) *pStart = i + 1;
- return 1;
- }
- }
+ // start the path if we reached a terminal node
+ if ( pObj->fMarkA )
+ return Abc_ObjSetPath( pObj, (void *)1 );
+ // explore the fanins
+ Abc_ObjForEachFanin( pObj, pNext, i )
+ if ( pNext != pPred && !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowBwdPath_rec(pNext) )
+ return Abc_ObjSetPath( pObj, pNext );
+ Abc_ObjForEachFanout( pObj, pNext, i )
+ if ( pNext != pPred && !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowBwdPath_rec(pNext) )
+ return Abc_ObjSetPath( pObj, pNext );
+ return 0;
}
- if ( pStart ) *pStart = 0;
+ // pObj has flow - find the fanout with flow
+ if ( pPred == NULL )
+ return 0;
+ // go through the successors of the predecessor
+ Abc_ObjForEachFanin( pPred, pNext, i )
+ if ( !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowBwdPath_rec( pNext ) )
+ return Abc_ObjSetPath( pPred, pNext );
+ Abc_ObjForEachFanout( pPred, pNext, i )
+ if ( !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowBwdPath_rec( pNext ) )
+ return Abc_ObjSetPath( pPred, pNext );
+ // try the fanout
+ if ( Abc_NtkMaxFlowBwdPath_rec( pPred ) )
+ return Abc_ObjSetPath( pPred, NULL );
return 0;
}
@@ -191,7 +292,59 @@ int Abc_NtkMaxFlowPath( Abc_Ntk_t * pNtk, int * pStart, int fForward )
SeeAlso []
***********************************************************************/
-int Abc_NtkMaxFlowBwdPath_rec( Abc_Obj_t * pObj )
+int Abc_NtkMaxFlowFwdPath_rec( Abc_Obj_t * pObj )
+{
+ Abc_Obj_t * pNext, * pPred;
+ int i;
+ // skip visited nodes
+ if ( Abc_NodeIsTravIdCurrent(pObj) )
+ return 0;
+ Abc_NodeSetTravIdCurrent(pObj);
+ // get the predecessor
+ pPred = Abc_ObjGetPredecessorFwd( pObj );
+ // process node without flow
+ if ( !Abc_ObjGetPath(pObj) )
+ {
+ // start the path if we reached a terminal node
+ if ( pObj->fMarkA )
+ return Abc_ObjSetPath( pObj, (void *)1 );
+ // explore the fanins
+ Abc_ObjForEachFanout( pObj, pNext, i )
+ if ( pNext != pPred && !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowFwdPath_rec(pNext) )
+ return Abc_ObjSetPath( pObj, pNext );
+ Abc_ObjForEachFanin( pObj, pNext, i )
+ if ( pNext != pPred && !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowFwdPath_rec(pNext) )
+ return Abc_ObjSetPath( pObj, pNext );
+ return 0;
+ }
+ // pObj has flow - find the fanout with flow
+ if ( pPred == NULL )
+ return 0;
+ // go through the successors of the predecessor
+ Abc_ObjForEachFanout( pPred, pNext, i )
+ if ( !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowFwdPath_rec( pNext ) )
+ return Abc_ObjSetPath( pPred, pNext );
+ Abc_ObjForEachFanin( pPred, pNext, i )
+ if ( !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowFwdPath_rec( pNext ) )
+ return Abc_ObjSetPath( pPred, pNext );
+ // try the fanout
+ if ( Abc_NtkMaxFlowFwdPath_rec( pPred ) )
+ return Abc_ObjSetPath( pPred, NULL );
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Tries to find an augmenting path originating in this node.]
+
+ Description [This procedure works for directed graphs only!]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkMaxFlowBwdPath2_rec( Abc_Obj_t * pObj )
{
Abc_Obj_t * pFanout, * pFanin;
int i;
@@ -207,7 +360,7 @@ int Abc_NtkMaxFlowBwdPath_rec( Abc_Obj_t * pObj )
return Abc_ObjSetPath( pObj, (void *)1 );
// explore the fanins
Abc_ObjForEachFanin( pObj, pFanin, i )
- if ( Abc_NtkMaxFlowBwdPath_rec(pFanin) )
+ if ( Abc_NtkMaxFlowBwdPath2_rec(pFanin) )
return Abc_ObjSetPath( pObj, pFanin );
return 0;
}
@@ -217,10 +370,10 @@ int Abc_NtkMaxFlowBwdPath_rec( Abc_Obj_t * pObj )
return 0;
// go through the fanins of the fanout with flow
Abc_ObjForEachFanin( pFanout, pFanin, i )
- if ( pFanin != pObj && Abc_NtkMaxFlowBwdPath_rec( pFanin ) )
+ if ( Abc_NtkMaxFlowBwdPath2_rec( pFanin ) )
return Abc_ObjSetPath( pFanout, pFanin );
// try the fanout
- if ( Abc_NtkMaxFlowBwdPath_rec( pFanout ) )
+ if ( Abc_NtkMaxFlowBwdPath2_rec( pFanout ) )
return Abc_ObjSetPath( pFanout, NULL );
return 0;
}
@@ -229,14 +382,14 @@ int Abc_NtkMaxFlowBwdPath_rec( Abc_Obj_t * pObj )
Synopsis [Tries to find an augmenting path originating in this node.]
- Description []
+ Description [This procedure works for directed graphs only!]
SideEffects []
SeeAlso []
***********************************************************************/
-int Abc_NtkMaxFlowFwdPath_rec( Abc_Obj_t * pObj )
+int Abc_NtkMaxFlowFwdPath2_rec( Abc_Obj_t * pObj )
{
Abc_Obj_t * pFanout, * pFanin;
int i;
@@ -252,7 +405,7 @@ int Abc_NtkMaxFlowFwdPath_rec( Abc_Obj_t * pObj )
return Abc_ObjSetPath( pObj, (void *)1 );
// explore the fanins
Abc_ObjForEachFanout( pObj, pFanout, i )
- if ( Abc_NtkMaxFlowFwdPath_rec(pFanout) )
+ if ( Abc_NtkMaxFlowFwdPath2_rec(pFanout) )
return Abc_ObjSetPath( pObj, pFanout );
return 0;
}
@@ -262,18 +415,17 @@ int Abc_NtkMaxFlowFwdPath_rec( Abc_Obj_t * pObj )
return 0;
// go through the fanins of the fanout with flow
Abc_ObjForEachFanout( pFanin, pFanout, i )
- if ( pFanout != pObj && Abc_NtkMaxFlowFwdPath_rec( pFanout ) )
+ if ( Abc_NtkMaxFlowFwdPath2_rec( pFanout ) )
return Abc_ObjSetPath( pFanin, pFanout );
// try the fanout
- if ( Abc_NtkMaxFlowFwdPath_rec( pFanin ) )
+ if ( Abc_NtkMaxFlowFwdPath2_rec( pFanin ) )
return Abc_ObjSetPath( pFanin, NULL );
return 0;
}
-
/**Function*************************************************************
- Synopsis [Find one minumum cut.]
+ Synopsis [Find minimum-volume minumum cut.]
Description []
@@ -282,7 +434,7 @@ int Abc_NtkMaxFlowFwdPath_rec( Abc_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Abc_NtkMaxFlowMinCut( Abc_Ntk_t * pNtk )
+Vec_Ptr_t * Abc_NtkMaxFlowMinCut( Abc_Ntk_t * pNtk, int fForward )
{
Vec_Ptr_t * vMinCut;
Abc_Obj_t * pObj;
@@ -306,6 +458,113 @@ Vec_Ptr_t * Abc_NtkMaxFlowMinCut( Abc_Ntk_t * pNtk )
/**Function*************************************************************
+ Synopsis [Marks the TFI cone with MarkA.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkMaxFlowMarkCut_rec( Abc_Obj_t * pObj )
+{
+ Abc_Obj_t * pNext;
+ int i;
+ if ( pObj->fMarkA )
+ return;
+ pObj->fMarkA = 1;
+ Abc_ObjForEachFanin( pObj, pNext, i )
+ Abc_NtkMaxFlowMarkCut_rec( pNext );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Visits the TFI up to marked nodes and collects marked nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkMaxFlowCollectCut_rec( Abc_Obj_t * pObj, Vec_Ptr_t * vNodes )
+{
+ Abc_Obj_t * pNext;
+ int i;
+ if ( Abc_NodeIsTravIdCurrent(pObj) )
+ return;
+ Abc_NodeSetTravIdCurrent(pObj);
+ if ( pObj->fMarkA )
+ {
+ Vec_PtrPush( vNodes, pObj );
+ return;
+ }
+ Abc_ObjForEachFanin( pObj, pNext, i )
+ Abc_NtkMaxFlowCollectCut_rec( pNext, vNodes );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Updates the minimum cut to be retimable.]
+
+ Description [This procedure also labels the nodes reachable from
+ the latches to the cut with fMarkA.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkMaxFlowMinCutUpdate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fForward )
+{
+ Abc_Obj_t * pObj, * pNext;
+ int i, k;
+ // clean marks
+ Abc_NtkForEachObj( pNtk, pObj, i )
+ pObj->fMarkA = 0;
+ // set latch outputs
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ Abc_ObjFanout0(pObj)->fMarkA = 1;
+ // traverse from cut nodes
+ Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Abc_NtkMaxFlowMarkCut_rec( pObj );
+ if ( fForward )
+ {
+ // change mincut to be nodes with unmarked fanouts
+ Vec_PtrClear( vMinCut );
+ Abc_NtkForEachObj( pNtk, pObj, i )
+ {
+ if ( !pObj->fMarkA )
+ continue;
+ Abc_ObjForEachFanout( pObj, pNext, k )
+ {
+ if ( pNext->fMarkA )
+ continue;
+ Vec_PtrPush( vMinCut, pObj );
+ break;
+ }
+ }
+ }
+ else
+ {
+ // change mincut to be marked fanins of the unmarked nodes
+ Vec_PtrClear( vMinCut );
+ Abc_NtkIncrementTravId(pNtk);
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ Abc_NtkMaxFlowCollectCut_rec( Abc_ObjFanin0(pObj), vMinCut );
+ // transfer the attribute
+ Abc_NtkForEachObj( pNtk, pObj, i )
+ pObj->fMarkA = Abc_NodeIsTravIdCurrent(pObj);
+ // unmark the cut nodes
+ Vec_PtrForEachEntry( vMinCut, pObj, i )
+ pObj->fMarkA = 0;
+ }
+}
+
+/**Function*************************************************************
+
Synopsis [Verifies the min-cut is indeed a cut.]
Description []
@@ -369,13 +628,11 @@ int Abc_NtkMaxFlowVerifyCut( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fForward
{
if ( fForward )
{
- assert( !Abc_ObjFanout0(pObj)->fMarkA );
if ( !Abc_NtkMaxFlowVerifyCut_rec( Abc_ObjFanout0(pObj), fForward ) )
return 0;
}
else
{
- assert( !Abc_ObjFanin0(pObj)->fMarkA );
if ( !Abc_NtkMaxFlowVerifyCut_rec( Abc_ObjFanin0(pObj), fForward ) )
return 0;
}
@@ -456,13 +713,18 @@ void Abc_NtkMaxFlowPrintFlow( Abc_Ntk_t * pNtk, int fForward )
SeeAlso []
***********************************************************************/
-void Abc_NtkMaxFlowPrintCut( Vec_Ptr_t * vMinCut )
+void Abc_NtkMaxFlowPrintCut( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut )
{
Abc_Obj_t * pObj;
int i;
printf( "Min-cut: " );
Vec_PtrForEachEntry( vMinCut, pObj, i )
- printf( "%d ", pObj->Id );
+ printf( "%s(%d) ", Abc_ObjName(pObj), pObj->Id );
+ printf( "\n" );
+ printf( "Marked nodes: " );
+ Abc_NtkForEachObj( pNtk, pObj, i )
+ if ( pObj->fMarkA )
+ printf( "%s(%d) ", Abc_ObjName(pObj), pObj->Id );
printf( "\n" );
}
diff --git a/src/opt/ret/retIncrem.c b/src/opt/ret/retIncrem.c
index d2ad6a72..93305a8e 100644
--- a/src/opt/ret/retIncrem.c
+++ b/src/opt/ret/retIncrem.c
@@ -24,8 +24,6 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static st_table * Abc_NtkRetimePrepareLatches( Abc_Ntk_t * pNtk );
-static int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nIdMaxStart );
static int Abc_NtkRetimeOneWay( Abc_Ntk_t * pNtk, int fForward, int fVerbose );
////////////////////////////////////////////////////////////////////////
@@ -57,13 +55,15 @@ int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int fForward, int fMinDelay, int
Abc_NtkOrderCisCos( pNtk );
if ( fMinDelay )
{
- nIterLimit = 2 * Abc_NtkGetLevelNum(pNtk);
+ nIterLimit = 2 * Abc_NtkLevel(pNtk);
pNtkCopy = Abc_NtkDup( pNtk );
tLatches = Abc_NtkRetimePrepareLatches( pNtkCopy );
st_free_table( tLatches );
}
// collect latches and remove CIs/COs
tLatches = Abc_NtkRetimePrepareLatches( pNtk );
+ // share the latches
+ Abc_NtkRetimeShareLatches( pNtk, 0 );
// save boxes
vBoxes = pNtk->vBoxes; pNtk->vBoxes = NULL;
// perform the retiming
@@ -74,7 +74,7 @@ int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int fForward, int fMinDelay, int
if ( fMinDelay )
Abc_NtkDelete( pNtkCopy );
// share the latches
- Abc_NtkRetimeShareLatches( pNtk );
+ Abc_NtkRetimeShareLatches( pNtk, 0 );
// restore boxes
pNtk->vBoxes = vBoxes;
// finalize the latches
@@ -83,7 +83,7 @@ int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int fForward, int fMinDelay, int
if ( RetValue == 0 )
return 0;
// fix the COs
- Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
+// Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
// check for correctness
if ( !Abc_NtkCheck( pNtk ) )
fprintf( stdout, "Abc_NtkRetimeForward(): Network check has failed.\n" );
@@ -121,7 +121,8 @@ st_table * Abc_NtkRetimePrepareLatches( Abc_Ntk_t * pNtk )
// disconnect LO
pLatchOut = Abc_ObjFanout0(pLatch);
pFanin = Abc_ObjFanin0(pLatchOut);
- Abc_ObjTransferFanout( pLatchOut, pFanin );
+ if ( Abc_ObjFanoutNum(pLatchOut) > 0 )
+ Abc_ObjTransferFanout( pLatchOut, pFanin );
Abc_ObjDeleteFanin( pLatchOut, pFanin );
}
return tLatches;
@@ -164,8 +165,8 @@ int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nId
// this is a new latch
pLatchIn = Abc_NtkCreateBi(pNtk);
pLatchOut = Abc_NtkCreateBo(pNtk);
- Abc_ObjAssignName( pLatchIn, Abc_ObjName(pLatchIn), NULL );
- Abc_ObjAssignName( pLatchOut, Abc_ObjName(pLatchOut), NULL );
+ Abc_ObjAssignName( pLatchOut, Abc_ObjName(pLatch), "_out" );
+ Abc_ObjAssignName( pLatchIn, Abc_ObjName(pLatch), "_in" );
}
else
{
@@ -184,7 +185,8 @@ int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nId
// connect
Abc_ObjAddFanin( pLatchIn, Abc_ObjFanin0(pLatch) );
Abc_ObjPatchFanin( pLatch, Abc_ObjFanin0(pLatch), pLatchIn );
- Abc_ObjTransferFanout( pLatch, pLatchOut );
+ if ( Abc_ObjFanoutNum(pLatch) > 0 )
+ Abc_ObjTransferFanout( pLatch, pLatchOut );
Abc_ObjAddFanin( pLatchOut, pLatch );
// add to the arrays
Vec_PtrPush( vCisNew, pLatchOut );
@@ -221,7 +223,7 @@ int Abc_NtkRetimeOneWay( Abc_Ntk_t * pNtk, int fForward, int fVerbose )
Abc_Ntk_t * pNtkNew;
Vec_Int_t * vValues;
Abc_Obj_t * pObj;
- int i, fChanges, nTotalMoves = 0, nTotalMovesLimit = 5000;
+ int i, fChanges, nTotalMoves = 0, nTotalMovesLimit = 10000;
if ( fForward )
Abc_NtkRetimeTranferToCopy( pNtk );
else
@@ -330,7 +332,8 @@ void Abc_NtkRetimeNode( Abc_Obj_t * pObj, int fForward, int fInitial )
}
// add a new latch on top
pNext = Abc_NtkCreateLatch(pObj->pNtk);
- Abc_ObjTransferFanout( pObj, pNext );
+ if ( Abc_ObjFanoutNum(pObj) > 0 )
+ Abc_ObjTransferFanout( pObj, pNext );
Abc_ObjAddFanin( pNext, pObj );
// set the initial value
if ( fInitial )
@@ -416,35 +419,36 @@ int Abc_NtkRetimeCheckCompatibleLatchFanouts( Abc_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-void Abc_NtkRetimeShareLatches( Abc_Ntk_t * pNtk )
+void Abc_NtkRetimeShareLatches( Abc_Ntk_t * pNtk, int fInitial )
{
Vec_Ptr_t * vNodes;
- Abc_Obj_t * pFanin, * pLatch, * pLatchTop, * pLatchCur;
+ Abc_Obj_t * pFanin, * pLatchTop, * pLatchCur;
int i, k;
vNodes = Vec_PtrAlloc( 10 );
// consider latch fanins
- Abc_NtkForEachObj( pNtk, pLatch, i )
+ Abc_NtkForEachObj( pNtk, pFanin, i )
{
- if ( !Abc_ObjIsLatch(pLatch) )
- continue;
- pFanin = Abc_ObjFanin0(pLatch);
if ( Abc_NtkRetimeCheckCompatibleLatchFanouts(pFanin) <= 1 )
continue;
// get the first latch
+ pLatchTop = NULL;
Abc_ObjForEachFanout( pFanin, pLatchTop, k )
if ( Abc_ObjIsLatch(pLatchTop) )
break;
- assert( Abc_ObjIsLatch(pLatchTop) );
+ assert( pLatchTop && Abc_ObjIsLatch(pLatchTop) );
// redirect compatible fanout latches to the first latch
Abc_NodeCollectFanouts( pFanin, vNodes );
Vec_PtrForEachEntry( vNodes, pLatchCur, k )
{
- if ( pLatchCur == pLatchTop )
- continue;
if ( !Abc_ObjIsLatch(pLatchCur) )
continue;
+ if ( pLatchCur == pLatchTop )
+ continue;
if ( pLatchCur->pData != pLatchTop->pData )
continue;
+ // connect the initial state
+ if ( fInitial )
+ Abc_ObjAddFanin( pLatchCur->pCopy, pLatchTop->pCopy );
// redirect the fanouts
Abc_ObjTransferFanout( pLatchCur, pLatchTop );
Abc_NtkDeleteObj(pLatchCur);
diff --git a/src/opt/ret/retInit.c b/src/opt/ret/retInit.c
index 3eb80da1..b53ceeae 100644
--- a/src/opt/ret/retInit.c
+++ b/src/opt/ret/retInit.c
@@ -281,7 +281,6 @@ void Abc_NtkRetimeBackwardInitialFinish( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew,
Abc_NtkForEachObj( pNtk, pObj, i )
if ( Abc_ObjIsLatch(pObj) )
Abc_ObjAddFanin( pObj->pCopy, Abc_NtkCreatePi(pNtkNew) );
- pObj = Abc_NtkPo(pNtkNew, 0);
// assign dummy node names
Abc_NtkAddDummyPiNames( pNtkNew );
Abc_NtkAddDummyPoNames( pNtkNew );
diff --git a/src/opt/ret/retInt.h b/src/opt/ret/retInt.h
index 9b3aa00a..28529cdc 100644
--- a/src/opt/ret/retInt.h
+++ b/src/opt/ret/retInt.h
@@ -51,9 +51,11 @@ extern int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly,
extern int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nIterLimit, int fForward, int fVerbose );
/*=== retDirect.c ========================================================*/
extern int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int fForward, int fMinDelay, int fVerbose );
-extern void Abc_NtkRetimeShareLatches( Abc_Ntk_t * pNtk );
+extern void Abc_NtkRetimeShareLatches( Abc_Ntk_t * pNtk, int fInitial );
extern int Abc_NtkRetimeNodeIsEnabled( Abc_Obj_t * pObj, int fForward );
extern void Abc_NtkRetimeNode( Abc_Obj_t * pObj, int fForward, int fInitial );
+extern st_table * Abc_NtkRetimePrepareLatches( Abc_Ntk_t * pNtk );
+extern int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nIdMaxStart );
/*=== retFlow.c ========================================================*/
extern void Abc_NtkMaxFlowTest( Abc_Ntk_t * pNtk );
extern Vec_Ptr_t * Abc_NtkMaxFlow( Abc_Ntk_t * pNtk, int fForward, int fVerbose );
@@ -66,6 +68,8 @@ extern Vec_Int_t * Abc_NtkRetimeCollectLatchValues( Abc_Ntk_t * pNtk );
extern void Abc_NtkRetimeInsertLatchValues( Abc_Ntk_t * pNtk, Vec_Int_t * vValues );
extern Abc_Ntk_t * Abc_NtkRetimeBackwardInitialStart( Abc_Ntk_t * pNtk );
extern void Abc_NtkRetimeBackwardInitialFinish( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, Vec_Int_t * vValuesOld, int fVerbose );
+/*=== retLvalue.c ========================================================*/
+extern int Abc_NtkRetimeLValue( Abc_Ntk_t * pNtk, int nIterLimit, int fVerbose );
#endif
diff --git a/src/opt/ret/retLvalue.c b/src/opt/ret/retLvalue.c
new file mode 100644
index 00000000..ebb42808
--- /dev/null
+++ b/src/opt/ret/retLvalue.c
@@ -0,0 +1,419 @@
+/**CFile****************************************************************
+
+ FileName [retLvalue.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Retiming package.]
+
+ Synopsis [Implementation of Pan's retiming algorithm.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - Oct 31, 2006.]
+
+ Revision [$Id: retLvalue.c,v 1.00 2006/10/31 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "retInt.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// node status after updating its arrival time
+enum { ABC_RET_UPDATE_FAIL, ABC_RET_UPDATE_NO, ABC_RET_UPDATE_YES };
+
+// the internal procedures
+static Vec_Int_t * Abc_NtkRetimeGetLags( Abc_Ntk_t * pNtk, int nIterLimit, int fVerbose );
+static int Abc_NtkRetimeUsingLags( Abc_Ntk_t * pNtk, Vec_Int_t * vLags, int fVerbose );
+static int Abc_NtkRetimeSearch_rec( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, int FiMin, int FiMax, int nMaxIters, int fVerbose );
+static int Abc_NtkRetimeForPeriod( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, int Fi, int nMaxIters, int fVerbose );
+static int Abc_NtkRetimeNodeUpdateLValue( Abc_Obj_t * pObj, int Fi );
+static Vec_Ptr_t * Abc_NtkRetimeCollect( Abc_Ntk_t * pNtk );
+
+static inline int Abc_NodeComputeLag( int LValue, int Fi ) { return (LValue + (1<<16)*Fi)/Fi - (1<<16) - (int)(LValue % Fi == 0); }
+static inline int Abc_NodeGetLValue( Abc_Obj_t * pNode ) { return (int)pNode->pCopy; }
+static inline void Abc_NodeSetLValue( Abc_Obj_t * pNode, int Value ) { pNode->pCopy = (void *)Value; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Implements Pan's retiming algorithm.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkRetimeLValue( Abc_Ntk_t * pNtk, int nIterLimit, int fVerbose )
+{
+ Vec_Int_t * vLags;
+ int nLatches = Abc_NtkLatchNum(pNtk);
+ assert( Abc_NtkIsLogic( pNtk ) );
+ // get the lags
+ vLags = Abc_NtkRetimeGetLags( pNtk, nIterLimit, fVerbose );
+ // compute the retiming
+// Abc_NtkRetimeUsingLags( pNtk, vLags, fVerbose );
+ Vec_IntFree( vLags );
+ // fix the COs
+// Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
+ // check for correctness
+ if ( !Abc_NtkCheck( pNtk ) )
+ fprintf( stdout, "Abc_NtkRetimeLValue(): Network check has failed.\n" );
+ // return the number of latches saved
+ return nLatches - Abc_NtkLatchNum(pNtk);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the retiming lags.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Abc_NtkRetimeGetLags( Abc_Ntk_t * pNtk, int nIterLimit, int fVerbose )
+{
+ Vec_Int_t * vLags;
+ Vec_Ptr_t * vNodes;
+ Abc_Obj_t * pNode;
+ int i, FiMax, FiBest, RetValue, clk, clkIter;
+ char NodeLag;
+
+ // get the upper bound on the clock period
+ FiMax = 10 + Abc_NtkLevel(pNtk);
+
+ // make sure this clock period is feasible
+ vNodes = Abc_NtkRetimeCollect(pNtk);
+ if ( !Abc_NtkRetimeForPeriod( pNtk, vNodes, FiMax, nIterLimit, fVerbose ) )
+ {
+ Vec_PtrFree( vNodes );
+ printf( "Abc_NtkRetimeGetLags() error: The upper bound on the clock period cannot be computed.\n" );
+ return Vec_IntStart( Abc_NtkObjNumMax(pNtk) + 1 );
+ }
+
+ // search for the optimal clock period between 0 and nLevelMax
+clk = clock();
+ FiBest = Abc_NtkRetimeSearch_rec( pNtk, vNodes, 0, FiMax, nIterLimit, fVerbose );
+clkIter = clock() - clk;
+
+ // recompute the best l-values
+ RetValue = Abc_NtkRetimeForPeriod( pNtk, vNodes, FiBest, nIterLimit, fVerbose );
+ assert( RetValue );
+ Vec_PtrFree( vNodes );
+
+ // fix the problem with non-converged delays
+ Abc_NtkForEachNode( pNtk, pNode, i )
+ if ( Abc_NodeGetLValue(pNode) < -ABC_INFINITY/2 )
+ Abc_NodeSetLValue( pNode, 0 );
+
+ // write the retiming lags
+ vLags = Vec_IntStart( Abc_NtkObjNumMax(pNtk) + 1 );
+ Abc_NtkForEachNode( pNtk, pNode, i )
+ {
+ NodeLag = Abc_NodeComputeLag( Abc_NodeGetLValue(pNode), FiBest );
+ Vec_IntWriteEntry( vLags, pNode->Id, NodeLag );
+ }
+
+ // print the result
+// if ( fVerbose )
+ printf( "The best clock period is %3d. (Currently, network is not modified.)\n", FiBest );
+/*
+ // print the statistic into a file
+ {
+ FILE * pTable;
+ pTable = fopen( "a/ret__stats.txt", "a+" );
+ fprintf( pTable, "%d ", FiBest );
+ fclose( pTable );
+ }
+*/
+
+/*
+ printf( "lvalues and lags : " );
+ Abc_NtkForEachNode( pNtk, pNode, i )
+ printf( "%d=%d(%d) ", pNode->Id, Abc_NodeGetLValue(pNode), Abc_NodeGetLag(pNode) );
+ printf( "\n" );
+*/
+/*
+ {
+ FILE * pTable;
+ pTable = fopen( "a/ret_stats_pan.txt", "a+" );
+ fprintf( pTable, "%s ", pNtk->pName );
+ fprintf( pTable, "%d ", FiBest );
+ fprintf( pTable, "\n" );
+ fclose( pTable );
+ }
+*/
+ return vLags;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs binary search for the optimal clock period.]
+
+ Description [Assumes that FiMin is infeasible while FiMax is feasible.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkRetimeSearch_rec( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, int FiMin, int FiMax, int nMaxIters, int fVerbose )
+{
+ int Median;
+ assert( FiMin < FiMax );
+ if ( FiMin + 1 == FiMax )
+ return FiMax;
+ Median = FiMin + (FiMax - FiMin)/2;
+ if ( Abc_NtkRetimeForPeriod( pNtk, vNodes, Median, nMaxIters, fVerbose ) )
+ return Abc_NtkRetimeSearch_rec( pNtk, vNodes, FiMin, Median, nMaxIters, fVerbose ); // Median is feasible
+ else
+ return Abc_NtkRetimeSearch_rec( pNtk, vNodes, Median, FiMax, nMaxIters, fVerbose ); // Median is infeasible
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if retiming with this clock period is feasible.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkRetimeForPeriod( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, int Fi, int nMaxIters, int fVerbose )
+{
+ Abc_Obj_t * pObj;
+ int i, c, fContained, fChange, RetValue, Counter;
+ char * pReason = "";
+
+ // set l-values of all nodes to be minus infinity, except PIs and constants
+ Abc_NtkForEachObj( pNtk, pObj, i )
+ if ( Abc_ObjFaninNum(pObj) == 0 )
+ Abc_NodeSetLValue( pObj, 0 );
+ else
+ Abc_NodeSetLValue( pObj, -ABC_INFINITY );
+
+ // update all values iteratively
+ Counter = 0;
+ fContained = 1;
+ fChange = 1;
+ for ( c = 0; fContained && fChange && c < nMaxIters; c++ )
+ {
+ // go through the nodes and detect change
+ fChange = 0;
+ Vec_PtrForEachEntry( vNodes, pObj, i )
+ {
+ RetValue = Abc_NtkRetimeNodeUpdateLValue( pObj, Fi );
+ if ( RetValue == ABC_RET_UPDATE_FAIL )
+ {
+ fContained = 0;
+ break;
+ }
+ if ( RetValue == ABC_RET_UPDATE_NO )
+ continue;
+ // updating happened
+ fChange = 1;
+ Counter++;
+ }
+ }
+ if ( c == nMaxIters )
+ {
+ fContained = 0;
+ pReason = "(timeout)";
+ }
+ else
+ c++;
+ // report the results
+ if ( fVerbose )
+ {
+ if ( !fContained )
+ printf( "Period = %3d. Iterations = %3d. Updates = %10d. Infeasible %s\n", Fi, c, Counter, pReason );
+ else
+ printf( "Period = %3d. Iterations = %3d. Updates = %10d. Feasible\n", Fi, c, Counter );
+ }
+/*
+ // check if any AND gates have infinite delay
+ Counter = 0;
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ Counter += (Abc_NodeGetLValue(pObj) < -ABC_INFINITY/2);
+ if ( Counter > 0 )
+ printf( "Warning: %d internal nodes have wrong l-values!\n", Counter );
+*/
+ return fContained;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the l-value of the node.]
+
+ Description [The node can be internal or a PO.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkRetimeNodeUpdateLValue( Abc_Obj_t * pObj, int Fi )
+{
+ Abc_Obj_t * pFanin;
+ int lValueNew, i;
+ // terminals
+ if ( Abc_ObjFaninNum(pObj) == 0 )
+ return ABC_RET_UPDATE_NO;
+ // primary outputs
+ if ( Abc_ObjIsPo(pObj) )
+ return (Abc_NodeGetLValue(Abc_ObjFanin0(pObj)) > Fi)? ABC_RET_UPDATE_FAIL : ABC_RET_UPDATE_NO;
+ // other types of objects
+ if ( Abc_ObjIsBi(pObj) || Abc_ObjIsBo(pObj) )
+ lValueNew = Abc_NodeGetLValue(Abc_ObjFanin0(pObj));
+ else if ( Abc_ObjIsLatch(pObj) )
+ lValueNew = Abc_NodeGetLValue(Abc_ObjFanin0(pObj)) - Fi;
+ else
+ {
+ assert( Abc_ObjIsNode(pObj) );
+ lValueNew = -ABC_INFINITY;
+ Abc_ObjForEachFanin( pObj, pFanin, i )
+ if ( lValueNew < Abc_NodeGetLValue(pFanin) )
+ lValueNew = Abc_NodeGetLValue(pFanin);
+ lValueNew++;
+ }
+ // check if it needs to be updated
+ if ( lValueNew <= Abc_NodeGetLValue(pObj) )
+ return ABC_RET_UPDATE_NO;
+ // update if needed
+ Abc_NodeSetLValue( pObj, lValueNew );
+ return ABC_RET_UPDATE_YES;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Implements the retiming given as a set of retiming lags.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkRetimeUsingLags( Abc_Ntk_t * pNtk, Vec_Int_t * vLags, int fVerbose )
+{
+ Abc_Obj_t * pObj;
+ int fChanges, fForward, nTotalMoves, Lag, Counter, i;
+ // iterate over the nodes
+ nTotalMoves = 0;
+ do {
+ fChanges = 0;
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ {
+ Lag = Vec_IntEntry( vLags, pObj->Id );
+ if ( !Lag )
+ continue;
+ fForward = (Lag < 0);
+ if ( Abc_NtkRetimeNodeIsEnabled( pObj, fForward ) )
+ {
+ Abc_NtkRetimeNode( pObj, fForward, 0 );
+ fChanges = 1;
+ nTotalMoves++;
+ Vec_IntAddToEntry( vLags, pObj->Id, fForward? 1 : -1 );
+ }
+ }
+ } while ( fChanges );
+ if ( fVerbose )
+ printf( "Total latch moves = %d.\n", nTotalMoves );
+ // check if there are remaining lags
+ Counter = 0;
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ Counter += (Vec_IntEntry( vLags, pObj->Id ) != 0);
+ if ( Counter )
+ printf( "Warning! The number of nodes with unrealized lag = %d.\n", Counter );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collect objects in the topological order from the latch inputs.]
+
+ Description [If flag fOnlyMarked is set, collects only marked nodes.
+ Otherwise, collects only unmarked nodes.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkRetimeCollect_rec( Abc_Obj_t * pObj, int fOnlyMarked, Vec_Ptr_t * vNodes )
+{
+ Abc_Obj_t * pFanin;
+ int i;
+ // skip collected nodes
+ if ( Abc_NodeIsTravIdCurrent(pObj) )
+ return;
+ Abc_NodeSetTravIdCurrent(pObj);
+ // collect recursively
+ if ( fOnlyMarked ^ pObj->fMarkA )
+ return;
+ // visit the fanins
+ Abc_ObjForEachFanin( pObj, pFanin, i )
+ Abc_NtkRetimeCollect_rec( pFanin, fOnlyMarked, vNodes );
+ // collect non-trivial objects
+ if ( Abc_ObjFaninNum(pObj) > 0 )
+ Vec_PtrPush( vNodes, pObj );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collect objects in the topological order using LIs as a cut.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Abc_NtkRetimeCollect( Abc_Ntk_t * pNtk )
+{
+ Vec_Ptr_t * vNodes;
+ Abc_Obj_t * pObj, * pFanin;
+ int i, k;
+ vNodes = Vec_PtrAlloc( 100 );
+ // mark the latch inputs
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ Abc_ObjFanin0(pObj)->fMarkA = 1;
+ // collect nodes in the DFS order from the marked nodes
+ Abc_NtkIncrementTravId(pNtk);
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ Abc_NtkRetimeCollect_rec( pObj, 0, vNodes );
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ Abc_ObjForEachFanin( Abc_ObjFanin0(pObj), pFanin, k )
+ Abc_NtkRetimeCollect_rec( pFanin, 0, vNodes );
+ // collect marked nodes
+ Abc_NtkIncrementTravId(pNtk);
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ Abc_NtkRetimeCollect_rec( Abc_ObjFanin0(pObj), 1, vNodes );
+ // clean the marks
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ Abc_ObjFanin0(pObj)->fMarkA = 0;
+ return vNodes;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/sat/bsat/satSolver.c b/src/sat/bsat/satSolver.c
index a84c82ef..2a6c17bf 100644
--- a/src/sat/bsat/satSolver.c
+++ b/src/sat/bsat/satSolver.c
@@ -1132,9 +1132,9 @@ int sat_solver_solve(sat_solver* s, lit* begin, lit* end, sint64 nConfLimit, sin
s->nConfLimit = s->stats.conflicts + nConfLimit;
if ( nInsLimit )
s->nInsLimit = s->stats.inspects + nInsLimit;
- if ( nConfLimitGlobal && s->nConfLimit > nConfLimitGlobal )
+ if ( nConfLimitGlobal && (s->nConfLimit == 0 || s->nConfLimit > nConfLimitGlobal) )
s->nConfLimit = nConfLimitGlobal;
- if ( nInsLimitGlobal && s->nInsLimit > nInsLimitGlobal )
+ if ( nInsLimitGlobal && (s->nInsLimit == 0 || s->nInsLimit > nInsLimitGlobal) )
s->nInsLimit = nInsLimitGlobal;
//printf("solve: "); printlits(begin, end); printf("\n");
diff --git a/src/sat/fraig/fraigMan.c b/src/sat/fraig/fraigMan.c
index b43f1093..4e188cf0 100644
--- a/src/sat/fraig/fraigMan.c
+++ b/src/sat/fraig/fraigMan.c
@@ -68,6 +68,7 @@ void Prove_ParamsSetDefault( Prove_Params_t * pParams )
// global SAT solver limits
pParams->nTotalBacktrackLimit = 0; // global limit on the number of backtracks
pParams->nTotalInspectLimit = 0; // global limit on the number of clause inspects
+// pParams->nTotalInspectLimit = 100000000; // global limit on the number of clause inspects
}
/**Function*************************************************************
diff --git a/src/temp/aig/aig.h b/src/temp/aig/aig.h
deleted file mode 100644
index 0dfc3f11..00000000
--- a/src/temp/aig/aig.h
+++ /dev/null
@@ -1,321 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aig.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [External declarations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006.]
-
- Revision [$Id: aig.c,v 1.00 2006/05/11 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 int Aig_Edge_t;
-
-// object types
-typedef enum {
- AIG_NONE, // 0: non-existent object
- AIG_CONST1, // 1: constant 1
- AIG_PI, // 2: primary input
- AIG_PO, // 3: primary output
- AIG_AND, // 4: AND node
- AIG_EXOR, // 5: EXOR node
- AIG_VOID // 6: unused object
-} Aig_Type_t;
-
-// the AIG node
-struct Aig_Obj_t_ // 4 words
-{
- void * pData; // misc
- 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 (level)
-};
-
-// 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
- Aig_Obj_t * pConst1; // the constant 1 node
- Aig_Obj_t Ghost; // the ghost node
- // AIG node counters
- int nObjs[AIG_VOID];// the number of objects by type
- int nCreated; // the number of created objects
- int nDeleted; // the number of deleted objects
- // stuctural hash table
- Aig_Obj_t ** pTable; // structural hash table
- int nTableSize; // structural hash table size
- // various data members
- void * pData; // the temporary data
- int nTravIds; // the current traversal ID
- int fRefCount; // enables reference counting
- int fCatchExor; // enables EXOR nodes
- // memory management
- Vec_Ptr_t * vChunks; // allocated memory pieces
- Vec_Ptr_t * vPages; // memory pages used by nodes
- Aig_Obj_t * pListFree; // the list of free 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))
-
-#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 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_Edge_t Aig_EdgeCreate( int Id, int fCompl ) { return (Id << 1) | fCompl; }
-static inline int Aig_EdgeId( Aig_Edge_t Edge ) { return Edge >> 1; }
-static inline int Aig_EdgeIsComplement( Aig_Edge_t Edge ) { return Edge & 1; }
-static inline Aig_Edge_t Aig_EdgeRegular( Aig_Edge_t Edge ) { return (Edge >> 1) << 1; }
-static inline Aig_Edge_t Aig_EdgeNot( Aig_Edge_t Edge ) { return Edge ^ 1; }
-static inline Aig_Edge_t Aig_EdgeNotCond( Aig_Edge_t Edge, int fCond ) { return Edge ^ fCond; }
-
-static inline int Aig_ManPiNum( Aig_Man_t * p ) { return p->nObjs[AIG_PI]; }
-static inline int Aig_ManPoNum( Aig_Man_t * p ) { return p->nObjs[AIG_PO]; }
-static inline int Aig_ManAndNum( Aig_Man_t * p ) { return p->nObjs[AIG_AND]; }
-static inline int Aig_ManExorNum( Aig_Man_t * p ) { return p->nObjs[AIG_EXOR]; }
-static inline int Aig_ManNodeNum( Aig_Man_t * p ) { return p->nObjs[AIG_AND]+p->nObjs[AIG_EXOR];}
-static inline int Aig_ManGetCost( Aig_Man_t * p ) { return p->nObjs[AIG_AND]+3*p->nObjs[AIG_EXOR]; }
-static inline int Aig_ManObjNum( Aig_Man_t * p ) { return p->nCreated - p->nDeleted; }
-
-static inline Aig_Type_t Aig_ObjType( Aig_Obj_t * pObj ) { return pObj->Type; }
-static inline int Aig_ObjIsNone( Aig_Obj_t * pObj ) { return pObj->Type == AIG_NONE; }
-static inline int Aig_ObjIsConst1( Aig_Obj_t * pObj ) { assert(!Aig_IsComplement(pObj)); return pObj->Type == AIG_CONST1; }
-static inline int Aig_ObjIsPi( Aig_Obj_t * pObj ) { return pObj->Type == AIG_PI; }
-static inline int Aig_ObjIsPo( Aig_Obj_t * pObj ) { return pObj->Type == AIG_PO; }
-static inline int Aig_ObjIsAnd( Aig_Obj_t * pObj ) { return pObj->Type == AIG_AND; }
-static inline int Aig_ObjIsExor( Aig_Obj_t * pObj ) { return pObj->Type == AIG_EXOR; }
-static inline int Aig_ObjIsNode( Aig_Obj_t * pObj ) { return pObj->Type == AIG_AND || pObj->Type == AIG_EXOR; }
-static inline int Aig_ObjIsTerm( Aig_Obj_t * pObj ) { return pObj->Type == AIG_PI || pObj->Type == AIG_PO || pObj->Type == AIG_CONST1; }
-static inline int Aig_ObjIsHash( Aig_Obj_t * pObj ) { return pObj->Type == AIG_AND || pObj->Type == AIG_EXOR; }
-
-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->pData = (void *)TravId; }
-static inline void Aig_ObjSetTravIdCurrent( Aig_Man_t * p, Aig_Obj_t * pObj ) { pObj->pData = (void *)p->nTravIds; }
-static inline void Aig_ObjSetTravIdPrevious( Aig_Man_t * p, Aig_Obj_t * pObj ) { pObj->pData = (void *)(p->nTravIds - 1); }
-static inline int Aig_ObjIsTravIdCurrent( Aig_Man_t * p, Aig_Obj_t * pObj ) { return (int )((int)pObj->pData == p->nTravIds); }
-static inline int Aig_ObjIsTravIdPrevious( Aig_Man_t * p, Aig_Obj_t * pObj ) { return (int )((int)pObj->pData == 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_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_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)->nRefs, Aig_ObjFanin1(pObj)->nRefs); }
-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_AND || !Aig_ObjIsConst1(Aig_Regular(p0)) );
- assert( p1 == NULL || !Aig_ObjIsConst1(Aig_Regular(p1)) );
- assert( Type == AIG_PI || Aig_Regular(p0) != Aig_Regular(p1) );
- pGhost = Aig_ManGhost(p);
- pGhost->Type = Type;
- pGhost->pFanin0 = p0 < p1? p0 : p1;
- pGhost->pFanin1 = p0 < p1? p1 : p0;
- return pGhost;
-}
-
-// internal memory manager
-static inline Aig_Obj_t * Aig_ManFetchMemory( Aig_Man_t * p )
-{
- extern void Aig_ManAddMemory( Aig_Man_t * p );
- Aig_Obj_t * pTemp;
- if ( p->pListFree == NULL )
- Aig_ManAddMemory( p );
- pTemp = p->pListFree;
- p->pListFree = *((Aig_Obj_t **)pTemp);
- memset( pTemp, 0, sizeof(Aig_Obj_t) );
- return pTemp;
-}
-static inline void Aig_ManRecycleMemory( Aig_Man_t * p, Aig_Obj_t * pEntry )
-{
- pEntry->Type = AIG_NONE; // distinquishes dead node from live node
- *((Aig_Obj_t **)pEntry) = p->pListFree;
- p->pListFree = pEntry;
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// 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_ManForEachNode( p, pObj, i ) \
- for ( i = 0; i < p->nTableSize; i++ ) \
- if ( ((pObj) = p->pTable[i]) == NULL ) {} else
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/*=== aigBalance.c ========================================================*/
-extern Aig_Man_t * Aig_ManBalance( Aig_Man_t * p, int fUpdateLevel );
-extern Aig_Obj_t * Aig_NodeBalanceBuildSuper( Aig_Man_t * p, Vec_Ptr_t * vSuper, Aig_Type_t Type, int fUpdateLevel );
-/*=== 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_ManDfsNode( Aig_Man_t * p, Aig_Obj_t * pNode );
-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_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 );
-/*=== 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_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 );
-/*=== 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 void Aig_ManIncrementTravId( Aig_Man_t * p );
-extern void Aig_ManCleanData( Aig_Man_t * p );
-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 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 );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/temp/aig/aigCheck.c b/src/temp/aig/aigCheck.c
deleted file mode 100644
index 61e4cf78..00000000
--- a/src/temp/aig/aigCheck.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aigCheck.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [AIG checking procedures.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006.]
-
- Revision [$Id: aigCheck.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "aig.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Checks the consistency of the AIG manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Aig_ManCheck( Aig_Man_t * p )
-{
- Aig_Obj_t * pObj, * pObj2;
- int i;
- // check primary inputs
- Aig_ManForEachPi( p, pObj, i )
- {
- if ( Aig_ObjFanin0(pObj) || Aig_ObjFanin1(pObj) )
- {
- printf( "Aig_ManCheck: The PI node \"%p\" has fanins.\n", pObj );
- return 0;
- }
- }
- // check primary outputs
- Aig_ManForEachPo( p, pObj, i )
- {
- if ( !Aig_ObjFanin0(pObj) )
- {
- printf( "Aig_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj );
- return 0;
- }
- if ( Aig_ObjFanin1(pObj) )
- {
- printf( "Aig_ManCheck: The PO node \"%p\" has second fanin.\n", pObj );
- return 0;
- }
- }
- // check internal nodes
- Aig_ManForEachNode( p, pObj, i )
- {
- if ( !Aig_ObjFanin0(pObj) || !Aig_ObjFanin1(pObj) )
- {
- printf( "Aig_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj );
- return 0;
- }
- if ( Aig_ObjFanin0(pObj) >= Aig_ObjFanin1(pObj) )
- {
- printf( "Aig_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj );
- return 0;
- }
- pObj2 = Aig_TableLookup( p, pObj );
- if ( pObj2 != pObj )
- {
- printf( "Aig_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj );
- return 0;
- }
- }
- // count the total number of nodes
- if ( Aig_ManObjNum(p) != 1 + Aig_ManPiNum(p) + Aig_ManPoNum(p) + Aig_ManAndNum(p) + Aig_ManExorNum(p) )
- {
- printf( "Aig_ManCheck: The number of created nodes is wrong.\n" );
- return 0;
- }
- // count the number of nodes in the table
- if ( Aig_TableCountEntries(p) != Aig_ManAndNum(p) + Aig_ManExorNum(p) )
- {
- printf( "Aig_ManCheck: The number of nodes in the structural hashing table is wrong.\n" );
- return 0;
- }
-// if ( !Aig_ManIsAcyclic(p) )
-// return 0;
- return 1;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/temp/aig/aigMem.c b/src/temp/aig/aigMem.c
deleted file mode 100644
index 1be78a88..00000000
--- a/src/temp/aig/aigMem.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aigMem.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [Memory management for the AIG nodes.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006.]
-
- Revision [$Id: aigMem.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "aig.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// memory management
-#define IVY_PAGE_SIZE 12 // page size containing 2^IVY_PAGE_SIZE nodes
-#define IVY_PAGE_MASK 4095 // page bitmask (2^IVY_PAGE_SIZE)-1
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Starts the internal memory manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManStartMemory( Aig_Man_t * p )
-{
- p->vChunks = Vec_PtrAlloc( 128 );
- p->vPages = Vec_PtrAlloc( 128 );
-}
-
-/**Function*************************************************************
-
- Synopsis [Stops the internal memory manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManStopMemory( Aig_Man_t * p )
-{
- void * pMemory;
- int i;
- Vec_PtrForEachEntry( p->vChunks, pMemory, i )
- free( pMemory );
- Vec_PtrFree( p->vChunks );
- Vec_PtrFree( p->vPages );
- p->pListFree = NULL;
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates additional memory for the nodes.]
-
- Description [Allocates IVY_PAGE_SIZE nodes. Aligns memory by 32 bytes.
- Records the pointer to the AIG manager in the -1 entry.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManAddMemory( Aig_Man_t * p )
-{
- char * pMemory;
- int i, nBytes;
- assert( sizeof(Aig_Obj_t) <= 64 );
- assert( p->pListFree == NULL );
-// assert( (Aig_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
- // allocate new memory page
- nBytes = sizeof(Aig_Obj_t) * (1<<IVY_PAGE_SIZE) + 64;
- pMemory = ALLOC( char, nBytes );
- Vec_PtrPush( p->vChunks, pMemory );
- // align memory at the 32-byte boundary
- pMemory = pMemory + 64 - (((int)pMemory) & 63);
- // remember the manager in the first entry
- Vec_PtrPush( p->vPages, pMemory );
- // break the memory down into nodes
- p->pListFree = (Aig_Obj_t *)pMemory;
- for ( i = 1; i <= IVY_PAGE_MASK; i++ )
- {
- *((char **)pMemory) = pMemory + sizeof(Aig_Obj_t);
- pMemory += sizeof(Aig_Obj_t);
- }
- *((char **)pMemory) = NULL;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/temp/aig/aigOper.c b/src/temp/aig/aigOper.c
deleted file mode 100644
index 9985093e..00000000
--- a/src/temp/aig/aigOper.c
+++ /dev/null
@@ -1,373 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aigOper.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [AIG operations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006.]
-
- Revision [$Id: aigOper.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "aig.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// procedure to detect an EXOR gate
-static inline int Aig_ObjIsExorType( Aig_Obj_t * p0, Aig_Obj_t * p1, Aig_Obj_t ** ppFan0, Aig_Obj_t ** ppFan1 )
-{
- if ( !Aig_IsComplement(p0) || !Aig_IsComplement(p1) )
- return 0;
- p0 = Aig_Regular(p0);
- p1 = Aig_Regular(p1);
- if ( !Aig_ObjIsAnd(p0) || !Aig_ObjIsAnd(p1) )
- return 0;
- if ( Aig_ObjFanin0(p0) != Aig_ObjFanin0(p1) || Aig_ObjFanin1(p0) != Aig_ObjFanin1(p1) )
- return 0;
- if ( Aig_ObjFaninC0(p0) == Aig_ObjFaninC0(p1) || Aig_ObjFaninC1(p0) == Aig_ObjFaninC1(p1) )
- return 0;
- *ppFan0 = Aig_ObjChild0(p0);
- *ppFan1 = Aig_ObjChild1(p0);
- return 1;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Returns i-th elementary variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_IthVar( Aig_Man_t * p, int i )
-{
- int v;
- for ( v = Aig_ManPiNum(p); v <= i; v++ )
- Aig_ObjCreatePi( p );
- assert( i < Vec_PtrSize(p->vPis) );
- return Aig_ManPi( p, i );
-}
-
-/**Function*************************************************************
-
- Synopsis [Perform one operation.]
-
- Description [The argument nodes can be complemented.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_Oper( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1, Aig_Type_t Type )
-{
- if ( Type == AIG_AND )
- return Aig_And( p, p0, p1 );
- if ( Type == AIG_EXOR )
- return Aig_Exor( p, p0, p1 );
- assert( 0 );
- return NULL;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs canonicization step.]
-
- Description [The argument nodes can be complemented.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_And( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
-{
- Aig_Obj_t * pGhost, * pResult;
-// Aig_Obj_t * pFan0, * pFan1;
- // check trivial cases
- if ( p0 == p1 )
- return p0;
- 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 ( Aig_ObjIsExorType( p0, p1, &pFan0, &pFan1 ) )
-// return Aig_Exor( p, pFan0, pFan1 );
- // check the table
- pGhost = Aig_ObjCreateGhost( p, p0, p1, AIG_AND );
- if ( pResult = Aig_TableLookup( p, pGhost ) )
- return pResult;
- return Aig_ObjCreate( p, pGhost );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs canonicization step.]
-
- Description [The argument nodes can be complemented.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_Exor( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
-{
-/*
- Aig_Obj_t * pGhost, * pResult;
- // check trivial cases
- if ( p0 == p1 )
- return Aig_Not(p->pConst1);
- if ( p0 == Aig_Not(p1) )
- return 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 = Aig_ObjCreateGhost( p, p0, p1, AIG_EXOR );
- if ( pResult = Aig_TableLookup( p, pGhost ) )
- return pResult;
- return Aig_ObjCreate( p, pGhost );
-*/
- return Aig_Or( p, Aig_And(p, p0, Aig_Not(p1)), Aig_And(p, Aig_Not(p0), p1) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Implements Boolean OR.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_Or( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
-{
- return Aig_Not( Aig_And( p, Aig_Not(p0), Aig_Not(p1) ) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Implements ITE operation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_Mux( Aig_Man_t * p, Aig_Obj_t * pC, Aig_Obj_t * p1, Aig_Obj_t * p0 )
-{
-/*
- Aig_Obj_t * pTempA1, * pTempA2, * pTempB1, * pTempB2, * pTemp;
- int Count0, Count1;
- // consider trivial cases
- 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 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, pC, p1, AIG_AND) );
- pTempA2 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pC), p0, AIG_AND) );
- if ( pTempA1 && pTempA2 )
- {
- pTemp = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pTempA1), Aig_Not(pTempA2), AIG_AND) );
- if ( pTemp ) return Aig_Not(pTemp);
- }
- Count0 = (pTempA1 != NULL) + (pTempA2 != NULL);
- // implement the second MUX (F' = C * x1' + C' * x0')
- pTempB1 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, pC, Aig_Not(p1), AIG_AND) );
- pTempB2 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pC), Aig_Not(p0), AIG_AND) );
- if ( pTempB1 && pTempB2 )
- {
- pTemp = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pTempB1), Aig_Not(pTempB2), AIG_AND) );
- if ( pTemp ) return pTemp;
- }
- Count1 = (pTempB1 != NULL) + (pTempB2 != NULL);
- // compare and decide which one to implement
- if ( Count0 >= Count1 )
- {
- 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 : 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 Aig_Or( p, Aig_And(p, pC, p1), Aig_And(p, Aig_Not(pC), p0) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Implements ITE operation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_Maj( Aig_Man_t * p, Aig_Obj_t * pA, Aig_Obj_t * pB, Aig_Obj_t * pC )
-{
- return Aig_Or( p, Aig_Or(p, Aig_And(p, pA, pB), Aig_And(p, pA, pC)), Aig_And(p, pB, pC) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Constructs the well-balanced tree of gates.]
-
- Description [Disregards levels and possible logic sharing.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_Multi_rec( Aig_Man_t * p, Aig_Obj_t ** ppObjs, int nObjs, Aig_Type_t Type )
-{
- Aig_Obj_t * pObj1, * pObj2;
- if ( nObjs == 1 )
- return ppObjs[0];
- 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*************************************************************
-
- Synopsis [Old code.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_Multi( Aig_Man_t * p, Aig_Obj_t ** pArgs, int nArgs, Aig_Type_t Type )
-{
- assert( Type == AIG_AND || Type == AIG_EXOR );
- assert( nArgs > 0 );
- return Aig_Multi_rec( p, pArgs, nArgs, Type );
-}
-
-/**Function*************************************************************
-
- Synopsis [Implements the miter.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-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] = Aig_Not( Aig_Exor( p, vPairs->pArray[i], vPairs->pArray[i+1] ) );
- vPairs->nSize = vPairs->nSize/2;
- return Aig_Not( Aig_Multi_rec( p, (Aig_Obj_t **)vPairs->pArray, vPairs->nSize, AIG_AND ) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates AND function with nVars inputs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_CreateAnd( Aig_Man_t * p, int nVars )
-{
- Aig_Obj_t * pFunc;
- int i;
- pFunc = Aig_ManConst1( p );
- for ( i = 0; i < nVars; i++ )
- pFunc = Aig_And( p, pFunc, Aig_IthVar(p, i) );
- return pFunc;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates AND function with nVars inputs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_CreateOr( Aig_Man_t * p, int nVars )
-{
- Aig_Obj_t * pFunc;
- int i;
- pFunc = Aig_ManConst0( p );
- for ( i = 0; i < nVars; i++ )
- pFunc = Aig_Or( p, pFunc, Aig_IthVar(p, i) );
- return pFunc;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates AND function with nVars inputs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_CreateExor( Aig_Man_t * p, int nVars )
-{
- Aig_Obj_t * pFunc;
- int i;
- pFunc = Aig_ManConst0( p );
- for ( i = 0; i < nVars; i++ )
- pFunc = Aig_Exor( p, pFunc, Aig_IthVar(p, i) );
- return pFunc;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/temp/aig/module.make b/src/temp/aig/module.make
deleted file mode 100644
index ef9b587c..00000000
--- a/src/temp/aig/module.make
+++ /dev/null
@@ -1,9 +0,0 @@
-SRC += src/temp/aig/aigBalance.c \
- src/temp/aig/aigCheck.c \
- src/temp/aig/aigDfs.c \
- src/temp/aig/aigMan.c \
- src/temp/aig/aigMem.c \
- src/temp/aig/aigObj.c \
- src/temp/aig/aigOper.c \
- src/temp/aig/aigTable.c \
- src/temp/aig/aigUtil.c
diff --git a/src/temp/aig_free/aig.h b/src/temp/aig_free/aig.h
deleted file mode 100644
index 0dfc3f11..00000000
--- a/src/temp/aig_free/aig.h
+++ /dev/null
@@ -1,321 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aig.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [External declarations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006.]
-
- Revision [$Id: aig.c,v 1.00 2006/05/11 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 int Aig_Edge_t;
-
-// object types
-typedef enum {
- AIG_NONE, // 0: non-existent object
- AIG_CONST1, // 1: constant 1
- AIG_PI, // 2: primary input
- AIG_PO, // 3: primary output
- AIG_AND, // 4: AND node
- AIG_EXOR, // 5: EXOR node
- AIG_VOID // 6: unused object
-} Aig_Type_t;
-
-// the AIG node
-struct Aig_Obj_t_ // 4 words
-{
- void * pData; // misc
- 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 (level)
-};
-
-// 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
- Aig_Obj_t * pConst1; // the constant 1 node
- Aig_Obj_t Ghost; // the ghost node
- // AIG node counters
- int nObjs[AIG_VOID];// the number of objects by type
- int nCreated; // the number of created objects
- int nDeleted; // the number of deleted objects
- // stuctural hash table
- Aig_Obj_t ** pTable; // structural hash table
- int nTableSize; // structural hash table size
- // various data members
- void * pData; // the temporary data
- int nTravIds; // the current traversal ID
- int fRefCount; // enables reference counting
- int fCatchExor; // enables EXOR nodes
- // memory management
- Vec_Ptr_t * vChunks; // allocated memory pieces
- Vec_Ptr_t * vPages; // memory pages used by nodes
- Aig_Obj_t * pListFree; // the list of free 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))
-
-#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 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_Edge_t Aig_EdgeCreate( int Id, int fCompl ) { return (Id << 1) | fCompl; }
-static inline int Aig_EdgeId( Aig_Edge_t Edge ) { return Edge >> 1; }
-static inline int Aig_EdgeIsComplement( Aig_Edge_t Edge ) { return Edge & 1; }
-static inline Aig_Edge_t Aig_EdgeRegular( Aig_Edge_t Edge ) { return (Edge >> 1) << 1; }
-static inline Aig_Edge_t Aig_EdgeNot( Aig_Edge_t Edge ) { return Edge ^ 1; }
-static inline Aig_Edge_t Aig_EdgeNotCond( Aig_Edge_t Edge, int fCond ) { return Edge ^ fCond; }
-
-static inline int Aig_ManPiNum( Aig_Man_t * p ) { return p->nObjs[AIG_PI]; }
-static inline int Aig_ManPoNum( Aig_Man_t * p ) { return p->nObjs[AIG_PO]; }
-static inline int Aig_ManAndNum( Aig_Man_t * p ) { return p->nObjs[AIG_AND]; }
-static inline int Aig_ManExorNum( Aig_Man_t * p ) { return p->nObjs[AIG_EXOR]; }
-static inline int Aig_ManNodeNum( Aig_Man_t * p ) { return p->nObjs[AIG_AND]+p->nObjs[AIG_EXOR];}
-static inline int Aig_ManGetCost( Aig_Man_t * p ) { return p->nObjs[AIG_AND]+3*p->nObjs[AIG_EXOR]; }
-static inline int Aig_ManObjNum( Aig_Man_t * p ) { return p->nCreated - p->nDeleted; }
-
-static inline Aig_Type_t Aig_ObjType( Aig_Obj_t * pObj ) { return pObj->Type; }
-static inline int Aig_ObjIsNone( Aig_Obj_t * pObj ) { return pObj->Type == AIG_NONE; }
-static inline int Aig_ObjIsConst1( Aig_Obj_t * pObj ) { assert(!Aig_IsComplement(pObj)); return pObj->Type == AIG_CONST1; }
-static inline int Aig_ObjIsPi( Aig_Obj_t * pObj ) { return pObj->Type == AIG_PI; }
-static inline int Aig_ObjIsPo( Aig_Obj_t * pObj ) { return pObj->Type == AIG_PO; }
-static inline int Aig_ObjIsAnd( Aig_Obj_t * pObj ) { return pObj->Type == AIG_AND; }
-static inline int Aig_ObjIsExor( Aig_Obj_t * pObj ) { return pObj->Type == AIG_EXOR; }
-static inline int Aig_ObjIsNode( Aig_Obj_t * pObj ) { return pObj->Type == AIG_AND || pObj->Type == AIG_EXOR; }
-static inline int Aig_ObjIsTerm( Aig_Obj_t * pObj ) { return pObj->Type == AIG_PI || pObj->Type == AIG_PO || pObj->Type == AIG_CONST1; }
-static inline int Aig_ObjIsHash( Aig_Obj_t * pObj ) { return pObj->Type == AIG_AND || pObj->Type == AIG_EXOR; }
-
-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->pData = (void *)TravId; }
-static inline void Aig_ObjSetTravIdCurrent( Aig_Man_t * p, Aig_Obj_t * pObj ) { pObj->pData = (void *)p->nTravIds; }
-static inline void Aig_ObjSetTravIdPrevious( Aig_Man_t * p, Aig_Obj_t * pObj ) { pObj->pData = (void *)(p->nTravIds - 1); }
-static inline int Aig_ObjIsTravIdCurrent( Aig_Man_t * p, Aig_Obj_t * pObj ) { return (int )((int)pObj->pData == p->nTravIds); }
-static inline int Aig_ObjIsTravIdPrevious( Aig_Man_t * p, Aig_Obj_t * pObj ) { return (int )((int)pObj->pData == 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_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_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)->nRefs, Aig_ObjFanin1(pObj)->nRefs); }
-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_AND || !Aig_ObjIsConst1(Aig_Regular(p0)) );
- assert( p1 == NULL || !Aig_ObjIsConst1(Aig_Regular(p1)) );
- assert( Type == AIG_PI || Aig_Regular(p0) != Aig_Regular(p1) );
- pGhost = Aig_ManGhost(p);
- pGhost->Type = Type;
- pGhost->pFanin0 = p0 < p1? p0 : p1;
- pGhost->pFanin1 = p0 < p1? p1 : p0;
- return pGhost;
-}
-
-// internal memory manager
-static inline Aig_Obj_t * Aig_ManFetchMemory( Aig_Man_t * p )
-{
- extern void Aig_ManAddMemory( Aig_Man_t * p );
- Aig_Obj_t * pTemp;
- if ( p->pListFree == NULL )
- Aig_ManAddMemory( p );
- pTemp = p->pListFree;
- p->pListFree = *((Aig_Obj_t **)pTemp);
- memset( pTemp, 0, sizeof(Aig_Obj_t) );
- return pTemp;
-}
-static inline void Aig_ManRecycleMemory( Aig_Man_t * p, Aig_Obj_t * pEntry )
-{
- pEntry->Type = AIG_NONE; // distinquishes dead node from live node
- *((Aig_Obj_t **)pEntry) = p->pListFree;
- p->pListFree = pEntry;
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// 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_ManForEachNode( p, pObj, i ) \
- for ( i = 0; i < p->nTableSize; i++ ) \
- if ( ((pObj) = p->pTable[i]) == NULL ) {} else
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/*=== aigBalance.c ========================================================*/
-extern Aig_Man_t * Aig_ManBalance( Aig_Man_t * p, int fUpdateLevel );
-extern Aig_Obj_t * Aig_NodeBalanceBuildSuper( Aig_Man_t * p, Vec_Ptr_t * vSuper, Aig_Type_t Type, int fUpdateLevel );
-/*=== 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_ManDfsNode( Aig_Man_t * p, Aig_Obj_t * pNode );
-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_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 );
-/*=== 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_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 );
-/*=== 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 void Aig_ManIncrementTravId( Aig_Man_t * p );
-extern void Aig_ManCleanData( Aig_Man_t * p );
-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 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 );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/temp/aig_free/aigBalance.c b/src/temp/aig_free/aigBalance.c
deleted file mode 100644
index 1abc672d..00000000
--- a/src/temp/aig_free/aigBalance.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aigBalance.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [Algebraic AIG balancing.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006.]
-
- Revision [$Id: aigBalance.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "aig.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-static Aig_Obj_t * Aig_NodeBalance_rec( Aig_Man_t * pNew, Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level, int fUpdateLevel );
-static Vec_Ptr_t * Aig_NodeBalanceCone( Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level );
-static int Aig_NodeBalanceFindLeft( Vec_Ptr_t * vSuper );
-static void Aig_NodeBalancePermute( Aig_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor );
-static void Aig_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Aig_Obj_t * pObj );
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Performs algebraic balancing of the AIG.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Man_t * Aig_ManBalance( Aig_Man_t * p, int fUpdateLevel )
-{
- Aig_Man_t * pNew;
- Aig_Obj_t * pObj, * pObjNew;
- Vec_Vec_t * vStore;
- int i;
- // create the new manager
- pNew = Aig_ManStart();
- pNew->fRefCount = 0;
- // map the PI nodes
- 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 );
- Aig_ManForEachPo( p, pObj, i )
- {
- pObjNew = Aig_NodeBalance_rec( pNew, Aig_ObjFanin0(pObj), vStore, 0, fUpdateLevel );
- Aig_ObjCreatePo( pNew, Aig_NotCond( pObjNew, Aig_ObjFaninC0(pObj) ) );
- }
- Vec_VecFree( vStore );
- // remove dangling nodes
-// Aig_ManCreateRefs( pNew );
-// if ( i = Aig_ManCleanup( pNew ) )
-// printf( "Cleanup after balancing removed %d dangling nodes.\n", i );
- // check the resulting AIG
- if ( !Aig_ManCheck(pNew) )
- printf( "Aig_ManBalance(): The check has failed.\n" );
- return pNew;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the new node constructed.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_NodeBalance_rec( Aig_Man_t * pNew, Aig_Obj_t * pObjOld, Vec_Vec_t * vStore, int Level, int fUpdateLevel )
-{
- Aig_Obj_t * pObjNew;
- Vec_Ptr_t * vSuper;
- int i;
- assert( !Aig_IsComplement(pObjOld) );
- // return if the result is known
- if ( pObjOld->pData )
- return pObjOld->pData;
- assert( Aig_ObjIsNode(pObjOld) );
- // get the implication supergate
- vSuper = Aig_NodeBalanceCone( pObjOld, vStore, Level );
- // check if supergate contains two nodes in the opposite polarity
- if ( vSuper->nSize == 0 )
- 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 = Aig_NodeBalance_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 = Aig_NodeBalanceBuildSuper( pNew, vSuper, Aig_ObjType(pObjOld), fUpdateLevel );
- // make sure the balanced node is not assigned
-// assert( pObjOld->Level >= Aig_Regular(pObjNew)->Level );
- assert( pObjOld->pData == NULL );
- return pObjOld->pData = pObjNew;
-}
-
-/**Function*************************************************************
-
- Synopsis [Collects the nodes of the supergate.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Aig_NodeBalanceCone_rec( Aig_Obj_t * pRoot, Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
-{
- int RetValue1, RetValue2, i;
- // check if the node is visited
- if ( Aig_Regular(pObj)->fMarkB )
- {
- // check if the node occurs in the same polarity
- for ( i = 0; i < vSuper->nSize; i++ )
- if ( vSuper->pArray[i] == pObj )
- return 1;
- // check if the node is present in the opposite polarity
- for ( i = 0; i < vSuper->nSize; i++ )
- 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 && (Aig_IsComplement(pObj) || Aig_ObjType(pObj) != Aig_ObjType(pRoot) || Aig_ObjRefs(pObj) > 1) )
- {
- Vec_PtrPush( vSuper, pObj );
- Aig_Regular(pObj)->fMarkB = 1;
- return 0;
- }
- assert( !Aig_IsComplement(pObj) );
- assert( Aig_ObjIsNode(pObj) );
- // go through the branches
- RetValue1 = Aig_NodeBalanceCone_rec( pRoot, Aig_ObjChild0(pObj), vSuper );
- RetValue2 = Aig_NodeBalanceCone_rec( pRoot, Aig_ObjChild1(pObj), vSuper );
- if ( RetValue1 == -1 || RetValue2 == -1 )
- return -1;
- // return 1 if at least one branch has a duplicate
- return RetValue1 || RetValue2;
-}
-
-/**Function*************************************************************
-
- Synopsis [Collects the nodes of the supergate.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Aig_NodeBalanceCone( Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level )
-{
- Vec_Ptr_t * vNodes;
- int RetValue, i;
- assert( !Aig_IsComplement(pObj) );
- // extend the storage
- if ( Vec_VecSize( vStore ) <= Level )
- Vec_VecPush( vStore, Level, 0 );
- // get the temporary array of nodes
- vNodes = Vec_VecEntry( vStore, Level );
- Vec_PtrClear( vNodes );
- // collect the nodes in the implication supergate
- RetValue = Aig_NodeBalanceCone_rec( pObj, pObj, vNodes );
- assert( vNodes->nSize > 1 );
- // unmark the visited nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
- 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 )
- vNodes->nSize = 0;
- return vNodes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Procedure used for sorting the nodes in decreasing order of levels.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Aig_NodeCompareLevelsDecrease( Aig_Obj_t ** pp1, Aig_Obj_t ** pp2 )
-{
- int Diff = Aig_ObjLevel(Aig_Regular(*pp1)) - Aig_ObjLevel(Aig_Regular(*pp2));
- if ( Diff > 0 )
- return -1;
- if ( Diff < 0 )
- return 1;
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Builds implication supergate.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_NodeBalanceBuildSuper( Aig_Man_t * p, Vec_Ptr_t * vSuper, Aig_Type_t Type, int fUpdateLevel )
-{
- Aig_Obj_t * pObj1, * pObj2;
- int LeftBound;
- assert( vSuper->nSize > 1 );
- // sort the new nodes by level in the decreasing order
- 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 : Aig_NodeBalanceFindLeft( vSuper );
- // find the node that can be shared (if no such node, randomize choice)
- Aig_NodeBalancePermute( p, vSuper, LeftBound, Type == AIG_EXOR );
- // pull out the last two nodes
- pObj1 = Vec_PtrPop(vSuper);
- pObj2 = Vec_PtrPop(vSuper);
- Aig_NodeBalancePushUniqueOrderByLevel( vSuper, Aig_Oper(p, pObj1, pObj2, Type) );
- }
- return Vec_PtrEntry(vSuper, 0);
-}
-
-/**Function*************************************************************
-
- Synopsis [Finds the left bound on the next candidate to be paired.]
-
- Description [The nodes in the array are in the decreasing order of levels.
- The last node in the array has the smallest level. By default it would be paired
- with the next node on the left. However, it may be possible to pair it with some
- other node on the left, in such a way that the new node is shared. This procedure
- finds the index of the left-most node, which can be paired with the last node.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Aig_NodeBalanceFindLeft( Vec_Ptr_t * vSuper )
-{
- Aig_Obj_t * pObjRight, * pObjLeft;
- int Current;
- // if two or less nodes, pair with the first
- if ( Vec_PtrSize(vSuper) < 3 )
- return 0;
- // set the pointer to the one before the last
- Current = Vec_PtrSize(vSuper) - 2;
- pObjRight = Vec_PtrEntry( vSuper, Current );
- // go through the nodes to the left of this one
- for ( Current--; Current >= 0; Current-- )
- {
- // get the next node on the left
- pObjLeft = Vec_PtrEntry( vSuper, Current );
- // if the level of this node is different, quit the loop
- 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( Aig_ObjLevel(Aig_Regular(pObjLeft)) == Aig_ObjLevel(Aig_Regular(pObjRight)) );
- return Current;
-}
-
-/**Function*************************************************************
-
- Synopsis [Moves closer to the end the node that is best for sharing.]
-
- Description [If there is no node with sharing, randomly chooses one of
- the legal nodes.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_NodeBalancePermute( Aig_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int fExor )
-{
- Aig_Obj_t * pObj1, * pObj2, * pObj3, * pGhost;
- int RightBound, i;
- // get the right bound
- RightBound = Vec_PtrSize(vSuper) - 2;
- assert( LeftBound <= RightBound );
- if ( LeftBound == RightBound )
- return;
- // get the two last nodes
- pObj1 = Vec_PtrEntry( vSuper, RightBound + 1 );
- pObj2 = Vec_PtrEntry( vSuper, RightBound );
- 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 ( Aig_Regular(pObj3) == p->pConst1 )
- {
- Vec_PtrWriteEntry( vSuper, i, pObj2 );
- Vec_PtrWriteEntry( vSuper, RightBound, pObj3 );
- return;
- }
- pGhost = Aig_ObjCreateGhost( p, pObj1, pObj3, fExor? AIG_EXOR : AIG_AND );
- if ( Aig_TableLookup( p, pGhost ) )
- {
- if ( pObj3 == pObj2 )
- return;
- Vec_PtrWriteEntry( vSuper, i, pObj2 );
- Vec_PtrWriteEntry( vSuper, RightBound, pObj3 );
- return;
- }
- }
-/*
- // we did not find the node to share, randomize choice
- {
- int Choice = rand() % (RightBound - LeftBound + 1);
- pObj3 = Vec_PtrEntry( vSuper, LeftBound + Choice );
- if ( pObj3 == pObj2 )
- return;
- Vec_PtrWriteEntry( vSuper, LeftBound + Choice, pObj2 );
- Vec_PtrWriteEntry( vSuper, RightBound, pObj3 );
- }
-*/
-}
-
-/**Function*************************************************************
-
- Synopsis [Inserts a new node in the order by levels.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Aig_Obj_t * pObj )
-{
- Aig_Obj_t * pObj1, * pObj2;
- int i;
- if ( Vec_PtrPushUnique(vStore, pObj) )
- return;
- // find the p of the node
- for ( i = vStore->nSize-1; i > 0; i-- )
- {
- pObj1 = vStore->pArray[i ];
- pObj2 = vStore->pArray[i-1];
- if ( Aig_ObjLevel(Aig_Regular(pObj1)) <= Aig_ObjLevel(Aig_Regular(pObj2)) )
- break;
- vStore->pArray[i ] = pObj2;
- vStore->pArray[i-1] = pObj1;
- }
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/temp/aig_free/aigDfs.c b/src/temp/aig_free/aigDfs.c
deleted file mode 100644
index c004cab0..00000000
--- a/src/temp/aig_free/aigDfs.c
+++ /dev/null
@@ -1,399 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aigDfs.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [DFS traversal procedures.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006.]
-
- Revision [$Id: aigDfs.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "aig.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Collects internal nodes in the DFS order.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManDfs_rec( Aig_Obj_t * pObj, Vec_Ptr_t * vNodes )
-{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
- return;
- Aig_ManDfs_rec( Aig_ObjFanin0(pObj), vNodes );
- Aig_ManDfs_rec( Aig_ObjFanin1(pObj), vNodes );
- assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjSetMarkA(pObj);
- Vec_PtrPush( vNodes, pObj );
-}
-
-/**Function*************************************************************
-
- Synopsis [Collects internal nodes in the DFS order.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Aig_ManDfs( Aig_Man_t * p )
-{
- Vec_Ptr_t * vNodes;
- Aig_Obj_t * pObj;
- int i;
- vNodes = Vec_PtrAlloc( Aig_ManNodeNum(p) );
- Aig_ManForEachNode( p, pObj, i )
- Aig_ManDfs_rec( pObj, vNodes );
- Aig_ManForEachNode( p, pObj, i )
- Aig_ObjClearMarkA(pObj);
- return vNodes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Collects internal nodes in the DFS order.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Aig_ManDfsNode( Aig_Man_t * p, Aig_Obj_t * pNode )
-{
- Vec_Ptr_t * vNodes;
- Aig_Obj_t * pObj;
- int i;
- assert( !Aig_IsComplement(pNode) );
- vNodes = Vec_PtrAlloc( 16 );
- Aig_ManDfs_rec( pNode, vNodes );
- Vec_PtrForEachEntry( vNodes, pObj, i )
- Aig_ObjClearMarkA(pObj);
- return vNodes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes the max number of levels in the manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Aig_ManCountLevels( Aig_Man_t * p )
-{
- Vec_Ptr_t * vNodes;
- Aig_Obj_t * pObj;
- int i, LevelsMax, Level0, Level1;
- // initialize the levels
- Aig_ManConst1(p)->pData = NULL;
- Aig_ManForEachPi( p, pObj, i )
- pObj->pData = NULL;
- // compute levels in a DFS order
- vNodes = Aig_ManDfs( p );
- Vec_PtrForEachEntry( vNodes, pObj, i )
- {
- 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;
- Aig_ManForEachPo( p, pObj, i )
- LevelsMax = AIG_MAX( LevelsMax, (int)Aig_ObjFanin0(pObj)->pData );
- return LevelsMax;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates correct reference counters at each node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManCreateRefs( Aig_Man_t * p )
-{
- Aig_Obj_t * pObj;
- int i;
- if ( p->fRefCount )
- return;
- p->fRefCount = 1;
- // clear refs
- Aig_ObjClearRef( Aig_ManConst1(p) );
- Aig_ManForEachPi( p, pObj, i )
- Aig_ObjClearRef( pObj );
- Aig_ManForEachNode( p, pObj, i )
- Aig_ObjClearRef( pObj );
- Aig_ManForEachPo( p, pObj, i )
- Aig_ObjClearRef( pObj );
- // set refs
- Aig_ManForEachNode( p, pObj, i )
- {
- Aig_ObjRef( Aig_ObjFanin0(pObj) );
- Aig_ObjRef( Aig_ObjFanin1(pObj) );
- }
- Aig_ManForEachPo( p, pObj, i )
- Aig_ObjRef( Aig_ObjFanin0(pObj) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of AIG nodes rooted at this cone.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ConeMark_rec( Aig_Obj_t * pObj )
-{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
- return;
- Aig_ConeMark_rec( Aig_ObjFanin0(pObj) );
- Aig_ConeMark_rec( Aig_ObjFanin1(pObj) );
- assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjSetMarkA( pObj );
-}
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of AIG nodes rooted at this cone.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ConeCleanAndMark_rec( Aig_Obj_t * pObj )
-{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
- return;
- Aig_ConeCleanAndMark_rec( Aig_ObjFanin0(pObj) );
- Aig_ConeCleanAndMark_rec( Aig_ObjFanin1(pObj) );
- assert( !Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjSetMarkA( pObj );
- pObj->pData = NULL;
-}
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of AIG nodes rooted at this cone.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Aig_ConeCountAndMark_rec( Aig_Obj_t * pObj )
-{
- int Counter;
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
- return 0;
- 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;
-}
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of AIG nodes rooted at this cone.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ConeUnmark_rec( Aig_Obj_t * pObj )
-{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || !Aig_ObjIsMarkA(pObj) )
- return;
- Aig_ConeUnmark_rec( Aig_ObjFanin0(pObj) );
- Aig_ConeUnmark_rec( Aig_ObjFanin1(pObj) );
- assert( Aig_ObjIsMarkA(pObj) ); // loop detection
- Aig_ObjClearMarkA( pObj );
-}
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of AIG nodes rooted at this cone.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Aig_DagSize( Aig_Obj_t * pObj )
-{
- int Counter;
- Counter = Aig_ConeCountAndMark_rec( Aig_Regular(pObj) );
- Aig_ConeUnmark_rec( Aig_Regular(pObj) );
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Transfers the AIG from one manager into another.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_Transfer_rec( Aig_Man_t * pDest, Aig_Obj_t * pObj )
-{
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) || Aig_ObjIsMarkA(pObj) )
- return;
- 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*************************************************************
-
- Synopsis [Transfers the AIG from one manager into another.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_Transfer( Aig_Man_t * pSour, Aig_Man_t * pDest, Aig_Obj_t * pRoot, int nVars )
-{
- Aig_Obj_t * pObj;
- int i;
- // solve simple cases
- if ( pSour == pDest )
- return pRoot;
- if ( Aig_ObjIsConst1( Aig_Regular(pRoot) ) )
- return Aig_NotCond( Aig_ManConst1(pDest), Aig_IsComplement(pRoot) );
- // set the PI mapping
- Aig_ManForEachPi( pSour, pObj, i )
- {
- if ( i == nVars )
- break;
- pObj->pData = Aig_IthVar(pDest, i);
- }
- // transfer and set markings
- Aig_Transfer_rec( pDest, Aig_Regular(pRoot) );
- // clear the markings
- Aig_ConeUnmark_rec( Aig_Regular(pRoot) );
- return Aig_NotCond( Aig_Regular(pRoot)->pData, Aig_IsComplement(pRoot) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Composes the AIG (pRoot) with the function (pFunc) using PI var (iVar).]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_Compose_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFunc, Aig_Obj_t * pVar )
-{
- assert( !Aig_IsComplement(pObj) );
- if ( Aig_ObjIsMarkA(pObj) )
- return;
- if ( Aig_ObjIsConst1(pObj) || Aig_ObjIsPi(pObj) )
- {
- pObj->pData = pObj == pVar ? pFunc : pObj;
- return;
- }
- 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*************************************************************
-
- Synopsis [Composes the AIG (pRoot) with the function (pFunc) using PI var (iVar).]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-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 >= Aig_ManPiNum(p) )
- {
- printf( "Aig_Compose(): The PI variable %d is not defined.\n", iVar );
- return NULL;
- }
- // recursively perform composition
- Aig_Compose_rec( p, Aig_Regular(pRoot), pFunc, Aig_ManPi(p, iVar) );
- // clear the markings
- Aig_ConeUnmark_rec( Aig_Regular(pRoot) );
- return Aig_NotCond( Aig_Regular(pRoot)->pData, Aig_IsComplement(pRoot) );
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/temp/aig_free/aigMan.c b/src/temp/aig_free/aigMan.c
deleted file mode 100644
index bb39712f..00000000
--- a/src/temp/aig_free/aigMan.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aigMan.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [AIG manager.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006.]
-
- Revision [$Id: aig_.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "aig.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Starts the AIG manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Man_t * Aig_ManStart()
-{
- Aig_Man_t * p;
- // start the manager
- p = ALLOC( Aig_Man_t, 1 );
- memset( p, 0, sizeof(Aig_Man_t) );
- // perform initializations
- p->nTravIds = 1;
- p->fRefCount = 1;
- p->fCatchExor = 0;
- // allocate arrays for nodes
- p->vPis = Vec_PtrAlloc( 100 );
- p->vPos = Vec_PtrAlloc( 100 );
- // prepare the internal memory manager
- Aig_ManStartMemory( p );
- // create the constant node
- p->pConst1 = Aig_ManFetchMemory( p );
- p->pConst1->Type = AIG_CONST1;
- p->pConst1->fPhase = 1;
- p->nCreated = 1;
- // start the table
- p->nTableSize = 10007;
- p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize );
- memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Stops the AIG manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManStop( Aig_Man_t * p )
-{
- Aig_Obj_t * pObj;
- int i;
- // make sure the nodes have clean marks
- pObj = Aig_ManConst1(p);
- assert( !pObj->fMarkA && !pObj->fMarkB );
- Aig_ManForEachPi( p, pObj, i )
- assert( !pObj->fMarkA && !pObj->fMarkB );
- Aig_ManForEachPo( p, pObj, i )
- assert( !pObj->fMarkA && !pObj->fMarkB );
- Aig_ManForEachNode( p, pObj, i )
- assert( !pObj->fMarkA && !pObj->fMarkB );
- // print time
- if ( p->time1 ) { PRT( "time1", p->time1 ); }
- if ( p->time2 ) { PRT( "time2", p->time2 ); }
-// Aig_TableProfile( p );
- if ( p->vChunks ) Aig_ManStopMemory( p );
- if ( p->vPis ) Vec_PtrFree( p->vPis );
- if ( p->vPos ) Vec_PtrFree( p->vPos );
- 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 * vNodes;
- Aig_Obj_t * pNode;
- int i, nNodesOld;
- assert( p->fRefCount );
- nNodesOld = Aig_ManNodeNum(p);
- // collect roots of dangling nodes
- vNodes = Vec_PtrAlloc( 100 );
- Aig_ManForEachNode( p, pNode, i )
- if ( Aig_ObjRefs(pNode) == 0 )
- Vec_PtrPush( vNodes, pNode );
- // recursively remove dangling nodes
- Vec_PtrForEachEntry( vNodes, pNode, i )
- Aig_ObjDelete_rec( p, pNode );
- Vec_PtrFree( vNodes );
- return nNodesOld - Aig_ManNodeNum(p);
-}
-
-/**Function*************************************************************
-
- Synopsis [Stops the AIG manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManPrintStats( Aig_Man_t * p )
-{
- printf( "PI/PO = %d/%d. ", Aig_ManPiNum(p), Aig_ManPoNum(p) );
- printf( "A = %7d. ", Aig_ManAndNum(p) );
- printf( "X = %5d. ", Aig_ManExorNum(p) );
- printf( "Cre = %7d. ", p->nCreated );
- printf( "Del = %7d. ", p->nDeleted );
- printf( "Lev = %3d. ", Aig_ManCountLevels(p) );
- printf( "\n" );
-}
-
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/temp/aig_free/aigObj.c b/src/temp/aig_free/aigObj.c
deleted file mode 100644
index 51ce6008..00000000
--- a/src/temp/aig_free/aigObj.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aigObj.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [Adding/removing objects.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006.]
-
- Revision [$Id: aigObj.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "aig.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Creates primary input.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_ObjCreatePi( Aig_Man_t * p )
-{
- Aig_Obj_t * pObj;
- pObj = Aig_ManFetchMemory( p );
- pObj->Type = AIG_PI;
- Vec_PtrPush( p->vPis, pObj );
- p->nObjs[AIG_PI]++;
- p->nCreated++;
- return pObj;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates primary output with the given driver.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_ObjCreatePo( Aig_Man_t * p, Aig_Obj_t * pDriver )
-{
- Aig_Obj_t * pObj;
- pObj = Aig_ManFetchMemory( p );
- pObj->Type = AIG_PO;
- Vec_PtrPush( p->vPos, pObj );
- // add connections
- pObj->pFanin0 = pDriver;
- if ( p->fRefCount )
- Aig_ObjRef( Aig_Regular(pDriver) );
- else
- pObj->nRefs = Aig_ObjLevel( Aig_Regular(pDriver) );
- // update node counters of the manager
- p->nObjs[AIG_PO]++;
- p->nCreated++;
- return pObj;
-}
-
-/**Function*************************************************************
-
- Synopsis [Create the new node assuming it does not exist.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_ObjCreate( Aig_Man_t * p, Aig_Obj_t * pGhost )
-{
- Aig_Obj_t * pObj;
- assert( !Aig_IsComplement(pGhost) );
- assert( Aig_ObjIsNode(pGhost) );
- assert( pGhost == &p->Ghost );
- // get memory for the new object
- pObj = Aig_ManFetchMemory( p );
- pObj->Type = pGhost->Type;
- // add connections
- Aig_ObjConnect( p, pObj, pGhost->pFanin0, pGhost->pFanin1 );
- // update node counters of the manager
- p->nObjs[Aig_ObjType(pObj)]++;
- p->nCreated++;
- return pObj;
-}
-
-/**Function*************************************************************
-
- Synopsis [Connect the object to the fanin.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ObjConnect( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFan0, Aig_Obj_t * pFan1 )
-{
- assert( !Aig_IsComplement(pObj) );
- assert( Aig_ObjIsNode(pObj) );
- // add the first fanin
- pObj->pFanin0 = pFan0;
- pObj->pFanin1 = pFan1;
- // increment references of the fanins and add their fanouts
- if ( p->fRefCount )
- {
- if ( pFan0 != NULL )
- Aig_ObjRef( Aig_ObjFanin0(pObj) );
- if ( pFan1 != NULL )
- Aig_ObjRef( Aig_ObjFanin1(pObj) );
- }
- else
- pObj->nRefs = Aig_ObjLevelNew( pObj );
- // add the node to the structural hash table
- Aig_TableInsert( p, pObj );
-}
-
-/**Function*************************************************************
-
- Synopsis [Connect the object to the fanin.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ObjDisconnect( Aig_Man_t * p, Aig_Obj_t * pObj )
-{
- assert( !Aig_IsComplement(pObj) );
- assert( Aig_ObjIsNode(pObj) );
- // remove connections
- if ( pObj->pFanin0 != NULL )
- Aig_ObjDeref(Aig_ObjFanin0(pObj));
- if ( pObj->pFanin1 != NULL )
- Aig_ObjDeref(Aig_ObjFanin1(pObj));
- // remove the node from the structural hash table
- Aig_TableDelete( p, pObj );
- // add the first fanin
- pObj->pFanin0 = NULL;
- pObj->pFanin1 = NULL;
-}
-
-/**Function*************************************************************
-
- Synopsis [Deletes the node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ObjDelete( Aig_Man_t * p, Aig_Obj_t * pObj )
-{
- assert( !Aig_IsComplement(pObj) );
- assert( !Aig_ObjIsTerm(pObj) );
- assert( Aig_ObjRefs(pObj) == 0 );
- // update node counters of the manager
- p->nObjs[pObj->Type]--;
- p->nDeleted++;
- // remove connections
- Aig_ObjDisconnect( p, pObj );
- // remove PIs/POs from the arrays
- if ( Aig_ObjIsPi(pObj) )
- Vec_PtrRemove( p->vPis, pObj );
- // free the node
- Aig_ManRecycleMemory( p, pObj );
-}
-
-/**Function*************************************************************
-
- Synopsis [Deletes the MFFC of the node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ObjDelete_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
-{
- Aig_Obj_t * pFanin0, * pFanin1;
- assert( !Aig_IsComplement(pObj) );
- if ( Aig_ObjIsConst1(pObj) || Aig_ObjIsPi(pObj) )
- return;
- assert( Aig_ObjIsNode(pObj) );
- pFanin0 = Aig_ObjFanin0(pObj);
- pFanin1 = Aig_ObjFanin1(pObj);
- Aig_ObjDelete( p, pObj );
- if ( pFanin0 && !Aig_ObjIsNone(pFanin0) && Aig_ObjRefs(pFanin0) == 0 )
- Aig_ObjDelete_rec( p, pFanin0 );
- if ( pFanin1 && !Aig_ObjIsNone(pFanin1) && Aig_ObjRefs(pFanin1) == 0 )
- Aig_ObjDelete_rec( p, pFanin1 );
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/temp/aig_free/aigTable.c b/src/temp/aig_free/aigTable.c
deleted file mode 100644
index 338faa45..00000000
--- a/src/temp/aig_free/aigTable.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aigTable.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [Structural hashing table.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006. ]
-
- Revision [$Id: aigTable.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "aig.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// hashing the node
-static unsigned long Aig_Hash( Aig_Obj_t * pObj, int TableSize )
-{
- 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 Aig_Obj_t ** Aig_TableFind( Aig_Man_t * p, Aig_Obj_t * pObj )
-{
- int i;
- assert( Aig_ObjChild0(pObj) && Aig_ObjChild1(pObj) );
- assert( Aig_ObjChild0(pObj) < Aig_ObjChild1(pObj) );
- for ( i = Aig_Hash(pObj, p->nTableSize); p->pTable[i]; i = (i+1) % p->nTableSize )
- if ( p->pTable[i] == pObj )
- break;
- return p->pTable + i;
-}
-
-static void Aig_TableResize( Aig_Man_t * p );
-static unsigned int Cudd_PrimeAig( unsigned int p );
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Checks if node with the given attributes is in the hash table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_TableLookup( Aig_Man_t * p, Aig_Obj_t * pGhost )
-{
- int i;
- assert( !Aig_IsComplement(pGhost) );
- assert( Aig_ObjChild0(pGhost) && Aig_ObjChild1(pGhost) );
- assert( Aig_ObjChild0(pGhost) < Aig_ObjChild1(pGhost) );
- if ( p->fRefCount && (!Aig_ObjRefs(Aig_ObjFanin0(pGhost)) || !Aig_ObjRefs(Aig_ObjFanin1(pGhost))) )
- return NULL;
- for ( i = Aig_Hash(pGhost, p->nTableSize); p->pTable[i]; i = (i+1) % p->nTableSize )
- {
- if ( Aig_ObjChild0(p->pTable[i]) == Aig_ObjChild0(pGhost) &&
- Aig_ObjChild1(p->pTable[i]) == Aig_ObjChild1(pGhost) &&
- Aig_ObjType(p->pTable[i]) == Aig_ObjType(pGhost) )
- return p->pTable[i];
- }
- return NULL;
-}
-
-/**Function*************************************************************
-
- Synopsis [Adds the new node to the hash table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_TableInsert( Aig_Man_t * p, Aig_Obj_t * pObj )
-{
- Aig_Obj_t ** ppPlace;
- assert( !Aig_IsComplement(pObj) );
- assert( Aig_TableLookup(p, pObj) == NULL );
- if ( p->nTableSize < 2 * Aig_ManNodeNum(p) )
- Aig_TableResize( p );
- ppPlace = Aig_TableFind( p, pObj );
- assert( *ppPlace == NULL );
- *ppPlace = pObj;
-}
-
-/**Function*************************************************************
-
- Synopsis [Deletes the node from the hash table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_TableDelete( Aig_Man_t * p, Aig_Obj_t * pObj )
-{
- Aig_Obj_t * pEntry, ** ppPlace;
- int i;
- assert( !Aig_IsComplement(pObj) );
- ppPlace = Aig_TableFind( p, pObj );
- assert( *ppPlace == pObj ); // node should be in the table
- *ppPlace = NULL;
- // rehash the adjacent entries
- i = ppPlace - p->pTable;
- for ( i = (i+1) % p->nTableSize; p->pTable[i]; i = (i+1) % p->nTableSize )
- {
- pEntry = p->pTable[i];
- p->pTable[i] = 0;
- Aig_TableInsert( p, pEntry );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Count the number of nodes in the table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Aig_TableCountEntries( Aig_Man_t * p )
-{
- int i, Counter = 0;
- for ( i = 0; i < p->nTableSize; i++ )
- Counter += (p->pTable[i] != NULL);
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Resizes the table.]
-
- Description [Typically this procedure should not be called.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_TableResize( Aig_Man_t * p )
-{
- Aig_Obj_t ** pTableOld, ** ppPlace;
- int nTableSizeOld, Counter, nEntries, e, clk;
-clk = clock();
- // save the old table
- pTableOld = p->pTable;
- nTableSizeOld = p->nTableSize;
- // get the new table
- p->nTableSize = Cudd_PrimeAig( 5 * 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 ( e = 0; e < nTableSizeOld; e++ )
- {
- if ( pTableOld[e] == 0 )
- continue;
- Counter++;
- // get the place where this entry goes in the table table
- ppPlace = Aig_TableFind( p, pTableOld[e] );
- assert( *ppPlace == NULL ); // should not be in the table
- *ppPlace = pTableOld[e];
- }
- nEntries = Aig_ManNodeNum(p);
-// assert( Counter == nEntries );
-// printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize );
-// PRT( "Time", clock() - clk );
- // replace the table and the parameters
- free( pTableOld );
-}
-
-/**Function********************************************************************
-
- Synopsis [Profiles the hash table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-void Aig_TableProfile( Aig_Man_t * p )
-{
- int i, Counter = 0;
- for ( i = 0; i < p->nTableSize; i++ )
- {
- if ( p->pTable[i] )
- Counter++;
- else if ( Counter )
- {
- printf( "%d ", Counter );
- Counter = 0;
- }
- }
-}
-
-/**Function********************************************************************
-
- Synopsis [Returns the next prime &gt;= p.]
-
- Description [Copied from CUDD, for stand-aloneness.]
-
- SideEffects [None]
-
- SeeAlso []
-
-******************************************************************************/
-unsigned int Cudd_PrimeAig( unsigned int 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 */
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/temp/aig_free/aigUtil.c b/src/temp/aig_free/aigUtil.c
deleted file mode 100644
index 623de32b..00000000
--- a/src/temp/aig_free/aigUtil.c
+++ /dev/null
@@ -1,513 +0,0 @@
-/**CFile****************************************************************
-
- FileName [aigUtil.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [And-Inverter Graph package.]
-
- Synopsis [Various procedures.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - May 11, 2006.]
-
- Revision [$Id: aigUtil.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "aig.h"
-
-int Extra_Base10Log( unsigned Num )
-{
- int Res;
- assert( Num >= 0 );
- if ( Num == 0 ) return 0;
- if ( Num == 1 ) return 1;
- for ( Res = 0, Num--; Num; Num /= 10, Res++ );
- return Res;
-} /* end of Extra_Base2Log */
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Increments the current traversal ID of the network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManIncrementTravId( Aig_Man_t * p )
-{
- if ( p->nTravIds >= (1<<30)-1 )
- Aig_ManCleanData( p );
- p->nTravIds++;
-}
-
-/**Function*************************************************************
-
- Synopsis [Sets the DFS ordering of the nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManCleanData( Aig_Man_t * p )
-{
- Aig_Obj_t * pObj;
- int i;
- p->nTravIds = 1;
- Aig_ManConst1(p)->pData = NULL;
- Aig_ManForEachPi( p, pObj, i )
- pObj->pData = NULL;
- Aig_ManForEachPo( p, pObj, i )
- pObj->pData = NULL;
- Aig_ManForEachNode( p, pObj, i )
- pObj->pData = NULL;
-}
-
-/**Function*************************************************************
-
- Synopsis [Detects multi-input gate rooted at this node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ObjCollectMulti_rec( Aig_Obj_t * pRoot, Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
-{
- if ( pRoot != pObj && (Aig_IsComplement(pObj) || Aig_ObjIsPi(pObj) || Aig_ObjType(pRoot) != Aig_ObjType(pObj)) )
- {
- Vec_PtrPushUnique(vSuper, pObj);
- return;
- }
- Aig_ObjCollectMulti_rec( pRoot, Aig_ObjChild0(pObj), vSuper );
- Aig_ObjCollectMulti_rec( pRoot, Aig_ObjChild1(pObj), vSuper );
-}
-
-/**Function*************************************************************
-
- Synopsis [Detects multi-input gate rooted at this node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ObjCollectMulti( Aig_Obj_t * pRoot, Vec_Ptr_t * vSuper )
-{
- assert( !Aig_IsComplement(pRoot) );
- Vec_PtrClear( vSuper );
- Aig_ObjCollectMulti_rec( pRoot, pRoot, vSuper );
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns 1 if the node is the root of MUX or EXOR/NEXOR.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Aig_ObjIsMuxType( Aig_Obj_t * pNode )
-{
- Aig_Obj_t * pNode0, * pNode1;
- // check that the node is regular
- assert( !Aig_IsComplement(pNode) );
- // if the node is not AND, this is not MUX
- if ( !Aig_ObjIsAnd(pNode) )
- return 0;
- // if the children are not complemented, this is not MUX
- if ( !Aig_ObjFaninC0(pNode) || !Aig_ObjFaninC1(pNode) )
- return 0;
- // get children
- pNode0 = Aig_ObjFanin0(pNode);
- pNode1 = Aig_ObjFanin1(pNode);
- // if the children are not ANDs, this is not MUX
- if ( !Aig_ObjIsAnd(pNode0) || !Aig_ObjIsAnd(pNode1) )
- return 0;
- // otherwise the node is MUX iff it has a pair of equal grandchildren
- 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)));
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Recognizes what nodes are inputs of the EXOR.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Aig_ObjRecognizeExor( Aig_Obj_t * pObj, Aig_Obj_t ** ppFan0, Aig_Obj_t ** ppFan1 )
-{
- Aig_Obj_t * p0, * p1;
- assert( !Aig_IsComplement(pObj) );
- if ( !Aig_ObjIsNode(pObj) )
- return 0;
- if ( Aig_ObjIsExor(pObj) )
- {
- *ppFan0 = Aig_ObjChild0(pObj);
- *ppFan1 = Aig_ObjChild1(pObj);
- return 1;
- }
- assert( Aig_ObjIsAnd(pObj) );
- p0 = Aig_ObjChild0(pObj);
- p1 = Aig_ObjChild1(pObj);
- if ( !Aig_IsComplement(p0) || !Aig_IsComplement(p1) )
- return 0;
- p0 = Aig_Regular(p0);
- p1 = Aig_Regular(p1);
- if ( !Aig_ObjIsAnd(p0) || !Aig_ObjIsAnd(p1) )
- return 0;
- if ( Aig_ObjFanin0(p0) != Aig_ObjFanin0(p1) || Aig_ObjFanin1(p0) != Aig_ObjFanin1(p1) )
- return 0;
- if ( Aig_ObjFaninC0(p0) == Aig_ObjFaninC0(p1) || Aig_ObjFaninC1(p0) == Aig_ObjFaninC1(p1) )
- return 0;
- *ppFan0 = Aig_ObjChild0(p0);
- *ppFan1 = Aig_ObjChild1(p0);
- return 1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Recognizes what nodes are control and data inputs of a MUX.]
-
- Description [If the node is a MUX, returns the control variable C.
- Assigns nodes T and E to be the then and else variables of the MUX.
- Node C is never complemented. Nodes T and E can be complemented.
- This function also recognizes EXOR/NEXOR gates as MUXes.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Aig_ObjRecognizeMux( Aig_Obj_t * pNode, Aig_Obj_t ** ppNodeT, Aig_Obj_t ** ppNodeE )
-{
- Aig_Obj_t * pNode0, * pNode1;
- assert( !Aig_IsComplement(pNode) );
- assert( Aig_ObjIsMuxType(pNode) );
- // get children
- pNode0 = Aig_ObjFanin0(pNode);
- pNode1 = Aig_ObjFanin1(pNode);
-
- // find the control variable
- if ( Aig_ObjFanin1(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC1(pNode1)) )
- {
-// if ( Fraig_IsComplement(pNode1->p2) )
- if ( Aig_ObjFaninC1(pNode0) )
- { // pNode2->p2 is positive phase of C
- *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 = Aig_Not(Aig_ObjChild0(pNode0));//pNode1->p1);
- *ppNodeE = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
- return Aig_ObjChild1(pNode0);//pNode1->p2;
- }
- }
- else if ( Aig_ObjFanin0(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC0(pNode1)) )
- {
-// if ( Fraig_IsComplement(pNode1->p1) )
- if ( Aig_ObjFaninC0(pNode0) )
- { // pNode2->p1 is positive phase of C
- *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 = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
- *ppNodeE = Aig_Not(Aig_ObjChild1(pNode1));//pNode2->p2);
- return Aig_ObjChild0(pNode0);//pNode1->p1;
- }
- }
- else if ( Aig_ObjFanin0(pNode0) == Aig_ObjFanin1(pNode1) && (Aig_ObjFaninC0(pNode0) ^ Aig_ObjFaninC1(pNode1)) )
- {
-// if ( Fraig_IsComplement(pNode1->p1) )
- if ( Aig_ObjFaninC0(pNode0) )
- { // pNode2->p2 is positive phase of C
- *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 = Aig_Not(Aig_ObjChild1(pNode0));//pNode1->p2);
- *ppNodeE = Aig_Not(Aig_ObjChild0(pNode1));//pNode2->p1);
- return Aig_ObjChild0(pNode0);//pNode1->p1;
- }
- }
- else if ( Aig_ObjFanin1(pNode0) == Aig_ObjFanin0(pNode1) && (Aig_ObjFaninC1(pNode0) ^ Aig_ObjFaninC0(pNode1)) )
- {
-// if ( Fraig_IsComplement(pNode1->p2) )
- if ( Aig_ObjFaninC1(pNode0) )
- { // pNode2->p1 is positive phase of C
- *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 = 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
- return NULL;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Prints Verilog formula for the AIG rooted at this node.]
-
- Description [The formula is in terms of PIs, which should have
- their names assigned in pObj->pData fields.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ObjPrintVerilog( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, int Level )
-{
- Vec_Ptr_t * vSuper;
- Aig_Obj_t * pFanin, * pFanin0, * pFanin1, * pFaninC;
- int fCompl, i;
- // store the complemented attribute
- fCompl = Aig_IsComplement(pObj);
- pObj = Aig_Regular(pObj);
- // constant case
- if ( Aig_ObjIsConst1(pObj) )
- {
- fprintf( pFile, "%d", !fCompl );
- return;
- }
- // PI case
- if ( Aig_ObjIsPi(pObj) )
- {
- fprintf( pFile, "%s%s", fCompl? "~" : "", pObj->pData );
- return;
- }
- // EXOR case
- if ( Aig_ObjIsExor(pObj) )
- {
- Vec_VecExpand( vLevels, Level );
- vSuper = Vec_VecEntry( vLevels, Level );
- Aig_ObjCollectMulti( pObj, vSuper );
- fprintf( pFile, "%s", (Level==0? "" : "(") );
- Vec_PtrForEachEntry( vSuper, pFanin, i )
- {
- Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin, (fCompl && i==0)), vLevels, Level+1 );
- if ( i < Vec_PtrSize(vSuper) - 1 )
- fprintf( pFile, " ^ " );
- }
- fprintf( pFile, "%s", (Level==0? "" : ")") );
- return;
- }
- // MUX case
- if ( Aig_ObjIsMuxType(pObj) )
- {
- if ( Aig_ObjRecognizeExor( pObj, &pFanin0, &pFanin1 ) )
- {
- fprintf( pFile, "%s", (Level==0? "" : "(") );
- Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin0, fCompl), vLevels, Level+1 );
- fprintf( pFile, " ^ " );
- Aig_ObjPrintVerilog( pFile, pFanin1, vLevels, Level+1 );
- fprintf( pFile, "%s", (Level==0? "" : ")") );
- }
- else
- {
- pFaninC = Aig_ObjRecognizeMux( pObj, &pFanin1, &pFanin0 );
- fprintf( pFile, "%s", (Level==0? "" : "(") );
- Aig_ObjPrintVerilog( pFile, pFaninC, vLevels, Level+1 );
- fprintf( pFile, " ? " );
- Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin1, fCompl), vLevels, Level+1 );
- fprintf( pFile, " : " );
- Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin0, fCompl), vLevels, Level+1 );
- fprintf( pFile, "%s", (Level==0? "" : ")") );
- }
- return;
- }
- // AND case
- Vec_VecExpand( vLevels, Level );
- vSuper = Vec_VecEntry(vLevels, Level);
- Aig_ObjCollectMulti( pObj, vSuper );
- fprintf( pFile, "%s", (Level==0? "" : "(") );
- Vec_PtrForEachEntry( vSuper, pFanin, i )
- {
- Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin, fCompl), vLevels, Level+1 );
- if ( i < Vec_PtrSize(vSuper) - 1 )
- fprintf( pFile, " %s ", fCompl? "|" : "&" );
- }
- fprintf( pFile, "%s", (Level==0? "" : ")") );
- return;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Prints node in HAIG.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ObjPrintVerbose( Aig_Obj_t * pObj, int fHaig )
-{
- assert( !Aig_IsComplement(pObj) );
- printf( "Node %p : ", pObj );
- if ( Aig_ObjIsConst1(pObj) )
- printf( "constant 1" );
- else if ( Aig_ObjIsPi(pObj) )
- printf( "PI" );
- else
- printf( "AND( %p%s, %p%s )",
- Aig_ObjFanin0(pObj), (Aig_ObjFaninC0(pObj)? "\'" : " "),
- Aig_ObjFanin1(pObj), (Aig_ObjFaninC1(pObj)? "\'" : " ") );
- printf( " (refs = %3d)", Aig_ObjRefs(pObj) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Prints node in HAIG.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManPrintVerbose( Aig_Man_t * p, int fHaig )
-{
- Vec_Ptr_t * vNodes;
- Aig_Obj_t * pObj;
- int i;
- printf( "PIs: " );
- Aig_ManForEachPi( p, pObj, i )
- printf( " %p", pObj );
- printf( "\n" );
- vNodes = Aig_ManDfs( p );
- Vec_PtrForEachEntry( vNodes, pObj, i )
- Aig_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
- printf( "\n" );
-}
-
-/**Function*************************************************************
-
- Synopsis [Writes the AIG into the BLIF file.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Aig_ManDumpBlif( Aig_Man_t * p, char * pFileName )
-{
- FILE * pFile;
- Vec_Ptr_t * vNodes;
- Aig_Obj_t * pObj, * pConst1 = NULL;
- int i, nDigits, Counter = 0;
- if ( Aig_ManPoNum(p) == 0 )
- {
- printf( "Aig_ManDumpBlif(): AIG manager does not have POs.\n" );
- return;
- }
- // collect nodes in the DFS order
- vNodes = Aig_ManDfs( p );
- // assign IDs to objects
- Aig_ManConst1(p)->pData = (void *)Counter++;
- Aig_ManForEachPi( p, pObj, i )
- pObj->pData = (void *)Counter++;
- 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 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" );
- Aig_ManForEachPi( p, pObj, i )
- fprintf( pFile, " n%0*d", nDigits, (int)pObj->pData );
- fprintf( pFile, "\n" );
- // write POs
- fprintf( pFile, ".outputs" );
- 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)Aig_ObjFanin0(pObj)->pData,
- nDigits, (int)Aig_ObjFanin1(pObj)->pData,
- nDigits, (int)pObj->pData );
- fprintf( pFile, "%d%d 1\n", !Aig_ObjFaninC0(pObj), !Aig_ObjFaninC1(pObj) );
- }
- // write POs
- Aig_ManForEachPo( p, pObj, i )
- {
- fprintf( pFile, ".names n%0*d n%0*d\n",
- nDigits, (int)Aig_ObjFanin0(pObj)->pData,
- nDigits, (int)pObj->pData );
- 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 );
- fprintf( pFile, ".end\n\n" );
- fclose( pFile );
- Vec_PtrFree( vNodes );
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/temp/aig_free/cudd2.c b/src/temp/aig_free/cudd2.c
deleted file mode 100644
index f95d3fd0..00000000
--- a/src/temp/aig_free/cudd2.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/**CFile****************************************************************
-
- FileName [cudd2.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [Recording AIGs for the BDD operations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - October 3, 2006.]
-
- Revision [$Id: cudd2.c,v 1.00 2006/10/03 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "aig.h"
-#include "st.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-typedef struct Aig_CuddMan_t_ Aig_CuddMan_t;
-struct Aig_CuddMan_t_
-{
- Aig_Man_t * pAig; // internal AIG package
- st_table * pTable; // hash table mapping BDD nodes into AIG nodes
-};
-
-// static Cudd AIG manager used in this experiment
-static Aig_CuddMan_t * s_pCuddMan = NULL;
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Start AIG recording.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_Init( unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int cacheSize, unsigned long maxMemory, void * pCudd )
-{
- int v;
- assert( s_pCuddMan == NULL );
- s_pCuddMan = ALLOC( Aig_CuddMan_t, 1 );
- s_pCuddMan->pAig = Aig_ManStart();
- s_pCuddMan->pTable = st_init_table( st_ptrcmp, st_ptrhash );
- for ( v = 0; v < (int)numVars; v++ )
- Aig_ObjCreatePi( s_pCuddMan->pAig );
-}
-
-/**Function*************************************************************
-
- Synopsis [Stops AIG recording.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_Quit( void * pCudd )
-{
- assert( s_pCuddMan != NULL );
- Aig_ManDumpBlif( s_pCuddMan->pAig, "aig_temp.blif" );
- Aig_ManStop( s_pCuddMan->pAig );
- st_free_table( s_pCuddMan->pTable );
- free( s_pCuddMan );
- s_pCuddMan = NULL;
-}
-
-/**Function*************************************************************
-
- Synopsis [Fetches AIG node corresponding to the BDD node from the hash table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static Aig_Obj_t * Cudd2_GetArg( void * pArg )
-{
- Aig_Obj_t * pNode;
- assert( s_pCuddMan != NULL );
- if ( !st_lookup( s_pCuddMan->pTable, (char *)Aig_Regular(pArg), (char **)&pNode ) )
- {
- printf( "Cudd2_GetArg(): An argument BDD is not in the hash table.\n" );
- return NULL;
- }
- return Aig_NotCond( pNode, Aig_IsComplement(pArg) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Inserts the AIG node corresponding to the BDD node into the hash table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static void Cudd2_SetArg( Aig_Obj_t * pNode, void * pResult )
-{
- assert( s_pCuddMan != NULL );
- if ( st_is_member( s_pCuddMan->pTable, (char *)Aig_Regular(pResult) ) )
- return;
- pNode = Aig_NotCond( pNode, Aig_IsComplement(pResult) );
- st_insert( s_pCuddMan->pTable, (char *)Aig_Regular(pResult), (char *)pNode );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Creates equivalent of BDD.ONE and BDD.ReadZero.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-
-void Cudd2_bddOne( void * pCudd, void * pResult )
-{
- Cudd2_SetArg( Aig_ManConst1(s_pCuddMan->pAig), pResult );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Adds elementary variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddIthVar( void * pCudd, int iVar, void * pResult )
-{
- int v;
- assert( s_pCuddMan != NULL );
- for ( v = Aig_ManPiNum(s_pCuddMan->pAig); v <= iVar; v++ )
- Aig_ObjCreatePi( s_pCuddMan->pAig );
- Cudd2_SetArg( Aig_ManPi(s_pCuddMan->pAig, iVar), pResult );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs BDD operation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddAnd( void * pCudd, void * pArg0, void * pArg1, void * pResult )
-{
- Aig_Obj_t * pNode0, * pNode1, * pNode;
- pNode0 = Cudd2_GetArg( pArg0 );
- pNode1 = Cudd2_GetArg( pArg1 );
- pNode = Aig_And( s_pCuddMan->pAig, pNode0, pNode1 );
- Cudd2_SetArg( pNode, pResult );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs BDD operation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddOr( void * pCudd, void * pArg0, void * pArg1, void * pResult )
-{
- Cudd2_bddAnd( pCudd, Aig_Not(pArg0), Aig_Not(pArg1), Aig_Not(pResult) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs BDD operation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddNand( void * pCudd, void * pArg0, void * pArg1, void * pResult )
-{
- Cudd2_bddAnd( pCudd, pArg0, pArg1, Aig_Not(pResult) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs BDD operation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddNor( void * pCudd, void * pArg0, void * pArg1, void * pResult )
-{
- Cudd2_bddAnd( pCudd, Aig_Not(pArg0), Aig_Not(pArg1), pResult );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs BDD operation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddXor( void * pCudd, void * pArg0, void * pArg1, void * pResult )
-{
- Aig_Obj_t * pNode0, * pNode1, * pNode;
- pNode0 = Cudd2_GetArg( pArg0 );
- pNode1 = Cudd2_GetArg( pArg1 );
- pNode = Aig_Exor( s_pCuddMan->pAig, pNode0, pNode1 );
- Cudd2_SetArg( pNode, pResult );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs BDD operation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddXnor( void * pCudd, void * pArg0, void * pArg1, void * pResult )
-{
- Cudd2_bddXor( pCudd, pArg0, pArg1, Aig_Not(pResult) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs BDD operation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddIte( void * pCudd, void * pArg0, void * pArg1, void * pArg2, void * pResult )
-{
- Aig_Obj_t * pNode0, * pNode1, * pNode2, * pNode;
- pNode0 = Cudd2_GetArg( pArg0 );
- pNode1 = Cudd2_GetArg( pArg1 );
- pNode2 = Cudd2_GetArg( pArg2 );
- pNode = Aig_Mux( s_pCuddMan->pAig, pNode0, pNode1, pNode2 );
- Cudd2_SetArg( pNode, pResult );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs BDD operation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddCompose( void * pCudd, void * pArg0, void * pArg1, int v, void * pResult )
-{
- Aig_Obj_t * pNode0, * pNode1, * pNode;
- pNode0 = Cudd2_GetArg( pArg0 );
- pNode1 = Cudd2_GetArg( pArg1 );
- pNode = Aig_Compose( s_pCuddMan->pAig, pNode0, pNode1, v );
- Cudd2_SetArg( pNode, pResult );
-}
-
-/**Function*************************************************************
-
- Synopsis [Should be called after each containment check.]
-
- Description [Result should be 1 if Cudd2_bddLeq returned 1.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddLeq( void * pCudd, void * pArg0, void * pArg1, int Result )
-{
- Aig_Obj_t * pNode0, * pNode1, * pNode;
- pNode0 = Cudd2_GetArg( pArg0 );
- pNode1 = Cudd2_GetArg( pArg1 );
- pNode = Aig_And( s_pCuddMan->pAig, pNode0, Aig_Not(pNode1) );
- Aig_ObjCreatePo( s_pCuddMan->pAig, pNode );
-}
-
-/**Function*************************************************************
-
- Synopsis [Should be called after each equality check.]
-
- Description [Result should be 1 if they are equal.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_bddEqual( void * pCudd, void * pArg0, void * pArg1, int Result )
-{
- Aig_Obj_t * pNode0, * pNode1, * pNode;
- pNode0 = Cudd2_GetArg( pArg0 );
- pNode1 = Cudd2_GetArg( pArg1 );
- pNode = Aig_Exor( s_pCuddMan->pAig, pNode0, pNode1 );
- Aig_ObjCreatePo( s_pCuddMan->pAig, pNode );
-}
-
-/**Function*************************************************************
-
- Synopsis [Should be called each time a BDD node is dereferenced.]
-
- Description [Removes mapping of a BDD node into an AIG node when the BDD
- node is dereferenced.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Cudd2_RecursiveDeref( void * pCudd, void * pArg )
-{
- assert( s_pCuddMan != NULL );
- assert( st_is_member(s_pCuddMan->pTable, (char *)Aig_Regular(pArg)) );
- st_delete( s_pCuddMan->pTable, (char *)Aig_Regular(pArg), NULL );
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/temp/aig_free/cudd2.h b/src/temp/aig_free/cudd2.h
deleted file mode 100644
index c80ec5ed..00000000
--- a/src/temp/aig_free/cudd2.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/**CFile****************************************************************
-
- FileName [cudd2.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Minimalistic And-Inverter Graph package.]
-
- Synopsis [External declarations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - October 3, 2006.]
-
- Revision [$Id: cudd2.h,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __CUDD2_H__
-#define __CUDD2_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// HA: Added for printing messages
-#ifndef MSG
-#define MSG(msg) (printf("%s = \n",(msg)));
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////////////////////
-/// ITERATORS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
- extern void Cudd2_Init ( unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int cacheSize, unsigned long maxMemory, void * pCudd );
- extern void Cudd2_Quit ( void * pCudd );
- extern void Cudd2_bddOne ( void * pCudd, void * pResult );
-
- extern void Cudd2_bddIthVar ( void * pCudd, int iVar, void * pResult );
- extern void Cudd2_bddAnd ( void * pCudd, void * pArg0, void * pArg1, void * pResult );
- extern void Cudd2_bddOr ( void * pCudd, void * pArg0, void * pArg1, void * pResult );
- extern void Cudd2_bddNand ( void * pCudd, void * pArg0, void * pArg1, void * pResult );
- extern void Cudd2_bddNor ( void * pCudd, void * pArg0, void * pArg1, void * pResult );
- extern void Cudd2_bddXor ( void * pCudd, void * pArg0, void * pArg1, void * pResult );
- extern void Cudd2_bddXnor ( void * pCudd, void * pArg0, void * pArg1, void * pResult );
- extern void Cudd2_bddIte ( void * pCudd, void * pArg0, void * pArg1, void * pArg2, void * pResult );
- extern void Cudd2_bddCompose( void * pCudd, void * pArg0, void * pArg1, int v, void * pResult );
- extern void Cudd2_bddLeq ( void * pCudd, void * pArg0, void * pArg1, int Result );
- extern void Cudd2_bddEqual ( void * pCudd, void * pArg0, void * pArg1, int Result );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/temp/aig_free/st.c b/src/temp/aig_free/st.c
deleted file mode 100644
index 5024e08d..00000000
--- a/src/temp/aig_free/st.c
+++ /dev/null
@@ -1,626 +0,0 @@
-/*
- * Revision Control Information
- *
- * /projects/hsis/CVS/utilities/st/st.c,v
- * serdar
- * 1.1
- * 1993/07/29 01:00:13
- *
- */
-#include <stdio.h>
-
-#include <stdlib.h>
-//#include "extra.h"
-#include "st.h"
-
-#ifndef ABS
-# define ABS(a) ((a) < 0 ? -(a) : (a))
-#endif
-
-#ifndef ALLOC
-#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))
-#endif
-
-#ifndef FREE
-#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
-#endif
-
-#ifndef REALLOC
-#define REALLOC(type, obj, num) \
- ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
- ((type *) malloc(sizeof(type) * (num))))
-#endif
-
-#define ST_NUMCMP(x,y) ((x) != (y))
-#define ST_NUMHASH(x,size) (ABS((long)x)%(size))
-#define ST_PTRHASH(x,size) ((int)((unsigned long)(x)>>2)%size)
-#define EQUAL(func, x, y) \
- ((((func) == st_numcmp) || ((func) == st_ptrcmp)) ?\
- (ST_NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0))
-
-
-#define do_hash(key, table)\
- ((table->hash == st_ptrhash) ? ST_PTRHASH((key),(table)->num_bins) :\
- (table->hash == st_numhash) ? ST_NUMHASH((key), (table)->num_bins) :\
- (*table->hash)((key), (table)->num_bins))
-
-static int rehash();
-int st_numhash(), st_ptrhash(), st_numcmp(), st_ptrcmp();
-
-st_table *
-st_init_table_with_params(compare, hash, size, density, grow_factor,
- reorder_flag)
-int (*compare)();
-int (*hash)();
-int size;
-int density;
-double grow_factor;
-int reorder_flag;
-{
- int i;
- st_table *new;
-
- new = ALLOC(st_table, 1);
- if (new == NULL) {
- return NULL;
- }
- new->compare = compare;
- new->hash = hash;
- new->num_entries = 0;
- new->max_density = density;
- new->grow_factor = grow_factor;
- new->reorder_flag = reorder_flag;
- if (size <= 0) {
- size = 1;
- }
- new->num_bins = size;
- new->bins = ALLOC(st_table_entry *, size);
- if (new->bins == NULL) {
- FREE(new);
- return NULL;
- }
- for(i = 0; i < size; i++) {
- new->bins[i] = 0;
- }
- return new;
-}
-
-st_table *
-st_init_table(compare, hash)
-int (*compare)();
-int (*hash)();
-{
- return st_init_table_with_params(compare, hash, ST_DEFAULT_INIT_TABLE_SIZE,
- ST_DEFAULT_MAX_DENSITY,
- ST_DEFAULT_GROW_FACTOR,
- ST_DEFAULT_REORDER_FLAG);
-}
-
-void
-st_free_table(table)
-st_table *table;
-{
- register st_table_entry *ptr, *next;
- int i;
-
- for(i = 0; i < table->num_bins ; i++) {
- ptr = table->bins[i];
- while (ptr != NULL) {
- next = ptr->next;
- FREE(ptr);
- ptr = next;
- }
- }
- FREE(table->bins);
- FREE(table);
-}
-
-#define PTR_NOT_EQUAL(table, ptr, user_key)\
-(ptr != NULL && !EQUAL(table->compare, user_key, (ptr)->key))
-
-#define FIND_ENTRY(table, hash_val, key, ptr, last) \
- (last) = &(table)->bins[hash_val];\
- (ptr) = *(last);\
- while (PTR_NOT_EQUAL((table), (ptr), (key))) {\
- (last) = &(ptr)->next; (ptr) = *(last);\
- }\
- if ((ptr) != NULL && (table)->reorder_flag) {\
- *(last) = (ptr)->next;\
- (ptr)->next = (table)->bins[hash_val];\
- (table)->bins[hash_val] = (ptr);\
- }
-
-int
-st_lookup(table, key, value)
-st_table *table;
-register char *key;
-char **value;
-{
- int hash_val;
- register st_table_entry *ptr, **last;
-
- hash_val = do_hash(key, table);
-
- FIND_ENTRY(table, hash_val, key, ptr, last);
-
- if (ptr == NULL) {
- return 0;
- } else {
- if (value != NULL) {
- *value = ptr->record;
- }
- return 1;
- }
-}
-
-int
-st_lookup_int(table, key, value)
-st_table *table;
-register char *key;
-int *value;
-{
- int hash_val;
- register st_table_entry *ptr, **last;
-
- hash_val = do_hash(key, table);
-
- FIND_ENTRY(table, hash_val, key, ptr, last);
-
- if (ptr == NULL) {
- return 0;
- } else {
- if (value != 0) {
- *value = (long) ptr->record;
- }
- return 1;
- }
-}
-
-/* This macro does not check if memory allocation fails. Use at you own risk */
-#define ADD_DIRECT(table, key, value, hash_val, new)\
-{\
- if (table->num_entries/table->num_bins >= table->max_density) {\
- rehash(table);\
- hash_val = do_hash(key,table);\
- }\
- \
- new = ALLOC(st_table_entry, 1);\
- \
- new->key = key;\
- new->record = value;\
- new->next = table->bins[hash_val];\
- table->bins[hash_val] = new;\
- table->num_entries++;\
-}
-
-int
-st_insert(table, key, value)
-register st_table *table;
-register char *key;
-char *value;
-{
- int hash_val;
- st_table_entry *new;
- register st_table_entry *ptr, **last;
-
- hash_val = do_hash(key, table);
-
- FIND_ENTRY(table, hash_val, key, ptr, last);
-
- if (ptr == NULL) {
- if (table->num_entries/table->num_bins >= table->max_density) {
- if (rehash(table) == ST_OUT_OF_MEM) {
- return ST_OUT_OF_MEM;
- }
- hash_val = do_hash(key, table);
- }
- new = ALLOC(st_table_entry, 1);
- if (new == NULL) {
- return ST_OUT_OF_MEM;
- }
- new->key = key;
- new->record = value;
- new->next = table->bins[hash_val];
- table->bins[hash_val] = new;
- table->num_entries++;
- return 0;
- } else {
- ptr->record = value;
- return 1;
- }
-}
-
-int
-st_add_direct(table, key, value)
-st_table *table;
-char *key;
-char *value;
-{
- int hash_val;
- st_table_entry *new;
-
- hash_val = do_hash(key, table);
- if (table->num_entries / table->num_bins >= table->max_density) {
- if (rehash(table) == ST_OUT_OF_MEM) {
- return ST_OUT_OF_MEM;
- }
- }
- hash_val = do_hash(key, table);
- new = ALLOC(st_table_entry, 1);
- if (new == NULL) {
- return ST_OUT_OF_MEM;
- }
- new->key = key;
- new->record = value;
- new->next = table->bins[hash_val];
- table->bins[hash_val] = new;
- table->num_entries++;
- return 1;
-}
-
-int
-st_find_or_add(table, key, slot)
-st_table *table;
-char *key;
-char ***slot;
-{
- int hash_val;
- st_table_entry *new, *ptr, **last;
-
- hash_val = do_hash(key, table);
-
- FIND_ENTRY(table, hash_val, key, ptr, last);
-
- if (ptr == NULL) {
- if (table->num_entries / table->num_bins >= table->max_density) {
- if (rehash(table) == ST_OUT_OF_MEM) {
- return ST_OUT_OF_MEM;
- }
- hash_val = do_hash(key, table);
- }
- new = ALLOC(st_table_entry, 1);
- if (new == NULL) {
- return ST_OUT_OF_MEM;
- }
- new->key = key;
- new->record = (char *) 0;
- new->next = table->bins[hash_val];
- table->bins[hash_val] = new;
- table->num_entries++;
- if (slot != NULL) *slot = &new->record;
- return 0;
- } else {
- if (slot != NULL) *slot = &ptr->record;
- return 1;
- }
-}
-
-int
-st_find(table, key, slot)
-st_table *table;
-char *key;
-char ***slot;
-{
- int hash_val;
- st_table_entry *ptr, **last;
-
- hash_val = do_hash(key, table);
-
- FIND_ENTRY(table, hash_val, key, ptr, last);
-
- if (ptr == NULL) {
- return 0;
- } else {
- if (slot != NULL) {
- *slot = &ptr->record;
- }
- return 1;
- }
-}
-
-static int
-rehash(table)
-register st_table *table;
-{
- register st_table_entry *ptr, *next, **old_bins;
- int i, old_num_bins, hash_val, old_num_entries;
-
- /* save old values */
- old_bins = table->bins;
- old_num_bins = table->num_bins;
- old_num_entries = table->num_entries;
-
- /* rehash */
- table->num_bins = (int)(table->grow_factor * old_num_bins);
- if (table->num_bins % 2 == 0) {
- table->num_bins += 1;
- }
- table->num_entries = 0;
- table->bins = ALLOC(st_table_entry *, table->num_bins);
- if (table->bins == NULL) {
- table->bins = old_bins;
- table->num_bins = old_num_bins;
- table->num_entries = old_num_entries;
- return ST_OUT_OF_MEM;
- }
- /* initialize */
- for (i = 0; i < table->num_bins; i++) {
- table->bins[i] = 0;
- }
-
- /* copy data over */
- for (i = 0; i < old_num_bins; i++) {
- ptr = old_bins[i];
- while (ptr != NULL) {
- next = ptr->next;
- hash_val = do_hash(ptr->key, table);
- ptr->next = table->bins[hash_val];
- table->bins[hash_val] = ptr;
- table->num_entries++;
- ptr = next;
- }
- }
- FREE(old_bins);
-
- return 1;
-}
-
-st_table *
-st_copy(old_table)
-st_table *old_table;
-{
- st_table *new_table;
- st_table_entry *ptr, *newptr, *next, *new;
- int i, j, num_bins = old_table->num_bins;
-
- new_table = ALLOC(st_table, 1);
- if (new_table == NULL) {
- return NULL;
- }
-
- *new_table = *old_table;
- new_table->bins = ALLOC(st_table_entry *, num_bins);
- if (new_table->bins == NULL) {
- FREE(new_table);
- return NULL;
- }
- for(i = 0; i < num_bins ; i++) {
- new_table->bins[i] = NULL;
- ptr = old_table->bins[i];
- while (ptr != NULL) {
- new = ALLOC(st_table_entry, 1);
- if (new == NULL) {
- for (j = 0; j <= i; j++) {
- newptr = new_table->bins[j];
- while (newptr != NULL) {
- next = newptr->next;
- FREE(newptr);
- newptr = next;
- }
- }
- FREE(new_table->bins);
- FREE(new_table);
- return NULL;
- }
- *new = *ptr;
- new->next = new_table->bins[i];
- new_table->bins[i] = new;
- ptr = ptr->next;
- }
- }
- return new_table;
-}
-
-int
-st_delete(table, keyp, value)
-register st_table *table;
-register char **keyp;
-char **value;
-{
- int hash_val;
- char *key = *keyp;
- register st_table_entry *ptr, **last;
-
- hash_val = do_hash(key, table);
-
- FIND_ENTRY(table, hash_val, key, ptr ,last);
-
- if (ptr == NULL) {
- return 0;
- }
-
- *last = ptr->next;
- if (value != NULL) *value = ptr->record;
- *keyp = ptr->key;
- FREE(ptr);
- table->num_entries--;
- return 1;
-}
-
-int
-st_delete_int(table, keyp, value)
-register st_table *table;
-register long *keyp;
-char **value;
-{
- int hash_val;
- char *key = (char *) *keyp;
- register st_table_entry *ptr, **last;
-
- hash_val = do_hash(key, table);
-
- FIND_ENTRY(table, hash_val, key, ptr ,last);
-
- if (ptr == NULL) {
- return 0;
- }
-
- *last = ptr->next;
- if (value != NULL) *value = ptr->record;
- *keyp = (long) ptr->key;
- FREE(ptr);
- table->num_entries--;
- return 1;
-}
-
-int
-st_foreach(table, func, arg)
-st_table *table;
-enum st_retval (*func)();
-char *arg;
-{
- st_table_entry *ptr, **last;
- enum st_retval retval;
- int i;
-
- for(i = 0; i < table->num_bins; i++) {
- last = &table->bins[i]; ptr = *last;
- while (ptr != NULL) {
- retval = (*func)(ptr->key, ptr->record, arg);
- switch (retval) {
- case ST_CONTINUE:
- last = &ptr->next; ptr = *last;
- break;
- case ST_STOP:
- return 0;
- case ST_DELETE:
- *last = ptr->next;
- table->num_entries--; /* cstevens@ic */
- FREE(ptr);
- ptr = *last;
- }
- }
- }
- return 1;
-}
-
-int
-st_strhash(string, modulus)
-register char *string;
-int modulus;
-{
- register int val = 0;
- register int c;
-
- while ((c = *string++) != '\0') {
- val = val*997 + c;
- }
-
- return ((val < 0) ? -val : val)%modulus;
-}
-
-int
-st_numhash(x, size)
-char *x;
-int size;
-{
- return ST_NUMHASH(x, size);
-}
-
-int
-st_ptrhash(x, size)
-char *x;
-int size;
-{
- return ST_PTRHASH(x, size);
-}
-
-int
-st_numcmp(x, y)
-char *x;
-char *y;
-{
- return ST_NUMCMP(x, y);
-}
-
-int
-st_ptrcmp(x, y)
-char *x;
-char *y;
-{
- return ST_NUMCMP(x, y);
-}
-
-st_generator *
-st_init_gen(table)
-st_table *table;
-{
- st_generator *gen;
-
- gen = ALLOC(st_generator, 1);
- if (gen == NULL) {
- return NULL;
- }
- gen->table = table;
- gen->entry = NULL;
- gen->index = 0;
- return gen;
-}
-
-
-int
-st_gen(gen, key_p, value_p)
-st_generator *gen;
-char **key_p;
-char **value_p;
-{
- register int i;
-
- if (gen->entry == NULL) {
- /* try to find next entry */
- for(i = gen->index; i < gen->table->num_bins; i++) {
- if (gen->table->bins[i] != NULL) {
- gen->index = i+1;
- gen->entry = gen->table->bins[i];
- break;
- }
- }
- if (gen->entry == NULL) {
- return 0; /* that's all folks ! */
- }
- }
- *key_p = gen->entry->key;
- if (value_p != 0) {
- *value_p = gen->entry->record;
- }
- gen->entry = gen->entry->next;
- return 1;
-}
-
-
-int
-st_gen_int(gen, key_p, value_p)
-st_generator *gen;
-char **key_p;
-long *value_p;
-{
- register int i;
-
- if (gen->entry == NULL) {
- /* try to find next entry */
- for(i = gen->index; i < gen->table->num_bins; i++) {
- if (gen->table->bins[i] != NULL) {
- gen->index = i+1;
- gen->entry = gen->table->bins[i];
- break;
- }
- }
- if (gen->entry == NULL) {
- return 0; /* that's all folks ! */
- }
- }
- *key_p = gen->entry->key;
- if (value_p != 0) {
- *value_p = (long) gen->entry->record;
- }
- gen->entry = gen->entry->next;
- return 1;
-}
-
-
-void
-st_free_gen(gen)
-st_generator *gen;
-{
- FREE(gen);
-}
diff --git a/src/temp/aig_free/st.h b/src/temp/aig_free/st.h
deleted file mode 100644
index b15f3c83..00000000
--- a/src/temp/aig_free/st.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Revision Control Information
- *
- * /projects/hsis/CVS/utilities/st/st.h,v
- * serdar
- * 1.1
- * 1993/07/29 01:00:21
- *
- */
-/* LINTLIBRARY */
-
-/* /projects/hsis/CVS/utilities/st/st.h,v 1.1 1993/07/29 01:00:21 serdar Exp */
-
-#ifndef ST_INCLUDED
-#define ST_INCLUDED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct st_table_entry st_table_entry;
-struct st_table_entry {
- char *key;
- char *record;
- st_table_entry *next;
-};
-
-typedef struct st_table st_table;
-struct st_table {
- int (*compare)();
- int (*hash)();
- int num_bins;
- int num_entries;
- int max_density;
- int reorder_flag;
- double grow_factor;
- st_table_entry **bins;
-};
-
-typedef struct st_generator st_generator;
-struct st_generator {
- st_table *table;
- st_table_entry *entry;
- int index;
-};
-
-#define st_is_member(table,key) st_lookup(table,key,(char **) 0)
-#define st_count(table) ((table)->num_entries)
-
-enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE};
-
-typedef enum st_retval (*ST_PFSR)();
-typedef int (*ST_PFI)();
-
-extern st_table *st_init_table_with_params (ST_PFI, ST_PFI, int, int, double, int);
-extern st_table *st_init_table (ST_PFI, ST_PFI);
-extern void st_free_table (st_table *);
-extern int st_lookup (st_table *, char *, char **);
-extern int st_lookup_int (st_table *, char *, int *);
-extern int st_insert (st_table *, char *, char *);
-extern int st_add_direct (st_table *, char *, char *);
-extern int st_find_or_add (st_table *, char *, char ***);
-extern int st_find (st_table *, char *, char ***);
-extern st_table *st_copy (st_table *);
-extern int st_delete (st_table *, char **, char **);
-extern int st_delete_int (st_table *, long *, char **);
-extern int st_foreach (st_table *, ST_PFSR, char *);
-extern int st_strhash (char *, int);
-extern int st_numhash (char *, int);
-extern int st_ptrhash (char *, int);
-extern int st_numcmp (char *, char *);
-extern int st_ptrcmp (char *, char *);
-extern st_generator *st_init_gen (st_table *);
-extern int st_gen (st_generator *, char **, char **);
-extern int st_gen_int (st_generator *, char **, long *);
-extern void st_free_gen (st_generator *);
-
-
-#define ST_DEFAULT_MAX_DENSITY 5
-#define ST_DEFAULT_INIT_TABLE_SIZE 11
-#define ST_DEFAULT_GROW_FACTOR 2.0
-#define ST_DEFAULT_REORDER_FLAG 0
-
-#define st_foreach_item(table, gen, key, value) \
- for(gen=st_init_gen(table); st_gen(gen,key,value) || (st_free_gen(gen),0);)
-
-#define st_foreach_item_int(table, gen, key, value) \
- for(gen=st_init_gen(table); st_gen_int(gen,key,value) || (st_free_gen(gen),0);)
-
-#define ST_OUT_OF_MEM -10000
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ST_INCLUDED */
diff --git a/src/temp/aig_free/subdir.mk b/src/temp/aig_free/subdir.mk
deleted file mode 100644
index 1867f777..00000000
--- a/src/temp/aig_free/subdir.mk
+++ /dev/null
@@ -1,87 +0,0 @@
-################################################################################
-# Automatically-generated file. Do not edit!
-################################################################################
-
-INCPATHS = -I$(ROOT)/aig-alan
-
-# Add inputs and outputs from these tool invocations to the build variables
-PURE_C_SRCS += \
-${addprefix $(ROOT)/aig-alan/, \
-aigBalance.c \
-aigCheck.c \
-aigDfs.c \
-aigMan.c \
-aigMem.c \
-aigObj.c \
-aigOper.c \
-aigTable.c \
-aigUtil.c \
-cudd2.c \
-st.c \
-}
-
-C_SRCS += $(PURE_C_SRCS)
-
-
-PURE_C_OBJS += \
-${addprefix $(ROOT)/obj/aig-alan/, \
-aigBalance.o \
-aigCheck.o \
-aigDfs.o \
-aigMan.o \
-aigMem.o \
-aigObj.o \
-aigOper.o \
-aigTable.o \
-aigUtil.o \
-cudd2.o \
-st.o \
-}
-
-OBJS += $(PURE_C_OBJS)
-
-PURE_C_DEPS += \
-${addprefix $(ROOT)/obj/aig-alan, \
-aigBalance.d \
-aigCheck.d \
-aigDfs.d \
-aigMan.d \
-aigMem.d \
-aigObj.d \
-aigOper.d \
-aigTable.d \
-aigUtil.d \
-cudd2.d \
-st.d \
-}
-
-DEPS += $(PURE_C_DEPS)
-
-
-OCAML_OBJS +=
-
-
-DEPEND_SRCS +=
-
-# Each subdirectory must supply rules for building sources it contributes
-$(ROOT)/obj/aig-alan/%.o: $(ROOT)/aig-alan/%.c
- @echo 'Building file: $<'
- @echo 'Invoking: GCC C Compiler: $(CC)'
- @echo $(CC) $(GPCC_OPTS) $(INCPATHS) -O3 -g3 -Wall -c -fmessage-length=0 -o$@ $<
- @$(CC) $(GPCC_OPTS) $(INCPATHS) -O3 -g3 -Wall -c -fmessage-length=0 -o$@ $< && \
- echo -n $(@:%.o=%.d) $(dir $@) > $(@:%.o=%.d) && \
- $(CC) -MM -MG -P -w $(GPCC_OPTS) $(INCPATHS) -O3 -g3 -Wall -c -fmessage-length=0 $< >> $(@:%.o=%.d)
- @echo 'Finished building: $<'
- @echo ' '
-
-$(ROOT)/obj/aig-alan/%.o: $(ROOT)/aig-alan/%.cpp
- @echo 'Building file: $<'
- @echo 'Invoking: G++ C Compiler: $(GPCC)'
- @echo $(GPPCC) $(GPCC_OPTS) $(INCPATHS) -O3 -g3 -Wall -c -fmessage-length=0 -o$@ $<
- @$(GPPCC) $(GPCC_OPTS) $(INCPATHS) -O3 -g3 -Wall -c -fmessage-length=0 -o$@ $< && \
- echo -n $(@:%.o=%.d) $(dir $@) > $(@:%.o=%.d) && \
- $(GPPCC) -MM -MG -P -w $(GPCC_OPTS) $(INCPATHS) -O3 -g3 -Wall -c -fmessage-length=0 $< >> $(@:%.o=%.d)
- @echo 'Finished building: $<'
- @echo ' '
-
-
diff --git a/src/temp/aig_free/vec.h b/src/temp/aig_free/vec.h
deleted file mode 100644
index 61737d3a..00000000
--- a/src/temp/aig_free/vec.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/**CFile****************************************************************
-
- FileName [vec.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Resizable arrays.]
-
- Synopsis [External declarations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: vec.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __VEC_H__
-#define __VEC_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-#ifdef _WIN32
-#define inline __inline // compatible with MS VS 6.0
-#endif
-
-#ifndef ALLOC
-#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))
-#endif
-
-#ifndef FREE
-#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
-#endif
-
-#ifndef REALLOC
-#define REALLOC(type, obj, num) \
- ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
- ((type *) malloc(sizeof(type) * (num))))
-#endif
-
-
-#include "vecInt.h"
-#include "vecFlt.h"
-#include "vecStr.h"
-#include "vecPtr.h"
-#include "vecVec.h"
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/temp/aig_free/vecFlt.h b/src/temp/aig_free/vecFlt.h
deleted file mode 100644
index 6d92d824..00000000
--- a/src/temp/aig_free/vecFlt.h
+++ /dev/null
@@ -1,667 +0,0 @@
-/**CFile****************************************************************
-
- FileName [vecFlt.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Resizable arrays.]
-
- Synopsis [Resizable arrays of floats.]
-
- Author [Aaron P. Hurst]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: vecInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __VEC_FLT_H__
-#define __VEC_FLT_H__
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-#include <stdio.h>
-//#include "extra.h"
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-typedef struct Vec_Flt_t_ Vec_Flt_t;
-struct Vec_Flt_t_
-{
- int nCap;
- int nSize;
- float * pArray;
-};
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-#define Vec_FltForEachEntry( vVec, Entry, i ) \
- for ( i = 0; (i < Vec_FltSize(vVec)) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )
-#define Vec_FltForEachEntryStart( vVec, Entry, i, Start ) \
- for ( i = Start; (i < Vec_FltSize(vVec)) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )
-#define Vec_FltForEachEntryStartStop( vVec, Entry, i, Start, Stop ) \
- for ( i = Start; (i < Stop) && (((Entry) = Vec_FltEntry(vVec, i)), 1); i++ )
-#define Vec_FltForEachEntryReverse( vVec, pEntry, i ) \
- for ( i = Vec_FltSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_FltEntry(vVec, i)), 1); i-- )
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Flt_t * Vec_FltAlloc( int nCap )
-{
- Vec_Flt_t * p;
- p = ALLOC( Vec_Flt_t, 1 );
- if ( nCap > 0 && nCap < 16 )
- nCap = 16;
- p->nSize = 0;
- p->nCap = nCap;
- p->pArray = p->nCap? ALLOC( float, p->nCap ) : NULL;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given size and cleans it.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Flt_t * Vec_FltStart( int nSize )
-{
- Vec_Flt_t * p;
- p = Vec_FltAlloc( nSize );
- p->nSize = nSize;
- memset( p->pArray, 0, sizeof(float) * nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the vector from a float array of the given size.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Flt_t * Vec_FltAllocArray( float * pArray, int nSize )
-{
- Vec_Flt_t * p;
- p = ALLOC( Vec_Flt_t, 1 );
- p->nSize = nSize;
- p->nCap = nSize;
- p->pArray = pArray;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the vector from a float array of the given size.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Flt_t * Vec_FltAllocArrayCopy( float * pArray, int nSize )
-{
- Vec_Flt_t * p;
- p = ALLOC( Vec_Flt_t, 1 );
- p->nSize = nSize;
- p->nCap = nSize;
- p->pArray = ALLOC( float, nSize );
- memcpy( p->pArray, pArray, sizeof(float) * nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Duplicates the float array.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Flt_t * Vec_FltDup( Vec_Flt_t * pVec )
-{
- Vec_Flt_t * p;
- p = ALLOC( Vec_Flt_t, 1 );
- p->nSize = pVec->nSize;
- p->nCap = pVec->nCap;
- p->pArray = p->nCap? ALLOC( float, p->nCap ) : NULL;
- memcpy( p->pArray, pVec->pArray, sizeof(float) * pVec->nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Transfers the array into another vector.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Flt_t * Vec_FltDupArray( Vec_Flt_t * pVec )
-{
- Vec_Flt_t * p;
- p = ALLOC( Vec_Flt_t, 1 );
- p->nSize = pVec->nSize;
- p->nCap = pVec->nCap;
- p->pArray = pVec->pArray;
- pVec->nSize = 0;
- pVec->nCap = 0;
- pVec->pArray = NULL;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltFree( Vec_Flt_t * p )
-{
- FREE( p->pArray );
- FREE( p );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline float * Vec_FltReleaseArray( Vec_Flt_t * p )
-{
- float * pArray = p->pArray;
- p->nCap = 0;
- p->nSize = 0;
- p->pArray = NULL;
- return pArray;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline float * Vec_FltArray( Vec_Flt_t * p )
-{
- return p->pArray;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_FltSize( Vec_Flt_t * p )
-{
- return p->nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline float Vec_FltEntry( Vec_Flt_t * p, int i )
-{
- assert( i >= 0 && i < p->nSize );
- return p->pArray[i];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltWriteEntry( Vec_Flt_t * p, int i, float Entry )
-{
- assert( i >= 0 && i < p->nSize );
- p->pArray[i] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltAddToEntry( Vec_Flt_t * p, int i, float Addition )
-{
- assert( i >= 0 && i < p->nSize );
- p->pArray[i] += Addition;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline float Vec_FltEntryLast( Vec_Flt_t * p )
-{
- return p->pArray[p->nSize-1];
-}
-
-/**Function*************************************************************
-
- Synopsis [Resizes the vector to the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltGrow( Vec_Flt_t * p, int nCapMin )
-{
- if ( p->nCap >= nCapMin )
- return;
- p->pArray = REALLOC( float, p->pArray, nCapMin );
- p->nCap = nCapMin;
-}
-
-/**Function*************************************************************
-
- Synopsis [Fills the vector with given number of entries.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltFill( Vec_Flt_t * p, int nSize, float Entry )
-{
- int i;
- Vec_FltGrow( p, nSize );
- for ( i = 0; i < nSize; i++ )
- p->pArray[i] = Entry;
- p->nSize = nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis [Fills the vector with given number of entries.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltFillExtra( Vec_Flt_t * p, int nSize, float Entry )
-{
- int i;
- if ( p->nSize >= nSize )
- return;
- Vec_FltGrow( p, nSize );
- for ( i = p->nSize; i < nSize; i++ )
- p->pArray[i] = Entry;
- p->nSize = nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltShrink( Vec_Flt_t * p, int nSizeNew )
-{
- assert( p->nSize >= nSizeNew );
- p->nSize = nSizeNew;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltClear( Vec_Flt_t * p )
-{
- p->nSize = 0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltPush( Vec_Flt_t * p, float Entry )
-{
- if ( p->nSize == p->nCap )
- {
- if ( p->nCap < 16 )
- Vec_FltGrow( p, 16 );
- else
- Vec_FltGrow( p, 2 * p->nCap );
- }
- p->pArray[p->nSize++] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-// HA: Commented as proposed by Alan M.
-// static inline void Vec_FltPushMem( Extra_MmStep_t * pMemMan, Vec_Flt_t * p, float Entry )
-// {
-// if ( p->nSize == p->nCap )
-// {
-// float * pArray;
-// int i;
-
-// if ( p->nSize == 0 )
-// p->nCap = 1;
-// pArray = (float *)Extra_MmStepEntryFetch( pMemMan, p->nCap * 8 );
-// // pArray = ALLOC( float, p->nCap * 2 );
-// if ( p->pArray )
-// {
-// for ( i = 0; i < p->nSize; i++ )
-// pArray[i] = p->pArray[i];
-// Extra_MmStepEntryRecycle( pMemMan, (char *)p->pArray, p->nCap * 4 );
-// // free( p->pArray );
-// }
-// p->nCap *= 2;
-// p->pArray = pArray;
-// }
-// p->pArray[p->nSize++] = Entry;
-// }
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltPushOrder( Vec_Flt_t * p, float Entry )
-{
- int i;
- if ( p->nSize == p->nCap )
- {
- if ( p->nCap < 16 )
- Vec_FltGrow( p, 16 );
- else
- Vec_FltGrow( p, 2 * p->nCap );
- }
- p->nSize++;
- for ( i = p->nSize-2; i >= 0; i-- )
- if ( p->pArray[i] > Entry )
- p->pArray[i+1] = p->pArray[i];
- else
- break;
- p->pArray[i+1] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_FltPushUnique( Vec_Flt_t * p, float Entry )
-{
- int i;
- for ( i = 0; i < p->nSize; i++ )
- if ( p->pArray[i] == Entry )
- return 1;
- Vec_FltPush( p, Entry );
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the last entry and removes it from the list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline float Vec_FltPop( Vec_Flt_t * p )
-{
- assert( p->nSize > 0 );
- return p->pArray[--p->nSize];
-}
-
-/**Function*************************************************************
-
- Synopsis [Find entry.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_FltFind( Vec_Flt_t * p, float Entry )
-{
- int i;
- for ( i = 0; i < p->nSize; i++ )
- if ( p->pArray[i] == Entry )
- return i;
- return -1;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_FltRemove( Vec_Flt_t * p, float Entry )
-{
- int i;
- for ( i = 0; i < p->nSize; i++ )
- if ( p->pArray[i] == Entry )
- break;
- if ( i == p->nSize )
- return 0;
- assert( i < p->nSize );
- for ( i++; i < p->nSize; i++ )
- p->pArray[i-1] = p->pArray[i];
- p->nSize--;
- return 1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Comparison procedure for two floats.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_FltSortCompare1( float * pp1, float * pp2 )
-{
- // for some reason commenting out lines (as shown) led to crashing of the release version
- if ( *pp1 < *pp2 )
- return -1;
- if ( *pp1 > *pp2 ) //
- return 1;
- return 0; //
-}
-
-/**Function*************************************************************
-
- Synopsis [Comparison procedure for two floats.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_FltSortCompare2( float * pp1, float * pp2 )
-{
- // for some reason commenting out lines (as shown) led to crashing of the release version
- if ( *pp1 > *pp2 )
- return -1;
- if ( *pp1 < *pp2 ) //
- return 1;
- return 0; //
-}
-
-/**Function*************************************************************
-
- Synopsis [Sorting the entries by their value.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_FltSort( Vec_Flt_t * p, int fReverse )
-{
- if ( fReverse )
- qsort( (void *)p->pArray, p->nSize, sizeof(float),
- (int (*)(const void *, const void *)) Vec_FltSortCompare2 );
- else
- qsort( (void *)p->pArray, p->nSize, sizeof(float),
- (int (*)(const void *, const void *)) Vec_FltSortCompare1 );
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-#endif
-
diff --git a/src/temp/aig_free/vecInt.h b/src/temp/aig_free/vecInt.h
deleted file mode 100644
index 77bf5849..00000000
--- a/src/temp/aig_free/vecInt.h
+++ /dev/null
@@ -1,781 +0,0 @@
-/**CFile****************************************************************
-
- FileName [vecInt.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Resizable arrays.]
-
- Synopsis [Resizable arrays of integers.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: vecInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __VEC_INT_H__
-#define __VEC_INT_H__
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-//HA: Commented as advised by Alan
-//#include "extra.h"
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-typedef struct Vec_Int_t_ Vec_Int_t;
-struct Vec_Int_t_
-{
- int nCap;
- int nSize;
- int * pArray;
-};
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-#define Vec_IntForEachEntry( vVec, Entry, i ) \
- for ( i = 0; (i < Vec_IntSize(vVec)) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ )
-#define Vec_IntForEachEntryStart( vVec, Entry, i, Start ) \
- for ( i = Start; (i < Vec_IntSize(vVec)) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ )
-#define Vec_IntForEachEntryStartStop( vVec, Entry, i, Start, Stop ) \
- for ( i = Start; (i < Stop) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ )
-#define Vec_IntForEachEntryReverse( vVec, pEntry, i ) \
- for ( i = Vec_IntSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_IntEntry(vVec, i)), 1); i-- )
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Int_t * Vec_IntAlloc( int nCap )
-{
- Vec_Int_t * p;
- p = ALLOC( Vec_Int_t, 1 );
- if ( nCap > 0 && nCap < 16 )
- nCap = 16;
- p->nSize = 0;
- p->nCap = nCap;
- p->pArray = p->nCap? ALLOC( int, p->nCap ) : NULL;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given size and cleans it.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Int_t * Vec_IntStart( int nSize )
-{
- Vec_Int_t * p;
- p = Vec_IntAlloc( nSize );
- p->nSize = nSize;
- memset( p->pArray, 0, sizeof(int) * nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the vector from an integer array of the given size.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Int_t * Vec_IntAllocArray( int * pArray, int nSize )
-{
- Vec_Int_t * p;
- p = ALLOC( Vec_Int_t, 1 );
- p->nSize = nSize;
- p->nCap = nSize;
- p->pArray = pArray;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the vector from an integer array of the given size.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Int_t * Vec_IntAllocArrayCopy( int * pArray, int nSize )
-{
- Vec_Int_t * p;
- p = ALLOC( Vec_Int_t, 1 );
- p->nSize = nSize;
- p->nCap = nSize;
- p->pArray = ALLOC( int, nSize );
- memcpy( p->pArray, pArray, sizeof(int) * nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Duplicates the integer array.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Int_t * Vec_IntDup( Vec_Int_t * pVec )
-{
- Vec_Int_t * p;
- p = ALLOC( Vec_Int_t, 1 );
- p->nSize = pVec->nSize;
- p->nCap = pVec->nCap;
- p->pArray = p->nCap? ALLOC( int, p->nCap ) : NULL;
- memcpy( p->pArray, pVec->pArray, sizeof(int) * pVec->nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Transfers the array into another vector.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Int_t * Vec_IntDupArray( Vec_Int_t * pVec )
-{
- Vec_Int_t * p;
- p = ALLOC( Vec_Int_t, 1 );
- p->nSize = pVec->nSize;
- p->nCap = pVec->nCap;
- p->pArray = pVec->pArray;
- pVec->nSize = 0;
- pVec->nCap = 0;
- pVec->pArray = NULL;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntFree( Vec_Int_t * p )
-{
- FREE( p->pArray );
- FREE( p );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int * Vec_IntReleaseArray( Vec_Int_t * p )
-{
- int * pArray = p->pArray;
- p->nCap = 0;
- p->nSize = 0;
- p->pArray = NULL;
- return pArray;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int * Vec_IntArray( Vec_Int_t * p )
-{
- return p->pArray;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntSize( Vec_Int_t * p )
-{
- return p->nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntEntry( Vec_Int_t * p, int i )
-{
- assert( i >= 0 && i < p->nSize );
- return p->pArray[i];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntWriteEntry( Vec_Int_t * p, int i, int Entry )
-{
- assert( i >= 0 && i < p->nSize );
- p->pArray[i] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntAddToEntry( Vec_Int_t * p, int i, int Addition )
-{
- assert( i >= 0 && i < p->nSize );
- p->pArray[i] += Addition;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntEntryLast( Vec_Int_t * p )
-{
- assert( p->nSize > 0 );
- return p->pArray[p->nSize-1];
-}
-
-/**Function*************************************************************
-
- Synopsis [Resizes the vector to the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntGrow( Vec_Int_t * p, int nCapMin )
-{
- if ( p->nCap >= nCapMin )
- return;
- p->pArray = REALLOC( int, p->pArray, nCapMin );
- assert( p->pArray );
- p->nCap = nCapMin;
-}
-
-/**Function*************************************************************
-
- Synopsis [Fills the vector with given number of entries.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntFill( Vec_Int_t * p, int nSize, int Entry )
-{
- int i;
- Vec_IntGrow( p, nSize );
- for ( i = 0; i < nSize; i++ )
- p->pArray[i] = Entry;
- p->nSize = nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis [Fills the vector with given number of entries.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntFillExtra( Vec_Int_t * p, int nSize, int Entry )
-{
- int i;
- if ( p->nSize >= nSize )
- return;
- Vec_IntGrow( p, nSize );
- for ( i = p->nSize; i < nSize; i++ )
- p->pArray[i] = Entry;
- p->nSize = nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntShrink( Vec_Int_t * p, int nSizeNew )
-{
- assert( p->nSize >= nSizeNew );
- p->nSize = nSizeNew;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntClear( Vec_Int_t * p )
-{
- p->nSize = 0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntPush( Vec_Int_t * p, int Entry )
-{
- if ( p->nSize == p->nCap )
- {
- if ( p->nCap < 16 )
- Vec_IntGrow( p, 16 );
- else
- Vec_IntGrow( p, 2 * p->nCap );
- }
- p->pArray[p->nSize++] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntPushFirst( Vec_Int_t * p, int Entry )
-{
- int i;
- if ( p->nSize == p->nCap )
- {
- if ( p->nCap < 16 )
- Vec_IntGrow( p, 16 );
- else
- Vec_IntGrow( p, 2 * p->nCap );
- }
- p->nSize++;
- for ( i = p->nSize - 1; i >= 1; i-- )
- p->pArray[i] = p->pArray[i-1];
- p->pArray[0] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-// HA: Commented as advised by Alan M.
-// static inline void Vec_IntPushMem( Extra_MmStep_t * pMemMan, Vec_Int_t * p, int Entry )
-// {
-// if ( p->nSize == p->nCap )
-// {
-// int * pArray;
-// int i;
-
-// if ( p->nSize == 0 )
-// p->nCap = 1;
-// if ( pMemMan )
-// pArray = (int *)Extra_MmStepEntryFetch( pMemMan, p->nCap * 8 );
-// else
-// pArray = ALLOC( int, p->nCap * 2 );
-// if ( p->pArray )
-// {
-// for ( i = 0; i < p->nSize; i++ )
-// pArray[i] = p->pArray[i];
-// if ( pMemMan )
-// Extra_MmStepEntryRecycle( pMemMan, (char *)p->pArray, p->nCap * 4 );
-// else
-// free( p->pArray );
-// }
-// p->nCap *= 2;
-// p->pArray = pArray;
-// }
-// p->pArray[p->nSize++] = Entry;
-//}
-
-/**Function*************************************************************
-
- Synopsis [Inserts the entry while preserving the increasing order.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntPushOrder( Vec_Int_t * p, int Entry )
-{
- int i;
- if ( p->nSize == p->nCap )
- {
- if ( p->nCap < 16 )
- Vec_IntGrow( p, 16 );
- else
- Vec_IntGrow( p, 2 * p->nCap );
- }
- p->nSize++;
- for ( i = p->nSize-2; i >= 0; i-- )
- if ( p->pArray[i] > Entry )
- p->pArray[i+1] = p->pArray[i];
- else
- break;
- p->pArray[i+1] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis [Inserts the entry while preserving the increasing order.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntPushUniqueOrder( Vec_Int_t * p, int Entry )
-{
- int i;
- for ( i = 0; i < p->nSize; i++ )
- if ( p->pArray[i] == Entry )
- return 1;
- Vec_IntPushOrder( p, Entry );
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntPushUnique( Vec_Int_t * p, int Entry )
-{
- int i;
- for ( i = 0; i < p->nSize; i++ )
- if ( p->pArray[i] == Entry )
- return 1;
- Vec_IntPush( p, Entry );
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the pointer to the next nWords entries in the vector.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline unsigned * Vec_IntFetch( Vec_Int_t * p, int nWords )
-{
- p->nSize += nWords;
- if ( p->nSize > p->nCap )
- {
-// Vec_IntGrow( p, 2 * p->nSize );
- return NULL;
- }
- return ((unsigned *)p->pArray) + p->nSize - nWords;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the last entry and removes it from the list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntPop( Vec_Int_t * p )
-{
- assert( p->nSize > 0 );
- return p->pArray[--p->nSize];
-}
-
-/**Function*************************************************************
-
- Synopsis [Find entry.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntFind( Vec_Int_t * p, int Entry )
-{
- int i;
- for ( i = 0; i < p->nSize; i++ )
- if ( p->pArray[i] == Entry )
- return i;
- return -1;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntRemove( Vec_Int_t * p, int Entry )
-{
- int i;
- for ( i = 0; i < p->nSize; i++ )
- if ( p->pArray[i] == Entry )
- break;
- if ( i == p->nSize )
- return 0;
- assert( i < p->nSize );
- for ( i++; i < p->nSize; i++ )
- p->pArray[i-1] = p->pArray[i];
- p->nSize--;
- return 1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Comparison procedure for two integers.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntSortCompare1( int * pp1, int * pp2 )
-{
- // for some reason commenting out lines (as shown) led to crashing of the release version
- if ( *pp1 < *pp2 )
- return -1;
- if ( *pp1 > *pp2 ) //
- return 1;
- return 0; //
-}
-
-/**Function*************************************************************
-
- Synopsis [Comparison procedure for two integers.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntSortCompare2( int * pp1, int * pp2 )
-{
- // for some reason commenting out lines (as shown) led to crashing of the release version
- if ( *pp1 > *pp2 )
- return -1;
- if ( *pp1 < *pp2 ) //
- return 1;
- return 0; //
-}
-
-/**Function*************************************************************
-
- Synopsis [Sorting the entries by their integer value.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntSort( Vec_Int_t * p, int fReverse )
-{
- if ( fReverse )
- qsort( (void *)p->pArray, p->nSize, sizeof(int),
- (int (*)(const void *, const void *)) Vec_IntSortCompare2 );
- else
- qsort( (void *)p->pArray, p->nSize, sizeof(int),
- (int (*)(const void *, const void *)) Vec_IntSortCompare1 );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Comparison procedure for two integers.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_IntSortCompareUnsigned( unsigned * pp1, unsigned * pp2 )
-{
- if ( *pp1 < *pp2 )
- return -1;
- if ( *pp1 > *pp2 )
- return 1;
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Sorting the entries by their integer value.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_IntSortUnsigned( Vec_Int_t * p )
-{
- qsort( (void *)p->pArray, p->nSize, sizeof(int),
- (int (*)(const void *, const void *)) Vec_IntSortCompareUnsigned );
-}
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/temp/aig_free/vecPtr.h b/src/temp/aig_free/vecPtr.h
deleted file mode 100644
index 72678ed6..00000000
--- a/src/temp/aig_free/vecPtr.h
+++ /dev/null
@@ -1,587 +0,0 @@
-/**CFile****************************************************************
-
- FileName [vecPtr.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Resizable arrays.]
-
- Synopsis [Resizable arrays of generic pointers.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: vecPtr.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __VEC_PTR_H__
-#define __VEC_PTR_H__
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-#include <stdio.h>
-//#include "extra.h"
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-typedef struct Vec_Ptr_t_ Vec_Ptr_t;
-struct Vec_Ptr_t_
-{
- int nCap;
- int nSize;
- void ** pArray;
-};
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// iterators through entries
-#define Vec_PtrForEachEntry( vVec, pEntry, i ) \
- for ( i = 0; (i < Vec_PtrSize(vVec)) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ )
-#define Vec_PtrForEachEntryStart( vVec, pEntry, i, Start ) \
- for ( i = Start; (i < Vec_PtrSize(vVec)) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ )
-#define Vec_PtrForEachEntryStop( vVec, pEntry, i, Stop ) \
- for ( i = 0; (i < Stop) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ )
-#define Vec_PtrForEachEntryStartStop( vVec, pEntry, i, Start, Stop ) \
- for ( i = Start; (i < Stop) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i++ )
-#define Vec_PtrForEachEntryReverse( vVec, pEntry, i ) \
- for ( i = Vec_PtrSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_PtrEntry(vVec, i)), 1); i-- )
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Ptr_t * Vec_PtrAlloc( int nCap )
-{
- Vec_Ptr_t * p;
- p = ALLOC( Vec_Ptr_t, 1 );
- if ( nCap > 0 && nCap < 8 )
- nCap = 8;
- p->nSize = 0;
- p->nCap = nCap;
- p->pArray = p->nCap? ALLOC( void *, p->nCap ) : NULL;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given size and cleans it.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Ptr_t * Vec_PtrStart( int nSize )
-{
- Vec_Ptr_t * p;
- p = Vec_PtrAlloc( nSize );
- p->nSize = nSize;
- memset( p->pArray, 0, sizeof(void *) * nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the vector from an integer array of the given size.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Ptr_t * Vec_PtrAllocArray( void ** pArray, int nSize )
-{
- Vec_Ptr_t * p;
- p = ALLOC( Vec_Ptr_t, 1 );
- p->nSize = nSize;
- p->nCap = nSize;
- p->pArray = pArray;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the vector from an integer array of the given size.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Ptr_t * Vec_PtrAllocArrayCopy( void ** pArray, int nSize )
-{
- Vec_Ptr_t * p;
- p = ALLOC( Vec_Ptr_t, 1 );
- p->nSize = nSize;
- p->nCap = nSize;
- p->pArray = ALLOC( void *, nSize );
- memcpy( p->pArray, pArray, sizeof(void *) * nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Duplicates the integer array.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Ptr_t * Vec_PtrDup( Vec_Ptr_t * pVec )
-{
- Vec_Ptr_t * p;
- p = ALLOC( Vec_Ptr_t, 1 );
- p->nSize = pVec->nSize;
- p->nCap = pVec->nCap;
- p->pArray = p->nCap? ALLOC( void *, p->nCap ) : NULL;
- memcpy( p->pArray, pVec->pArray, sizeof(void *) * pVec->nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Transfers the array into another vector.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Ptr_t * Vec_PtrDupArray( Vec_Ptr_t * pVec )
-{
- Vec_Ptr_t * p;
- p = ALLOC( Vec_Ptr_t, 1 );
- p->nSize = pVec->nSize;
- p->nCap = pVec->nCap;
- p->pArray = pVec->pArray;
- pVec->nSize = 0;
- pVec->nCap = 0;
- pVec->pArray = NULL;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Frees the vector.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrFree( Vec_Ptr_t * p )
-{
- FREE( p->pArray );
- FREE( p );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void ** Vec_PtrReleaseArray( Vec_Ptr_t * p )
-{
- void ** pArray = p->pArray;
- p->nCap = 0;
- p->nSize = 0;
- p->pArray = NULL;
- return pArray;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void ** Vec_PtrArray( Vec_Ptr_t * p )
-{
- return p->pArray;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_PtrSize( Vec_Ptr_t * p )
-{
- return p->nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void * Vec_PtrEntry( Vec_Ptr_t * p, int i )
-{
- assert( i >= 0 && i < p->nSize );
- return p->pArray[i];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void ** Vec_PtrEntryP( Vec_Ptr_t * p, int i )
-{
- assert( i >= 0 && i < p->nSize );
- return p->pArray + i;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrWriteEntry( Vec_Ptr_t * p, int i, void * Entry )
-{
- assert( i >= 0 && i < p->nSize );
- p->pArray[i] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void * Vec_PtrEntryLast( Vec_Ptr_t * p )
-{
- assert( p->nSize > 0 );
- return p->pArray[p->nSize-1];
-}
-
-/**Function*************************************************************
-
- Synopsis [Resizes the vector to the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrGrow( Vec_Ptr_t * p, int nCapMin )
-{
- if ( p->nCap >= nCapMin )
- return;
- p->pArray = REALLOC( void *, p->pArray, nCapMin );
- p->nCap = nCapMin;
-}
-
-/**Function*************************************************************
-
- Synopsis [Fills the vector with given number of entries.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrFill( Vec_Ptr_t * p, int nSize, void * Entry )
-{
- int i;
- Vec_PtrGrow( p, nSize );
- for ( i = 0; i < nSize; i++ )
- p->pArray[i] = Entry;
- p->nSize = nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis [Fills the vector with given number of entries.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrFillExtra( Vec_Ptr_t * p, int nSize, void * Entry )
-{
- int i;
- if ( p->nSize >= nSize )
- return;
- if ( p->nSize < 2 * nSize )
- Vec_PtrGrow( p, 2 * nSize );
- else
- Vec_PtrGrow( p, p->nSize );
- for ( i = p->nSize; i < nSize; i++ )
- p->pArray[i] = Entry;
- p->nSize = nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrShrink( Vec_Ptr_t * p, int nSizeNew )
-{
- assert( p->nSize >= nSizeNew );
- p->nSize = nSizeNew;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrClear( Vec_Ptr_t * p )
-{
- p->nSize = 0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrPush( Vec_Ptr_t * p, void * Entry )
-{
- if ( p->nSize == p->nCap )
- {
- if ( p->nCap < 16 )
- Vec_PtrGrow( p, 16 );
- else
- Vec_PtrGrow( p, 2 * p->nCap );
- }
- p->pArray[p->nSize++] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_PtrPushUnique( Vec_Ptr_t * p, void * Entry )
-{
- int i;
- for ( i = 0; i < p->nSize; i++ )
- if ( p->pArray[i] == Entry )
- return 1;
- Vec_PtrPush( p, Entry );
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the last entry and removes it from the list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void * Vec_PtrPop( Vec_Ptr_t * p )
-{
- assert( p->nSize > 0 );
- return p->pArray[--p->nSize];
-}
-
-/**Function*************************************************************
-
- Synopsis [Find entry.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_PtrFind( Vec_Ptr_t * p, void * Entry )
-{
- int i;
- for ( i = 0; i < p->nSize; i++ )
- if ( p->pArray[i] == Entry )
- return i;
- return -1;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrRemove( Vec_Ptr_t * p, void * Entry )
-{
- int i;
- // delete assuming that it is closer to the end
- for ( i = p->nSize - 1; i >= 0; i-- )
- if ( p->pArray[i] == Entry )
- break;
- assert( i >= 0 );
-/*
- // delete assuming that it is closer to the beginning
- for ( i = 0; i < p->nSize; i++ )
- if ( p->pArray[i] == Entry )
- break;
- assert( i < p->nSize );
-*/
- for ( i++; i < p->nSize; i++ )
- p->pArray[i-1] = p->pArray[i];
- p->nSize--;
-}
-
-/**Function*************************************************************
-
- Synopsis [Moves the first nItems to the end.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrReorder( Vec_Ptr_t * p, int nItems )
-{
- assert( nItems < p->nSize );
- Vec_PtrGrow( p, nItems + p->nSize );
- memmove( (char **)p->pArray + p->nSize, p->pArray, nItems * sizeof(void*) );
- memmove( p->pArray, (char **)p->pArray + nItems, p->nSize * sizeof(void*) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Sorting the entries by their integer value.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_PtrSort( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() )
-{
- qsort( (void *)p->pArray, p->nSize, sizeof(void *),
- (int (*)(const void *, const void *)) Vec_PtrSortCompare );
-}
-
-#endif
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/temp/aig_free/vecStr.h b/src/temp/aig_free/vecStr.h
deleted file mode 100644
index a36734f6..00000000
--- a/src/temp/aig_free/vecStr.h
+++ /dev/null
@@ -1,510 +0,0 @@
-/**CFile****************************************************************
-
- FileName [vecStr.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Resizable arrays.]
-
- Synopsis [Resizable arrays of characters.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: vecStr.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __VEC_STR_H__
-#define __VEC_STR_H__
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-#include <stdio.h>
-//#include "extra.h"
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-typedef struct Vec_Str_t_ Vec_Str_t;
-struct Vec_Str_t_
-{
- int nCap;
- int nSize;
- char * pArray;
-};
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-#define Vec_StrForEachEntry( vVec, Entry, i ) \
- for ( i = 0; (i < Vec_StrSize(vVec)) && (((Entry) = Vec_StrEntry(vVec, i)), 1); i++ )
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Str_t * Vec_StrAlloc( int nCap )
-{
- Vec_Str_t * p;
- p = ALLOC( Vec_Str_t, 1 );
- if ( nCap > 0 && nCap < 16 )
- nCap = 16;
- p->nSize = 0;
- p->nCap = nCap;
- p->pArray = p->nCap? ALLOC( char, p->nCap ) : NULL;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given size and cleans it.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Str_t * Vec_StrStart( int nSize )
-{
- Vec_Str_t * p;
- p = Vec_StrAlloc( nSize );
- p->nSize = nSize;
- memset( p->pArray, 0, sizeof(char) * nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the vector from an integer array of the given size.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Str_t * Vec_StrAllocArray( char * pArray, int nSize )
-{
- Vec_Str_t * p;
- p = ALLOC( Vec_Str_t, 1 );
- p->nSize = nSize;
- p->nCap = nSize;
- p->pArray = pArray;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the vector from an integer array of the given size.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Str_t * Vec_StrAllocArrayCopy( char * pArray, int nSize )
-{
- Vec_Str_t * p;
- p = ALLOC( Vec_Str_t, 1 );
- p->nSize = nSize;
- p->nCap = nSize;
- p->pArray = ALLOC( char, nSize );
- memcpy( p->pArray, pArray, sizeof(char) * nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Duplicates the integer array.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Str_t * Vec_StrDup( Vec_Str_t * pVec )
-{
- Vec_Str_t * p;
- p = ALLOC( Vec_Str_t, 1 );
- p->nSize = pVec->nSize;
- p->nCap = pVec->nCap;
- p->pArray = p->nCap? ALLOC( char, p->nCap ) : NULL;
- memcpy( p->pArray, pVec->pArray, sizeof(char) * pVec->nSize );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Transfers the array into another vector.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Str_t * Vec_StrDupArray( Vec_Str_t * pVec )
-{
- Vec_Str_t * p;
- p = ALLOC( Vec_Str_t, 1 );
- p->nSize = pVec->nSize;
- p->nCap = pVec->nCap;
- p->pArray = pVec->pArray;
- pVec->nSize = 0;
- pVec->nCap = 0;
- pVec->pArray = NULL;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_StrFree( Vec_Str_t * p )
-{
- FREE( p->pArray );
- FREE( p );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline char * Vec_StrReleaseArray( Vec_Str_t * p )
-{
- char * pArray = p->pArray;
- p->nCap = 0;
- p->nSize = 0;
- p->pArray = NULL;
- return pArray;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline char * Vec_StrArray( Vec_Str_t * p )
-{
- return p->pArray;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_StrSize( Vec_Str_t * p )
-{
- return p->nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline char Vec_StrEntry( Vec_Str_t * p, int i )
-{
- assert( i >= 0 && i < p->nSize );
- return p->pArray[i];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_StrWriteEntry( Vec_Str_t * p, int i, char Entry )
-{
- assert( i >= 0 && i < p->nSize );
- p->pArray[i] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline char Vec_StrEntryLast( Vec_Str_t * p )
-{
- assert( p->nSize > 0 );
- return p->pArray[p->nSize-1];
-}
-
-/**Function*************************************************************
-
- Synopsis [Resizes the vector to the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_StrGrow( Vec_Str_t * p, int nCapMin )
-{
- if ( p->nCap >= nCapMin )
- return;
- p->pArray = REALLOC( char, p->pArray, 2 * nCapMin );
- p->nCap = 2 * nCapMin;
-}
-
-/**Function*************************************************************
-
- Synopsis [Fills the vector with given number of entries.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_StrFill( Vec_Str_t * p, int nSize, char Entry )
-{
- int i;
- Vec_StrGrow( p, nSize );
- p->nSize = nSize;
- for ( i = 0; i < p->nSize; i++ )
- p->pArray[i] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_StrShrink( Vec_Str_t * p, int nSizeNew )
-{
- assert( p->nSize >= nSizeNew );
- p->nSize = nSizeNew;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_StrClear( Vec_Str_t * p )
-{
- p->nSize = 0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_StrPush( Vec_Str_t * p, char Entry )
-{
- if ( p->nSize == p->nCap )
- {
- if ( p->nCap < 16 )
- Vec_StrGrow( p, 16 );
- else
- Vec_StrGrow( p, 2 * p->nCap );
- }
- p->pArray[p->nSize++] = Entry;
-}
-
-/**Function*************************************************************
-
- Synopsis [Appends the string to the char vector.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_StrAppend( Vec_Str_t * p, char * pString )
-{
- int i, nLength = strlen(pString);
- Vec_StrGrow( p, p->nSize + nLength );
- for ( i = 0; i < nLength; i++ )
- p->pArray[p->nSize + i] = pString[i];
- p->nSize += nLength;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the last entry and removes it from the list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline char Vec_StrPop( Vec_Str_t * p )
-{
- assert( p->nSize > 0 );
- return p->pArray[--p->nSize];
-}
-
-/**Function*************************************************************
-
- Synopsis [Comparison procedure for two clauses.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_StrSortCompare1( char * pp1, char * pp2 )
-{
- // for some reason commenting out lines (as shown) led to crashing of the release version
- if ( *pp1 < *pp2 )
- return -1;
- if ( *pp1 > *pp2 ) //
- return 1;
- return 0; //
-}
-
-/**Function*************************************************************
-
- Synopsis [Comparison procedure for two clauses.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_StrSortCompare2( char * pp1, char * pp2 )
-{
- // for some reason commenting out lines (as shown) led to crashing of the release version
- if ( *pp1 > *pp2 )
- return -1;
- if ( *pp1 < *pp2 ) //
- return 1;
- return 0; //
-}
-
-/**Function*************************************************************
-
- Synopsis [Sorting the entries by their integer value.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_StrSort( Vec_Str_t * p, int fReverse )
-{
- if ( fReverse )
- qsort( (void *)p->pArray, p->nSize, sizeof(char),
- (int (*)(const void *, const void *)) Vec_StrSortCompare2 );
- else
- qsort( (void *)p->pArray, p->nSize, sizeof(char),
- (int (*)(const void *, const void *)) Vec_StrSortCompare1 );
-}
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/temp/aig_free/vecVec.h b/src/temp/aig_free/vecVec.h
deleted file mode 100644
index 2de38619..00000000
--- a/src/temp/aig_free/vecVec.h
+++ /dev/null
@@ -1,289 +0,0 @@
-/**CFile****************************************************************
-
- FileName [vecVec.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Resizable arrays.]
-
- Synopsis [Resizable vector of resizable vectors.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: vecVec.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __VEC_VEC_H__
-#define __VEC_VEC_H__
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-#include <stdio.h>
-//#include "extra.h"
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-typedef struct Vec_Vec_t_ Vec_Vec_t;
-struct Vec_Vec_t_
-{
- int nCap;
- int nSize;
- void ** pArray;
-};
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// iterators through levels
-#define Vec_VecForEachLevel( vGlob, vVec, i ) \
- for ( i = 0; (i < Vec_VecSize(vGlob)) && (((vVec) = (Vec_Ptr_t*)Vec_VecEntry(vGlob, i)), 1); i++ )
-#define Vec_VecForEachLevelStart( vGlob, vVec, i, LevelStart ) \
- for ( i = LevelStart; (i < Vec_VecSize(vGlob)) && (((vVec) = (Vec_Ptr_t*)Vec_VecEntry(vGlob, i)), 1); i++ )
-#define Vec_VecForEachLevelStartStop( vGlob, vVec, i, LevelStart, LevelStop ) \
- for ( i = LevelStart; (i <= LevelStop) && (((vVec) = (Vec_Ptr_t*)Vec_VecEntry(vGlob, i)), 1); i++ )
-#define Vec_VecForEachLevelReverse( vGlob, vVec, i ) \
- for ( i = Vec_VecSize(vGlob) - 1; (i >= 0) && (((vVec) = (Vec_Ptr_t*)Vec_VecEntry(vGlob, i)), 1); i-- )
-
-// iteratores through entries
-#define Vec_VecForEachEntry( vGlob, pEntry, i, k ) \
- for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \
- Vec_PtrForEachEntry( Vec_VecEntry(vGlob, i), pEntry, k )
-#define Vec_VecForEachEntryStart( vGlob, pEntry, i, k, LevelStart ) \
- for ( i = LevelStart; i < Vec_VecSize(vGlob); i++ ) \
- Vec_PtrForEachEntry( Vec_VecEntry(vGlob, i), pEntry, k )
-#define Vec_VecForEachEntryStartStop( vGlob, pEntry, i, k, LevelStart, LevelStop ) \
- for ( i = LevelStart; i <= LevelStop; i++ ) \
- Vec_PtrForEachEntry( Vec_VecEntry(vGlob, i), pEntry, k )
-#define Vec_VecForEachEntryReverse( vGlob, pEntry, i, k ) \
- for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \
- Vec_PtrForEachEntryReverse( Vec_VecEntry(vGlob, i), pEntry, k )
-#define Vec_VecForEachEntryReverseReverse( vGlob, pEntry, i, k ) \
- for ( i = Vec_VecSize(vGlob) - 1; i >= 0; i-- ) \
- Vec_PtrForEachEntryReverse( Vec_VecEntry(vGlob, i), pEntry, k )
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Vec_t * Vec_VecAlloc( int nCap )
-{
- Vec_Vec_t * p;
- p = ALLOC( Vec_Vec_t, 1 );
- if ( nCap > 0 && nCap < 8 )
- nCap = 8;
- p->nSize = 0;
- p->nCap = nCap;
- p->pArray = p->nCap? ALLOC( void *, p->nCap ) : NULL;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline Vec_Vec_t * Vec_VecStart( int nSize )
-{
- Vec_Vec_t * p;
- int i;
- p = Vec_VecAlloc( nSize );
- for ( i = 0; i < nSize; i++ )
- p->pArray[i] = Vec_PtrAlloc( 0 );
- p->nSize = nSize;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates a vector with the given capacity.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_VecExpand( Vec_Vec_t * p, int Level )
-{
- int i;
- if ( p->nSize >= Level + 1 )
- return;
- Vec_PtrGrow( (Vec_Ptr_t *)p, Level + 1 );
- for ( i = p->nSize; i <= Level; i++ )
- p->pArray[i] = Vec_PtrAlloc( 0 );
- p->nSize = Level + 1;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_VecSize( Vec_Vec_t * p )
-{
- return p->nSize;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void * Vec_VecEntry( Vec_Vec_t * p, int i )
-{
- assert( i >= 0 && i < p->nSize );
- return p->pArray[i];
-}
-
-/**Function*************************************************************
-
- Synopsis [Frees the vector.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_VecFree( Vec_Vec_t * p )
-{
- Vec_Ptr_t * vVec;
- int i;
- Vec_VecForEachLevel( p, vVec, i )
- Vec_PtrFree( vVec );
- Vec_PtrFree( (Vec_Ptr_t *)p );
-}
-
-/**Function*************************************************************
-
- Synopsis [Frees the vector of vectors.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Vec_VecSizeSize( Vec_Vec_t * p )
-{
- Vec_Ptr_t * vVec;
- int i, Counter = 0;
- Vec_VecForEachLevel( p, vVec, i )
- Counter += vVec->nSize;
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_VecClear( Vec_Vec_t * p )
-{
- Vec_Ptr_t * vVec;
- int i;
- Vec_VecForEachLevel( p, vVec, i )
- Vec_PtrClear( vVec );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_VecPush( Vec_Vec_t * p, int Level, void * Entry )
-{
- if ( p->nSize < Level + 1 )
- {
- int i;
- Vec_PtrGrow( (Vec_Ptr_t *)p, Level + 1 );
- for ( i = p->nSize; i < Level + 1; i++ )
- p->pArray[i] = Vec_PtrAlloc( 0 );
- p->nSize = Level + 1;
- }
- Vec_PtrPush( (Vec_Ptr_t*)p->pArray[Level], Entry );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Vec_VecPushUnique( Vec_Vec_t * p, int Level, void * Entry )
-{
- if ( p->nSize < Level + 1 )
- Vec_VecPush( p, Level, Entry );
- else
- Vec_PtrPushUnique( (Vec_Ptr_t*)p->pArray[Level], Entry );
-}
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/temp/ivy/module.make b/src/temp/ivy/module.make
deleted file mode 100644
index f5f34f27..00000000
--- a/src/temp/ivy/module.make
+++ /dev/null
@@ -1,23 +0,0 @@
-SRC += src/temp/ivy/ivyBalance.c \
- src/temp/ivy/ivyCanon.c \
- src/temp/ivy/ivyCheck.c \
- src/temp/ivy/ivyCut.c \
- src/temp/ivy/ivyCutTrav.c \
- src/temp/ivy/ivyDfs.c \
- src/temp/ivy/ivyDsd.c \
- src/temp/ivy/ivyFanout.c \
- src/temp/ivy/ivyFastMap.c \
- src/temp/ivy/ivyFraig.c \
- src/temp/ivy/ivyHaig.c \
- src/temp/ivy/ivyIsop.c \
- src/temp/ivy/ivyMan.c \
- src/temp/ivy/ivyMem.c \
- src/temp/ivy/ivyMulti.c \
- src/temp/ivy/ivyObj.c \
- src/temp/ivy/ivyOper.c \
- src/temp/ivy/ivyResyn.c \
- src/temp/ivy/ivyRwr.c \
- src/temp/ivy/ivySeq.c \
- src/temp/ivy/ivyShow.c \
- src/temp/ivy/ivyTable.c \
- src/temp/ivy/ivyUtil.c
diff --git a/src/temp/mem/module.make b/src/temp/mem/module.make
deleted file mode 100644
index 5e4d1d6a..00000000
--- a/src/temp/mem/module.make
+++ /dev/null
@@ -1 +0,0 @@
-SRC += src/temp/mem/mem.c
diff --git a/src/temp/rwt/module.make b/src/temp/rwt/module.make
deleted file mode 100644
index 8bbde36d..00000000
--- a/src/temp/rwt/module.make
+++ /dev/null
@@ -1,3 +0,0 @@
-SRC += src/temp/rwt/rwtDec.c \
- src/temp/rwt/rwtMan.c \
- src/temp/rwt/rwtUtil.c
diff --git a/src/temp/ver/module.make b/src/temp/ver/module.make
deleted file mode 100644
index a58a2c60..00000000
--- a/src/temp/ver/module.make
+++ /dev/null
@@ -1,4 +0,0 @@
-SRC += src/temp/ver/verCore.c \
- src/temp/ver/verFormula.c \
- src/temp/ver/verParse.c \
- src/temp/ver/verStream.c